ng-bootstrap.js 379 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399
  1. import { Injectable, ɵɵdefineInjectable, Directive, TemplateRef, Input, ContentChildren, EventEmitter, Component, ViewEncapsulation, Output, Optional, Host, NgModule, ChangeDetectionStrategy, Renderer2, ElementRef, forwardRef, ChangeDetectorRef, Inject, PLATFORM_ID, NgZone, HostListener, LOCALE_ID, ɵɵinject, ViewChild, ViewContainerRef, ComponentFactoryResolver, ContentChild, Injector, ApplicationRef, RendererFactory2, INJECTOR, Attribute, InjectionToken } from '@angular/core';
  2. import { CommonModule, isPlatformBrowser, getLocaleDayNames, FormStyle, TranslationWidth, getLocaleMonthNames, formatDate, DOCUMENT, getLocaleDayPeriods } from '@angular/common';
  3. import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule } from '@angular/forms';
  4. import { Subject, BehaviorSubject, combineLatest, timer, NEVER, fromEvent, merge, race, Observable } from 'rxjs';
  5. import { map, startWith, distinctUntilChanged, switchMap, takeUntil, filter, take, tap, withLatestFrom, delay, share } from 'rxjs/operators';
  6. /**
  7. * @fileoverview added by tsickle
  8. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9. */
  10. /**
  11. * @param {?} value
  12. * @return {?}
  13. */
  14. function toInteger(value) {
  15. return parseInt(`${value}`, 10);
  16. }
  17. /**
  18. * @param {?} value
  19. * @return {?}
  20. */
  21. function toString(value) {
  22. return (value !== undefined && value !== null) ? `${value}` : '';
  23. }
  24. /**
  25. * @param {?} value
  26. * @param {?} max
  27. * @param {?=} min
  28. * @return {?}
  29. */
  30. function getValueInRange(value, max, min = 0) {
  31. return Math.max(Math.min(value, max), min);
  32. }
  33. /**
  34. * @param {?} value
  35. * @return {?}
  36. */
  37. function isString(value) {
  38. return typeof value === 'string';
  39. }
  40. /**
  41. * @param {?} value
  42. * @return {?}
  43. */
  44. function isNumber(value) {
  45. return !isNaN(toInteger(value));
  46. }
  47. /**
  48. * @param {?} value
  49. * @return {?}
  50. */
  51. function isInteger(value) {
  52. return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
  53. }
  54. /**
  55. * @param {?} value
  56. * @return {?}
  57. */
  58. function isDefined(value) {
  59. return value !== undefined && value !== null;
  60. }
  61. /**
  62. * @param {?} value
  63. * @return {?}
  64. */
  65. function padNumber(value) {
  66. if (isNumber(value)) {
  67. return `0${value}`.slice(-2);
  68. }
  69. else {
  70. return '';
  71. }
  72. }
  73. /**
  74. * @param {?} text
  75. * @return {?}
  76. */
  77. function regExpEscape(text) {
  78. return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
  79. }
  80. /**
  81. * @param {?} element
  82. * @param {?} className
  83. * @return {?}
  84. */
  85. function hasClassName(element, className) {
  86. return element && element.className && element.className.split &&
  87. element.className.split(/\s+/).indexOf(className) >= 0;
  88. }
  89. if (typeof Element !== 'undefined' && !Element.prototype.closest) {
  90. // Polyfill for ie10+
  91. if (!Element.prototype.matches) {
  92. // IE uses the non-standard name: msMatchesSelector
  93. Element.prototype.matches = ((/** @type {?} */ (Element.prototype))).msMatchesSelector || Element.prototype.webkitMatchesSelector;
  94. }
  95. Element.prototype.closest = (/**
  96. * @param {?} s
  97. * @return {?}
  98. */
  99. function (s) {
  100. /** @type {?} */
  101. let el = this;
  102. if (!document.documentElement.contains(el)) {
  103. return null;
  104. }
  105. do {
  106. if (el.matches(s)) {
  107. return el;
  108. }
  109. el = el.parentElement || el.parentNode;
  110. } while (el !== null && el.nodeType === 1);
  111. return null;
  112. });
  113. }
  114. /**
  115. * @param {?} element
  116. * @param {?} selector
  117. * @return {?}
  118. */
  119. function closest(element, selector) {
  120. if (!selector) {
  121. return null;
  122. }
  123. return element.closest(selector);
  124. }
  125. /**
  126. * @fileoverview added by tsickle
  127. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  128. */
  129. /**
  130. * A configuration service for the [NgbAccordion](#/components/accordion/api#NgbAccordion) component.
  131. *
  132. * You can inject this service, typically in your root component, and customize its properties
  133. * to provide default values for all accordions used in the application.
  134. */
  135. class NgbAccordionConfig {
  136. constructor() {
  137. this.closeOthers = false;
  138. }
  139. }
  140. NgbAccordionConfig.decorators = [
  141. { type: Injectable, args: [{ providedIn: 'root' },] }
  142. ];
  143. /** @nocollapse */ NgbAccordionConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbAccordionConfig_Factory() { return new NgbAccordionConfig(); }, token: NgbAccordionConfig, providedIn: "root" });
  144. /**
  145. * @fileoverview added by tsickle
  146. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  147. */
  148. /** @type {?} */
  149. let nextId = 0;
  150. /**
  151. * A directive that wraps an accordion panel header with any HTML markup and a toggling button
  152. * marked with [`NgbPanelToggle`](#/components/accordion/api#NgbPanelToggle).
  153. * See the [header customization demo](#/components/accordion/examples#header) for more details.
  154. *
  155. * You can also use [`NgbPanelTitle`](#/components/accordion/api#NgbPanelTitle) to customize only the panel title.
  156. *
  157. * \@since 4.1.0
  158. */
  159. class NgbPanelHeader {
  160. /**
  161. * @param {?} templateRef
  162. */
  163. constructor(templateRef) {
  164. this.templateRef = templateRef;
  165. }
  166. }
  167. NgbPanelHeader.decorators = [
  168. { type: Directive, args: [{ selector: 'ng-template[ngbPanelHeader]' },] }
  169. ];
  170. /** @nocollapse */
  171. NgbPanelHeader.ctorParameters = () => [
  172. { type: TemplateRef }
  173. ];
  174. /**
  175. * A directive that wraps only the panel title with HTML markup inside.
  176. *
  177. * You can also use [`NgbPanelHeader`](#/components/accordion/api#NgbPanelHeader) to customize the full panel header.
  178. */
  179. class NgbPanelTitle {
  180. /**
  181. * @param {?} templateRef
  182. */
  183. constructor(templateRef) {
  184. this.templateRef = templateRef;
  185. }
  186. }
  187. NgbPanelTitle.decorators = [
  188. { type: Directive, args: [{ selector: 'ng-template[ngbPanelTitle]' },] }
  189. ];
  190. /** @nocollapse */
  191. NgbPanelTitle.ctorParameters = () => [
  192. { type: TemplateRef }
  193. ];
  194. /**
  195. * A directive that wraps the accordion panel content.
  196. */
  197. class NgbPanelContent {
  198. /**
  199. * @param {?} templateRef
  200. */
  201. constructor(templateRef) {
  202. this.templateRef = templateRef;
  203. }
  204. }
  205. NgbPanelContent.decorators = [
  206. { type: Directive, args: [{ selector: 'ng-template[ngbPanelContent]' },] }
  207. ];
  208. /** @nocollapse */
  209. NgbPanelContent.ctorParameters = () => [
  210. { type: TemplateRef }
  211. ];
  212. /**
  213. * A directive that wraps an individual accordion panel with title and collapsible content.
  214. */
  215. class NgbPanel {
  216. constructor() {
  217. /**
  218. * If `true`, the panel is disabled an can't be toggled.
  219. */
  220. this.disabled = false;
  221. /**
  222. * An optional id for the panel that must be unique on the page.
  223. *
  224. * If not provided, it will be auto-generated in the `ngb-panel-xxx` format.
  225. */
  226. this.id = `ngb-panel-${nextId++}`;
  227. this.isOpen = false;
  228. }
  229. /**
  230. * @return {?}
  231. */
  232. ngAfterContentChecked() {
  233. // We are using @ContentChildren instead of @ContentChild as in the Angular version being used
  234. // only @ContentChildren allows us to specify the {descendants: false} option.
  235. // Without {descendants: false} we are hitting bugs described in:
  236. // https://github.com/ng-bootstrap/ng-bootstrap/issues/2240
  237. this.titleTpl = this.titleTpls.first;
  238. this.headerTpl = this.headerTpls.first;
  239. this.contentTpl = this.contentTpls.first;
  240. }
  241. }
  242. NgbPanel.decorators = [
  243. { type: Directive, args: [{ selector: 'ngb-panel' },] }
  244. ];
  245. NgbPanel.propDecorators = {
  246. disabled: [{ type: Input }],
  247. id: [{ type: Input }],
  248. title: [{ type: Input }],
  249. type: [{ type: Input }],
  250. titleTpls: [{ type: ContentChildren, args: [NgbPanelTitle, { descendants: false },] }],
  251. headerTpls: [{ type: ContentChildren, args: [NgbPanelHeader, { descendants: false },] }],
  252. contentTpls: [{ type: ContentChildren, args: [NgbPanelContent, { descendants: false },] }]
  253. };
  254. /**
  255. * Accordion is a collection of collapsible panels (bootstrap cards).
  256. *
  257. * It can ensure only one panel is opened at a time and allows to customize panel
  258. * headers.
  259. */
  260. class NgbAccordion {
  261. /**
  262. * @param {?} config
  263. */
  264. constructor(config) {
  265. /**
  266. * An array or comma separated strings of panel ids that should be opened **initially**.
  267. *
  268. * For subsequent changes use methods like `expand()`, `collapse()`, etc. and
  269. * the `(panelChange)` event.
  270. */
  271. this.activeIds = [];
  272. /**
  273. * If `true`, panel content will be detached from DOM and not simply hidden when the panel is collapsed.
  274. */
  275. this.destroyOnHide = true;
  276. /**
  277. * Event emitted right before the panel toggle happens.
  278. *
  279. * See [NgbPanelChangeEvent](#/components/accordion/api#NgbPanelChangeEvent) for payload details.
  280. */
  281. this.panelChange = new EventEmitter();
  282. this.type = config.type;
  283. this.closeOtherPanels = config.closeOthers;
  284. }
  285. /**
  286. * Checks if a panel with a given id is expanded.
  287. * @param {?} panelId
  288. * @return {?}
  289. */
  290. isExpanded(panelId) { return this.activeIds.indexOf(panelId) > -1; }
  291. /**
  292. * Expands a panel with a given id.
  293. *
  294. * Has no effect if the panel is already expanded or disabled.
  295. * @param {?} panelId
  296. * @return {?}
  297. */
  298. expand(panelId) { this._changeOpenState(this._findPanelById(panelId), true); }
  299. /**
  300. * Expands all panels, if `[closeOthers]` is `false`.
  301. *
  302. * If `[closeOthers]` is `true`, it will expand the first panel, unless there is already a panel opened.
  303. * @return {?}
  304. */
  305. expandAll() {
  306. if (this.closeOtherPanels) {
  307. if (this.activeIds.length === 0 && this.panels.length) {
  308. this._changeOpenState(this.panels.first, true);
  309. }
  310. }
  311. else {
  312. this.panels.forEach((/**
  313. * @param {?} panel
  314. * @return {?}
  315. */
  316. panel => this._changeOpenState(panel, true)));
  317. }
  318. }
  319. /**
  320. * Collapses a panel with the given id.
  321. *
  322. * Has no effect if the panel is already collapsed or disabled.
  323. * @param {?} panelId
  324. * @return {?}
  325. */
  326. collapse(panelId) { this._changeOpenState(this._findPanelById(panelId), false); }
  327. /**
  328. * Collapses all opened panels.
  329. * @return {?}
  330. */
  331. collapseAll() {
  332. this.panels.forEach((/**
  333. * @param {?} panel
  334. * @return {?}
  335. */
  336. (panel) => { this._changeOpenState(panel, false); }));
  337. }
  338. /**
  339. * Toggles a panel with the given id.
  340. *
  341. * Has no effect if the panel is disabled.
  342. * @param {?} panelId
  343. * @return {?}
  344. */
  345. toggle(panelId) {
  346. /** @type {?} */
  347. const panel = this._findPanelById(panelId);
  348. if (panel) {
  349. this._changeOpenState(panel, !panel.isOpen);
  350. }
  351. }
  352. /**
  353. * @return {?}
  354. */
  355. ngAfterContentChecked() {
  356. // active id updates
  357. if (isString(this.activeIds)) {
  358. this.activeIds = this.activeIds.split(/\s*,\s*/);
  359. }
  360. // update panels open states
  361. this.panels.forEach((/**
  362. * @param {?} panel
  363. * @return {?}
  364. */
  365. panel => panel.isOpen = !panel.disabled && this.activeIds.indexOf(panel.id) > -1));
  366. // closeOthers updates
  367. if (this.activeIds.length > 1 && this.closeOtherPanels) {
  368. this._closeOthers(this.activeIds[0]);
  369. this._updateActiveIds();
  370. }
  371. }
  372. /**
  373. * @private
  374. * @param {?} panel
  375. * @param {?} nextState
  376. * @return {?}
  377. */
  378. _changeOpenState(panel, nextState) {
  379. if (panel && !panel.disabled && panel.isOpen !== nextState) {
  380. /** @type {?} */
  381. let defaultPrevented = false;
  382. this.panelChange.emit({ panelId: panel.id, nextState: nextState, preventDefault: (/**
  383. * @return {?}
  384. */
  385. () => { defaultPrevented = true; }) });
  386. if (!defaultPrevented) {
  387. panel.isOpen = nextState;
  388. if (nextState && this.closeOtherPanels) {
  389. this._closeOthers(panel.id);
  390. }
  391. this._updateActiveIds();
  392. }
  393. }
  394. }
  395. /**
  396. * @private
  397. * @param {?} panelId
  398. * @return {?}
  399. */
  400. _closeOthers(panelId) {
  401. this.panels.forEach((/**
  402. * @param {?} panel
  403. * @return {?}
  404. */
  405. panel => {
  406. if (panel.id !== panelId) {
  407. panel.isOpen = false;
  408. }
  409. }));
  410. }
  411. /**
  412. * @private
  413. * @param {?} panelId
  414. * @return {?}
  415. */
  416. _findPanelById(panelId) { return this.panels.find((/**
  417. * @param {?} p
  418. * @return {?}
  419. */
  420. p => p.id === panelId)); }
  421. /**
  422. * @private
  423. * @return {?}
  424. */
  425. _updateActiveIds() {
  426. this.activeIds = this.panels.filter((/**
  427. * @param {?} panel
  428. * @return {?}
  429. */
  430. panel => panel.isOpen && !panel.disabled)).map((/**
  431. * @param {?} panel
  432. * @return {?}
  433. */
  434. panel => panel.id));
  435. }
  436. }
  437. NgbAccordion.decorators = [
  438. { type: Component, args: [{
  439. selector: 'ngb-accordion',
  440. exportAs: 'ngbAccordion',
  441. encapsulation: ViewEncapsulation.None,
  442. host: { 'class': 'accordion', 'role': 'tablist', '[attr.aria-multiselectable]': '!closeOtherPanels' },
  443. template: `
  444. <ng-template #t ngbPanelHeader let-panel>
  445. <button class="btn btn-link" [ngbPanelToggle]="panel">
  446. {{panel.title}}<ng-template [ngTemplateOutlet]="panel.titleTpl?.templateRef"></ng-template>
  447. </button>
  448. </ng-template>
  449. <ng-template ngFor let-panel [ngForOf]="panels">
  450. <div class="card">
  451. <div role="tab" id="{{panel.id}}-header" [class]="'card-header ' + (panel.type ? 'bg-'+panel.type: type ? 'bg-'+type : '')">
  452. <ng-template [ngTemplateOutlet]="panel.headerTpl?.templateRef || t"
  453. [ngTemplateOutletContext]="{$implicit: panel, opened: panel.isOpen}"></ng-template>
  454. </div>
  455. <div id="{{panel.id}}" role="tabpanel" [attr.aria-labelledby]="panel.id + '-header'"
  456. class="collapse" [class.show]="panel.isOpen" *ngIf="!destroyOnHide || panel.isOpen">
  457. <div class="card-body">
  458. <ng-template [ngTemplateOutlet]="panel.contentTpl?.templateRef"></ng-template>
  459. </div>
  460. </div>
  461. </div>
  462. </ng-template>
  463. `
  464. }] }
  465. ];
  466. /** @nocollapse */
  467. NgbAccordion.ctorParameters = () => [
  468. { type: NgbAccordionConfig }
  469. ];
  470. NgbAccordion.propDecorators = {
  471. panels: [{ type: ContentChildren, args: [NgbPanel,] }],
  472. activeIds: [{ type: Input }],
  473. closeOtherPanels: [{ type: Input, args: ['closeOthers',] }],
  474. destroyOnHide: [{ type: Input }],
  475. type: [{ type: Input }],
  476. panelChange: [{ type: Output }]
  477. };
  478. /**
  479. * A directive to put on a button that toggles panel opening and closing.
  480. *
  481. * To be used inside the [`NgbPanelHeader`](#/components/accordion/api#NgbPanelHeader)
  482. *
  483. * \@since 4.1.0
  484. */
  485. class NgbPanelToggle {
  486. /**
  487. * @param {?} accordion
  488. * @param {?} panel
  489. */
  490. constructor(accordion, panel) {
  491. this.accordion = accordion;
  492. this.panel = panel;
  493. }
  494. /**
  495. * @param {?} panel
  496. * @return {?}
  497. */
  498. set ngbPanelToggle(panel) {
  499. if (panel) {
  500. this.panel = panel;
  501. }
  502. }
  503. }
  504. NgbPanelToggle.decorators = [
  505. { type: Directive, args: [{
  506. selector: 'button[ngbPanelToggle]',
  507. host: {
  508. 'type': 'button',
  509. '[disabled]': 'panel.disabled',
  510. '[class.collapsed]': '!panel.isOpen',
  511. '[attr.aria-expanded]': 'panel.isOpen',
  512. '[attr.aria-controls]': 'panel.id',
  513. '(click)': 'accordion.toggle(panel.id)'
  514. }
  515. },] }
  516. ];
  517. /** @nocollapse */
  518. NgbPanelToggle.ctorParameters = () => [
  519. { type: NgbAccordion },
  520. { type: NgbPanel, decorators: [{ type: Optional }, { type: Host }] }
  521. ];
  522. NgbPanelToggle.propDecorators = {
  523. ngbPanelToggle: [{ type: Input }]
  524. };
  525. /**
  526. * @fileoverview added by tsickle
  527. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  528. */
  529. /** @type {?} */
  530. const NGB_ACCORDION_DIRECTIVES = [NgbAccordion, NgbPanel, NgbPanelTitle, NgbPanelContent, NgbPanelHeader, NgbPanelToggle];
  531. class NgbAccordionModule {
  532. }
  533. NgbAccordionModule.decorators = [
  534. { type: NgModule, args: [{ declarations: NGB_ACCORDION_DIRECTIVES, exports: NGB_ACCORDION_DIRECTIVES, imports: [CommonModule] },] }
  535. ];
  536. /**
  537. * @fileoverview added by tsickle
  538. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  539. */
  540. /**
  541. * A configuration service for the [NgbAlert](#/components/alert/api#NgbAlert) component.
  542. *
  543. * You can inject this service, typically in your root component, and customize its properties
  544. * to provide default values for all alerts used in the application.
  545. */
  546. class NgbAlertConfig {
  547. constructor() {
  548. this.dismissible = true;
  549. this.type = 'warning';
  550. }
  551. }
  552. NgbAlertConfig.decorators = [
  553. { type: Injectable, args: [{ providedIn: 'root' },] }
  554. ];
  555. /** @nocollapse */ NgbAlertConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbAlertConfig_Factory() { return new NgbAlertConfig(); }, token: NgbAlertConfig, providedIn: "root" });
  556. /**
  557. * @fileoverview added by tsickle
  558. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  559. */
  560. /**
  561. * Alert is a component to provide contextual feedback messages for user.
  562. *
  563. * It supports several alert types and can be dismissed.
  564. */
  565. class NgbAlert {
  566. /**
  567. * @param {?} config
  568. * @param {?} _renderer
  569. * @param {?} _element
  570. */
  571. constructor(config, _renderer, _element) {
  572. this._renderer = _renderer;
  573. this._element = _element;
  574. /**
  575. * An event emitted when the close button is clicked. It has no payload and only relevant for dismissible alerts.
  576. */
  577. this.close = new EventEmitter();
  578. this.dismissible = config.dismissible;
  579. this.type = config.type;
  580. }
  581. /**
  582. * @return {?}
  583. */
  584. closeHandler() { this.close.emit(null); }
  585. /**
  586. * @param {?} changes
  587. * @return {?}
  588. */
  589. ngOnChanges(changes) {
  590. /** @type {?} */
  591. const typeChange = changes['type'];
  592. if (typeChange && !typeChange.firstChange) {
  593. this._renderer.removeClass(this._element.nativeElement, `alert-${typeChange.previousValue}`);
  594. this._renderer.addClass(this._element.nativeElement, `alert-${typeChange.currentValue}`);
  595. }
  596. }
  597. /**
  598. * @return {?}
  599. */
  600. ngOnInit() { this._renderer.addClass(this._element.nativeElement, `alert-${this.type}`); }
  601. }
  602. NgbAlert.decorators = [
  603. { type: Component, args: [{
  604. selector: 'ngb-alert',
  605. changeDetection: ChangeDetectionStrategy.OnPush,
  606. encapsulation: ViewEncapsulation.None,
  607. host: { 'role': 'alert', 'class': 'alert', '[class.alert-dismissible]': 'dismissible' },
  608. template: `
  609. <ng-content></ng-content>
  610. <button *ngIf="dismissible" type="button" class="close" aria-label="Close" i18n-aria-label="@@ngb.alert.close"
  611. (click)="closeHandler()">
  612. <span aria-hidden="true">&times;</span>
  613. </button>
  614. `,
  615. styles: ["ngb-alert{display:block}"]
  616. }] }
  617. ];
  618. /** @nocollapse */
  619. NgbAlert.ctorParameters = () => [
  620. { type: NgbAlertConfig },
  621. { type: Renderer2 },
  622. { type: ElementRef }
  623. ];
  624. NgbAlert.propDecorators = {
  625. dismissible: [{ type: Input }],
  626. type: [{ type: Input }],
  627. close: [{ type: Output }]
  628. };
  629. /**
  630. * @fileoverview added by tsickle
  631. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  632. */
  633. class NgbAlertModule {
  634. }
  635. NgbAlertModule.decorators = [
  636. { type: NgModule, args: [{ declarations: [NgbAlert], exports: [NgbAlert], imports: [CommonModule], entryComponents: [NgbAlert] },] }
  637. ];
  638. /**
  639. * @fileoverview added by tsickle
  640. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  641. */
  642. class NgbButtonLabel {
  643. }
  644. NgbButtonLabel.decorators = [
  645. { type: Directive, args: [{
  646. selector: '[ngbButtonLabel]',
  647. host: { '[class.btn]': 'true', '[class.active]': 'active', '[class.disabled]': 'disabled', '[class.focus]': 'focused' }
  648. },] }
  649. ];
  650. /**
  651. * @fileoverview added by tsickle
  652. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  653. */
  654. /** @type {?} */
  655. const NGB_CHECKBOX_VALUE_ACCESSOR = {
  656. provide: NG_VALUE_ACCESSOR,
  657. useExisting: forwardRef((/**
  658. * @return {?}
  659. */
  660. () => NgbCheckBox)),
  661. multi: true
  662. };
  663. /**
  664. * Allows to easily create Bootstrap-style checkbox buttons.
  665. *
  666. * Integrates with forms, so the value of a checked button is bound to the underlying form control
  667. * either in a reactive or template-driven way.
  668. */
  669. class NgbCheckBox {
  670. /**
  671. * @param {?} _label
  672. * @param {?} _cd
  673. */
  674. constructor(_label, _cd) {
  675. this._label = _label;
  676. this._cd = _cd;
  677. /**
  678. * If `true`, the checkbox button will be disabled
  679. */
  680. this.disabled = false;
  681. /**
  682. * The form control value when the checkbox is checked.
  683. */
  684. this.valueChecked = true;
  685. /**
  686. * The form control value when the checkbox is unchecked.
  687. */
  688. this.valueUnChecked = false;
  689. this.onChange = (/**
  690. * @param {?} _
  691. * @return {?}
  692. */
  693. (_) => { });
  694. this.onTouched = (/**
  695. * @return {?}
  696. */
  697. () => { });
  698. }
  699. /**
  700. * @param {?} isFocused
  701. * @return {?}
  702. */
  703. set focused(isFocused) {
  704. this._label.focused = isFocused;
  705. if (!isFocused) {
  706. this.onTouched();
  707. }
  708. }
  709. /**
  710. * @param {?} $event
  711. * @return {?}
  712. */
  713. onInputChange($event) {
  714. /** @type {?} */
  715. const modelToPropagate = $event.target.checked ? this.valueChecked : this.valueUnChecked;
  716. this.onChange(modelToPropagate);
  717. this.onTouched();
  718. this.writeValue(modelToPropagate);
  719. }
  720. /**
  721. * @param {?} fn
  722. * @return {?}
  723. */
  724. registerOnChange(fn) { this.onChange = fn; }
  725. /**
  726. * @param {?} fn
  727. * @return {?}
  728. */
  729. registerOnTouched(fn) { this.onTouched = fn; }
  730. /**
  731. * @param {?} isDisabled
  732. * @return {?}
  733. */
  734. setDisabledState(isDisabled) {
  735. this.disabled = isDisabled;
  736. this._label.disabled = isDisabled;
  737. }
  738. /**
  739. * @param {?} value
  740. * @return {?}
  741. */
  742. writeValue(value) {
  743. this.checked = value === this.valueChecked;
  744. this._label.active = this.checked;
  745. // label won't be updated, if it is inside the OnPush component when [ngModel] changes
  746. this._cd.markForCheck();
  747. }
  748. }
  749. NgbCheckBox.decorators = [
  750. { type: Directive, args: [{
  751. selector: '[ngbButton][type=checkbox]',
  752. host: {
  753. '[checked]': 'checked',
  754. '[disabled]': 'disabled',
  755. '(change)': 'onInputChange($event)',
  756. '(focus)': 'focused = true',
  757. '(blur)': 'focused = false'
  758. },
  759. providers: [NGB_CHECKBOX_VALUE_ACCESSOR]
  760. },] }
  761. ];
  762. /** @nocollapse */
  763. NgbCheckBox.ctorParameters = () => [
  764. { type: NgbButtonLabel },
  765. { type: ChangeDetectorRef }
  766. ];
  767. NgbCheckBox.propDecorators = {
  768. disabled: [{ type: Input }],
  769. valueChecked: [{ type: Input }],
  770. valueUnChecked: [{ type: Input }]
  771. };
  772. /**
  773. * @fileoverview added by tsickle
  774. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  775. */
  776. /** @type {?} */
  777. const NGB_RADIO_VALUE_ACCESSOR = {
  778. provide: NG_VALUE_ACCESSOR,
  779. useExisting: forwardRef((/**
  780. * @return {?}
  781. */
  782. () => NgbRadioGroup)),
  783. multi: true
  784. };
  785. /** @type {?} */
  786. let nextId$1 = 0;
  787. /**
  788. * Allows to easily create Bootstrap-style radio buttons.
  789. *
  790. * Integrates with forms, so the value of a checked button is bound to the underlying form control
  791. * either in a reactive or template-driven way.
  792. */
  793. class NgbRadioGroup {
  794. constructor() {
  795. this._radios = new Set();
  796. this._value = null;
  797. /**
  798. * Name of the radio group applied to radio input elements.
  799. *
  800. * Will be applied to all radio input elements inside the group,
  801. * unless [`NgbRadio`](#/components/buttons/api#NgbRadio)'s specify names themselves.
  802. *
  803. * If not provided, will be generated in the `ngb-radio-xx` format.
  804. */
  805. this.name = `ngb-radio-${nextId$1++}`;
  806. this.onChange = (/**
  807. * @param {?} _
  808. * @return {?}
  809. */
  810. (_) => { });
  811. this.onTouched = (/**
  812. * @return {?}
  813. */
  814. () => { });
  815. }
  816. /**
  817. * @return {?}
  818. */
  819. get disabled() { return this._disabled; }
  820. /**
  821. * @param {?} isDisabled
  822. * @return {?}
  823. */
  824. set disabled(isDisabled) { this.setDisabledState(isDisabled); }
  825. /**
  826. * @param {?} radio
  827. * @return {?}
  828. */
  829. onRadioChange(radio) {
  830. this.writeValue(radio.value);
  831. this.onChange(radio.value);
  832. }
  833. /**
  834. * @return {?}
  835. */
  836. onRadioValueUpdate() { this._updateRadiosValue(); }
  837. /**
  838. * @param {?} radio
  839. * @return {?}
  840. */
  841. register(radio) { this._radios.add(radio); }
  842. /**
  843. * @param {?} fn
  844. * @return {?}
  845. */
  846. registerOnChange(fn) { this.onChange = fn; }
  847. /**
  848. * @param {?} fn
  849. * @return {?}
  850. */
  851. registerOnTouched(fn) { this.onTouched = fn; }
  852. /**
  853. * @param {?} isDisabled
  854. * @return {?}
  855. */
  856. setDisabledState(isDisabled) {
  857. this._disabled = isDisabled;
  858. this._updateRadiosDisabled();
  859. }
  860. /**
  861. * @param {?} radio
  862. * @return {?}
  863. */
  864. unregister(radio) { this._radios.delete(radio); }
  865. /**
  866. * @param {?} value
  867. * @return {?}
  868. */
  869. writeValue(value) {
  870. this._value = value;
  871. this._updateRadiosValue();
  872. }
  873. /**
  874. * @private
  875. * @return {?}
  876. */
  877. _updateRadiosValue() { this._radios.forEach((/**
  878. * @param {?} radio
  879. * @return {?}
  880. */
  881. (radio) => radio.updateValue(this._value))); }
  882. /**
  883. * @private
  884. * @return {?}
  885. */
  886. _updateRadiosDisabled() { this._radios.forEach((/**
  887. * @param {?} radio
  888. * @return {?}
  889. */
  890. (radio) => radio.updateDisabled())); }
  891. }
  892. NgbRadioGroup.decorators = [
  893. { type: Directive, args: [{ selector: '[ngbRadioGroup]', host: { 'role': 'radiogroup' }, providers: [NGB_RADIO_VALUE_ACCESSOR] },] }
  894. ];
  895. NgbRadioGroup.propDecorators = {
  896. name: [{ type: Input }]
  897. };
  898. /**
  899. * A directive that marks an input of type "radio" as a part of the
  900. * [`NgbRadioGroup`](#/components/buttons/api#NgbRadioGroup).
  901. */
  902. class NgbRadio {
  903. /**
  904. * @param {?} _group
  905. * @param {?} _label
  906. * @param {?} _renderer
  907. * @param {?} _element
  908. * @param {?} _cd
  909. */
  910. constructor(_group, _label, _renderer, _element, _cd) {
  911. this._group = _group;
  912. this._label = _label;
  913. this._renderer = _renderer;
  914. this._element = _element;
  915. this._cd = _cd;
  916. this._value = null;
  917. this._group.register(this);
  918. this.updateDisabled();
  919. }
  920. /**
  921. * The form control value when current radio button is checked.
  922. * @param {?} value
  923. * @return {?}
  924. */
  925. set value(value) {
  926. this._value = value;
  927. /** @type {?} */
  928. const stringValue = value ? value.toString() : '';
  929. this._renderer.setProperty(this._element.nativeElement, 'value', stringValue);
  930. this._group.onRadioValueUpdate();
  931. }
  932. /**
  933. * If `true`, current radio button will be disabled.
  934. * @param {?} isDisabled
  935. * @return {?}
  936. */
  937. set disabled(isDisabled) {
  938. this._disabled = isDisabled !== false;
  939. this.updateDisabled();
  940. }
  941. /**
  942. * @param {?} isFocused
  943. * @return {?}
  944. */
  945. set focused(isFocused) {
  946. if (this._label) {
  947. this._label.focused = isFocused;
  948. }
  949. if (!isFocused) {
  950. this._group.onTouched();
  951. }
  952. }
  953. /**
  954. * @return {?}
  955. */
  956. get checked() { return this._checked; }
  957. /**
  958. * @return {?}
  959. */
  960. get disabled() { return this._group.disabled || this._disabled; }
  961. /**
  962. * @return {?}
  963. */
  964. get value() { return this._value; }
  965. /**
  966. * @return {?}
  967. */
  968. get nameAttr() { return this.name || this._group.name; }
  969. /**
  970. * @return {?}
  971. */
  972. ngOnDestroy() { this._group.unregister(this); }
  973. /**
  974. * @return {?}
  975. */
  976. onChange() { this._group.onRadioChange(this); }
  977. /**
  978. * @param {?} value
  979. * @return {?}
  980. */
  981. updateValue(value) {
  982. // label won't be updated, if it is inside the OnPush component when [ngModel] changes
  983. if (this.value !== value) {
  984. this._cd.markForCheck();
  985. }
  986. this._checked = this.value === value;
  987. this._label.active = this._checked;
  988. }
  989. /**
  990. * @return {?}
  991. */
  992. updateDisabled() { this._label.disabled = this.disabled; }
  993. }
  994. NgbRadio.decorators = [
  995. { type: Directive, args: [{
  996. selector: '[ngbButton][type=radio]',
  997. host: {
  998. '[checked]': 'checked',
  999. '[disabled]': 'disabled',
  1000. '[name]': 'nameAttr',
  1001. '(change)': 'onChange()',
  1002. '(focus)': 'focused = true',
  1003. '(blur)': 'focused = false'
  1004. }
  1005. },] }
  1006. ];
  1007. /** @nocollapse */
  1008. NgbRadio.ctorParameters = () => [
  1009. { type: NgbRadioGroup },
  1010. { type: NgbButtonLabel },
  1011. { type: Renderer2 },
  1012. { type: ElementRef },
  1013. { type: ChangeDetectorRef }
  1014. ];
  1015. NgbRadio.propDecorators = {
  1016. name: [{ type: Input }],
  1017. value: [{ type: Input, args: ['value',] }],
  1018. disabled: [{ type: Input, args: ['disabled',] }]
  1019. };
  1020. /**
  1021. * @fileoverview added by tsickle
  1022. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1023. */
  1024. /** @type {?} */
  1025. const NGB_BUTTON_DIRECTIVES = [NgbButtonLabel, NgbCheckBox, NgbRadioGroup, NgbRadio];
  1026. class NgbButtonsModule {
  1027. }
  1028. NgbButtonsModule.decorators = [
  1029. { type: NgModule, args: [{ declarations: NGB_BUTTON_DIRECTIVES, exports: NGB_BUTTON_DIRECTIVES },] }
  1030. ];
  1031. /**
  1032. * @fileoverview added by tsickle
  1033. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1034. */
  1035. /**
  1036. * A configuration service for the [NgbCarousel](#/components/carousel/api#NgbCarousel) component.
  1037. *
  1038. * You can inject this service, typically in your root component, and customize its properties
  1039. * to provide default values for all carousels used in the application.
  1040. */
  1041. class NgbCarouselConfig {
  1042. constructor() {
  1043. this.interval = 5000;
  1044. this.wrap = true;
  1045. this.keyboard = true;
  1046. this.pauseOnHover = true;
  1047. this.showNavigationArrows = true;
  1048. this.showNavigationIndicators = true;
  1049. }
  1050. }
  1051. NgbCarouselConfig.decorators = [
  1052. { type: Injectable, args: [{ providedIn: 'root' },] }
  1053. ];
  1054. /** @nocollapse */ NgbCarouselConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbCarouselConfig_Factory() { return new NgbCarouselConfig(); }, token: NgbCarouselConfig, providedIn: "root" });
  1055. /**
  1056. * @fileoverview added by tsickle
  1057. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1058. */
  1059. /** @type {?} */
  1060. let nextId$2 = 0;
  1061. /**
  1062. * A directive that wraps the individual carousel slide.
  1063. */
  1064. class NgbSlide {
  1065. /**
  1066. * @param {?} tplRef
  1067. */
  1068. constructor(tplRef) {
  1069. this.tplRef = tplRef;
  1070. /**
  1071. * Slide id that must be unique for the entire document.
  1072. *
  1073. * If not provided, will be generated in the `ngb-slide-xx` format.
  1074. */
  1075. this.id = `ngb-slide-${nextId$2++}`;
  1076. }
  1077. }
  1078. NgbSlide.decorators = [
  1079. { type: Directive, args: [{ selector: 'ng-template[ngbSlide]' },] }
  1080. ];
  1081. /** @nocollapse */
  1082. NgbSlide.ctorParameters = () => [
  1083. { type: TemplateRef }
  1084. ];
  1085. NgbSlide.propDecorators = {
  1086. id: [{ type: Input }]
  1087. };
  1088. /**
  1089. * Carousel is a component to easily create and control slideshows.
  1090. *
  1091. * Allows to set intervals, change the way user interacts with the slides and provides a programmatic API.
  1092. */
  1093. class NgbCarousel {
  1094. /**
  1095. * @param {?} config
  1096. * @param {?} _platformId
  1097. * @param {?} _ngZone
  1098. * @param {?} _cd
  1099. */
  1100. constructor(config, _platformId, _ngZone, _cd) {
  1101. this._platformId = _platformId;
  1102. this._ngZone = _ngZone;
  1103. this._cd = _cd;
  1104. this.NgbSlideEventSource = NgbSlideEventSource;
  1105. this._destroy$ = new Subject();
  1106. this._interval$ = new BehaviorSubject(0);
  1107. this._mouseHover$ = new BehaviorSubject(false);
  1108. this._pauseOnHover$ = new BehaviorSubject(false);
  1109. this._pause$ = new BehaviorSubject(false);
  1110. this._wrap$ = new BehaviorSubject(false);
  1111. /**
  1112. * An event emitted right after the slide transition is completed.
  1113. *
  1114. * See [`NgbSlideEvent`](#/components/carousel/api#NgbSlideEvent) for payload details.
  1115. */
  1116. this.slide = new EventEmitter();
  1117. this.interval = config.interval;
  1118. this.wrap = config.wrap;
  1119. this.keyboard = config.keyboard;
  1120. this.pauseOnHover = config.pauseOnHover;
  1121. this.showNavigationArrows = config.showNavigationArrows;
  1122. this.showNavigationIndicators = config.showNavigationIndicators;
  1123. }
  1124. /**
  1125. * Time in milliseconds before the next slide is shown.
  1126. * @param {?} value
  1127. * @return {?}
  1128. */
  1129. set interval(value) {
  1130. this._interval$.next(value);
  1131. }
  1132. /**
  1133. * @return {?}
  1134. */
  1135. get interval() { return this._interval$.value; }
  1136. /**
  1137. * If `true`, will 'wrap' the carousel by switching from the last slide back to the first.
  1138. * @param {?} value
  1139. * @return {?}
  1140. */
  1141. set wrap(value) {
  1142. this._wrap$.next(value);
  1143. }
  1144. /**
  1145. * @return {?}
  1146. */
  1147. get wrap() { return this._wrap$.value; }
  1148. /**
  1149. * If `true`, will pause slide switching when mouse cursor hovers the slide.
  1150. *
  1151. * \@since 2.2.0
  1152. * @param {?} value
  1153. * @return {?}
  1154. */
  1155. set pauseOnHover(value) {
  1156. this._pauseOnHover$.next(value);
  1157. }
  1158. /**
  1159. * @return {?}
  1160. */
  1161. get pauseOnHover() { return this._pauseOnHover$.value; }
  1162. /**
  1163. * @return {?}
  1164. */
  1165. mouseEnter() {
  1166. this._mouseHover$.next(true);
  1167. }
  1168. /**
  1169. * @return {?}
  1170. */
  1171. mouseLeave() {
  1172. this._mouseHover$.next(false);
  1173. }
  1174. /**
  1175. * @return {?}
  1176. */
  1177. ngAfterContentInit() {
  1178. // setInterval() doesn't play well with SSR and protractor,
  1179. // so we should run it in the browser and outside Angular
  1180. if (isPlatformBrowser(this._platformId)) {
  1181. this._ngZone.runOutsideAngular((/**
  1182. * @return {?}
  1183. */
  1184. () => {
  1185. /** @type {?} */
  1186. const hasNextSlide$ = combineLatest(this.slide.pipe(map((/**
  1187. * @param {?} slideEvent
  1188. * @return {?}
  1189. */
  1190. slideEvent => slideEvent.current)), startWith(this.activeId)), this._wrap$, this.slides.changes.pipe(startWith(null)))
  1191. .pipe(map((/**
  1192. * @param {?} __0
  1193. * @return {?}
  1194. */
  1195. ([currentSlideId, wrap]) => {
  1196. /** @type {?} */
  1197. const slideArr = this.slides.toArray();
  1198. /** @type {?} */
  1199. const currentSlideIdx = this._getSlideIdxById(currentSlideId);
  1200. return wrap ? slideArr.length > 1 : currentSlideIdx < slideArr.length - 1;
  1201. })), distinctUntilChanged());
  1202. combineLatest(this._pause$, this._pauseOnHover$, this._mouseHover$, this._interval$, hasNextSlide$)
  1203. .pipe(map((/**
  1204. * @param {?} __0
  1205. * @return {?}
  1206. */
  1207. ([pause, pauseOnHover, mouseHover, interval, hasNextSlide]) => ((pause || (pauseOnHover && mouseHover) || !hasNextSlide) ? 0 : interval))), distinctUntilChanged(), switchMap((/**
  1208. * @param {?} interval
  1209. * @return {?}
  1210. */
  1211. interval => interval > 0 ? timer(interval, interval) : NEVER)), takeUntil(this._destroy$))
  1212. .subscribe((/**
  1213. * @return {?}
  1214. */
  1215. () => this._ngZone.run((/**
  1216. * @return {?}
  1217. */
  1218. () => this.next(NgbSlideEventSource.TIMER)))));
  1219. }));
  1220. }
  1221. this.slides.changes.pipe(takeUntil(this._destroy$)).subscribe((/**
  1222. * @return {?}
  1223. */
  1224. () => this._cd.markForCheck()));
  1225. }
  1226. /**
  1227. * @return {?}
  1228. */
  1229. ngAfterContentChecked() {
  1230. /** @type {?} */
  1231. let activeSlide = this._getSlideById(this.activeId);
  1232. this.activeId = activeSlide ? activeSlide.id : (this.slides.length ? this.slides.first.id : null);
  1233. }
  1234. /**
  1235. * @return {?}
  1236. */
  1237. ngOnDestroy() { this._destroy$.next(); }
  1238. /**
  1239. * Navigates to a slide with the specified identifier.
  1240. * @param {?} slideId
  1241. * @param {?=} source
  1242. * @return {?}
  1243. */
  1244. select(slideId, source) {
  1245. this._cycleToSelected(slideId, this._getSlideEventDirection(this.activeId, slideId), source);
  1246. }
  1247. /**
  1248. * Navigates to the previous slide.
  1249. * @param {?=} source
  1250. * @return {?}
  1251. */
  1252. prev(source) {
  1253. this._cycleToSelected(this._getPrevSlide(this.activeId), NgbSlideEventDirection.RIGHT, source);
  1254. }
  1255. /**
  1256. * Navigates to the next slide.
  1257. * @param {?=} source
  1258. * @return {?}
  1259. */
  1260. next(source) {
  1261. this._cycleToSelected(this._getNextSlide(this.activeId), NgbSlideEventDirection.LEFT, source);
  1262. }
  1263. /**
  1264. * Pauses cycling through the slides.
  1265. * @return {?}
  1266. */
  1267. pause() { this._pause$.next(true); }
  1268. /**
  1269. * Restarts cycling through the slides from left to right.
  1270. * @return {?}
  1271. */
  1272. cycle() { this._pause$.next(false); }
  1273. /**
  1274. * @private
  1275. * @param {?} slideIdx
  1276. * @param {?} direction
  1277. * @param {?=} source
  1278. * @return {?}
  1279. */
  1280. _cycleToSelected(slideIdx, direction, source) {
  1281. /** @type {?} */
  1282. let selectedSlide = this._getSlideById(slideIdx);
  1283. if (selectedSlide && selectedSlide.id !== this.activeId) {
  1284. this.slide.emit({ prev: this.activeId, current: selectedSlide.id, direction: direction, paused: this._pause$.value, source });
  1285. this.activeId = selectedSlide.id;
  1286. }
  1287. // we get here after the interval fires or any external API call like next(), prev() or select()
  1288. this._cd.markForCheck();
  1289. }
  1290. /**
  1291. * @private
  1292. * @param {?} currentActiveSlideId
  1293. * @param {?} nextActiveSlideId
  1294. * @return {?}
  1295. */
  1296. _getSlideEventDirection(currentActiveSlideId, nextActiveSlideId) {
  1297. /** @type {?} */
  1298. const currentActiveSlideIdx = this._getSlideIdxById(currentActiveSlideId);
  1299. /** @type {?} */
  1300. const nextActiveSlideIdx = this._getSlideIdxById(nextActiveSlideId);
  1301. return currentActiveSlideIdx > nextActiveSlideIdx ? NgbSlideEventDirection.RIGHT : NgbSlideEventDirection.LEFT;
  1302. }
  1303. /**
  1304. * @private
  1305. * @param {?} slideId
  1306. * @return {?}
  1307. */
  1308. _getSlideById(slideId) { return this.slides.find((/**
  1309. * @param {?} slide
  1310. * @return {?}
  1311. */
  1312. slide => slide.id === slideId)); }
  1313. /**
  1314. * @private
  1315. * @param {?} slideId
  1316. * @return {?}
  1317. */
  1318. _getSlideIdxById(slideId) {
  1319. return this.slides.toArray().indexOf(this._getSlideById(slideId));
  1320. }
  1321. /**
  1322. * @private
  1323. * @param {?} currentSlideId
  1324. * @return {?}
  1325. */
  1326. _getNextSlide(currentSlideId) {
  1327. /** @type {?} */
  1328. const slideArr = this.slides.toArray();
  1329. /** @type {?} */
  1330. const currentSlideIdx = this._getSlideIdxById(currentSlideId);
  1331. /** @type {?} */
  1332. const isLastSlide = currentSlideIdx === slideArr.length - 1;
  1333. return isLastSlide ? (this.wrap ? slideArr[0].id : slideArr[slideArr.length - 1].id) :
  1334. slideArr[currentSlideIdx + 1].id;
  1335. }
  1336. /**
  1337. * @private
  1338. * @param {?} currentSlideId
  1339. * @return {?}
  1340. */
  1341. _getPrevSlide(currentSlideId) {
  1342. /** @type {?} */
  1343. const slideArr = this.slides.toArray();
  1344. /** @type {?} */
  1345. const currentSlideIdx = this._getSlideIdxById(currentSlideId);
  1346. /** @type {?} */
  1347. const isFirstSlide = currentSlideIdx === 0;
  1348. return isFirstSlide ? (this.wrap ? slideArr[slideArr.length - 1].id : slideArr[0].id) :
  1349. slideArr[currentSlideIdx - 1].id;
  1350. }
  1351. }
  1352. NgbCarousel.decorators = [
  1353. { type: Component, args: [{
  1354. selector: 'ngb-carousel',
  1355. exportAs: 'ngbCarousel',
  1356. changeDetection: ChangeDetectionStrategy.OnPush,
  1357. encapsulation: ViewEncapsulation.None,
  1358. host: {
  1359. 'class': 'carousel slide',
  1360. '[style.display]': '"block"',
  1361. 'tabIndex': '0',
  1362. '(keydown.arrowLeft)': 'keyboard && prev(NgbSlideEventSource.ARROW_LEFT)',
  1363. '(keydown.arrowRight)': 'keyboard && next(NgbSlideEventSource.ARROW_RIGHT)'
  1364. },
  1365. template: `
  1366. <ol class="carousel-indicators" *ngIf="showNavigationIndicators">
  1367. <li *ngFor="let slide of slides" [id]="slide.id" [class.active]="slide.id === activeId"
  1368. (click)="select(slide.id, NgbSlideEventSource.INDICATOR)"></li>
  1369. </ol>
  1370. <div class="carousel-inner">
  1371. <div *ngFor="let slide of slides" class="carousel-item" [class.active]="slide.id === activeId">
  1372. <ng-template [ngTemplateOutlet]="slide.tplRef"></ng-template>
  1373. </div>
  1374. </div>
  1375. <a class="carousel-control-prev" role="button" (click)="prev(NgbSlideEventSource.ARROW_LEFT)" *ngIf="showNavigationArrows">
  1376. <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  1377. <span class="sr-only" i18n="@@ngb.carousel.previous">Previous</span>
  1378. </a>
  1379. <a class="carousel-control-next" role="button" (click)="next(NgbSlideEventSource.ARROW_RIGHT)" *ngIf="showNavigationArrows">
  1380. <span class="carousel-control-next-icon" aria-hidden="true"></span>
  1381. <span class="sr-only" i18n="@@ngb.carousel.next">Next</span>
  1382. </a>
  1383. `
  1384. }] }
  1385. ];
  1386. /** @nocollapse */
  1387. NgbCarousel.ctorParameters = () => [
  1388. { type: NgbCarouselConfig },
  1389. { type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] },
  1390. { type: NgZone },
  1391. { type: ChangeDetectorRef }
  1392. ];
  1393. NgbCarousel.propDecorators = {
  1394. slides: [{ type: ContentChildren, args: [NgbSlide,] }],
  1395. activeId: [{ type: Input }],
  1396. interval: [{ type: Input }],
  1397. wrap: [{ type: Input }],
  1398. keyboard: [{ type: Input }],
  1399. pauseOnHover: [{ type: Input }],
  1400. showNavigationArrows: [{ type: Input }],
  1401. showNavigationIndicators: [{ type: Input }],
  1402. slide: [{ type: Output }],
  1403. mouseEnter: [{ type: HostListener, args: ['mouseenter',] }],
  1404. mouseLeave: [{ type: HostListener, args: ['mouseleave',] }]
  1405. };
  1406. /** @enum {string} */
  1407. const NgbSlideEventDirection = {
  1408. LEFT: (/** @type {?} */ ('left')),
  1409. RIGHT: (/** @type {?} */ ('right')),
  1410. };
  1411. /** @enum {string} */
  1412. const NgbSlideEventSource = {
  1413. TIMER: 'timer',
  1414. ARROW_LEFT: 'arrowLeft',
  1415. ARROW_RIGHT: 'arrowRight',
  1416. INDICATOR: 'indicator',
  1417. };
  1418. /** @type {?} */
  1419. const NGB_CAROUSEL_DIRECTIVES = [NgbCarousel, NgbSlide];
  1420. /**
  1421. * @fileoverview added by tsickle
  1422. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1423. */
  1424. class NgbCarouselModule {
  1425. }
  1426. NgbCarouselModule.decorators = [
  1427. { type: NgModule, args: [{ declarations: NGB_CAROUSEL_DIRECTIVES, exports: NGB_CAROUSEL_DIRECTIVES, imports: [CommonModule] },] }
  1428. ];
  1429. /**
  1430. * @fileoverview added by tsickle
  1431. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1432. */
  1433. /**
  1434. * A directive to provide a simple way of hiding and showing elements on the page.
  1435. */
  1436. class NgbCollapse {
  1437. constructor() {
  1438. /**
  1439. * If `true`, will collapse the element or show it otherwise.
  1440. */
  1441. this.collapsed = false;
  1442. }
  1443. }
  1444. NgbCollapse.decorators = [
  1445. { type: Directive, args: [{
  1446. selector: '[ngbCollapse]',
  1447. exportAs: 'ngbCollapse',
  1448. host: { '[class.collapse]': 'true', '[class.show]': '!collapsed' }
  1449. },] }
  1450. ];
  1451. NgbCollapse.propDecorators = {
  1452. collapsed: [{ type: Input, args: ['ngbCollapse',] }]
  1453. };
  1454. /**
  1455. * @fileoverview added by tsickle
  1456. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1457. */
  1458. class NgbCollapseModule {
  1459. }
  1460. NgbCollapseModule.decorators = [
  1461. { type: NgModule, args: [{ declarations: [NgbCollapse], exports: [NgbCollapse] },] }
  1462. ];
  1463. /**
  1464. * @fileoverview added by tsickle
  1465. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1466. */
  1467. /**
  1468. * A simple class that represents a date that datepicker also uses internally.
  1469. *
  1470. * It is the implementation of the `NgbDateStruct` interface that adds some convenience methods,
  1471. * like `.equals()`, `.before()`, etc.
  1472. *
  1473. * All datepicker APIs consume `NgbDateStruct`, but return `NgbDate`.
  1474. *
  1475. * In many cases it is simpler to manipulate these objects together with
  1476. * [`NgbCalendar`](#/components/datepicker/api#NgbCalendar) than native JS Dates.
  1477. *
  1478. * See the [date format overview](#/components/datepicker/overview#date-model) for more details.
  1479. *
  1480. * \@since 3.0.0
  1481. */
  1482. class NgbDate {
  1483. /**
  1484. * A **static method** that creates a new date object from the `NgbDateStruct`,
  1485. *
  1486. * ex. `NgbDate.from({year: 2000, month: 5, day: 1})`.
  1487. *
  1488. * If the `date` is already of `NgbDate` type, the method will return the same object.
  1489. * @param {?} date
  1490. * @return {?}
  1491. */
  1492. static from(date) {
  1493. if (date instanceof NgbDate) {
  1494. return date;
  1495. }
  1496. return date ? new NgbDate(date.year, date.month, date.day) : null;
  1497. }
  1498. /**
  1499. * @param {?} year
  1500. * @param {?} month
  1501. * @param {?} day
  1502. */
  1503. constructor(year, month, day) {
  1504. this.year = isInteger(year) ? year : null;
  1505. this.month = isInteger(month) ? month : null;
  1506. this.day = isInteger(day) ? day : null;
  1507. }
  1508. /**
  1509. * Checks if the current date is equal to another date.
  1510. * @param {?} other
  1511. * @return {?}
  1512. */
  1513. equals(other) {
  1514. return other && this.year === other.year && this.month === other.month && this.day === other.day;
  1515. }
  1516. /**
  1517. * Checks if the current date is before another date.
  1518. * @param {?} other
  1519. * @return {?}
  1520. */
  1521. before(other) {
  1522. if (!other) {
  1523. return false;
  1524. }
  1525. if (this.year === other.year) {
  1526. if (this.month === other.month) {
  1527. return this.day === other.day ? false : this.day < other.day;
  1528. }
  1529. else {
  1530. return this.month < other.month;
  1531. }
  1532. }
  1533. else {
  1534. return this.year < other.year;
  1535. }
  1536. }
  1537. /**
  1538. * Checks if the current date is after another date.
  1539. * @param {?} other
  1540. * @return {?}
  1541. */
  1542. after(other) {
  1543. if (!other) {
  1544. return false;
  1545. }
  1546. if (this.year === other.year) {
  1547. if (this.month === other.month) {
  1548. return this.day === other.day ? false : this.day > other.day;
  1549. }
  1550. else {
  1551. return this.month > other.month;
  1552. }
  1553. }
  1554. else {
  1555. return this.year > other.year;
  1556. }
  1557. }
  1558. }
  1559. /**
  1560. * @fileoverview added by tsickle
  1561. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1562. */
  1563. /**
  1564. * @param {?} jsDate
  1565. * @return {?}
  1566. */
  1567. function fromJSDate(jsDate) {
  1568. return new NgbDate(jsDate.getFullYear(), jsDate.getMonth() + 1, jsDate.getDate());
  1569. }
  1570. /**
  1571. * @param {?} date
  1572. * @return {?}
  1573. */
  1574. function toJSDate(date) {
  1575. /** @type {?} */
  1576. const jsDate = new Date(date.year, date.month - 1, date.day, 12);
  1577. // this is done avoid 30 -> 1930 conversion
  1578. if (!isNaN(jsDate.getTime())) {
  1579. jsDate.setFullYear(date.year);
  1580. }
  1581. return jsDate;
  1582. }
  1583. /**
  1584. * @return {?}
  1585. */
  1586. function NGB_DATEPICKER_CALENDAR_FACTORY() {
  1587. return new NgbCalendarGregorian();
  1588. }
  1589. /**
  1590. * A service that represents the calendar used by the datepicker.
  1591. *
  1592. * The default implementation uses the Gregorian calendar. You can inject it in your own
  1593. * implementations if necessary to simplify `NgbDate` calculations.
  1594. * @abstract
  1595. */
  1596. class NgbCalendar {
  1597. }
  1598. NgbCalendar.decorators = [
  1599. { type: Injectable, args: [{ providedIn: 'root', useFactory: NGB_DATEPICKER_CALENDAR_FACTORY },] }
  1600. ];
  1601. /** @nocollapse */ NgbCalendar.ngInjectableDef = ɵɵdefineInjectable({ factory: NGB_DATEPICKER_CALENDAR_FACTORY, token: NgbCalendar, providedIn: "root" });
  1602. class NgbCalendarGregorian extends NgbCalendar {
  1603. /**
  1604. * @return {?}
  1605. */
  1606. getDaysPerWeek() { return 7; }
  1607. /**
  1608. * @return {?}
  1609. */
  1610. getMonths() { return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; }
  1611. /**
  1612. * @return {?}
  1613. */
  1614. getWeeksPerMonth() { return 6; }
  1615. /**
  1616. * @param {?} date
  1617. * @param {?=} period
  1618. * @param {?=} number
  1619. * @return {?}
  1620. */
  1621. getNext(date, period = 'd', number = 1) {
  1622. /** @type {?} */
  1623. let jsDate = toJSDate(date);
  1624. /** @type {?} */
  1625. let checkMonth = true;
  1626. /** @type {?} */
  1627. let expectedMonth = jsDate.getMonth();
  1628. switch (period) {
  1629. case 'y':
  1630. jsDate.setFullYear(jsDate.getFullYear() + number);
  1631. break;
  1632. case 'm':
  1633. expectedMonth += number;
  1634. jsDate.setMonth(expectedMonth);
  1635. expectedMonth = expectedMonth % 12;
  1636. if (expectedMonth < 0) {
  1637. expectedMonth = expectedMonth + 12;
  1638. }
  1639. break;
  1640. case 'd':
  1641. jsDate.setDate(jsDate.getDate() + number);
  1642. checkMonth = false;
  1643. break;
  1644. default:
  1645. return date;
  1646. }
  1647. if (checkMonth && jsDate.getMonth() !== expectedMonth) {
  1648. // this means the destination month has less days than the initial month
  1649. // let's go back to the end of the previous month:
  1650. jsDate.setDate(0);
  1651. }
  1652. return fromJSDate(jsDate);
  1653. }
  1654. /**
  1655. * @param {?} date
  1656. * @param {?=} period
  1657. * @param {?=} number
  1658. * @return {?}
  1659. */
  1660. getPrev(date, period = 'd', number = 1) { return this.getNext(date, period, -number); }
  1661. /**
  1662. * @param {?} date
  1663. * @return {?}
  1664. */
  1665. getWeekday(date) {
  1666. /** @type {?} */
  1667. let jsDate = toJSDate(date);
  1668. /** @type {?} */
  1669. let day = jsDate.getDay();
  1670. // in JS Date Sun=0, in ISO 8601 Sun=7
  1671. return day === 0 ? 7 : day;
  1672. }
  1673. /**
  1674. * @param {?} week
  1675. * @param {?} firstDayOfWeek
  1676. * @return {?}
  1677. */
  1678. getWeekNumber(week, firstDayOfWeek) {
  1679. // in JS Date Sun=0, in ISO 8601 Sun=7
  1680. if (firstDayOfWeek === 7) {
  1681. firstDayOfWeek = 0;
  1682. }
  1683. /** @type {?} */
  1684. const thursdayIndex = (4 + 7 - firstDayOfWeek) % 7;
  1685. /** @type {?} */
  1686. let date = week[thursdayIndex];
  1687. /** @type {?} */
  1688. const jsDate = toJSDate(date);
  1689. jsDate.setDate(jsDate.getDate() + 4 - (jsDate.getDay() || 7)); // Thursday
  1690. // Thursday
  1691. /** @type {?} */
  1692. const time = jsDate.getTime();
  1693. jsDate.setMonth(0); // Compare with Jan 1
  1694. jsDate.setDate(1);
  1695. return Math.floor(Math.round((time - jsDate.getTime()) / 86400000) / 7) + 1;
  1696. }
  1697. /**
  1698. * @return {?}
  1699. */
  1700. getToday() { return fromJSDate(new Date()); }
  1701. /**
  1702. * @param {?} date
  1703. * @return {?}
  1704. */
  1705. isValid(date) {
  1706. if (!date || !isInteger(date.year) || !isInteger(date.month) || !isInteger(date.day)) {
  1707. return false;
  1708. }
  1709. // year 0 doesn't exist in Gregorian calendar
  1710. if (date.year === 0) {
  1711. return false;
  1712. }
  1713. /** @type {?} */
  1714. const jsDate = toJSDate(date);
  1715. return !isNaN(jsDate.getTime()) && jsDate.getFullYear() === date.year && jsDate.getMonth() + 1 === date.month &&
  1716. jsDate.getDate() === date.day;
  1717. }
  1718. }
  1719. NgbCalendarGregorian.decorators = [
  1720. { type: Injectable }
  1721. ];
  1722. /**
  1723. * @fileoverview added by tsickle
  1724. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1725. */
  1726. /**
  1727. * @param {?} prev
  1728. * @param {?} next
  1729. * @return {?}
  1730. */
  1731. function isChangedDate(prev, next) {
  1732. return !dateComparator(prev, next);
  1733. }
  1734. /**
  1735. * @param {?} prev
  1736. * @param {?} next
  1737. * @return {?}
  1738. */
  1739. function isChangedMonth(prev, next) {
  1740. return !prev && !next ? false : !prev || !next ? true : prev.year !== next.year || prev.month !== next.month;
  1741. }
  1742. /**
  1743. * @param {?} prev
  1744. * @param {?} next
  1745. * @return {?}
  1746. */
  1747. function dateComparator(prev, next) {
  1748. return (!prev && !next) || (!!prev && !!next && prev.equals(next));
  1749. }
  1750. /**
  1751. * @param {?} minDate
  1752. * @param {?} maxDate
  1753. * @return {?}
  1754. */
  1755. function checkMinBeforeMax(minDate, maxDate) {
  1756. if (maxDate && minDate && maxDate.before(minDate)) {
  1757. throw new Error(`'maxDate' ${maxDate} should be greater than 'minDate' ${minDate}`);
  1758. }
  1759. }
  1760. /**
  1761. * @param {?} date
  1762. * @param {?} minDate
  1763. * @param {?} maxDate
  1764. * @return {?}
  1765. */
  1766. function checkDateInRange(date, minDate, maxDate) {
  1767. if (date && minDate && date.before(minDate)) {
  1768. return minDate;
  1769. }
  1770. if (date && maxDate && date.after(maxDate)) {
  1771. return maxDate;
  1772. }
  1773. return date;
  1774. }
  1775. /**
  1776. * @param {?} date
  1777. * @param {?} state
  1778. * @return {?}
  1779. */
  1780. function isDateSelectable(date, state) {
  1781. const { minDate, maxDate, disabled, markDisabled } = state;
  1782. // clang-format off
  1783. return !(!isDefined(date) ||
  1784. disabled ||
  1785. (markDisabled && markDisabled(date, { year: date.year, month: date.month })) ||
  1786. (minDate && date.before(minDate)) ||
  1787. (maxDate && date.after(maxDate)));
  1788. // clang-format on
  1789. }
  1790. /**
  1791. * @param {?} calendar
  1792. * @param {?} date
  1793. * @param {?} minDate
  1794. * @param {?} maxDate
  1795. * @return {?}
  1796. */
  1797. function generateSelectBoxMonths(calendar, date, minDate, maxDate) {
  1798. if (!date) {
  1799. return [];
  1800. }
  1801. /** @type {?} */
  1802. let months = calendar.getMonths(date.year);
  1803. if (minDate && date.year === minDate.year) {
  1804. /** @type {?} */
  1805. const index = months.findIndex((/**
  1806. * @param {?} month
  1807. * @return {?}
  1808. */
  1809. month => month === minDate.month));
  1810. months = months.slice(index);
  1811. }
  1812. if (maxDate && date.year === maxDate.year) {
  1813. /** @type {?} */
  1814. const index = months.findIndex((/**
  1815. * @param {?} month
  1816. * @return {?}
  1817. */
  1818. month => month === maxDate.month));
  1819. months = months.slice(0, index + 1);
  1820. }
  1821. return months;
  1822. }
  1823. /**
  1824. * @param {?} date
  1825. * @param {?} minDate
  1826. * @param {?} maxDate
  1827. * @return {?}
  1828. */
  1829. function generateSelectBoxYears(date, minDate, maxDate) {
  1830. if (!date) {
  1831. return [];
  1832. }
  1833. /** @type {?} */
  1834. const start = minDate ? Math.max(minDate.year, date.year - 500) : date.year - 10;
  1835. /** @type {?} */
  1836. const end = maxDate ? Math.min(maxDate.year, date.year + 500) : date.year + 10;
  1837. /** @type {?} */
  1838. const length = end - start + 1;
  1839. /** @type {?} */
  1840. const numbers = Array(length);
  1841. for (let i = 0; i < length; i++) {
  1842. numbers[i] = start + i;
  1843. }
  1844. return numbers;
  1845. }
  1846. /**
  1847. * @param {?} calendar
  1848. * @param {?} date
  1849. * @param {?} maxDate
  1850. * @return {?}
  1851. */
  1852. function nextMonthDisabled(calendar, date, maxDate) {
  1853. /** @type {?} */
  1854. const nextDate = Object.assign(calendar.getNext(date, 'm'), { day: 1 });
  1855. return maxDate && nextDate.after(maxDate);
  1856. }
  1857. /**
  1858. * @param {?} calendar
  1859. * @param {?} date
  1860. * @param {?} minDate
  1861. * @return {?}
  1862. */
  1863. function prevMonthDisabled(calendar, date, minDate) {
  1864. /** @type {?} */
  1865. const prevDate = Object.assign(calendar.getPrev(date, 'm'), { day: 1 });
  1866. return minDate && (prevDate.year === minDate.year && prevDate.month < minDate.month ||
  1867. prevDate.year < minDate.year && minDate.month === 1);
  1868. }
  1869. /**
  1870. * @param {?} calendar
  1871. * @param {?} date
  1872. * @param {?} state
  1873. * @param {?} i18n
  1874. * @param {?} force
  1875. * @return {?}
  1876. */
  1877. function buildMonths(calendar, date, state, i18n, force) {
  1878. const { displayMonths, months } = state;
  1879. // move old months to a temporary array
  1880. /** @type {?} */
  1881. const monthsToReuse = months.splice(0, months.length);
  1882. // generate new first dates, nullify or reuse months
  1883. /** @type {?} */
  1884. const firstDates = Array.from({ length: displayMonths }, (/**
  1885. * @param {?} _
  1886. * @param {?} i
  1887. * @return {?}
  1888. */
  1889. (_, i) => {
  1890. /** @type {?} */
  1891. const firstDate = Object.assign(calendar.getNext(date, 'm', i), { day: 1 });
  1892. months[i] = null;
  1893. if (!force) {
  1894. /** @type {?} */
  1895. const reusedIndex = monthsToReuse.findIndex((/**
  1896. * @param {?} month
  1897. * @return {?}
  1898. */
  1899. month => month.firstDate.equals(firstDate)));
  1900. // move reused month back to months
  1901. if (reusedIndex !== -1) {
  1902. months[i] = monthsToReuse.splice(reusedIndex, 1)[0];
  1903. }
  1904. }
  1905. return firstDate;
  1906. }));
  1907. // rebuild nullified months
  1908. firstDates.forEach((/**
  1909. * @param {?} firstDate
  1910. * @param {?} i
  1911. * @return {?}
  1912. */
  1913. (firstDate, i) => {
  1914. if (months[i] === null) {
  1915. months[i] = buildMonth(calendar, firstDate, state, i18n, monthsToReuse.shift() || (/** @type {?} */ ({})));
  1916. }
  1917. }));
  1918. return months;
  1919. }
  1920. /**
  1921. * @param {?} calendar
  1922. * @param {?} date
  1923. * @param {?} state
  1924. * @param {?} i18n
  1925. * @param {?=} month
  1926. * @return {?}
  1927. */
  1928. function buildMonth(calendar, date, state, i18n, month = (/** @type {?} */ ({}))) {
  1929. const { dayTemplateData, minDate, maxDate, firstDayOfWeek, markDisabled, outsideDays } = state;
  1930. /** @type {?} */
  1931. const calendarToday = calendar.getToday();
  1932. month.firstDate = null;
  1933. month.lastDate = null;
  1934. month.number = date.month;
  1935. month.year = date.year;
  1936. month.weeks = month.weeks || [];
  1937. month.weekdays = month.weekdays || [];
  1938. date = getFirstViewDate(calendar, date, firstDayOfWeek);
  1939. // month has weeks
  1940. for (let week = 0; week < calendar.getWeeksPerMonth(); week++) {
  1941. /** @type {?} */
  1942. let weekObject = month.weeks[week];
  1943. if (!weekObject) {
  1944. weekObject = month.weeks[week] = { number: 0, days: [], collapsed: true };
  1945. }
  1946. /** @type {?} */
  1947. const days = weekObject.days;
  1948. // week has days
  1949. for (let day = 0; day < calendar.getDaysPerWeek(); day++) {
  1950. if (week === 0) {
  1951. month.weekdays[day] = calendar.getWeekday(date);
  1952. }
  1953. /** @type {?} */
  1954. const newDate = new NgbDate(date.year, date.month, date.day);
  1955. /** @type {?} */
  1956. const nextDate = calendar.getNext(newDate);
  1957. /** @type {?} */
  1958. const ariaLabel = i18n.getDayAriaLabel(newDate);
  1959. // marking date as disabled
  1960. /** @type {?} */
  1961. let disabled = !!((minDate && newDate.before(minDate)) || (maxDate && newDate.after(maxDate)));
  1962. if (!disabled && markDisabled) {
  1963. disabled = markDisabled(newDate, { month: month.number, year: month.year });
  1964. }
  1965. // today
  1966. /** @type {?} */
  1967. let today = newDate.equals(calendarToday);
  1968. // adding user-provided data to the context
  1969. /** @type {?} */
  1970. let contextUserData = dayTemplateData ? dayTemplateData(newDate, { month: month.number, year: month.year }) : undefined;
  1971. // saving first date of the month
  1972. if (month.firstDate === null && newDate.month === month.number) {
  1973. month.firstDate = newDate;
  1974. }
  1975. // saving last date of the month
  1976. if (newDate.month === month.number && nextDate.month !== month.number) {
  1977. month.lastDate = newDate;
  1978. }
  1979. /** @type {?} */
  1980. let dayObject = days[day];
  1981. if (!dayObject) {
  1982. dayObject = days[day] = (/** @type {?} */ ({}));
  1983. }
  1984. dayObject.date = newDate;
  1985. dayObject.context = Object.assign(dayObject.context || {}, {
  1986. $implicit: newDate,
  1987. date: newDate,
  1988. data: contextUserData,
  1989. currentMonth: month.number,
  1990. currentYear: month.year, disabled,
  1991. focused: false,
  1992. selected: false, today
  1993. });
  1994. dayObject.tabindex = -1;
  1995. dayObject.ariaLabel = ariaLabel;
  1996. dayObject.hidden = false;
  1997. date = nextDate;
  1998. }
  1999. weekObject.number = calendar.getWeekNumber(days.map((/**
  2000. * @param {?} day
  2001. * @return {?}
  2002. */
  2003. day => day.date)), firstDayOfWeek);
  2004. // marking week as collapsed
  2005. weekObject.collapsed = outsideDays === 'collapsed' && days[0].date.month !== month.number &&
  2006. days[days.length - 1].date.month !== month.number;
  2007. }
  2008. return month;
  2009. }
  2010. /**
  2011. * @param {?} calendar
  2012. * @param {?} date
  2013. * @param {?} firstDayOfWeek
  2014. * @return {?}
  2015. */
  2016. function getFirstViewDate(calendar, date, firstDayOfWeek) {
  2017. /** @type {?} */
  2018. const daysPerWeek = calendar.getDaysPerWeek();
  2019. /** @type {?} */
  2020. const firstMonthDate = new NgbDate(date.year, date.month, 1);
  2021. /** @type {?} */
  2022. const dayOfWeek = calendar.getWeekday(firstMonthDate) % daysPerWeek;
  2023. return calendar.getPrev(firstMonthDate, 'd', (daysPerWeek + dayOfWeek - firstDayOfWeek) % daysPerWeek);
  2024. }
  2025. /**
  2026. * @fileoverview added by tsickle
  2027. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2028. */
  2029. /**
  2030. * @param {?} locale
  2031. * @return {?}
  2032. */
  2033. function NGB_DATEPICKER_18N_FACTORY(locale) {
  2034. return new NgbDatepickerI18nDefault(locale);
  2035. }
  2036. /**
  2037. * A service supplying i18n data to the datepicker component.
  2038. *
  2039. * The default implementation of this service uses the Angular locale and registered locale data for
  2040. * weekdays and month names (as explained in the Angular i18n guide).
  2041. *
  2042. * It also provides a way to i18n data that depends on calendar calculations, like aria labels, day, week and year
  2043. * numerals. For other static labels the datepicker uses the default Angular i18n.
  2044. *
  2045. * See the [i18n demo](#/components/datepicker/examples#i18n) and
  2046. * [Hebrew calendar demo](#/components/datepicker/calendars#hebrew) on how to extend this class and define
  2047. * a custom provider for i18n.
  2048. * @abstract
  2049. */
  2050. class NgbDatepickerI18n {
  2051. /**
  2052. * Returns the textual representation of a day that is rendered in a day cell.
  2053. *
  2054. * \@since 3.0.0
  2055. * @param {?} date
  2056. * @return {?}
  2057. */
  2058. getDayNumerals(date) { return `${date.day}`; }
  2059. /**
  2060. * Returns the textual representation of a week number rendered by datepicker.
  2061. *
  2062. * \@since 3.0.0
  2063. * @param {?} weekNumber
  2064. * @return {?}
  2065. */
  2066. getWeekNumerals(weekNumber) { return `${weekNumber}`; }
  2067. /**
  2068. * Returns the textual representation of a year that is rendered in the datepicker year select box.
  2069. *
  2070. * \@since 3.0.0
  2071. * @param {?} year
  2072. * @return {?}
  2073. */
  2074. getYearNumerals(year) { return `${year}`; }
  2075. }
  2076. NgbDatepickerI18n.decorators = [
  2077. { type: Injectable, args: [{ providedIn: 'root', useFactory: NGB_DATEPICKER_18N_FACTORY, deps: [LOCALE_ID] },] }
  2078. ];
  2079. /** @nocollapse */ NgbDatepickerI18n.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbDatepickerI18n_Factory() { return NGB_DATEPICKER_18N_FACTORY(ɵɵinject(LOCALE_ID)); }, token: NgbDatepickerI18n, providedIn: "root" });
  2080. class NgbDatepickerI18nDefault extends NgbDatepickerI18n {
  2081. /**
  2082. * @param {?} _locale
  2083. */
  2084. constructor(_locale) {
  2085. super();
  2086. this._locale = _locale;
  2087. /** @type {?} */
  2088. const weekdaysStartingOnSunday = getLocaleDayNames(_locale, FormStyle.Standalone, TranslationWidth.Short);
  2089. this._weekdaysShort = weekdaysStartingOnSunday.map((/**
  2090. * @param {?} day
  2091. * @param {?} index
  2092. * @return {?}
  2093. */
  2094. (day, index) => weekdaysStartingOnSunday[(index + 1) % 7]));
  2095. this._monthsShort = getLocaleMonthNames(_locale, FormStyle.Standalone, TranslationWidth.Abbreviated);
  2096. this._monthsFull = getLocaleMonthNames(_locale, FormStyle.Standalone, TranslationWidth.Wide);
  2097. }
  2098. /**
  2099. * @param {?} weekday
  2100. * @return {?}
  2101. */
  2102. getWeekdayShortName(weekday) { return this._weekdaysShort[weekday - 1]; }
  2103. /**
  2104. * @param {?} month
  2105. * @return {?}
  2106. */
  2107. getMonthShortName(month) { return this._monthsShort[month - 1]; }
  2108. /**
  2109. * @param {?} month
  2110. * @return {?}
  2111. */
  2112. getMonthFullName(month) { return this._monthsFull[month - 1]; }
  2113. /**
  2114. * @param {?} date
  2115. * @return {?}
  2116. */
  2117. getDayAriaLabel(date) {
  2118. /** @type {?} */
  2119. const jsDate = new Date(date.year, date.month - 1, date.day);
  2120. return formatDate(jsDate, 'fullDate', this._locale);
  2121. }
  2122. }
  2123. NgbDatepickerI18nDefault.decorators = [
  2124. { type: Injectable }
  2125. ];
  2126. /** @nocollapse */
  2127. NgbDatepickerI18nDefault.ctorParameters = () => [
  2128. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
  2129. ];
  2130. /**
  2131. * @fileoverview added by tsickle
  2132. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2133. */
  2134. class NgbDatepickerService {
  2135. /**
  2136. * @param {?} _calendar
  2137. * @param {?} _i18n
  2138. */
  2139. constructor(_calendar, _i18n) {
  2140. this._calendar = _calendar;
  2141. this._i18n = _i18n;
  2142. this._VALIDATORS = {
  2143. dayTemplateData: (/**
  2144. * @param {?} dayTemplateData
  2145. * @return {?}
  2146. */
  2147. (dayTemplateData) => {
  2148. if (this._state.dayTemplateData !== dayTemplateData) {
  2149. return { dayTemplateData };
  2150. }
  2151. }),
  2152. displayMonths: (/**
  2153. * @param {?} displayMonths
  2154. * @return {?}
  2155. */
  2156. (displayMonths) => {
  2157. displayMonths = toInteger(displayMonths);
  2158. if (isInteger(displayMonths) && displayMonths > 0 && this._state.displayMonths !== displayMonths) {
  2159. return { displayMonths };
  2160. }
  2161. }),
  2162. disabled: (/**
  2163. * @param {?} disabled
  2164. * @return {?}
  2165. */
  2166. (disabled) => {
  2167. if (this._state.disabled !== disabled) {
  2168. return { disabled };
  2169. }
  2170. }),
  2171. firstDayOfWeek: (/**
  2172. * @param {?} firstDayOfWeek
  2173. * @return {?}
  2174. */
  2175. (firstDayOfWeek) => {
  2176. firstDayOfWeek = toInteger(firstDayOfWeek);
  2177. if (isInteger(firstDayOfWeek) && firstDayOfWeek >= 0 && this._state.firstDayOfWeek !== firstDayOfWeek) {
  2178. return { firstDayOfWeek };
  2179. }
  2180. }),
  2181. focusVisible: (/**
  2182. * @param {?} focusVisible
  2183. * @return {?}
  2184. */
  2185. (focusVisible) => {
  2186. if (this._state.focusVisible !== focusVisible && !this._state.disabled) {
  2187. return { focusVisible };
  2188. }
  2189. }),
  2190. markDisabled: (/**
  2191. * @param {?} markDisabled
  2192. * @return {?}
  2193. */
  2194. (markDisabled) => {
  2195. if (this._state.markDisabled !== markDisabled) {
  2196. return { markDisabled };
  2197. }
  2198. }),
  2199. maxDate: (/**
  2200. * @param {?} date
  2201. * @return {?}
  2202. */
  2203. (date) => {
  2204. /** @type {?} */
  2205. const maxDate = this.toValidDate(date, null);
  2206. if (isChangedDate(this._state.maxDate, maxDate)) {
  2207. return { maxDate };
  2208. }
  2209. }),
  2210. minDate: (/**
  2211. * @param {?} date
  2212. * @return {?}
  2213. */
  2214. (date) => {
  2215. /** @type {?} */
  2216. const minDate = this.toValidDate(date, null);
  2217. if (isChangedDate(this._state.minDate, minDate)) {
  2218. return { minDate };
  2219. }
  2220. }),
  2221. navigation: (/**
  2222. * @param {?} navigation
  2223. * @return {?}
  2224. */
  2225. (navigation) => {
  2226. if (this._state.navigation !== navigation) {
  2227. return { navigation };
  2228. }
  2229. }),
  2230. outsideDays: (/**
  2231. * @param {?} outsideDays
  2232. * @return {?}
  2233. */
  2234. (outsideDays) => {
  2235. if (this._state.outsideDays !== outsideDays) {
  2236. return { outsideDays };
  2237. }
  2238. })
  2239. };
  2240. this._model$ = new Subject();
  2241. this._dateSelect$ = new Subject();
  2242. this._state = {
  2243. disabled: false,
  2244. displayMonths: 1,
  2245. firstDayOfWeek: 1,
  2246. focusVisible: false,
  2247. months: [],
  2248. navigation: 'select',
  2249. outsideDays: 'visible',
  2250. prevDisabled: false,
  2251. nextDisabled: false,
  2252. selectBoxes: { years: [], months: [] },
  2253. selectedDate: null
  2254. };
  2255. }
  2256. /**
  2257. * @return {?}
  2258. */
  2259. get model$() { return this._model$.pipe(filter((/**
  2260. * @param {?} model
  2261. * @return {?}
  2262. */
  2263. model => model.months.length > 0))); }
  2264. /**
  2265. * @return {?}
  2266. */
  2267. get dateSelect$() { return this._dateSelect$.pipe(filter((/**
  2268. * @param {?} date
  2269. * @return {?}
  2270. */
  2271. date => date !== null))); }
  2272. /**
  2273. * @param {?} options
  2274. * @return {?}
  2275. */
  2276. set(options) {
  2277. /** @type {?} */
  2278. let patch = Object.keys(options)
  2279. .map((/**
  2280. * @param {?} key
  2281. * @return {?}
  2282. */
  2283. key => this._VALIDATORS[key](options[key])))
  2284. .reduce((/**
  2285. * @param {?} obj
  2286. * @param {?} part
  2287. * @return {?}
  2288. */
  2289. (obj, part) => (Object.assign({}, obj, part))), {});
  2290. if (Object.keys(patch).length > 0) {
  2291. this._nextState(patch);
  2292. }
  2293. }
  2294. /**
  2295. * @param {?} date
  2296. * @return {?}
  2297. */
  2298. focus(date) {
  2299. if (!this._state.disabled && this._calendar.isValid(date) && isChangedDate(this._state.focusDate, date)) {
  2300. this._nextState({ focusDate: date });
  2301. }
  2302. }
  2303. /**
  2304. * @return {?}
  2305. */
  2306. focusSelect() {
  2307. if (isDateSelectable(this._state.focusDate, this._state)) {
  2308. this.select(this._state.focusDate, { emitEvent: true });
  2309. }
  2310. }
  2311. /**
  2312. * @param {?} date
  2313. * @return {?}
  2314. */
  2315. open(date) {
  2316. /** @type {?} */
  2317. const firstDate = this.toValidDate(date, this._calendar.getToday());
  2318. if (!this._state.disabled && (!this._state.firstDate || isChangedMonth(this._state.firstDate, date))) {
  2319. this._nextState({ firstDate });
  2320. }
  2321. }
  2322. /**
  2323. * @param {?} date
  2324. * @param {?=} options
  2325. * @return {?}
  2326. */
  2327. select(date, options = {}) {
  2328. /** @type {?} */
  2329. const selectedDate = this.toValidDate(date, null);
  2330. if (!this._state.disabled) {
  2331. if (isChangedDate(this._state.selectedDate, selectedDate)) {
  2332. this._nextState({ selectedDate });
  2333. }
  2334. if (options.emitEvent && isDateSelectable(selectedDate, this._state)) {
  2335. this._dateSelect$.next(selectedDate);
  2336. }
  2337. }
  2338. }
  2339. /**
  2340. * @param {?} date
  2341. * @param {?=} defaultValue
  2342. * @return {?}
  2343. */
  2344. toValidDate(date, defaultValue) {
  2345. /** @type {?} */
  2346. const ngbDate = NgbDate.from(date);
  2347. if (defaultValue === undefined) {
  2348. defaultValue = this._calendar.getToday();
  2349. }
  2350. return this._calendar.isValid(ngbDate) ? ngbDate : defaultValue;
  2351. }
  2352. /**
  2353. * @private
  2354. * @param {?} patch
  2355. * @return {?}
  2356. */
  2357. _nextState(patch) {
  2358. /** @type {?} */
  2359. const newState = this._updateState(patch);
  2360. this._patchContexts(newState);
  2361. this._state = newState;
  2362. this._model$.next(this._state);
  2363. }
  2364. /**
  2365. * @private
  2366. * @param {?} state
  2367. * @return {?}
  2368. */
  2369. _patchContexts(state) {
  2370. const { months, displayMonths, selectedDate, focusDate, focusVisible, disabled, outsideDays } = state;
  2371. state.months.forEach((/**
  2372. * @param {?} month
  2373. * @return {?}
  2374. */
  2375. month => {
  2376. month.weeks.forEach((/**
  2377. * @param {?} week
  2378. * @return {?}
  2379. */
  2380. week => {
  2381. week.days.forEach((/**
  2382. * @param {?} day
  2383. * @return {?}
  2384. */
  2385. day => {
  2386. // patch focus flag
  2387. if (focusDate) {
  2388. day.context.focused = focusDate.equals(day.date) && focusVisible;
  2389. }
  2390. // calculating tabindex
  2391. day.tabindex = !disabled && day.date.equals(focusDate) && focusDate.month === month.number ? 0 : -1;
  2392. // override context disabled
  2393. if (disabled === true) {
  2394. day.context.disabled = true;
  2395. }
  2396. // patch selection flag
  2397. if (selectedDate !== undefined) {
  2398. day.context.selected = selectedDate !== null && selectedDate.equals(day.date);
  2399. }
  2400. // visibility
  2401. if (month.number !== day.date.month) {
  2402. day.hidden = outsideDays === 'hidden' || outsideDays === 'collapsed' ||
  2403. (displayMonths > 1 && day.date.after(months[0].firstDate) &&
  2404. day.date.before(months[displayMonths - 1].lastDate));
  2405. }
  2406. }));
  2407. }));
  2408. }));
  2409. }
  2410. /**
  2411. * @private
  2412. * @param {?} patch
  2413. * @return {?}
  2414. */
  2415. _updateState(patch) {
  2416. // patching fields
  2417. /** @type {?} */
  2418. const state = Object.assign({}, this._state, patch);
  2419. /** @type {?} */
  2420. let startDate = state.firstDate;
  2421. // min/max dates changed
  2422. if ('minDate' in patch || 'maxDate' in patch) {
  2423. checkMinBeforeMax(state.minDate, state.maxDate);
  2424. state.focusDate = checkDateInRange(state.focusDate, state.minDate, state.maxDate);
  2425. state.firstDate = checkDateInRange(state.firstDate, state.minDate, state.maxDate);
  2426. startDate = state.focusDate;
  2427. }
  2428. // disabled
  2429. if ('disabled' in patch) {
  2430. state.focusVisible = false;
  2431. }
  2432. // initial rebuild via 'select()'
  2433. if ('selectedDate' in patch && this._state.months.length === 0) {
  2434. startDate = state.selectedDate;
  2435. }
  2436. // terminate early if only focus visibility was changed
  2437. if ('focusVisible' in patch) {
  2438. return state;
  2439. }
  2440. // focus date changed
  2441. if ('focusDate' in patch) {
  2442. state.focusDate = checkDateInRange(state.focusDate, state.minDate, state.maxDate);
  2443. startDate = state.focusDate;
  2444. // nothing to rebuild if only focus changed and it is still visible
  2445. if (state.months.length !== 0 && !state.focusDate.before(state.firstDate) &&
  2446. !state.focusDate.after(state.lastDate)) {
  2447. return state;
  2448. }
  2449. }
  2450. // first date changed
  2451. if ('firstDate' in patch) {
  2452. state.firstDate = checkDateInRange(state.firstDate, state.minDate, state.maxDate);
  2453. startDate = state.firstDate;
  2454. }
  2455. // rebuilding months
  2456. if (startDate) {
  2457. /** @type {?} */
  2458. const forceRebuild = 'dayTemplateData' in patch || 'firstDayOfWeek' in patch || 'markDisabled' in patch ||
  2459. 'minDate' in patch || 'maxDate' in patch || 'disabled' in patch || 'outsideDays' in patch;
  2460. /** @type {?} */
  2461. const months = buildMonths(this._calendar, startDate, state, this._i18n, forceRebuild);
  2462. // updating months and boundary dates
  2463. state.months = months;
  2464. state.firstDate = months.length > 0 ? months[0].firstDate : undefined;
  2465. state.lastDate = months.length > 0 ? months[months.length - 1].lastDate : undefined;
  2466. // reset selected date if 'markDisabled' returns true
  2467. if ('selectedDate' in patch && !isDateSelectable(state.selectedDate, state)) {
  2468. state.selectedDate = null;
  2469. }
  2470. // adjusting focus after months were built
  2471. if ('firstDate' in patch) {
  2472. if (state.focusDate === undefined || state.focusDate.before(state.firstDate) ||
  2473. state.focusDate.after(state.lastDate)) {
  2474. state.focusDate = startDate;
  2475. }
  2476. }
  2477. // adjusting months/years for the select box navigation
  2478. /** @type {?} */
  2479. const yearChanged = !this._state.firstDate || this._state.firstDate.year !== state.firstDate.year;
  2480. /** @type {?} */
  2481. const monthChanged = !this._state.firstDate || this._state.firstDate.month !== state.firstDate.month;
  2482. if (state.navigation === 'select') {
  2483. // years -> boundaries (min/max were changed)
  2484. if ('minDate' in patch || 'maxDate' in patch || state.selectBoxes.years.length === 0 || yearChanged) {
  2485. state.selectBoxes.years = generateSelectBoxYears(state.firstDate, state.minDate, state.maxDate);
  2486. }
  2487. // months -> when current year or boundaries change
  2488. if ('minDate' in patch || 'maxDate' in patch || state.selectBoxes.months.length === 0 || yearChanged) {
  2489. state.selectBoxes.months =
  2490. generateSelectBoxMonths(this._calendar, state.firstDate, state.minDate, state.maxDate);
  2491. }
  2492. }
  2493. else {
  2494. state.selectBoxes = { years: [], months: [] };
  2495. }
  2496. // updating navigation arrows -> boundaries change (min/max) or month/year changes
  2497. if ((state.navigation === 'arrows' || state.navigation === 'select') &&
  2498. (monthChanged || yearChanged || 'minDate' in patch || 'maxDate' in patch || 'disabled' in patch)) {
  2499. state.prevDisabled = state.disabled || prevMonthDisabled(this._calendar, state.firstDate, state.minDate);
  2500. state.nextDisabled = state.disabled || nextMonthDisabled(this._calendar, state.lastDate, state.maxDate);
  2501. }
  2502. }
  2503. return state;
  2504. }
  2505. }
  2506. NgbDatepickerService.decorators = [
  2507. { type: Injectable }
  2508. ];
  2509. /** @nocollapse */
  2510. NgbDatepickerService.ctorParameters = () => [
  2511. { type: NgbCalendar },
  2512. { type: NgbDatepickerI18n }
  2513. ];
  2514. /**
  2515. * @fileoverview added by tsickle
  2516. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2517. */
  2518. /** @enum {number} */
  2519. const Key = {
  2520. Tab: 9,
  2521. Enter: 13,
  2522. Escape: 27,
  2523. Space: 32,
  2524. PageUp: 33,
  2525. PageDown: 34,
  2526. End: 35,
  2527. Home: 36,
  2528. ArrowLeft: 37,
  2529. ArrowUp: 38,
  2530. ArrowRight: 39,
  2531. ArrowDown: 40,
  2532. };
  2533. Key[Key.Tab] = 'Tab';
  2534. Key[Key.Enter] = 'Enter';
  2535. Key[Key.Escape] = 'Escape';
  2536. Key[Key.Space] = 'Space';
  2537. Key[Key.PageUp] = 'PageUp';
  2538. Key[Key.PageDown] = 'PageDown';
  2539. Key[Key.End] = 'End';
  2540. Key[Key.Home] = 'Home';
  2541. Key[Key.ArrowLeft] = 'ArrowLeft';
  2542. Key[Key.ArrowUp] = 'ArrowUp';
  2543. Key[Key.ArrowRight] = 'ArrowRight';
  2544. Key[Key.ArrowDown] = 'ArrowDown';
  2545. /**
  2546. * @fileoverview added by tsickle
  2547. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2548. */
  2549. /**
  2550. * A service that represents the keyboard navigation.
  2551. *
  2552. * Default keyboard shortcuts [are documented in the overview](#/components/datepicker/overview#keyboard-shortcuts)
  2553. *
  2554. * \@since 5.2.0
  2555. */
  2556. class NgbDatepickerKeyboardService {
  2557. /**
  2558. * Processes a keyboard event.
  2559. * @param {?} event
  2560. * @param {?} datepicker
  2561. * @param {?} calendar
  2562. * @return {?}
  2563. */
  2564. processKey(event, datepicker, calendar) {
  2565. /** @type {?} */
  2566. const state = datepicker.state;
  2567. // tslint:disable-next-line:deprecation
  2568. switch (event.which) {
  2569. case Key.PageUp:
  2570. datepicker.focusDate(calendar.getPrev(state.focusedDate, event.shiftKey ? 'y' : 'm', 1));
  2571. break;
  2572. case Key.PageDown:
  2573. datepicker.focusDate(calendar.getNext(state.focusedDate, event.shiftKey ? 'y' : 'm', 1));
  2574. break;
  2575. case Key.End:
  2576. datepicker.focusDate(event.shiftKey ? state.maxDate : state.lastDate);
  2577. break;
  2578. case Key.Home:
  2579. datepicker.focusDate(event.shiftKey ? state.minDate : state.firstDate);
  2580. break;
  2581. case Key.ArrowLeft:
  2582. datepicker.focusDate(calendar.getPrev(state.focusedDate, 'd', 1));
  2583. break;
  2584. case Key.ArrowUp:
  2585. datepicker.focusDate(calendar.getPrev(state.focusedDate, 'd', calendar.getDaysPerWeek()));
  2586. break;
  2587. case Key.ArrowRight:
  2588. datepicker.focusDate(calendar.getNext(state.focusedDate, 'd', 1));
  2589. break;
  2590. case Key.ArrowDown:
  2591. datepicker.focusDate(calendar.getNext(state.focusedDate, 'd', calendar.getDaysPerWeek()));
  2592. break;
  2593. case Key.Enter:
  2594. case Key.Space:
  2595. datepicker.focusSelect();
  2596. break;
  2597. default:
  2598. return;
  2599. }
  2600. event.preventDefault();
  2601. event.stopPropagation();
  2602. }
  2603. }
  2604. NgbDatepickerKeyboardService.decorators = [
  2605. { type: Injectable, args: [{ providedIn: 'root' },] }
  2606. ];
  2607. /** @nocollapse */ NgbDatepickerKeyboardService.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbDatepickerKeyboardService_Factory() { return new NgbDatepickerKeyboardService(); }, token: NgbDatepickerKeyboardService, providedIn: "root" });
  2608. /**
  2609. * @fileoverview added by tsickle
  2610. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2611. */
  2612. /** @enum {number} */
  2613. const NavigationEvent = {
  2614. PREV: 0,
  2615. NEXT: 1,
  2616. };
  2617. NavigationEvent[NavigationEvent.PREV] = 'PREV';
  2618. NavigationEvent[NavigationEvent.NEXT] = 'NEXT';
  2619. /**
  2620. * @fileoverview added by tsickle
  2621. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2622. */
  2623. /**
  2624. * A configuration service for the [`NgbDatepicker`](#/components/datepicker/api#NgbDatepicker) component.
  2625. *
  2626. * You can inject this service, typically in your root component, and customize the values of its properties in
  2627. * order to provide default values for all the datepickers used in the application.
  2628. */
  2629. class NgbDatepickerConfig {
  2630. constructor() {
  2631. this.displayMonths = 1;
  2632. this.firstDayOfWeek = 1;
  2633. this.navigation = 'select';
  2634. this.outsideDays = 'visible';
  2635. this.showWeekdays = true;
  2636. this.showWeekNumbers = false;
  2637. }
  2638. }
  2639. NgbDatepickerConfig.decorators = [
  2640. { type: Injectable, args: [{ providedIn: 'root' },] }
  2641. ];
  2642. /** @nocollapse */ NgbDatepickerConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbDatepickerConfig_Factory() { return new NgbDatepickerConfig(); }, token: NgbDatepickerConfig, providedIn: "root" });
  2643. /**
  2644. * @fileoverview added by tsickle
  2645. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2646. */
  2647. /**
  2648. * @return {?}
  2649. */
  2650. function NGB_DATEPICKER_DATE_ADAPTER_FACTORY() {
  2651. return new NgbDateStructAdapter();
  2652. }
  2653. /**
  2654. * An abstract service that does the conversion between the internal datepicker `NgbDateStruct` model and
  2655. * any provided user date model `D`, ex. a string, a native date, etc.
  2656. *
  2657. * The adapter is used **only** for conversion when binding datepicker to a form control,
  2658. * ex. `[(ngModel)]="userDateModel"`. Here `userDateModel` can be of any type.
  2659. *
  2660. * The default datepicker implementation assumes we use `NgbDateStruct` as a user model.
  2661. *
  2662. * See the [date format overview](#/components/datepicker/overview#date-model) for more details
  2663. * and the [custom adapter demo](#/components/datepicker/examples#adapter) for an example.
  2664. * @abstract
  2665. * @template D
  2666. */
  2667. class NgbDateAdapter {
  2668. }
  2669. NgbDateAdapter.decorators = [
  2670. { type: Injectable, args: [{ providedIn: 'root', useFactory: NGB_DATEPICKER_DATE_ADAPTER_FACTORY },] }
  2671. ];
  2672. /** @nocollapse */ NgbDateAdapter.ngInjectableDef = ɵɵdefineInjectable({ factory: NGB_DATEPICKER_DATE_ADAPTER_FACTORY, token: NgbDateAdapter, providedIn: "root" });
  2673. class NgbDateStructAdapter extends NgbDateAdapter {
  2674. /**
  2675. * Converts a NgbDateStruct value into NgbDateStruct value
  2676. * @param {?} date
  2677. * @return {?}
  2678. */
  2679. fromModel(date) {
  2680. return (date && isInteger(date.year) && isInteger(date.month) && isInteger(date.day)) ?
  2681. { year: date.year, month: date.month, day: date.day } :
  2682. null;
  2683. }
  2684. /**
  2685. * Converts a NgbDateStruct value into NgbDateStruct value
  2686. * @param {?} date
  2687. * @return {?}
  2688. */
  2689. toModel(date) {
  2690. return (date && isInteger(date.year) && isInteger(date.month) && isInteger(date.day)) ?
  2691. { year: date.year, month: date.month, day: date.day } :
  2692. null;
  2693. }
  2694. }
  2695. NgbDateStructAdapter.decorators = [
  2696. { type: Injectable }
  2697. ];
  2698. /**
  2699. * @fileoverview added by tsickle
  2700. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  2701. */
  2702. /** @type {?} */
  2703. const NGB_DATEPICKER_VALUE_ACCESSOR = {
  2704. provide: NG_VALUE_ACCESSOR,
  2705. useExisting: forwardRef((/**
  2706. * @return {?}
  2707. */
  2708. () => NgbDatepicker)),
  2709. multi: true
  2710. };
  2711. /**
  2712. * A highly configurable component that helps you with selecting calendar dates.
  2713. *
  2714. * `NgbDatepicker` is meant to be displayed inline on a page or put inside a popup.
  2715. */
  2716. class NgbDatepicker {
  2717. /**
  2718. * @param {?} _service
  2719. * @param {?} _calendar
  2720. * @param {?} i18n
  2721. * @param {?} config
  2722. * @param {?} _keyboardService
  2723. * @param {?} cd
  2724. * @param {?} _elementRef
  2725. * @param {?} _ngbDateAdapter
  2726. * @param {?} _ngZone
  2727. */
  2728. constructor(_service, _calendar, i18n, config, _keyboardService, cd, _elementRef, _ngbDateAdapter, _ngZone) {
  2729. this._service = _service;
  2730. this._calendar = _calendar;
  2731. this.i18n = i18n;
  2732. this._keyboardService = _keyboardService;
  2733. this._elementRef = _elementRef;
  2734. this._ngbDateAdapter = _ngbDateAdapter;
  2735. this._ngZone = _ngZone;
  2736. this._destroyed$ = new Subject();
  2737. this._publicState = (/** @type {?} */ ({}));
  2738. /**
  2739. * An event emitted right before the navigation happens and displayed month changes.
  2740. *
  2741. * See [`NgbDatepickerNavigateEvent`](#/components/datepicker/api#NgbDatepickerNavigateEvent) for the payload info.
  2742. */
  2743. this.navigate = new EventEmitter();
  2744. /**
  2745. * An event emitted when user selects a date using keyboard or mouse.
  2746. *
  2747. * The payload of the event is currently selected `NgbDate`.
  2748. *
  2749. * \@since 5.2.0
  2750. */
  2751. this.dateSelect = new EventEmitter();
  2752. /**
  2753. * An event emitted when user selects a date using keyboard or mouse.
  2754. *
  2755. * The payload of the event is currently selected `NgbDate`.
  2756. *
  2757. * Please use 'dateSelect' output instead, this will be deprecated in version 6.0 due to collision with native
  2758. * 'select' event.
  2759. */
  2760. this.select = this.dateSelect;
  2761. this.onChange = (/**
  2762. * @param {?} _
  2763. * @return {?}
  2764. */
  2765. (_) => { });
  2766. this.onTouched = (/**
  2767. * @return {?}
  2768. */
  2769. () => { });
  2770. ['dayTemplate', 'dayTemplateData', 'displayMonths', 'firstDayOfWeek', 'footerTemplate', 'markDisabled', 'minDate',
  2771. 'maxDate', 'navigation', 'outsideDays', 'showWeekdays', 'showWeekNumbers', 'startDate']
  2772. .forEach((/**
  2773. * @param {?} input
  2774. * @return {?}
  2775. */
  2776. input => this[input] = config[input]));
  2777. _service.dateSelect$.pipe(takeUntil(this._destroyed$)).subscribe((/**
  2778. * @param {?} date
  2779. * @return {?}
  2780. */
  2781. date => { this.dateSelect.emit(date); }));
  2782. _service.model$.pipe(takeUntil(this._destroyed$)).subscribe((/**
  2783. * @param {?} model
  2784. * @return {?}
  2785. */
  2786. model => {
  2787. /** @type {?} */
  2788. const newDate = model.firstDate;
  2789. /** @type {?} */
  2790. const oldDate = this.model ? this.model.firstDate : null;
  2791. // update public state
  2792. this._publicState = {
  2793. maxDate: model.maxDate,
  2794. minDate: model.minDate,
  2795. firstDate: model.firstDate,
  2796. lastDate: model.lastDate,
  2797. focusedDate: model.focusDate
  2798. };
  2799. /** @type {?} */
  2800. let navigationPrevented = false;
  2801. // emitting navigation event if the first month changes
  2802. if (!newDate.equals(oldDate)) {
  2803. this.navigate.emit({
  2804. current: oldDate ? { year: oldDate.year, month: oldDate.month } : null,
  2805. next: { year: newDate.year, month: newDate.month },
  2806. preventDefault: (/**
  2807. * @return {?}
  2808. */
  2809. () => navigationPrevented = true)
  2810. });
  2811. // can't prevent the very first navigation
  2812. if (navigationPrevented && oldDate !== null) {
  2813. this._service.open(oldDate);
  2814. return;
  2815. }
  2816. }
  2817. /** @type {?} */
  2818. const newSelectedDate = model.selectedDate;
  2819. /** @type {?} */
  2820. const newFocusedDate = model.focusDate;
  2821. /** @type {?} */
  2822. const oldFocusedDate = this.model ? this.model.focusDate : null;
  2823. this.model = model;
  2824. // handling selection change
  2825. if (isChangedDate(newSelectedDate, this._controlValue)) {
  2826. this._controlValue = newSelectedDate;
  2827. this.onTouched();
  2828. this.onChange(this._ngbDateAdapter.toModel(newSelectedDate));
  2829. }
  2830. // handling focus change
  2831. if (isChangedDate(newFocusedDate, oldFocusedDate) && oldFocusedDate && model.focusVisible) {
  2832. this.focus();
  2833. }
  2834. cd.markForCheck();
  2835. }));
  2836. }
  2837. /**
  2838. * Returns the readonly public state of the datepicker
  2839. *
  2840. * \@since 5.2.0
  2841. * @return {?}
  2842. */
  2843. get state() { return this._publicState; }
  2844. /**
  2845. * Focuses on given date.
  2846. * @param {?} date
  2847. * @return {?}
  2848. */
  2849. focusDate(date) { this._service.focus(NgbDate.from(date)); }
  2850. /**
  2851. * Selects focused date.
  2852. * @return {?}
  2853. */
  2854. focusSelect() { this._service.focusSelect(); }
  2855. /**
  2856. * @return {?}
  2857. */
  2858. focus() {
  2859. this._ngZone.onStable.asObservable().pipe(take(1)).subscribe((/**
  2860. * @return {?}
  2861. */
  2862. () => {
  2863. /** @type {?} */
  2864. const elementToFocus = this._elementRef.nativeElement.querySelector('div.ngb-dp-day[tabindex="0"]');
  2865. if (elementToFocus) {
  2866. elementToFocus.focus();
  2867. }
  2868. }));
  2869. }
  2870. /**
  2871. * Navigates to the provided date.
  2872. *
  2873. * With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
  2874. * If nothing or invalid date provided calendar will open current month.
  2875. *
  2876. * Use the `[startDate]` input as an alternative.
  2877. * @param {?=} date
  2878. * @return {?}
  2879. */
  2880. navigateTo(date) {
  2881. this._service.open(NgbDate.from(date ? date.day ? (/** @type {?} */ (date)) : Object.assign({}, date, { day: 1 }) : null));
  2882. }
  2883. /**
  2884. * @return {?}
  2885. */
  2886. ngAfterViewInit() {
  2887. this._ngZone.runOutsideAngular((/**
  2888. * @return {?}
  2889. */
  2890. () => {
  2891. /** @type {?} */
  2892. const focusIns$ = fromEvent(this._monthsEl.nativeElement, 'focusin');
  2893. /** @type {?} */
  2894. const focusOuts$ = fromEvent(this._monthsEl.nativeElement, 'focusout');
  2895. const { nativeElement } = this._elementRef;
  2896. // we're changing 'focusVisible' only when entering or leaving months view
  2897. // and ignoring all focus events where both 'target' and 'related' target are day cells
  2898. merge(focusIns$, focusOuts$)
  2899. .pipe(filter((/**
  2900. * @param {?} __0
  2901. * @return {?}
  2902. */
  2903. ({ target, relatedTarget }) => !(hasClassName(target, 'ngb-dp-day') && hasClassName(relatedTarget, 'ngb-dp-day') &&
  2904. nativeElement.contains((/** @type {?} */ (target))) && nativeElement.contains((/** @type {?} */ (relatedTarget)))))), takeUntil(this._destroyed$))
  2905. .subscribe((/**
  2906. * @param {?} __0
  2907. * @return {?}
  2908. */
  2909. ({ type }) => this._ngZone.run((/**
  2910. * @return {?}
  2911. */
  2912. () => this._service.set({ focusVisible: type === 'focusin' })))));
  2913. }));
  2914. }
  2915. /**
  2916. * @return {?}
  2917. */
  2918. ngOnDestroy() { this._destroyed$.next(); }
  2919. /**
  2920. * @return {?}
  2921. */
  2922. ngOnInit() {
  2923. if (this.model === undefined) {
  2924. /** @type {?} */
  2925. const inputs = {};
  2926. ['dayTemplateData', 'displayMonths', 'markDisabled', 'firstDayOfWeek', 'navigation', 'minDate', 'maxDate',
  2927. 'outsideDays']
  2928. .forEach((/**
  2929. * @param {?} name
  2930. * @return {?}
  2931. */
  2932. name => inputs[name] = this[name]));
  2933. this._service.set(inputs);
  2934. this.navigateTo(this.startDate);
  2935. }
  2936. }
  2937. /**
  2938. * @param {?} changes
  2939. * @return {?}
  2940. */
  2941. ngOnChanges(changes) {
  2942. /** @type {?} */
  2943. const inputs = {};
  2944. ['dayTemplateData', 'displayMonths', 'markDisabled', 'firstDayOfWeek', 'navigation', 'minDate', 'maxDate',
  2945. 'outsideDays']
  2946. .filter((/**
  2947. * @param {?} name
  2948. * @return {?}
  2949. */
  2950. name => name in changes))
  2951. .forEach((/**
  2952. * @param {?} name
  2953. * @return {?}
  2954. */
  2955. name => inputs[name] = this[name]));
  2956. this._service.set(inputs);
  2957. if ('startDate' in changes) {
  2958. const { currentValue, previousValue } = changes.startDate;
  2959. if (isChangedMonth(previousValue, currentValue)) {
  2960. this.navigateTo(this.startDate);
  2961. }
  2962. }
  2963. }
  2964. /**
  2965. * @param {?} date
  2966. * @return {?}
  2967. */
  2968. onDateSelect(date) {
  2969. this._service.focus(date);
  2970. this._service.select(date, { emitEvent: true });
  2971. }
  2972. /**
  2973. * @param {?} event
  2974. * @return {?}
  2975. */
  2976. onKeyDown(event) { this._keyboardService.processKey(event, this, this._calendar); }
  2977. /**
  2978. * @param {?} date
  2979. * @return {?}
  2980. */
  2981. onNavigateDateSelect(date) { this._service.open(date); }
  2982. /**
  2983. * @param {?} event
  2984. * @return {?}
  2985. */
  2986. onNavigateEvent(event) {
  2987. switch (event) {
  2988. case NavigationEvent.PREV:
  2989. this._service.open(this._calendar.getPrev(this.model.firstDate, 'm', 1));
  2990. break;
  2991. case NavigationEvent.NEXT:
  2992. this._service.open(this._calendar.getNext(this.model.firstDate, 'm', 1));
  2993. break;
  2994. }
  2995. }
  2996. /**
  2997. * @param {?} fn
  2998. * @return {?}
  2999. */
  3000. registerOnChange(fn) { this.onChange = fn; }
  3001. /**
  3002. * @param {?} fn
  3003. * @return {?}
  3004. */
  3005. registerOnTouched(fn) { this.onTouched = fn; }
  3006. /**
  3007. * @param {?} disabled
  3008. * @return {?}
  3009. */
  3010. setDisabledState(disabled) { this._service.set({ disabled }); }
  3011. /**
  3012. * @param {?} value
  3013. * @return {?}
  3014. */
  3015. writeValue(value) {
  3016. this._controlValue = NgbDate.from(this._ngbDateAdapter.fromModel(value));
  3017. this._service.select(this._controlValue);
  3018. }
  3019. }
  3020. NgbDatepicker.decorators = [
  3021. { type: Component, args: [{
  3022. exportAs: 'ngbDatepicker',
  3023. selector: 'ngb-datepicker',
  3024. changeDetection: ChangeDetectionStrategy.OnPush,
  3025. encapsulation: ViewEncapsulation.None,
  3026. template: `
  3027. <ng-template #dt let-date="date" let-currentMonth="currentMonth" let-selected="selected" let-disabled="disabled" let-focused="focused">
  3028. <div ngbDatepickerDayView
  3029. [date]="date"
  3030. [currentMonth]="currentMonth"
  3031. [selected]="selected"
  3032. [disabled]="disabled"
  3033. [focused]="focused">
  3034. </div>
  3035. </ng-template>
  3036. <div class="ngb-dp-header">
  3037. <ngb-datepicker-navigation *ngIf="navigation !== 'none'"
  3038. [date]="model.firstDate"
  3039. [months]="model.months"
  3040. [disabled]="model.disabled"
  3041. [showSelect]="model.navigation === 'select'"
  3042. [prevDisabled]="model.prevDisabled"
  3043. [nextDisabled]="model.nextDisabled"
  3044. [selectBoxes]="model.selectBoxes"
  3045. (navigate)="onNavigateEvent($event)"
  3046. (select)="onNavigateDateSelect($event)">
  3047. </ngb-datepicker-navigation>
  3048. </div>
  3049. <div #months class="ngb-dp-months" (keydown)="onKeyDown($event)">
  3050. <ng-template ngFor let-month [ngForOf]="model.months" let-i="index">
  3051. <div class="ngb-dp-month">
  3052. <div *ngIf="navigation === 'none' || (displayMonths > 1 && navigation === 'select')"
  3053. class="ngb-dp-month-name">
  3054. {{ i18n.getMonthFullName(month.number, month.year) }} {{ i18n.getYearNumerals(month.year) }}
  3055. </div>
  3056. <ngb-datepicker-month-view
  3057. [month]="month"
  3058. [dayTemplate]="dayTemplate || dt"
  3059. [showWeekdays]="showWeekdays"
  3060. [showWeekNumbers]="showWeekNumbers"
  3061. (select)="onDateSelect($event)">
  3062. </ngb-datepicker-month-view>
  3063. </div>
  3064. </ng-template>
  3065. </div>
  3066. <ng-template [ngTemplateOutlet]="footerTemplate"></ng-template>
  3067. `,
  3068. providers: [NGB_DATEPICKER_VALUE_ACCESSOR, NgbDatepickerService],
  3069. styles: ["ngb-datepicker{border:1px solid #dfdfdf;border-radius:.25rem;display:inline-block}ngb-datepicker-month-view{pointer-events:auto}ngb-datepicker.dropdown-menu{padding:0}.ngb-dp-body{z-index:1050}.ngb-dp-header{border-bottom:0;border-radius:.25rem .25rem 0 0;padding-top:.25rem;background-color:#f8f9fa;background-color:var(--light)}.ngb-dp-months{display:-ms-flexbox;display:flex}.ngb-dp-month{pointer-events:none}.ngb-dp-month-name{font-size:larger;height:2rem;line-height:2rem;text-align:center;background-color:#f8f9fa;background-color:var(--light)}.ngb-dp-month+.ngb-dp-month .ngb-dp-month-name,.ngb-dp-month+.ngb-dp-month .ngb-dp-week{padding-left:1rem}.ngb-dp-month:last-child .ngb-dp-week{padding-right:.25rem}.ngb-dp-month:first-child .ngb-dp-week{padding-left:.25rem}.ngb-dp-month .ngb-dp-week:last-child{padding-bottom:.25rem}"]
  3070. }] }
  3071. ];
  3072. /** @nocollapse */
  3073. NgbDatepicker.ctorParameters = () => [
  3074. { type: NgbDatepickerService },
  3075. { type: NgbCalendar },
  3076. { type: NgbDatepickerI18n },
  3077. { type: NgbDatepickerConfig },
  3078. { type: NgbDatepickerKeyboardService },
  3079. { type: ChangeDetectorRef },
  3080. { type: ElementRef },
  3081. { type: NgbDateAdapter },
  3082. { type: NgZone }
  3083. ];
  3084. NgbDatepicker.propDecorators = {
  3085. _monthsEl: [{ type: ViewChild, args: ['months', { static: true },] }],
  3086. dayTemplate: [{ type: Input }],
  3087. dayTemplateData: [{ type: Input }],
  3088. displayMonths: [{ type: Input }],
  3089. firstDayOfWeek: [{ type: Input }],
  3090. footerTemplate: [{ type: Input }],
  3091. markDisabled: [{ type: Input }],
  3092. maxDate: [{ type: Input }],
  3093. minDate: [{ type: Input }],
  3094. navigation: [{ type: Input }],
  3095. outsideDays: [{ type: Input }],
  3096. showWeekdays: [{ type: Input }],
  3097. showWeekNumbers: [{ type: Input }],
  3098. startDate: [{ type: Input }],
  3099. navigate: [{ type: Output }],
  3100. dateSelect: [{ type: Output }],
  3101. select: [{ type: Output }]
  3102. };
  3103. /**
  3104. * @fileoverview added by tsickle
  3105. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3106. */
  3107. class NgbDatepickerMonthView {
  3108. /**
  3109. * @param {?} i18n
  3110. */
  3111. constructor(i18n) {
  3112. this.i18n = i18n;
  3113. this.select = new EventEmitter();
  3114. }
  3115. /**
  3116. * @param {?} day
  3117. * @return {?}
  3118. */
  3119. doSelect(day) {
  3120. if (!day.context.disabled && !day.hidden) {
  3121. this.select.emit(day.date);
  3122. }
  3123. }
  3124. }
  3125. NgbDatepickerMonthView.decorators = [
  3126. { type: Component, args: [{
  3127. selector: 'ngb-datepicker-month-view',
  3128. host: { 'role': 'grid' },
  3129. encapsulation: ViewEncapsulation.None,
  3130. template: `
  3131. <div *ngIf="showWeekdays" class="ngb-dp-week ngb-dp-weekdays" role="row">
  3132. <div *ngIf="showWeekNumbers" class="ngb-dp-weekday ngb-dp-showweek"></div>
  3133. <div *ngFor="let w of month.weekdays" class="ngb-dp-weekday small" role="columnheader">
  3134. {{ i18n.getWeekdayShortName(w) }}
  3135. </div>
  3136. </div>
  3137. <ng-template ngFor let-week [ngForOf]="month.weeks">
  3138. <div *ngIf="!week.collapsed" class="ngb-dp-week" role="row">
  3139. <div *ngIf="showWeekNumbers" class="ngb-dp-week-number small text-muted">{{ i18n.getWeekNumerals(week.number) }}</div>
  3140. <div *ngFor="let day of week.days" (click)="doSelect(day); $event.preventDefault()" class="ngb-dp-day" role="gridcell"
  3141. [class.disabled]="day.context.disabled"
  3142. [tabindex]="day.tabindex"
  3143. [class.hidden]="day.hidden"
  3144. [class.ngb-dp-today]="day.context.today"
  3145. [attr.aria-label]="day.ariaLabel">
  3146. <ng-template [ngIf]="!day.hidden">
  3147. <ng-template [ngTemplateOutlet]="dayTemplate" [ngTemplateOutletContext]="day.context"></ng-template>
  3148. </ng-template>
  3149. </div>
  3150. </div>
  3151. </ng-template>
  3152. `,
  3153. styles: ["ngb-datepicker-month-view{display:block}.ngb-dp-week-number,.ngb-dp-weekday{line-height:2rem;text-align:center;font-style:italic}.ngb-dp-weekday{color:#5bc0de;color:var(--info)}.ngb-dp-week{border-radius:.25rem;display:-ms-flexbox;display:flex}.ngb-dp-weekdays{border-bottom:1px solid rgba(0,0,0,.125);border-radius:0;background-color:#f8f9fa;background-color:var(--light)}.ngb-dp-day,.ngb-dp-week-number,.ngb-dp-weekday{width:2rem;height:2rem}.ngb-dp-day{cursor:pointer}.ngb-dp-day.disabled,.ngb-dp-day.hidden{cursor:default}.ngb-dp-day[tabindex=\"0\"]{z-index:1}"]
  3154. }] }
  3155. ];
  3156. /** @nocollapse */
  3157. NgbDatepickerMonthView.ctorParameters = () => [
  3158. { type: NgbDatepickerI18n }
  3159. ];
  3160. NgbDatepickerMonthView.propDecorators = {
  3161. dayTemplate: [{ type: Input }],
  3162. month: [{ type: Input }],
  3163. showWeekdays: [{ type: Input }],
  3164. showWeekNumbers: [{ type: Input }],
  3165. select: [{ type: Output }]
  3166. };
  3167. /**
  3168. * @fileoverview added by tsickle
  3169. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3170. */
  3171. class NgbDatepickerNavigation {
  3172. /**
  3173. * @param {?} i18n
  3174. */
  3175. constructor(i18n) {
  3176. this.i18n = i18n;
  3177. this.navigation = NavigationEvent;
  3178. this.months = [];
  3179. this.navigate = new EventEmitter();
  3180. this.select = new EventEmitter();
  3181. }
  3182. /**
  3183. * @param {?} event
  3184. * @return {?}
  3185. */
  3186. onClickPrev(event) {
  3187. ((/** @type {?} */ (event.currentTarget))).focus();
  3188. this.navigate.emit(this.navigation.PREV);
  3189. }
  3190. /**
  3191. * @param {?} event
  3192. * @return {?}
  3193. */
  3194. onClickNext(event) {
  3195. ((/** @type {?} */ (event.currentTarget))).focus();
  3196. this.navigate.emit(this.navigation.NEXT);
  3197. }
  3198. }
  3199. NgbDatepickerNavigation.decorators = [
  3200. { type: Component, args: [{
  3201. selector: 'ngb-datepicker-navigation',
  3202. changeDetection: ChangeDetectionStrategy.OnPush,
  3203. encapsulation: ViewEncapsulation.None,
  3204. template: `
  3205. <div class="ngb-dp-arrow">
  3206. <button type="button" class="btn btn-link ngb-dp-arrow-btn" (click)="onClickPrev($event)" [disabled]="prevDisabled"
  3207. i18n-aria-label="@@ngb.datepicker.previous-month" aria-label="Previous month"
  3208. i18n-title="@@ngb.datepicker.previous-month" title="Previous month">
  3209. <span class="ngb-dp-navigation-chevron"></span>
  3210. </button>
  3211. </div>
  3212. <ngb-datepicker-navigation-select *ngIf="showSelect" class="ngb-dp-navigation-select"
  3213. [date]="date"
  3214. [disabled] = "disabled"
  3215. [months]="selectBoxes.months"
  3216. [years]="selectBoxes.years"
  3217. (select)="select.emit($event)">
  3218. </ngb-datepicker-navigation-select>
  3219. <ng-template *ngIf="!showSelect" ngFor let-month [ngForOf]="months" let-i="index">
  3220. <div class="ngb-dp-arrow" *ngIf="i > 0"></div>
  3221. <div class="ngb-dp-month-name">
  3222. {{ i18n.getMonthFullName(month.number, month.year) }} {{ i18n.getYearNumerals(month.year) }}
  3223. </div>
  3224. <div class="ngb-dp-arrow" *ngIf="i !== months.length - 1"></div>
  3225. </ng-template>
  3226. <div class="ngb-dp-arrow right">
  3227. <button type="button" class="btn btn-link ngb-dp-arrow-btn" (click)="onClickNext($event)" [disabled]="nextDisabled"
  3228. i18n-aria-label="@@ngb.datepicker.next-month" aria-label="Next month"
  3229. i18n-title="@@ngb.datepicker.next-month" title="Next month">
  3230. <span class="ngb-dp-navigation-chevron"></span>
  3231. </button>
  3232. </div>
  3233. `,
  3234. styles: ["ngb-datepicker-navigation{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.ngb-dp-navigation-chevron{border-style:solid;border-width:.2em .2em 0 0;display:inline-block;width:.75em;height:.75em;margin-left:.25em;margin-right:.15em;-webkit-transform:rotate(-135deg);transform:rotate(-135deg)}.right .ngb-dp-navigation-chevron{-webkit-transform:rotate(45deg);transform:rotate(45deg);margin-left:.15em;margin-right:.25em}.ngb-dp-arrow{display:-ms-flexbox;display:flex;-ms-flex:1 1 auto;flex:1 1 auto;padding-right:0;padding-left:0;margin:0;width:2rem;height:2rem}.ngb-dp-arrow.right{-ms-flex-pack:end;justify-content:flex-end}.ngb-dp-arrow-btn{padding:0 .25rem;margin:0 .5rem;border:none;background-color:transparent;z-index:1}.ngb-dp-arrow-btn:focus{outline-width:1px;outline-style:auto}@media all and (-ms-high-contrast:none),(-ms-high-contrast:active){.ngb-dp-arrow-btn:focus{outline-style:solid}}.ngb-dp-month-name{font-size:larger;height:2rem;line-height:2rem;text-align:center}.ngb-dp-navigation-select{display:-ms-flexbox;display:flex;-ms-flex:1 1 9rem;flex:1 1 9rem}"]
  3235. }] }
  3236. ];
  3237. /** @nocollapse */
  3238. NgbDatepickerNavigation.ctorParameters = () => [
  3239. { type: NgbDatepickerI18n }
  3240. ];
  3241. NgbDatepickerNavigation.propDecorators = {
  3242. date: [{ type: Input }],
  3243. disabled: [{ type: Input }],
  3244. months: [{ type: Input }],
  3245. showSelect: [{ type: Input }],
  3246. prevDisabled: [{ type: Input }],
  3247. nextDisabled: [{ type: Input }],
  3248. selectBoxes: [{ type: Input }],
  3249. navigate: [{ type: Output }],
  3250. select: [{ type: Output }]
  3251. };
  3252. /**
  3253. * @fileoverview added by tsickle
  3254. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3255. */
  3256. /** @type {?} */
  3257. const isContainedIn = (/**
  3258. * @param {?} element
  3259. * @param {?=} array
  3260. * @return {?}
  3261. */
  3262. (element, array) => array ? array.some((/**
  3263. * @param {?} item
  3264. * @return {?}
  3265. */
  3266. item => item.contains(element))) : false);
  3267. /** @type {?} */
  3268. const matchesSelectorIfAny = (/**
  3269. * @param {?} element
  3270. * @param {?=} selector
  3271. * @return {?}
  3272. */
  3273. (element, selector) => !selector || closest(element, selector) != null);
  3274. // we'll have to use 'touch' events instead of 'mouse' events on iOS and add a more significant delay
  3275. // to avoid re-opening when handling (click) on a toggling element
  3276. // TODO: use proper Angular platform detection when NgbAutoClose becomes a service and we can inject PLATFORM_ID
  3277. /** @type {?} */
  3278. let iOS = false;
  3279. if (typeof navigator !== 'undefined') {
  3280. iOS = !!navigator.userAgent && /iPad|iPhone|iPod/.test(navigator.userAgent);
  3281. }
  3282. // setting 'ngbAutoClose' synchronously on iOS results in immediate popup closing
  3283. // when tapping on the triggering element
  3284. /** @type {?} */
  3285. const wrapAsyncForiOS = (/**
  3286. * @param {?} fn
  3287. * @return {?}
  3288. */
  3289. fn => iOS ? (/**
  3290. * @return {?}
  3291. */
  3292. () => setTimeout((/**
  3293. * @return {?}
  3294. */
  3295. () => fn()), 100)) : fn);
  3296. /**
  3297. * @param {?} zone
  3298. * @param {?} document
  3299. * @param {?} type
  3300. * @param {?} close
  3301. * @param {?} closed$
  3302. * @param {?} insideElements
  3303. * @param {?=} ignoreElements
  3304. * @param {?=} insideSelector
  3305. * @return {?}
  3306. */
  3307. function ngbAutoClose(zone, document, type, close, closed$, insideElements, ignoreElements, insideSelector) {
  3308. // closing on ESC and outside clicks
  3309. if (type) {
  3310. zone.runOutsideAngular(wrapAsyncForiOS((/**
  3311. * @return {?}
  3312. */
  3313. () => {
  3314. /** @type {?} */
  3315. const shouldCloseOnClick = (/**
  3316. * @param {?} event
  3317. * @return {?}
  3318. */
  3319. (event) => {
  3320. /** @type {?} */
  3321. const element = (/** @type {?} */ (event.target));
  3322. if (event.button === 2 || isContainedIn(element, ignoreElements)) {
  3323. return false;
  3324. }
  3325. if (type === 'inside') {
  3326. return isContainedIn(element, insideElements) && matchesSelectorIfAny(element, insideSelector);
  3327. }
  3328. else if (type === 'outside') {
  3329. return !isContainedIn(element, insideElements);
  3330. }
  3331. else /* if (type === true) */ {
  3332. return matchesSelectorIfAny(element, insideSelector) || !isContainedIn(element, insideElements);
  3333. }
  3334. });
  3335. /** @type {?} */
  3336. const escapes$ = fromEvent(document, 'keydown')
  3337. .pipe(takeUntil(closed$),
  3338. // tslint:disable-next-line:deprecation
  3339. filter((/**
  3340. * @param {?} e
  3341. * @return {?}
  3342. */
  3343. e => e.which === Key.Escape)), tap((/**
  3344. * @param {?} e
  3345. * @return {?}
  3346. */
  3347. e => e.preventDefault())));
  3348. // we have to pre-calculate 'shouldCloseOnClick' on 'mousedown/touchstart',
  3349. // because on 'mouseup/touchend' DOM nodes might be detached
  3350. /** @type {?} */
  3351. const mouseDowns$ = fromEvent(document, 'mousedown').pipe(map(shouldCloseOnClick), takeUntil(closed$));
  3352. /** @type {?} */
  3353. const closeableClicks$ = (/** @type {?} */ (fromEvent(document, 'mouseup')
  3354. .pipe(withLatestFrom(mouseDowns$), filter((/**
  3355. * @param {?} __0
  3356. * @return {?}
  3357. */
  3358. ([_, shouldClose]) => shouldClose)), delay(0), takeUntil(closed$))));
  3359. race([escapes$, closeableClicks$]).subscribe((/**
  3360. * @return {?}
  3361. */
  3362. () => zone.run(close)));
  3363. })));
  3364. }
  3365. }
  3366. /**
  3367. * @fileoverview added by tsickle
  3368. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3369. */
  3370. /** @type {?} */
  3371. const FOCUSABLE_ELEMENTS_SELECTOR = [
  3372. 'a[href]', 'button:not([disabled])', 'input:not([disabled]):not([type="hidden"])', 'select:not([disabled])',
  3373. 'textarea:not([disabled])', '[contenteditable]', '[tabindex]:not([tabindex="-1"])'
  3374. ].join(', ');
  3375. /**
  3376. * Returns first and last focusable elements inside of a given element based on specific CSS selector
  3377. * @param {?} element
  3378. * @return {?}
  3379. */
  3380. function getFocusableBoundaryElements(element) {
  3381. /** @type {?} */
  3382. const list = Array.from((/** @type {?} */ (element.querySelectorAll(FOCUSABLE_ELEMENTS_SELECTOR))))
  3383. .filter((/**
  3384. * @param {?} el
  3385. * @return {?}
  3386. */
  3387. el => el.tabIndex !== -1));
  3388. return [list[0], list[list.length - 1]];
  3389. }
  3390. /**
  3391. * Function that enforces browser focus to be trapped inside a DOM element.
  3392. *
  3393. * Works only for clicks inside the element and navigation with 'Tab', ignoring clicks outside of the element
  3394. *
  3395. * \@param zone Angular zone
  3396. * \@param element The element around which focus will be trapped inside
  3397. * \@param stopFocusTrap$ The observable stream. When completed the focus trap will clean up listeners
  3398. * and free internal resources
  3399. * \@param refocusOnClick Put the focus back to the last focused element whenever a click occurs on element (default to
  3400. * false)
  3401. * @type {?}
  3402. */
  3403. const ngbFocusTrap = (/**
  3404. * @param {?} zone
  3405. * @param {?} element
  3406. * @param {?} stopFocusTrap$
  3407. * @param {?=} refocusOnClick
  3408. * @return {?}
  3409. */
  3410. (zone, element, stopFocusTrap$, refocusOnClick = false) => {
  3411. zone.runOutsideAngular((/**
  3412. * @return {?}
  3413. */
  3414. () => {
  3415. // last focused element
  3416. /** @type {?} */
  3417. const lastFocusedElement$ = fromEvent(element, 'focusin').pipe(takeUntil(stopFocusTrap$), map((/**
  3418. * @param {?} e
  3419. * @return {?}
  3420. */
  3421. e => e.target)));
  3422. // 'tab' / 'shift+tab' stream
  3423. fromEvent(element, 'keydown')
  3424. .pipe(takeUntil(stopFocusTrap$),
  3425. // tslint:disable:deprecation
  3426. filter((/**
  3427. * @param {?} e
  3428. * @return {?}
  3429. */
  3430. e => e.which === Key.Tab)),
  3431. // tslint:enable:deprecation
  3432. withLatestFrom(lastFocusedElement$))
  3433. .subscribe((/**
  3434. * @param {?} __0
  3435. * @return {?}
  3436. */
  3437. ([tabEvent, focusedElement]) => {
  3438. const [first, last] = getFocusableBoundaryElements(element);
  3439. if ((focusedElement === first || focusedElement === element) && tabEvent.shiftKey) {
  3440. last.focus();
  3441. tabEvent.preventDefault();
  3442. }
  3443. if (focusedElement === last && !tabEvent.shiftKey) {
  3444. first.focus();
  3445. tabEvent.preventDefault();
  3446. }
  3447. }));
  3448. // inside click
  3449. if (refocusOnClick) {
  3450. fromEvent(element, 'click')
  3451. .pipe(takeUntil(stopFocusTrap$), withLatestFrom(lastFocusedElement$), map((/**
  3452. * @param {?} arr
  3453. * @return {?}
  3454. */
  3455. arr => (/** @type {?} */ (arr[1])))))
  3456. .subscribe((/**
  3457. * @param {?} lastFocusedElement
  3458. * @return {?}
  3459. */
  3460. lastFocusedElement => lastFocusedElement.focus()));
  3461. }
  3462. }));
  3463. });
  3464. /**
  3465. * @fileoverview added by tsickle
  3466. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3467. */
  3468. // previous version:
  3469. // https://github.com/angular-ui/bootstrap/blob/07c31d0731f7cb068a1932b8e01d2312b796b4ec/src/position/position.js
  3470. class Positioning {
  3471. /**
  3472. * @private
  3473. * @param {?} element
  3474. * @return {?}
  3475. */
  3476. getAllStyles(element) { return window.getComputedStyle(element); }
  3477. /**
  3478. * @private
  3479. * @param {?} element
  3480. * @param {?} prop
  3481. * @return {?}
  3482. */
  3483. getStyle(element, prop) { return this.getAllStyles(element)[prop]; }
  3484. /**
  3485. * @private
  3486. * @param {?} element
  3487. * @return {?}
  3488. */
  3489. isStaticPositioned(element) {
  3490. return (this.getStyle(element, 'position') || 'static') === 'static';
  3491. }
  3492. /**
  3493. * @private
  3494. * @param {?} element
  3495. * @return {?}
  3496. */
  3497. offsetParent(element) {
  3498. /** @type {?} */
  3499. let offsetParentEl = (/** @type {?} */ (element.offsetParent)) || document.documentElement;
  3500. while (offsetParentEl && offsetParentEl !== document.documentElement && this.isStaticPositioned(offsetParentEl)) {
  3501. offsetParentEl = (/** @type {?} */ (offsetParentEl.offsetParent));
  3502. }
  3503. return offsetParentEl || document.documentElement;
  3504. }
  3505. /**
  3506. * @param {?} element
  3507. * @param {?=} round
  3508. * @return {?}
  3509. */
  3510. position(element, round = true) {
  3511. /** @type {?} */
  3512. let elPosition;
  3513. /** @type {?} */
  3514. let parentOffset = { width: 0, height: 0, top: 0, bottom: 0, left: 0, right: 0 };
  3515. if (this.getStyle(element, 'position') === 'fixed') {
  3516. elPosition = element.getBoundingClientRect();
  3517. elPosition = {
  3518. top: elPosition.top,
  3519. bottom: elPosition.bottom,
  3520. left: elPosition.left,
  3521. right: elPosition.right,
  3522. height: elPosition.height,
  3523. width: elPosition.width
  3524. };
  3525. }
  3526. else {
  3527. /** @type {?} */
  3528. const offsetParentEl = this.offsetParent(element);
  3529. elPosition = this.offset(element, false);
  3530. if (offsetParentEl !== document.documentElement) {
  3531. parentOffset = this.offset(offsetParentEl, false);
  3532. }
  3533. parentOffset.top += offsetParentEl.clientTop;
  3534. parentOffset.left += offsetParentEl.clientLeft;
  3535. }
  3536. elPosition.top -= parentOffset.top;
  3537. elPosition.bottom -= parentOffset.top;
  3538. elPosition.left -= parentOffset.left;
  3539. elPosition.right -= parentOffset.left;
  3540. if (round) {
  3541. elPosition.top = Math.round(elPosition.top);
  3542. elPosition.bottom = Math.round(elPosition.bottom);
  3543. elPosition.left = Math.round(elPosition.left);
  3544. elPosition.right = Math.round(elPosition.right);
  3545. }
  3546. return elPosition;
  3547. }
  3548. /**
  3549. * @param {?} element
  3550. * @param {?=} round
  3551. * @return {?}
  3552. */
  3553. offset(element, round = true) {
  3554. /** @type {?} */
  3555. const elBcr = element.getBoundingClientRect();
  3556. /** @type {?} */
  3557. const viewportOffset = {
  3558. top: window.pageYOffset - document.documentElement.clientTop,
  3559. left: window.pageXOffset - document.documentElement.clientLeft
  3560. };
  3561. /** @type {?} */
  3562. let elOffset = {
  3563. height: elBcr.height || element.offsetHeight,
  3564. width: elBcr.width || element.offsetWidth,
  3565. top: elBcr.top + viewportOffset.top,
  3566. bottom: elBcr.bottom + viewportOffset.top,
  3567. left: elBcr.left + viewportOffset.left,
  3568. right: elBcr.right + viewportOffset.left
  3569. };
  3570. if (round) {
  3571. elOffset.height = Math.round(elOffset.height);
  3572. elOffset.width = Math.round(elOffset.width);
  3573. elOffset.top = Math.round(elOffset.top);
  3574. elOffset.bottom = Math.round(elOffset.bottom);
  3575. elOffset.left = Math.round(elOffset.left);
  3576. elOffset.right = Math.round(elOffset.right);
  3577. }
  3578. return elOffset;
  3579. }
  3580. /*
  3581. Return false if the element to position is outside the viewport
  3582. */
  3583. /**
  3584. * @param {?} hostElement
  3585. * @param {?} targetElement
  3586. * @param {?} placement
  3587. * @param {?=} appendToBody
  3588. * @return {?}
  3589. */
  3590. positionElements(hostElement, targetElement, placement, appendToBody) {
  3591. const [placementPrimary = 'top', placementSecondary = 'center'] = placement.split('-');
  3592. /** @type {?} */
  3593. const hostElPosition = appendToBody ? this.offset(hostElement, false) : this.position(hostElement, false);
  3594. /** @type {?} */
  3595. const targetElStyles = this.getAllStyles(targetElement);
  3596. /** @type {?} */
  3597. const marginTop = parseFloat(targetElStyles.marginTop);
  3598. /** @type {?} */
  3599. const marginBottom = parseFloat(targetElStyles.marginBottom);
  3600. /** @type {?} */
  3601. const marginLeft = parseFloat(targetElStyles.marginLeft);
  3602. /** @type {?} */
  3603. const marginRight = parseFloat(targetElStyles.marginRight);
  3604. /** @type {?} */
  3605. let topPosition = 0;
  3606. /** @type {?} */
  3607. let leftPosition = 0;
  3608. switch (placementPrimary) {
  3609. case 'top':
  3610. topPosition = (hostElPosition.top - (targetElement.offsetHeight + marginTop + marginBottom));
  3611. break;
  3612. case 'bottom':
  3613. topPosition = (hostElPosition.top + hostElPosition.height);
  3614. break;
  3615. case 'left':
  3616. leftPosition = (hostElPosition.left - (targetElement.offsetWidth + marginLeft + marginRight));
  3617. break;
  3618. case 'right':
  3619. leftPosition = (hostElPosition.left + hostElPosition.width);
  3620. break;
  3621. }
  3622. switch (placementSecondary) {
  3623. case 'top':
  3624. topPosition = hostElPosition.top;
  3625. break;
  3626. case 'bottom':
  3627. topPosition = hostElPosition.top + hostElPosition.height - targetElement.offsetHeight;
  3628. break;
  3629. case 'left':
  3630. leftPosition = hostElPosition.left;
  3631. break;
  3632. case 'right':
  3633. leftPosition = hostElPosition.left + hostElPosition.width - targetElement.offsetWidth;
  3634. break;
  3635. case 'center':
  3636. if (placementPrimary === 'top' || placementPrimary === 'bottom') {
  3637. leftPosition = (hostElPosition.left + hostElPosition.width / 2 - targetElement.offsetWidth / 2);
  3638. }
  3639. else {
  3640. topPosition = (hostElPosition.top + hostElPosition.height / 2 - targetElement.offsetHeight / 2);
  3641. }
  3642. break;
  3643. }
  3644. /// The translate3d/gpu acceleration render a blurry text on chrome, the next line is commented until a browser fix
  3645. // targetElement.style.transform = `translate3d(${Math.round(leftPosition)}px, ${Math.floor(topPosition)}px, 0px)`;
  3646. targetElement.style.transform = `translate(${Math.round(leftPosition)}px, ${Math.round(topPosition)}px)`;
  3647. // Check if the targetElement is inside the viewport
  3648. /** @type {?} */
  3649. const targetElBCR = targetElement.getBoundingClientRect();
  3650. /** @type {?} */
  3651. const html = document.documentElement;
  3652. /** @type {?} */
  3653. const windowHeight = window.innerHeight || html.clientHeight;
  3654. /** @type {?} */
  3655. const windowWidth = window.innerWidth || html.clientWidth;
  3656. return targetElBCR.left >= 0 && targetElBCR.top >= 0 && targetElBCR.right <= windowWidth &&
  3657. targetElBCR.bottom <= windowHeight;
  3658. }
  3659. }
  3660. /** @type {?} */
  3661. const placementSeparator = /\s+/;
  3662. /** @type {?} */
  3663. const positionService = new Positioning();
  3664. /*
  3665. * Accept the placement array and applies the appropriate placement dependent on the viewport.
  3666. * Returns the applied placement.
  3667. * In case of auto placement, placements are selected in order
  3668. * 'top', 'bottom', 'left', 'right',
  3669. * 'top-left', 'top-right',
  3670. * 'bottom-left', 'bottom-right',
  3671. * 'left-top', 'left-bottom',
  3672. * 'right-top', 'right-bottom'.
  3673. * */
  3674. /**
  3675. * @param {?} hostElement
  3676. * @param {?} targetElement
  3677. * @param {?} placement
  3678. * @param {?=} appendToBody
  3679. * @param {?=} baseClass
  3680. * @return {?}
  3681. */
  3682. function positionElements(hostElement, targetElement, placement, appendToBody, baseClass) {
  3683. /** @type {?} */
  3684. let placementVals = Array.isArray(placement) ? placement : (/** @type {?} */ (placement.split(placementSeparator)));
  3685. /** @type {?} */
  3686. const allowedPlacements = [
  3687. 'top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right', 'left-top', 'left-bottom',
  3688. 'right-top', 'right-bottom'
  3689. ];
  3690. /** @type {?} */
  3691. const classList = targetElement.classList;
  3692. /** @type {?} */
  3693. const addClassesToTarget = (/**
  3694. * @param {?} targetPlacement
  3695. * @return {?}
  3696. */
  3697. (targetPlacement) => {
  3698. const [primary, secondary] = targetPlacement.split('-');
  3699. /** @type {?} */
  3700. const classes = [];
  3701. if (baseClass) {
  3702. classes.push(`${baseClass}-${primary}`);
  3703. if (secondary) {
  3704. classes.push(`${baseClass}-${primary}-${secondary}`);
  3705. }
  3706. classes.forEach((/**
  3707. * @param {?} classname
  3708. * @return {?}
  3709. */
  3710. (classname) => { classList.add(classname); }));
  3711. }
  3712. return classes;
  3713. });
  3714. // Remove old placement classes to avoid issues
  3715. if (baseClass) {
  3716. allowedPlacements.forEach((/**
  3717. * @param {?} placementToRemove
  3718. * @return {?}
  3719. */
  3720. (placementToRemove) => { classList.remove(`${baseClass}-${placementToRemove}`); }));
  3721. }
  3722. // replace auto placement with other placements
  3723. /** @type {?} */
  3724. let hasAuto = placementVals.findIndex((/**
  3725. * @param {?} val
  3726. * @return {?}
  3727. */
  3728. val => val === 'auto'));
  3729. if (hasAuto >= 0) {
  3730. allowedPlacements.forEach((/**
  3731. * @param {?} obj
  3732. * @return {?}
  3733. */
  3734. function (obj) {
  3735. if (placementVals.find((/**
  3736. * @param {?} val
  3737. * @return {?}
  3738. */
  3739. val => val.search('^' + obj) !== -1)) == null) {
  3740. placementVals.splice(hasAuto++, 1, (/** @type {?} */ (obj)));
  3741. }
  3742. }));
  3743. }
  3744. // coordinates where to position
  3745. // Required for transform:
  3746. /** @type {?} */
  3747. const style = targetElement.style;
  3748. style.position = 'absolute';
  3749. style.top = '0';
  3750. style.left = '0';
  3751. style['will-change'] = 'transform';
  3752. /** @type {?} */
  3753. let testPlacement;
  3754. /** @type {?} */
  3755. let isInViewport = false;
  3756. for (testPlacement of placementVals) {
  3757. /** @type {?} */
  3758. let addedClasses = addClassesToTarget(testPlacement);
  3759. if (positionService.positionElements(hostElement, targetElement, testPlacement, appendToBody)) {
  3760. isInViewport = true;
  3761. break;
  3762. }
  3763. // Remove the baseClasses for further calculation
  3764. if (baseClass) {
  3765. addedClasses.forEach((/**
  3766. * @param {?} classname
  3767. * @return {?}
  3768. */
  3769. (classname) => { classList.remove(classname); }));
  3770. }
  3771. }
  3772. if (!isInViewport) {
  3773. // If nothing match, the first placement is the default one
  3774. testPlacement = placementVals[0];
  3775. addClassesToTarget(testPlacement);
  3776. positionService.positionElements(hostElement, targetElement, testPlacement, appendToBody);
  3777. }
  3778. return testPlacement;
  3779. }
  3780. /**
  3781. * @fileoverview added by tsickle
  3782. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3783. */
  3784. /**
  3785. * @return {?}
  3786. */
  3787. function NGB_DATEPICKER_PARSER_FORMATTER_FACTORY() {
  3788. return new NgbDateISOParserFormatter();
  3789. }
  3790. /**
  3791. * An abstract service for parsing and formatting dates for the
  3792. * [`NgbInputDatepicker`](#/components/datepicker/api#NgbInputDatepicker) directive.
  3793. * Converts between the internal `NgbDateStruct` model presentation and a `string` that is displayed in the
  3794. * input element.
  3795. *
  3796. * When user types something in the input this service attempts to parse it into a `NgbDateStruct` object.
  3797. * And vice versa, when users selects a date in the calendar with the mouse, it must be displayed as a `string`
  3798. * in the input.
  3799. *
  3800. * Default implementation uses the ISO 8601 format, but you can provide another implementation via DI
  3801. * to use an alternative string format or a custom parsing logic.
  3802. *
  3803. * See the [date format overview](#/components/datepicker/overview#date-model) for more details.
  3804. * @abstract
  3805. */
  3806. class NgbDateParserFormatter {
  3807. }
  3808. NgbDateParserFormatter.decorators = [
  3809. { type: Injectable, args: [{ providedIn: 'root', useFactory: NGB_DATEPICKER_PARSER_FORMATTER_FACTORY },] }
  3810. ];
  3811. /** @nocollapse */ NgbDateParserFormatter.ngInjectableDef = ɵɵdefineInjectable({ factory: NGB_DATEPICKER_PARSER_FORMATTER_FACTORY, token: NgbDateParserFormatter, providedIn: "root" });
  3812. class NgbDateISOParserFormatter extends NgbDateParserFormatter {
  3813. /**
  3814. * @param {?} value
  3815. * @return {?}
  3816. */
  3817. parse(value) {
  3818. if (value) {
  3819. /** @type {?} */
  3820. const dateParts = value.trim().split('-');
  3821. if (dateParts.length === 1 && isNumber(dateParts[0])) {
  3822. return { year: toInteger(dateParts[0]), month: null, day: null };
  3823. }
  3824. else if (dateParts.length === 2 && isNumber(dateParts[0]) && isNumber(dateParts[1])) {
  3825. return { year: toInteger(dateParts[0]), month: toInteger(dateParts[1]), day: null };
  3826. }
  3827. else if (dateParts.length === 3 && isNumber(dateParts[0]) && isNumber(dateParts[1]) && isNumber(dateParts[2])) {
  3828. return { year: toInteger(dateParts[0]), month: toInteger(dateParts[1]), day: toInteger(dateParts[2]) };
  3829. }
  3830. }
  3831. return null;
  3832. }
  3833. /**
  3834. * @param {?} date
  3835. * @return {?}
  3836. */
  3837. format(date) {
  3838. return date ?
  3839. `${date.year}-${isNumber(date.month) ? padNumber(date.month) : ''}-${isNumber(date.day) ? padNumber(date.day) : ''}` :
  3840. '';
  3841. }
  3842. }
  3843. NgbDateISOParserFormatter.decorators = [
  3844. { type: Injectable }
  3845. ];
  3846. /**
  3847. * @fileoverview added by tsickle
  3848. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3849. */
  3850. /**
  3851. * A configuration service for the [`NgbDatepickerInput`](#/components/datepicker/api#NgbDatepicker) component.
  3852. *
  3853. * You can inject this service, typically in your root component, and customize the values of its properties in
  3854. * order to provide default values for all the datepicker inputs used in the application.
  3855. *
  3856. * \@since 5.2.0
  3857. */
  3858. class NgbInputDatepickerConfig extends NgbDatepickerConfig {
  3859. constructor() {
  3860. super(...arguments);
  3861. this.autoClose = true;
  3862. this.placement = ['bottom-left', 'bottom-right', 'top-left', 'top-right'];
  3863. this.restoreFocus = true;
  3864. }
  3865. }
  3866. NgbInputDatepickerConfig.decorators = [
  3867. { type: Injectable, args: [{ providedIn: 'root' },] }
  3868. ];
  3869. /** @nocollapse */ NgbInputDatepickerConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbInputDatepickerConfig_Factory() { return new NgbInputDatepickerConfig(); }, token: NgbInputDatepickerConfig, providedIn: "root" });
  3870. /**
  3871. * @fileoverview added by tsickle
  3872. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  3873. */
  3874. /** @type {?} */
  3875. const NGB_DATEPICKER_VALUE_ACCESSOR$1 = {
  3876. provide: NG_VALUE_ACCESSOR,
  3877. useExisting: forwardRef((/**
  3878. * @return {?}
  3879. */
  3880. () => NgbInputDatepicker)),
  3881. multi: true
  3882. };
  3883. /** @type {?} */
  3884. const NGB_DATEPICKER_VALIDATOR = {
  3885. provide: NG_VALIDATORS,
  3886. useExisting: forwardRef((/**
  3887. * @return {?}
  3888. */
  3889. () => NgbInputDatepicker)),
  3890. multi: true
  3891. };
  3892. /**
  3893. * A directive that allows to stick a datepicker popup to an input field.
  3894. *
  3895. * Manages interaction with the input field itself, does value formatting and provides forms integration.
  3896. */
  3897. class NgbInputDatepicker {
  3898. /**
  3899. * @param {?} _parserFormatter
  3900. * @param {?} _elRef
  3901. * @param {?} _vcRef
  3902. * @param {?} _renderer
  3903. * @param {?} _cfr
  3904. * @param {?} _ngZone
  3905. * @param {?} _calendar
  3906. * @param {?} _dateAdapter
  3907. * @param {?} _document
  3908. * @param {?} _changeDetector
  3909. * @param {?} config
  3910. */
  3911. constructor(_parserFormatter, _elRef, _vcRef, _renderer, _cfr, _ngZone, _calendar, _dateAdapter, _document, _changeDetector, config) {
  3912. this._parserFormatter = _parserFormatter;
  3913. this._elRef = _elRef;
  3914. this._vcRef = _vcRef;
  3915. this._renderer = _renderer;
  3916. this._cfr = _cfr;
  3917. this._ngZone = _ngZone;
  3918. this._calendar = _calendar;
  3919. this._dateAdapter = _dateAdapter;
  3920. this._document = _document;
  3921. this._changeDetector = _changeDetector;
  3922. this._cRef = null;
  3923. this._disabled = false;
  3924. this._elWithFocus = null;
  3925. /**
  3926. * An event emitted when user selects a date using keyboard or mouse.
  3927. *
  3928. * The payload of the event is currently selected `NgbDate`.
  3929. *
  3930. * \@since 1.1.1
  3931. */
  3932. this.dateSelect = new EventEmitter();
  3933. /**
  3934. * Event emitted right after the navigation happens and displayed month changes.
  3935. *
  3936. * See [`NgbDatepickerNavigateEvent`](#/components/datepicker/api#NgbDatepickerNavigateEvent) for the payload info.
  3937. */
  3938. this.navigate = new EventEmitter();
  3939. /**
  3940. * An event fired after closing datepicker window.
  3941. *
  3942. * \@since 4.2.0
  3943. */
  3944. this.closed = new EventEmitter();
  3945. this._onChange = (/**
  3946. * @param {?} _
  3947. * @return {?}
  3948. */
  3949. (_) => { });
  3950. this._onTouched = (/**
  3951. * @return {?}
  3952. */
  3953. () => { });
  3954. this._validatorChange = (/**
  3955. * @return {?}
  3956. */
  3957. () => { });
  3958. ['autoClose', 'container', 'positionTarget', 'placement'].forEach((/**
  3959. * @param {?} input
  3960. * @return {?}
  3961. */
  3962. input => this[input] = config[input]));
  3963. this._zoneSubscription = _ngZone.onStable.subscribe((/**
  3964. * @return {?}
  3965. */
  3966. () => this._updatePopupPosition()));
  3967. }
  3968. /**
  3969. * @return {?}
  3970. */
  3971. get disabled() {
  3972. return this._disabled;
  3973. }
  3974. /**
  3975. * @param {?} value
  3976. * @return {?}
  3977. */
  3978. set disabled(value) {
  3979. this._disabled = value === '' || (value && value !== 'false');
  3980. if (this.isOpen()) {
  3981. this._cRef.instance.setDisabledState(this._disabled);
  3982. }
  3983. }
  3984. /**
  3985. * @param {?} fn
  3986. * @return {?}
  3987. */
  3988. registerOnChange(fn) { this._onChange = fn; }
  3989. /**
  3990. * @param {?} fn
  3991. * @return {?}
  3992. */
  3993. registerOnTouched(fn) { this._onTouched = fn; }
  3994. /**
  3995. * @param {?} fn
  3996. * @return {?}
  3997. */
  3998. registerOnValidatorChange(fn) { this._validatorChange = fn; }
  3999. /**
  4000. * @param {?} isDisabled
  4001. * @return {?}
  4002. */
  4003. setDisabledState(isDisabled) { this.disabled = isDisabled; }
  4004. /**
  4005. * @param {?} c
  4006. * @return {?}
  4007. */
  4008. validate(c) {
  4009. /** @type {?} */
  4010. const value = c.value;
  4011. if (value === null || value === undefined) {
  4012. return null;
  4013. }
  4014. /** @type {?} */
  4015. const ngbDate = this._fromDateStruct(this._dateAdapter.fromModel(value));
  4016. if (!this._calendar.isValid(ngbDate)) {
  4017. return { 'ngbDate': { invalid: c.value } };
  4018. }
  4019. if (this.minDate && ngbDate.before(NgbDate.from(this.minDate))) {
  4020. return { 'ngbDate': { requiredBefore: this.minDate } };
  4021. }
  4022. if (this.maxDate && ngbDate.after(NgbDate.from(this.maxDate))) {
  4023. return { 'ngbDate': { requiredAfter: this.maxDate } };
  4024. }
  4025. }
  4026. /**
  4027. * @param {?} value
  4028. * @return {?}
  4029. */
  4030. writeValue(value) {
  4031. this._model = this._fromDateStruct(this._dateAdapter.fromModel(value));
  4032. this._writeModelValue(this._model);
  4033. }
  4034. /**
  4035. * @param {?} value
  4036. * @param {?=} updateView
  4037. * @return {?}
  4038. */
  4039. manualDateChange(value, updateView = false) {
  4040. /** @type {?} */
  4041. const inputValueChanged = value !== this._inputValue;
  4042. if (inputValueChanged) {
  4043. this._inputValue = value;
  4044. this._model = this._fromDateStruct(this._parserFormatter.parse(value));
  4045. }
  4046. if (inputValueChanged || !updateView) {
  4047. this._onChange(this._model ? this._dateAdapter.toModel(this._model) : (value === '' ? null : value));
  4048. }
  4049. if (updateView && this._model) {
  4050. this._writeModelValue(this._model);
  4051. }
  4052. }
  4053. /**
  4054. * @return {?}
  4055. */
  4056. isOpen() { return !!this._cRef; }
  4057. /**
  4058. * Opens the datepicker popup.
  4059. *
  4060. * If the related form control contains a valid date, the corresponding month will be opened.
  4061. * @return {?}
  4062. */
  4063. open() {
  4064. if (!this.isOpen()) {
  4065. /** @type {?} */
  4066. const cf = this._cfr.resolveComponentFactory(NgbDatepicker);
  4067. this._cRef = this._vcRef.createComponent(cf);
  4068. this._applyPopupStyling(this._cRef.location.nativeElement);
  4069. this._applyDatepickerInputs(this._cRef.instance);
  4070. this._subscribeForDatepickerOutputs(this._cRef.instance);
  4071. this._cRef.instance.ngOnInit();
  4072. this._cRef.instance.writeValue(this._dateAdapter.toModel(this._model));
  4073. // date selection event handling
  4074. this._cRef.instance.registerOnChange((/**
  4075. * @param {?} selectedDate
  4076. * @return {?}
  4077. */
  4078. (selectedDate) => {
  4079. this.writeValue(selectedDate);
  4080. this._onChange(selectedDate);
  4081. this._onTouched();
  4082. }));
  4083. this._cRef.changeDetectorRef.detectChanges();
  4084. this._cRef.instance.setDisabledState(this.disabled);
  4085. if (this.container === 'body') {
  4086. window.document.querySelector(this.container).appendChild(this._cRef.location.nativeElement);
  4087. }
  4088. // focus handling
  4089. this._elWithFocus = this._document.activeElement;
  4090. ngbFocusTrap(this._ngZone, this._cRef.location.nativeElement, this.closed, true);
  4091. this._cRef.instance.focus();
  4092. ngbAutoClose(this._ngZone, this._document, this.autoClose, (/**
  4093. * @return {?}
  4094. */
  4095. () => this.close()), this.closed, [], [this._elRef.nativeElement, this._cRef.location.nativeElement]);
  4096. }
  4097. }
  4098. /**
  4099. * Closes the datepicker popup.
  4100. * @return {?}
  4101. */
  4102. close() {
  4103. if (this.isOpen()) {
  4104. this._vcRef.remove(this._vcRef.indexOf(this._cRef.hostView));
  4105. this._cRef = null;
  4106. this.closed.emit();
  4107. this._changeDetector.markForCheck();
  4108. // restore focus
  4109. /** @type {?} */
  4110. let elementToFocus = this._elWithFocus;
  4111. if (isString(this.restoreFocus)) {
  4112. elementToFocus = this._document.querySelector(this.restoreFocus);
  4113. }
  4114. else if (this.restoreFocus !== undefined) {
  4115. elementToFocus = this.restoreFocus;
  4116. }
  4117. // in IE document.activeElement can contain an object without 'focus()' sometimes
  4118. if (elementToFocus && elementToFocus['focus']) {
  4119. elementToFocus.focus();
  4120. }
  4121. else {
  4122. this._document.body.focus();
  4123. }
  4124. }
  4125. }
  4126. /**
  4127. * Toggles the datepicker popup.
  4128. * @return {?}
  4129. */
  4130. toggle() {
  4131. if (this.isOpen()) {
  4132. this.close();
  4133. }
  4134. else {
  4135. this.open();
  4136. }
  4137. }
  4138. /**
  4139. * Navigates to the provided date.
  4140. *
  4141. * With the default calendar we use ISO 8601: 'month' is 1=Jan ... 12=Dec.
  4142. * If nothing or invalid date provided calendar will open current month.
  4143. *
  4144. * Use the `[startDate]` input as an alternative.
  4145. * @param {?=} date
  4146. * @return {?}
  4147. */
  4148. navigateTo(date) {
  4149. if (this.isOpen()) {
  4150. this._cRef.instance.navigateTo(date);
  4151. }
  4152. }
  4153. /**
  4154. * @return {?}
  4155. */
  4156. onBlur() { this._onTouched(); }
  4157. /**
  4158. * @return {?}
  4159. */
  4160. onFocus() { this._elWithFocus = this._elRef.nativeElement; }
  4161. /**
  4162. * @param {?} changes
  4163. * @return {?}
  4164. */
  4165. ngOnChanges(changes) {
  4166. if (changes['minDate'] || changes['maxDate']) {
  4167. this._validatorChange();
  4168. if (this.isOpen()) {
  4169. if (changes['minDate']) {
  4170. this._cRef.instance.minDate = this._dateAdapter.toModel(changes.minDate.currentValue);
  4171. }
  4172. if (changes['maxDate']) {
  4173. this._cRef.instance.maxDate = this._dateAdapter.toModel(changes.maxDate.currentValue);
  4174. }
  4175. this._cRef.instance.ngOnChanges(changes);
  4176. }
  4177. }
  4178. }
  4179. /**
  4180. * @return {?}
  4181. */
  4182. ngOnDestroy() {
  4183. this.close();
  4184. this._zoneSubscription.unsubscribe();
  4185. }
  4186. /**
  4187. * @private
  4188. * @param {?} datepickerInstance
  4189. * @return {?}
  4190. */
  4191. _applyDatepickerInputs(datepickerInstance) {
  4192. ['dayTemplate', 'dayTemplateData', 'displayMonths', 'firstDayOfWeek', 'footerTemplate', 'markDisabled', 'minDate',
  4193. 'maxDate', 'navigation', 'outsideDays', 'showNavigation', 'showWeekdays', 'showWeekNumbers']
  4194. .forEach((/**
  4195. * @param {?} optionName
  4196. * @return {?}
  4197. */
  4198. (optionName) => {
  4199. if (this[optionName] !== undefined) {
  4200. datepickerInstance[optionName] = this[optionName];
  4201. }
  4202. }));
  4203. datepickerInstance.startDate = this.startDate || this._model;
  4204. }
  4205. /**
  4206. * @private
  4207. * @param {?} nativeElement
  4208. * @return {?}
  4209. */
  4210. _applyPopupStyling(nativeElement) {
  4211. this._renderer.addClass(nativeElement, 'dropdown-menu');
  4212. this._renderer.addClass(nativeElement, 'show');
  4213. if (this.container === 'body') {
  4214. this._renderer.addClass(nativeElement, 'ngb-dp-body');
  4215. }
  4216. }
  4217. /**
  4218. * @private
  4219. * @param {?} datepickerInstance
  4220. * @return {?}
  4221. */
  4222. _subscribeForDatepickerOutputs(datepickerInstance) {
  4223. datepickerInstance.navigate.subscribe((/**
  4224. * @param {?} navigateEvent
  4225. * @return {?}
  4226. */
  4227. navigateEvent => this.navigate.emit(navigateEvent)));
  4228. datepickerInstance.dateSelect.subscribe((/**
  4229. * @param {?} date
  4230. * @return {?}
  4231. */
  4232. date => {
  4233. this.dateSelect.emit(date);
  4234. if (this.autoClose === true || this.autoClose === 'inside') {
  4235. this.close();
  4236. }
  4237. }));
  4238. }
  4239. /**
  4240. * @private
  4241. * @param {?} model
  4242. * @return {?}
  4243. */
  4244. _writeModelValue(model) {
  4245. /** @type {?} */
  4246. const value = this._parserFormatter.format(model);
  4247. this._inputValue = value;
  4248. this._renderer.setProperty(this._elRef.nativeElement, 'value', value);
  4249. if (this.isOpen()) {
  4250. this._cRef.instance.writeValue(this._dateAdapter.toModel(model));
  4251. this._onTouched();
  4252. }
  4253. }
  4254. /**
  4255. * @private
  4256. * @param {?} date
  4257. * @return {?}
  4258. */
  4259. _fromDateStruct(date) {
  4260. /** @type {?} */
  4261. const ngbDate = date ? new NgbDate(date.year, date.month, date.day) : null;
  4262. return this._calendar.isValid(ngbDate) ? ngbDate : null;
  4263. }
  4264. /**
  4265. * @private
  4266. * @return {?}
  4267. */
  4268. _updatePopupPosition() {
  4269. if (!this._cRef) {
  4270. return;
  4271. }
  4272. /** @type {?} */
  4273. let hostElement;
  4274. if (isString(this.positionTarget)) {
  4275. hostElement = this._document.querySelector(this.positionTarget);
  4276. }
  4277. else if (this.positionTarget instanceof HTMLElement) {
  4278. hostElement = this.positionTarget;
  4279. }
  4280. else {
  4281. hostElement = this._elRef.nativeElement;
  4282. }
  4283. if (this.positionTarget && !hostElement) {
  4284. throw new Error('ngbDatepicker could not find element declared in [positionTarget] to position against.');
  4285. }
  4286. positionElements(hostElement, this._cRef.location.nativeElement, this.placement, this.container === 'body');
  4287. }
  4288. }
  4289. NgbInputDatepicker.decorators = [
  4290. { type: Directive, args: [{
  4291. selector: 'input[ngbDatepicker]',
  4292. exportAs: 'ngbDatepicker',
  4293. host: {
  4294. '(input)': 'manualDateChange($event.target.value)',
  4295. '(change)': 'manualDateChange($event.target.value, true)',
  4296. '(focus)': 'onFocus()',
  4297. '(blur)': 'onBlur()',
  4298. '[disabled]': 'disabled'
  4299. },
  4300. providers: [
  4301. NGB_DATEPICKER_VALUE_ACCESSOR$1, NGB_DATEPICKER_VALIDATOR,
  4302. { provide: NgbDatepickerConfig, useExisting: NgbInputDatepickerConfig }
  4303. ],
  4304. },] }
  4305. ];
  4306. /** @nocollapse */
  4307. NgbInputDatepicker.ctorParameters = () => [
  4308. { type: NgbDateParserFormatter },
  4309. { type: ElementRef },
  4310. { type: ViewContainerRef },
  4311. { type: Renderer2 },
  4312. { type: ComponentFactoryResolver },
  4313. { type: NgZone },
  4314. { type: NgbCalendar },
  4315. { type: NgbDateAdapter },
  4316. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
  4317. { type: ChangeDetectorRef },
  4318. { type: NgbInputDatepickerConfig }
  4319. ];
  4320. NgbInputDatepicker.propDecorators = {
  4321. autoClose: [{ type: Input }],
  4322. dayTemplate: [{ type: Input }],
  4323. dayTemplateData: [{ type: Input }],
  4324. displayMonths: [{ type: Input }],
  4325. firstDayOfWeek: [{ type: Input }],
  4326. footerTemplate: [{ type: Input }],
  4327. markDisabled: [{ type: Input }],
  4328. minDate: [{ type: Input }],
  4329. maxDate: [{ type: Input }],
  4330. navigation: [{ type: Input }],
  4331. outsideDays: [{ type: Input }],
  4332. placement: [{ type: Input }],
  4333. restoreFocus: [{ type: Input }],
  4334. showWeekdays: [{ type: Input }],
  4335. showWeekNumbers: [{ type: Input }],
  4336. startDate: [{ type: Input }],
  4337. container: [{ type: Input }],
  4338. positionTarget: [{ type: Input }],
  4339. dateSelect: [{ type: Output }],
  4340. navigate: [{ type: Output }],
  4341. closed: [{ type: Output }],
  4342. disabled: [{ type: Input }]
  4343. };
  4344. /**
  4345. * @fileoverview added by tsickle
  4346. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4347. */
  4348. class NgbDatepickerDayView {
  4349. /**
  4350. * @param {?} i18n
  4351. */
  4352. constructor(i18n) {
  4353. this.i18n = i18n;
  4354. }
  4355. /**
  4356. * @return {?}
  4357. */
  4358. isMuted() { return !this.selected && (this.date.month !== this.currentMonth || this.disabled); }
  4359. }
  4360. NgbDatepickerDayView.decorators = [
  4361. { type: Component, args: [{
  4362. selector: '[ngbDatepickerDayView]',
  4363. changeDetection: ChangeDetectionStrategy.OnPush,
  4364. encapsulation: ViewEncapsulation.None,
  4365. host: {
  4366. 'class': 'btn-light',
  4367. '[class.bg-primary]': 'selected',
  4368. '[class.text-white]': 'selected',
  4369. '[class.text-muted]': 'isMuted()',
  4370. '[class.outside]': 'isMuted()',
  4371. '[class.active]': 'focused'
  4372. },
  4373. template: `{{ i18n.getDayNumerals(date) }}`,
  4374. styles: ["[ngbDatepickerDayView]{text-align:center;width:2rem;height:2rem;line-height:2rem;border-radius:.25rem;background:0 0}[ngbDatepickerDayView].outside{opacity:.5}"]
  4375. }] }
  4376. ];
  4377. /** @nocollapse */
  4378. NgbDatepickerDayView.ctorParameters = () => [
  4379. { type: NgbDatepickerI18n }
  4380. ];
  4381. NgbDatepickerDayView.propDecorators = {
  4382. currentMonth: [{ type: Input }],
  4383. date: [{ type: Input }],
  4384. disabled: [{ type: Input }],
  4385. focused: [{ type: Input }],
  4386. selected: [{ type: Input }]
  4387. };
  4388. /**
  4389. * @fileoverview added by tsickle
  4390. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4391. */
  4392. class NgbDatepickerNavigationSelect {
  4393. /**
  4394. * @param {?} i18n
  4395. * @param {?} _renderer
  4396. */
  4397. constructor(i18n, _renderer) {
  4398. this.i18n = i18n;
  4399. this._renderer = _renderer;
  4400. this.select = new EventEmitter();
  4401. this._month = -1;
  4402. this._year = -1;
  4403. }
  4404. /**
  4405. * @param {?} month
  4406. * @return {?}
  4407. */
  4408. changeMonth(month) { this.select.emit(new NgbDate(this.date.year, toInteger(month), 1)); }
  4409. /**
  4410. * @param {?} year
  4411. * @return {?}
  4412. */
  4413. changeYear(year) { this.select.emit(new NgbDate(toInteger(year), this.date.month, 1)); }
  4414. /**
  4415. * @return {?}
  4416. */
  4417. ngAfterViewChecked() {
  4418. if (this.date) {
  4419. if (this.date.month !== this._month) {
  4420. this._month = this.date.month;
  4421. this._renderer.setProperty(this.monthSelect.nativeElement, 'value', this._month);
  4422. }
  4423. if (this.date.year !== this._year) {
  4424. this._year = this.date.year;
  4425. this._renderer.setProperty(this.yearSelect.nativeElement, 'value', this._year);
  4426. }
  4427. }
  4428. }
  4429. }
  4430. NgbDatepickerNavigationSelect.decorators = [
  4431. { type: Component, args: [{
  4432. selector: 'ngb-datepicker-navigation-select',
  4433. changeDetection: ChangeDetectionStrategy.OnPush,
  4434. encapsulation: ViewEncapsulation.None,
  4435. template: `
  4436. <select #month
  4437. [disabled]="disabled"
  4438. class="custom-select"
  4439. i18n-aria-label="@@ngb.datepicker.select-month" aria-label="Select month"
  4440. i18n-title="@@ngb.datepicker.select-month" title="Select month"
  4441. (change)="changeMonth($event.target.value)">
  4442. <option *ngFor="let m of months" [attr.aria-label]="i18n.getMonthFullName(m, date?.year)"
  4443. [value]="m">{{ i18n.getMonthShortName(m, date?.year) }}</option>
  4444. </select><select #year
  4445. [disabled]="disabled"
  4446. class="custom-select"
  4447. i18n-aria-label="@@ngb.datepicker.select-year" aria-label="Select year"
  4448. i18n-title="@@ngb.datepicker.select-year" title="Select year"
  4449. (change)="changeYear($event.target.value)">
  4450. <option *ngFor="let y of years" [value]="y">{{ i18n.getYearNumerals(y) }}</option>
  4451. </select>
  4452. `,
  4453. styles: ["ngb-datepicker-navigation-select>.custom-select{-ms-flex:1 1 auto;flex:1 1 auto;padding:0 .5rem;font-size:.875rem;height:1.85rem}ngb-datepicker-navigation-select>.custom-select:focus{z-index:1}ngb-datepicker-navigation-select>.custom-select::-ms-value{background-color:transparent!important}"]
  4454. }] }
  4455. ];
  4456. /** @nocollapse */
  4457. NgbDatepickerNavigationSelect.ctorParameters = () => [
  4458. { type: NgbDatepickerI18n },
  4459. { type: Renderer2 }
  4460. ];
  4461. NgbDatepickerNavigationSelect.propDecorators = {
  4462. date: [{ type: Input }],
  4463. disabled: [{ type: Input }],
  4464. months: [{ type: Input }],
  4465. years: [{ type: Input }],
  4466. select: [{ type: Output }],
  4467. monthSelect: [{ type: ViewChild, args: ['month', { static: true, read: ElementRef },] }],
  4468. yearSelect: [{ type: ViewChild, args: ['year', { static: true, read: ElementRef },] }]
  4469. };
  4470. /**
  4471. * @fileoverview added by tsickle
  4472. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4473. */
  4474. /**
  4475. * @abstract
  4476. */
  4477. class NgbCalendarHijri extends NgbCalendar {
  4478. /**
  4479. * @return {?}
  4480. */
  4481. getDaysPerWeek() { return 7; }
  4482. /**
  4483. * @return {?}
  4484. */
  4485. getMonths() { return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; }
  4486. /**
  4487. * @return {?}
  4488. */
  4489. getWeeksPerMonth() { return 6; }
  4490. /**
  4491. * @param {?} date
  4492. * @param {?=} period
  4493. * @param {?=} number
  4494. * @return {?}
  4495. */
  4496. getNext(date, period = 'd', number = 1) {
  4497. date = new NgbDate(date.year, date.month, date.day);
  4498. switch (period) {
  4499. case 'y':
  4500. date = this._setYear(date, date.year + number);
  4501. date.month = 1;
  4502. date.day = 1;
  4503. return date;
  4504. case 'm':
  4505. date = this._setMonth(date, date.month + number);
  4506. date.day = 1;
  4507. return date;
  4508. case 'd':
  4509. return this._setDay(date, date.day + number);
  4510. default:
  4511. return date;
  4512. }
  4513. }
  4514. /**
  4515. * @param {?} date
  4516. * @param {?=} period
  4517. * @param {?=} number
  4518. * @return {?}
  4519. */
  4520. getPrev(date, period = 'd', number = 1) { return this.getNext(date, period, -number); }
  4521. /**
  4522. * @param {?} date
  4523. * @return {?}
  4524. */
  4525. getWeekday(date) {
  4526. /** @type {?} */
  4527. const day = this.toGregorian(date).getDay();
  4528. // in JS Date Sun=0, in ISO 8601 Sun=7
  4529. return day === 0 ? 7 : day;
  4530. }
  4531. /**
  4532. * @param {?} week
  4533. * @param {?} firstDayOfWeek
  4534. * @return {?}
  4535. */
  4536. getWeekNumber(week, firstDayOfWeek) {
  4537. // in JS Date Sun=0, in ISO 8601 Sun=7
  4538. if (firstDayOfWeek === 7) {
  4539. firstDayOfWeek = 0;
  4540. }
  4541. /** @type {?} */
  4542. const thursdayIndex = (4 + 7 - firstDayOfWeek) % 7;
  4543. /** @type {?} */
  4544. const date = week[thursdayIndex];
  4545. /** @type {?} */
  4546. const jsDate = this.toGregorian(date);
  4547. jsDate.setDate(jsDate.getDate() + 4 - (jsDate.getDay() || 7)); // Thursday
  4548. // Thursday
  4549. /** @type {?} */
  4550. const time = jsDate.getTime();
  4551. /** @type {?} */
  4552. const MuhDate = this.toGregorian(new NgbDate(date.year, 1, 1));
  4553. return Math.floor(Math.round((time - MuhDate.getTime()) / 86400000) / 7) + 1;
  4554. }
  4555. /**
  4556. * @return {?}
  4557. */
  4558. getToday() { return this.fromGregorian(new Date()); }
  4559. /**
  4560. * @param {?} date
  4561. * @return {?}
  4562. */
  4563. isValid(date) {
  4564. return date && isNumber(date.year) && isNumber(date.month) && isNumber(date.day) &&
  4565. !isNaN(this.toGregorian(date).getTime());
  4566. }
  4567. /**
  4568. * @private
  4569. * @param {?} date
  4570. * @param {?} day
  4571. * @return {?}
  4572. */
  4573. _setDay(date, day) {
  4574. day = +day;
  4575. /** @type {?} */
  4576. let mDays = this.getDaysPerMonth(date.month, date.year);
  4577. if (day <= 0) {
  4578. while (day <= 0) {
  4579. date = this._setMonth(date, date.month - 1);
  4580. mDays = this.getDaysPerMonth(date.month, date.year);
  4581. day += mDays;
  4582. }
  4583. }
  4584. else if (day > mDays) {
  4585. while (day > mDays) {
  4586. day -= mDays;
  4587. date = this._setMonth(date, date.month + 1);
  4588. mDays = this.getDaysPerMonth(date.month, date.year);
  4589. }
  4590. }
  4591. date.day = day;
  4592. return date;
  4593. }
  4594. /**
  4595. * @private
  4596. * @param {?} date
  4597. * @param {?} month
  4598. * @return {?}
  4599. */
  4600. _setMonth(date, month) {
  4601. month = +month;
  4602. date.year = date.year + Math.floor((month - 1) / 12);
  4603. date.month = Math.floor(((month - 1) % 12 + 12) % 12) + 1;
  4604. return date;
  4605. }
  4606. /**
  4607. * @private
  4608. * @param {?} date
  4609. * @param {?} year
  4610. * @return {?}
  4611. */
  4612. _setYear(date, year) {
  4613. date.year = +year;
  4614. return date;
  4615. }
  4616. }
  4617. NgbCalendarHijri.decorators = [
  4618. { type: Injectable }
  4619. ];
  4620. /**
  4621. * @fileoverview added by tsickle
  4622. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4623. */
  4624. /**
  4625. * Checks if islamic year is a leap year
  4626. * @param {?} hYear
  4627. * @return {?}
  4628. */
  4629. function isIslamicLeapYear(hYear) {
  4630. return (14 + 11 * hYear) % 30 < 11;
  4631. }
  4632. /**
  4633. * Checks if gregorian years is a leap year
  4634. * @param {?} gDate
  4635. * @return {?}
  4636. */
  4637. function isGregorianLeapYear(gDate) {
  4638. /** @type {?} */
  4639. const year = gDate.getFullYear();
  4640. return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
  4641. }
  4642. /**
  4643. * Returns the start of Hijri Month.
  4644. * `hMonth` is 0 for Muharram, 1 for Safar, etc.
  4645. * `hYear` is any Hijri hYear.
  4646. * @param {?} hYear
  4647. * @param {?} hMonth
  4648. * @return {?}
  4649. */
  4650. function getIslamicMonthStart(hYear, hMonth) {
  4651. return Math.ceil(29.5 * hMonth) + (hYear - 1) * 354 + Math.floor((3 + 11 * hYear) / 30.0);
  4652. }
  4653. /**
  4654. * Returns the start of Hijri year.
  4655. * `year` is any Hijri year.
  4656. * @param {?} year
  4657. * @return {?}
  4658. */
  4659. function getIslamicYearStart(year) {
  4660. return (year - 1) * 354 + Math.floor((3 + 11 * year) / 30.0);
  4661. }
  4662. /**
  4663. * @param {?} a
  4664. * @param {?} b
  4665. * @return {?}
  4666. */
  4667. function mod(a, b) {
  4668. return a - b * Math.floor(a / b);
  4669. }
  4670. /**
  4671. * The civil calendar is one type of Hijri calendars used in islamic countries.
  4672. * Uses a fixed cycle of alternating 29- and 30-day months,
  4673. * with a leap day added to the last month of 11 out of every 30 years.
  4674. * http://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types
  4675. * All the calculations here are based on the equations from "Calendrical Calculations" By Edward M. Reingold, Nachum
  4676. * Dershowitz.
  4677. * @type {?}
  4678. */
  4679. const GREGORIAN_EPOCH = 1721425.5;
  4680. /** @type {?} */
  4681. const ISLAMIC_EPOCH = 1948439.5;
  4682. class NgbCalendarIslamicCivil extends NgbCalendarHijri {
  4683. /**
  4684. * Returns the equivalent islamic(civil) date value for a give input Gregorian date.
  4685. * `gDate` is a JS Date to be converted to Hijri.
  4686. * @param {?} gDate
  4687. * @return {?}
  4688. */
  4689. fromGregorian(gDate) {
  4690. /** @type {?} */
  4691. const gYear = gDate.getFullYear();
  4692. /** @type {?} */
  4693. const gMonth = gDate.getMonth();
  4694. /** @type {?} */
  4695. const gDay = gDate.getDate();
  4696. /** @type {?} */
  4697. let julianDay = GREGORIAN_EPOCH - 1 + 365 * (gYear - 1) + Math.floor((gYear - 1) / 4) +
  4698. -Math.floor((gYear - 1) / 100) + Math.floor((gYear - 1) / 400) +
  4699. Math.floor((367 * (gMonth + 1) - 362) / 12 + (gMonth + 1 <= 2 ? 0 : isGregorianLeapYear(gDate) ? -1 : -2) + gDay);
  4700. julianDay = Math.floor(julianDay) + 0.5;
  4701. /** @type {?} */
  4702. const days = julianDay - ISLAMIC_EPOCH;
  4703. /** @type {?} */
  4704. const hYear = Math.floor((30 * days + 10646) / 10631.0);
  4705. /** @type {?} */
  4706. let hMonth = Math.ceil((days - 29 - getIslamicYearStart(hYear)) / 29.5);
  4707. hMonth = Math.min(hMonth, 11);
  4708. /** @type {?} */
  4709. const hDay = Math.ceil(days - getIslamicMonthStart(hYear, hMonth)) + 1;
  4710. return new NgbDate(hYear, hMonth + 1, hDay);
  4711. }
  4712. /**
  4713. * Returns the equivalent JS date value for a give input islamic(civil) date.
  4714. * `hDate` is an islamic(civil) date to be converted to Gregorian.
  4715. * @param {?} hDate
  4716. * @return {?}
  4717. */
  4718. toGregorian(hDate) {
  4719. /** @type {?} */
  4720. const hYear = hDate.year;
  4721. /** @type {?} */
  4722. const hMonth = hDate.month - 1;
  4723. /** @type {?} */
  4724. const hDay = hDate.day;
  4725. /** @type {?} */
  4726. const julianDay = hDay + Math.ceil(29.5 * hMonth) + (hYear - 1) * 354 + Math.floor((3 + 11 * hYear) / 30) + ISLAMIC_EPOCH - 1;
  4727. /** @type {?} */
  4728. const wjd = Math.floor(julianDay - 0.5) + 0.5;
  4729. /** @type {?} */
  4730. const depoch = wjd - GREGORIAN_EPOCH;
  4731. /** @type {?} */
  4732. const quadricent = Math.floor(depoch / 146097);
  4733. /** @type {?} */
  4734. const dqc = mod(depoch, 146097);
  4735. /** @type {?} */
  4736. const cent = Math.floor(dqc / 36524);
  4737. /** @type {?} */
  4738. const dcent = mod(dqc, 36524);
  4739. /** @type {?} */
  4740. const quad = Math.floor(dcent / 1461);
  4741. /** @type {?} */
  4742. const dquad = mod(dcent, 1461);
  4743. /** @type {?} */
  4744. const yindex = Math.floor(dquad / 365);
  4745. /** @type {?} */
  4746. let year = quadricent * 400 + cent * 100 + quad * 4 + yindex;
  4747. if (!(cent === 4 || yindex === 4)) {
  4748. year++;
  4749. }
  4750. /** @type {?} */
  4751. const gYearStart = GREGORIAN_EPOCH + 365 * (year - 1) + Math.floor((year - 1) / 4) - Math.floor((year - 1) / 100) +
  4752. Math.floor((year - 1) / 400);
  4753. /** @type {?} */
  4754. const yearday = wjd - gYearStart;
  4755. /** @type {?} */
  4756. const tjd = GREGORIAN_EPOCH - 1 + 365 * (year - 1) + Math.floor((year - 1) / 4) - Math.floor((year - 1) / 100) +
  4757. Math.floor((year - 1) / 400) + Math.floor(739 / 12 + (isGregorianLeapYear(new Date(year, 3, 1)) ? -1 : -2) + 1);
  4758. /** @type {?} */
  4759. const leapadj = wjd < tjd ? 0 : isGregorianLeapYear(new Date(year, 3, 1)) ? 1 : 2;
  4760. /** @type {?} */
  4761. const month = Math.floor(((yearday + leapadj) * 12 + 373) / 367);
  4762. /** @type {?} */
  4763. const tjd2 = GREGORIAN_EPOCH - 1 + 365 * (year - 1) + Math.floor((year - 1) / 4) - Math.floor((year - 1) / 100) +
  4764. Math.floor((year - 1) / 400) +
  4765. Math.floor((367 * month - 362) / 12 + (month <= 2 ? 0 : isGregorianLeapYear(new Date(year, month - 1, 1)) ? -1 : -2) +
  4766. 1);
  4767. /** @type {?} */
  4768. const day = wjd - tjd2 + 1;
  4769. return new Date(year, month - 1, day);
  4770. }
  4771. /**
  4772. * Returns the number of days in a specific Hijri month.
  4773. * `month` is 1 for Muharram, 2 for Safar, etc.
  4774. * `year` is any Hijri year.
  4775. * @param {?} month
  4776. * @param {?} year
  4777. * @return {?}
  4778. */
  4779. getDaysPerMonth(month, year) {
  4780. year = year + Math.floor(month / 13);
  4781. month = ((month - 1) % 12) + 1;
  4782. /** @type {?} */
  4783. let length = 29 + month % 2;
  4784. if (month === 12 && isIslamicLeapYear(year)) {
  4785. length++;
  4786. }
  4787. return length;
  4788. }
  4789. }
  4790. NgbCalendarIslamicCivil.decorators = [
  4791. { type: Injectable }
  4792. ];
  4793. /**
  4794. * @fileoverview added by tsickle
  4795. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  4796. */
  4797. /**
  4798. * Umalqura calendar is one type of Hijri calendars used in islamic countries.
  4799. * This Calendar is used by Saudi Arabia for administrative purpose.
  4800. * Unlike tabular calendars, the algorithm involves astronomical calculation, but it's still deterministic.
  4801. * http://cldr.unicode.org/development/development-process/design-proposals/islamic-calendar-types
  4802. * @type {?}
  4803. */
  4804. const GREGORIAN_FIRST_DATE = new Date(1882, 10, 12);
  4805. /** @type {?} */
  4806. const GREGORIAN_LAST_DATE = new Date(2174, 10, 25);
  4807. /** @type {?} */
  4808. const HIJRI_BEGIN = 1300;
  4809. /** @type {?} */
  4810. const HIJRI_END = 1600;
  4811. /** @type {?} */
  4812. const ONE_DAY = 1000 * 60 * 60 * 24;
  4813. /** @type {?} */
  4814. const MONTH_LENGTH = [
  4815. // 1300-1304
  4816. '101010101010', '110101010100', '111011001001', '011011010100', '011011101010',
  4817. // 1305-1309
  4818. '001101101100', '101010101101', '010101010101', '011010101001', '011110010010',
  4819. // 1310-1314
  4820. '101110101001', '010111010100', '101011011010', '010101011100', '110100101101',
  4821. // 1315-1319
  4822. '011010010101', '011101001010', '101101010100', '101101101010', '010110101101',
  4823. // 1320-1324
  4824. '010010101110', '101001001111', '010100010111', '011010001011', '011010100101',
  4825. // 1325-1329
  4826. '101011010101', '001011010110', '100101011011', '010010011101', '101001001101',
  4827. // 1330-1334
  4828. '110100100110', '110110010101', '010110101100', '100110110110', '001010111010',
  4829. // 1335-1339
  4830. '101001011011', '010100101011', '101010010101', '011011001010', '101011101001',
  4831. // 1340-1344
  4832. '001011110100', '100101110110', '001010110110', '100101010110', '101011001010',
  4833. // 1345-1349
  4834. '101110100100', '101111010010', '010111011001', '001011011100', '100101101101',
  4835. // 1350-1354
  4836. '010101001101', '101010100101', '101101010010', '101110100101', '010110110100',
  4837. // 1355-1359
  4838. '100110110110', '010101010111', '001010010111', '010101001011', '011010100011',
  4839. // 1360-1364
  4840. '011101010010', '101101100101', '010101101010', '101010101011', '010100101011',
  4841. // 1365-1369
  4842. '110010010101', '110101001010', '110110100101', '010111001010', '101011010110',
  4843. // 1370-1374
  4844. '100101010111', '010010101011', '100101001011', '101010100101', '101101010010',
  4845. // 1375-1379
  4846. '101101101010', '010101110101', '001001110110', '100010110111', '010001011011',
  4847. // 1380-1384
  4848. '010101010101', '010110101001', '010110110100', '100111011010', '010011011101',
  4849. // 1385-1389
  4850. '001001101110', '100100110110', '101010101010', '110101010100', '110110110010',
  4851. // 1390-1394
  4852. '010111010101', '001011011010', '100101011011', '010010101011', '101001010101',
  4853. // 1395-1399
  4854. '101101001001', '101101100100', '101101110001', '010110110100', '101010110101',
  4855. // 1400-1404
  4856. '101001010101', '110100100101', '111010010010', '111011001001', '011011010100',
  4857. // 1405-1409
  4858. '101011101001', '100101101011', '010010101011', '101010010011', '110101001001',
  4859. // 1410-1414
  4860. '110110100100', '110110110010', '101010111001', '010010111010', '101001011011',
  4861. // 1415-1419
  4862. '010100101011', '101010010101', '101100101010', '101101010101', '010101011100',
  4863. // 1420-1424
  4864. '010010111101', '001000111101', '100100011101', '101010010101', '101101001010',
  4865. // 1425-1429
  4866. '101101011010', '010101101101', '001010110110', '100100111011', '010010011011',
  4867. // 1430-1434
  4868. '011001010101', '011010101001', '011101010100', '101101101010', '010101101100',
  4869. // 1435-1439
  4870. '101010101101', '010101010101', '101100101001', '101110010010', '101110101001',
  4871. // 1440-1444
  4872. '010111010100', '101011011010', '010101011010', '101010101011', '010110010101',
  4873. // 1445-1449
  4874. '011101001001', '011101100100', '101110101010', '010110110101', '001010110110',
  4875. // 1450-1454
  4876. '101001010110', '111001001101', '101100100101', '101101010010', '101101101010',
  4877. // 1455-1459
  4878. '010110101101', '001010101110', '100100101111', '010010010111', '011001001011',
  4879. // 1460-1464
  4880. '011010100101', '011010101100', '101011010110', '010101011101', '010010011101',
  4881. // 1465-1469
  4882. '101001001101', '110100010110', '110110010101', '010110101010', '010110110101',
  4883. // 1470-1474
  4884. '001011011010', '100101011011', '010010101101', '010110010101', '011011001010',
  4885. // 1475-1479
  4886. '011011100100', '101011101010', '010011110101', '001010110110', '100101010110',
  4887. // 1480-1484
  4888. '101010101010', '101101010100', '101111010010', '010111011001', '001011101010',
  4889. // 1485-1489
  4890. '100101101101', '010010101101', '101010010101', '101101001010', '101110100101',
  4891. // 1490-1494
  4892. '010110110010', '100110110101', '010011010110', '101010010111', '010101000111',
  4893. // 1495-1499
  4894. '011010010011', '011101001001', '101101010101', '010101101010', '101001101011',
  4895. // 1500-1504
  4896. '010100101011', '101010001011', '110101000110', '110110100011', '010111001010',
  4897. // 1505-1509
  4898. '101011010110', '010011011011', '001001101011', '100101001011', '101010100101',
  4899. // 1510-1514
  4900. '101101010010', '101101101001', '010101110101', '000101110110', '100010110111',
  4901. // 1515-1519
  4902. '001001011011', '010100101011', '010101100101', '010110110100', '100111011010',
  4903. // 1520-1524
  4904. '010011101101', '000101101101', '100010110110', '101010100110', '110101010010',
  4905. // 1525-1529
  4906. '110110101001', '010111010100', '101011011010', '100101011011', '010010101011',
  4907. // 1530-1534
  4908. '011001010011', '011100101001', '011101100010', '101110101001', '010110110010',
  4909. // 1535-1539
  4910. '101010110101', '010101010101', '101100100101', '110110010010', '111011001001',
  4911. // 1540-1544
  4912. '011011010010', '101011101001', '010101101011', '010010101011', '101001010101',
  4913. // 1545-1549
  4914. '110100101001', '110101010100', '110110101010', '100110110101', '010010111010',
  4915. // 1550-1554
  4916. '101000111011', '010010011011', '101001001101', '101010101010', '101011010101',
  4917. // 1555-1559
  4918. '001011011010', '100101011101', '010001011110', '101000101110', '110010011010',
  4919. // 1560-1564
  4920. '110101010101', '011010110010', '011010111001', '010010111010', '101001011101',
  4921. // 1565-1569
  4922. '010100101101', '101010010101', '101101010010', '101110101000', '101110110100',
  4923. // 1570-1574
  4924. '010110111001', '001011011010', '100101011010', '101101001010', '110110100100',
  4925. // 1575-1579
  4926. '111011010001', '011011101000', '101101101010', '010101101101', '010100110101',
  4927. // 1580-1584
  4928. '011010010101', '110101001010', '110110101000', '110111010100', '011011011010',
  4929. // 1585-1589
  4930. '010101011011', '001010011101', '011000101011', '101100010101', '101101001010',
  4931. // 1590-1594
  4932. '101110010101', '010110101010', '101010101110', '100100101110', '110010001111',
  4933. // 1595-1599
  4934. '010100100111', '011010010101', '011010101010', '101011010110', '010101011101',
  4935. // 1600
  4936. '001010011101'
  4937. ];
  4938. /**
  4939. * @param {?} date1
  4940. * @param {?} date2
  4941. * @return {?}
  4942. */
  4943. function getDaysDiff(date1, date2) {
  4944. // Ignores the time part in date1 and date2:
  4945. /** @type {?} */
  4946. const time1 = Date.UTC(date1.getFullYear(), date1.getMonth(), date1.getDate());
  4947. /** @type {?} */
  4948. const time2 = Date.UTC(date2.getFullYear(), date2.getMonth(), date2.getDate());
  4949. /** @type {?} */
  4950. const diff = Math.abs(time1 - time2);
  4951. return Math.round(diff / ONE_DAY);
  4952. }
  4953. class NgbCalendarIslamicUmalqura extends NgbCalendarIslamicCivil {
  4954. /**
  4955. * Returns the equivalent islamic(Umalqura) date value for a give input Gregorian date.
  4956. * `gdate` is s JS Date to be converted to Hijri.
  4957. * @param {?} gDate
  4958. * @return {?}
  4959. */
  4960. fromGregorian(gDate) {
  4961. /** @type {?} */
  4962. let hDay = 1;
  4963. /** @type {?} */
  4964. let hMonth = 0;
  4965. /** @type {?} */
  4966. let hYear = 1300;
  4967. /** @type {?} */
  4968. let daysDiff = getDaysDiff(gDate, GREGORIAN_FIRST_DATE);
  4969. if (gDate.getTime() - GREGORIAN_FIRST_DATE.getTime() >= 0 && gDate.getTime() - GREGORIAN_LAST_DATE.getTime() <= 0) {
  4970. /** @type {?} */
  4971. let year = 1300;
  4972. for (let i = 0; i < MONTH_LENGTH.length; i++, year++) {
  4973. for (let j = 0; j < 12; j++) {
  4974. /** @type {?} */
  4975. let numOfDays = +MONTH_LENGTH[i][j] + 29;
  4976. if (daysDiff <= numOfDays) {
  4977. hDay = daysDiff + 1;
  4978. if (hDay > numOfDays) {
  4979. hDay = 1;
  4980. j++;
  4981. }
  4982. if (j > 11) {
  4983. j = 0;
  4984. year++;
  4985. }
  4986. hMonth = j;
  4987. hYear = year;
  4988. return new NgbDate(hYear, hMonth + 1, hDay);
  4989. }
  4990. daysDiff = daysDiff - numOfDays;
  4991. }
  4992. }
  4993. }
  4994. else {
  4995. return super.fromGregorian(gDate);
  4996. }
  4997. }
  4998. /**
  4999. * Converts the current Hijri date to Gregorian.
  5000. * @param {?} hDate
  5001. * @return {?}
  5002. */
  5003. toGregorian(hDate) {
  5004. /** @type {?} */
  5005. const hYear = hDate.year;
  5006. /** @type {?} */
  5007. const hMonth = hDate.month - 1;
  5008. /** @type {?} */
  5009. const hDay = hDate.day;
  5010. /** @type {?} */
  5011. let gDate = new Date(GREGORIAN_FIRST_DATE);
  5012. /** @type {?} */
  5013. let dayDiff = hDay - 1;
  5014. if (hYear >= HIJRI_BEGIN && hYear <= HIJRI_END) {
  5015. for (let y = 0; y < hYear - HIJRI_BEGIN; y++) {
  5016. for (let m = 0; m < 12; m++) {
  5017. dayDiff += +MONTH_LENGTH[y][m] + 29;
  5018. }
  5019. }
  5020. for (let m = 0; m < hMonth; m++) {
  5021. dayDiff += +MONTH_LENGTH[hYear - HIJRI_BEGIN][m] + 29;
  5022. }
  5023. gDate.setDate(GREGORIAN_FIRST_DATE.getDate() + dayDiff);
  5024. }
  5025. else {
  5026. gDate = super.toGregorian(hDate);
  5027. }
  5028. return gDate;
  5029. }
  5030. /**
  5031. * Returns the number of days in a specific Hijri hMonth.
  5032. * `hMonth` is 1 for Muharram, 2 for Safar, etc.
  5033. * `hYear` is any Hijri hYear.
  5034. * @param {?} hMonth
  5035. * @param {?} hYear
  5036. * @return {?}
  5037. */
  5038. getDaysPerMonth(hMonth, hYear) {
  5039. if (hYear >= HIJRI_BEGIN && hYear <= HIJRI_END) {
  5040. /** @type {?} */
  5041. const pos = hYear - HIJRI_BEGIN;
  5042. return +MONTH_LENGTH[pos][hMonth - 1] + 29;
  5043. }
  5044. return super.getDaysPerMonth(hMonth, hYear);
  5045. }
  5046. }
  5047. NgbCalendarIslamicUmalqura.decorators = [
  5048. { type: Injectable }
  5049. ];
  5050. /**
  5051. * @fileoverview added by tsickle
  5052. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5053. */
  5054. /**
  5055. * Returns the equivalent JS date value for a give input Jalali date.
  5056. * `jalaliDate` is an Jalali date to be converted to Gregorian.
  5057. * @param {?} jalaliDate
  5058. * @return {?}
  5059. */
  5060. function toGregorian(jalaliDate) {
  5061. /** @type {?} */
  5062. let jdn = jalaliToJulian(jalaliDate.year, jalaliDate.month, jalaliDate.day);
  5063. /** @type {?} */
  5064. let date = julianToGregorian(jdn);
  5065. date.setHours(6, 30, 3, 200);
  5066. return date;
  5067. }
  5068. /**
  5069. * Returns the equivalent jalali date value for a give input Gregorian date.
  5070. * `gdate` is a JS Date to be converted to jalali.
  5071. * utc to local
  5072. * @param {?} gdate
  5073. * @return {?}
  5074. */
  5075. function fromGregorian(gdate) {
  5076. /** @type {?} */
  5077. let g2d = gregorianToJulian(gdate.getFullYear(), gdate.getMonth() + 1, gdate.getDate());
  5078. return julianToJalali(g2d);
  5079. }
  5080. /**
  5081. * @param {?} date
  5082. * @param {?} yearValue
  5083. * @return {?}
  5084. */
  5085. function setJalaliYear(date, yearValue) {
  5086. date.year = +yearValue;
  5087. return date;
  5088. }
  5089. /**
  5090. * @param {?} date
  5091. * @param {?} month
  5092. * @return {?}
  5093. */
  5094. function setJalaliMonth(date, month) {
  5095. month = +month;
  5096. date.year = date.year + Math.floor((month - 1) / 12);
  5097. date.month = Math.floor(((month - 1) % 12 + 12) % 12) + 1;
  5098. return date;
  5099. }
  5100. /**
  5101. * @param {?} date
  5102. * @param {?} day
  5103. * @return {?}
  5104. */
  5105. function setJalaliDay(date, day) {
  5106. /** @type {?} */
  5107. let mDays = getDaysPerMonth(date.month, date.year);
  5108. if (day <= 0) {
  5109. while (day <= 0) {
  5110. date = setJalaliMonth(date, date.month - 1);
  5111. mDays = getDaysPerMonth(date.month, date.year);
  5112. day += mDays;
  5113. }
  5114. }
  5115. else if (day > mDays) {
  5116. while (day > mDays) {
  5117. day -= mDays;
  5118. date = setJalaliMonth(date, date.month + 1);
  5119. mDays = getDaysPerMonth(date.month, date.year);
  5120. }
  5121. }
  5122. date.day = day;
  5123. return date;
  5124. }
  5125. /**
  5126. * @param {?} a
  5127. * @param {?} b
  5128. * @return {?}
  5129. */
  5130. function mod$1(a, b) {
  5131. return a - b * Math.floor(a / b);
  5132. }
  5133. /**
  5134. * @param {?} a
  5135. * @param {?} b
  5136. * @return {?}
  5137. */
  5138. function div(a, b) {
  5139. return Math.trunc(a / b);
  5140. }
  5141. /*
  5142. This function determines if the Jalali (Persian) year is
  5143. leap (366-day long) or is the common year (365 days), and
  5144. finds the day in March (Gregorian calendar) of the first
  5145. day of the Jalali year (jalaliYear).
  5146. @param jalaliYear Jalali calendar year (-61 to 3177)
  5147. @return
  5148. leap: number of years since the last leap year (0 to 4)
  5149. gYear: Gregorian year of the beginning of Jalali year
  5150. march: the March day of Farvardin the 1st (1st day of jalaliYear)
  5151. @see: http://www.astro.uni.torun.pl/~kb/Papers/EMP/PersianC-EMP.htm
  5152. @see: http://www.fourmilab.ch/documents/calendar/
  5153. */
  5154. /**
  5155. * @param {?} jalaliYear
  5156. * @return {?}
  5157. */
  5158. function jalCal(jalaliYear) {
  5159. // Jalali years starting the 33-year rule.
  5160. /** @type {?} */
  5161. let breaks = [-61, 9, 38, 199, 426, 686, 756, 818, 1111, 1181, 1210, 1635, 2060, 2097, 2192, 2262, 2324, 2394, 2456, 3178];
  5162. /** @type {?} */
  5163. const breaksLength = breaks.length;
  5164. /** @type {?} */
  5165. const gYear = jalaliYear + 621;
  5166. /** @type {?} */
  5167. let leapJ = -14;
  5168. /** @type {?} */
  5169. let jp = breaks[0];
  5170. if (jalaliYear < jp || jalaliYear >= breaks[breaksLength - 1]) {
  5171. throw new Error('Invalid Jalali year ' + jalaliYear);
  5172. }
  5173. // Find the limiting years for the Jalali year jalaliYear.
  5174. /** @type {?} */
  5175. let jump;
  5176. for (let i = 1; i < breaksLength; i += 1) {
  5177. /** @type {?} */
  5178. const jm = breaks[i];
  5179. jump = jm - jp;
  5180. if (jalaliYear < jm) {
  5181. break;
  5182. }
  5183. leapJ = leapJ + div(jump, 33) * 8 + div(mod$1(jump, 33), 4);
  5184. jp = jm;
  5185. }
  5186. /** @type {?} */
  5187. let n = jalaliYear - jp;
  5188. // Find the number of leap years from AD 621 to the beginning
  5189. // of the current Jalali year in the Persian calendar.
  5190. leapJ = leapJ + div(n, 33) * 8 + div(mod$1(n, 33) + 3, 4);
  5191. if (mod$1(jump, 33) === 4 && jump - n === 4) {
  5192. leapJ += 1;
  5193. }
  5194. // And the same in the Gregorian calendar (until the year gYear).
  5195. /** @type {?} */
  5196. const leapG = div(gYear, 4) - div((div(gYear, 100) + 1) * 3, 4) - 150;
  5197. // Determine the Gregorian date of Farvardin the 1st.
  5198. /** @type {?} */
  5199. const march = 20 + leapJ - leapG;
  5200. // Find how many years have passed since the last leap year.
  5201. if (jump - n < 6) {
  5202. n = n - jump + div(jump + 4, 33) * 33;
  5203. }
  5204. /** @type {?} */
  5205. let leap = mod$1(mod$1(n + 1, 33) - 1, 4);
  5206. if (leap === -1) {
  5207. leap = 4;
  5208. }
  5209. return { leap: leap, gy: gYear, march: march };
  5210. }
  5211. /*
  5212. Calculates Gregorian and Julian calendar dates from the Julian Day number
  5213. (jdn) for the period since jdn=-34839655 (i.e. the year -100100 of both
  5214. calendars) to some millions years ahead of the present.
  5215. @param jdn Julian Day number
  5216. @return
  5217. gYear: Calendar year (years BC numbered 0, -1, -2, ...)
  5218. gMonth: Calendar month (1 to 12)
  5219. gDay: Calendar day of the month M (1 to 28/29/30/31)
  5220. */
  5221. /**
  5222. * @param {?} julianDayNumber
  5223. * @return {?}
  5224. */
  5225. function julianToGregorian(julianDayNumber) {
  5226. /** @type {?} */
  5227. let j = 4 * julianDayNumber + 139361631;
  5228. j = j + div(div(4 * julianDayNumber + 183187720, 146097) * 3, 4) * 4 - 3908;
  5229. /** @type {?} */
  5230. const i = div(mod$1(j, 1461), 4) * 5 + 308;
  5231. /** @type {?} */
  5232. const gDay = div(mod$1(i, 153), 5) + 1;
  5233. /** @type {?} */
  5234. const gMonth = mod$1(div(i, 153), 12) + 1;
  5235. /** @type {?} */
  5236. const gYear = div(j, 1461) - 100100 + div(8 - gMonth, 6);
  5237. return new Date(gYear, gMonth - 1, gDay);
  5238. }
  5239. /*
  5240. Converts a date of the Jalali calendar to the Julian Day number.
  5241. @param jy Jalali year (1 to 3100)
  5242. @param jm Jalali month (1 to 12)
  5243. @param jd Jalali day (1 to 29/31)
  5244. @return Julian Day number
  5245. */
  5246. /**
  5247. * @param {?} gy
  5248. * @param {?} gm
  5249. * @param {?} gd
  5250. * @return {?}
  5251. */
  5252. function gregorianToJulian(gy, gm, gd) {
  5253. /** @type {?} */
  5254. let d = div((gy + div(gm - 8, 6) + 100100) * 1461, 4) + div(153 * mod$1(gm + 9, 12) + 2, 5) + gd - 34840408;
  5255. d = d - div(div(gy + 100100 + div(gm - 8, 6), 100) * 3, 4) + 752;
  5256. return d;
  5257. }
  5258. /*
  5259. Converts the Julian Day number to a date in the Jalali calendar.
  5260. @param julianDayNumber Julian Day number
  5261. @return
  5262. jalaliYear: Jalali year (1 to 3100)
  5263. jalaliMonth: Jalali month (1 to 12)
  5264. jalaliDay: Jalali day (1 to 29/31)
  5265. */
  5266. /**
  5267. * @param {?} julianDayNumber
  5268. * @return {?}
  5269. */
  5270. function julianToJalali(julianDayNumber) {
  5271. /** @type {?} */
  5272. let gy = julianToGregorian(julianDayNumber).getFullYear() // Calculate Gregorian year (gy).
  5273. ;
  5274. /** @type {?} */
  5275. let jalaliYear = gy - 621;
  5276. /** @type {?} */
  5277. let r = jalCal(jalaliYear);
  5278. /** @type {?} */
  5279. let gregorianDay = gregorianToJulian(gy, 3, r.march);
  5280. /** @type {?} */
  5281. let jalaliDay;
  5282. /** @type {?} */
  5283. let jalaliMonth;
  5284. /** @type {?} */
  5285. let numberOfDays;
  5286. // Find number of days that passed since 1 Farvardin.
  5287. numberOfDays = julianDayNumber - gregorianDay;
  5288. if (numberOfDays >= 0) {
  5289. if (numberOfDays <= 185) {
  5290. // The first 6 months.
  5291. jalaliMonth = 1 + div(numberOfDays, 31);
  5292. jalaliDay = mod$1(numberOfDays, 31) + 1;
  5293. return new NgbDate(jalaliYear, jalaliMonth, jalaliDay);
  5294. }
  5295. else {
  5296. // The remaining months.
  5297. numberOfDays -= 186;
  5298. }
  5299. }
  5300. else {
  5301. // Previous Jalali year.
  5302. jalaliYear -= 1;
  5303. numberOfDays += 179;
  5304. if (r.leap === 1) {
  5305. numberOfDays += 1;
  5306. }
  5307. }
  5308. jalaliMonth = 7 + div(numberOfDays, 30);
  5309. jalaliDay = mod$1(numberOfDays, 30) + 1;
  5310. return new NgbDate(jalaliYear, jalaliMonth, jalaliDay);
  5311. }
  5312. /*
  5313. Converts a date of the Jalali calendar to the Julian Day number.
  5314. @param jYear Jalali year (1 to 3100)
  5315. @param jMonth Jalali month (1 to 12)
  5316. @param jDay Jalali day (1 to 29/31)
  5317. @return Julian Day number
  5318. */
  5319. /**
  5320. * @param {?} jYear
  5321. * @param {?} jMonth
  5322. * @param {?} jDay
  5323. * @return {?}
  5324. */
  5325. function jalaliToJulian(jYear, jMonth, jDay) {
  5326. /** @type {?} */
  5327. let r = jalCal(jYear);
  5328. return gregorianToJulian(r.gy, 3, r.march) + (jMonth - 1) * 31 - div(jMonth, 7) * (jMonth - 7) + jDay - 1;
  5329. }
  5330. /**
  5331. * Returns the number of days in a specific jalali month.
  5332. * @param {?} month
  5333. * @param {?} year
  5334. * @return {?}
  5335. */
  5336. function getDaysPerMonth(month, year) {
  5337. if (month <= 6) {
  5338. return 31;
  5339. }
  5340. if (month <= 11) {
  5341. return 30;
  5342. }
  5343. if (jalCal(year).leap === 0) {
  5344. return 30;
  5345. }
  5346. return 29;
  5347. }
  5348. /**
  5349. * @fileoverview added by tsickle
  5350. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5351. */
  5352. class NgbCalendarPersian extends NgbCalendar {
  5353. /**
  5354. * @return {?}
  5355. */
  5356. getDaysPerWeek() { return 7; }
  5357. /**
  5358. * @return {?}
  5359. */
  5360. getMonths() { return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; }
  5361. /**
  5362. * @return {?}
  5363. */
  5364. getWeeksPerMonth() { return 6; }
  5365. /**
  5366. * @param {?} date
  5367. * @param {?=} period
  5368. * @param {?=} number
  5369. * @return {?}
  5370. */
  5371. getNext(date, period = 'd', number = 1) {
  5372. date = new NgbDate(date.year, date.month, date.day);
  5373. switch (period) {
  5374. case 'y':
  5375. date = setJalaliYear(date, date.year + number);
  5376. date.month = 1;
  5377. date.day = 1;
  5378. return date;
  5379. case 'm':
  5380. date = setJalaliMonth(date, date.month + number);
  5381. date.day = 1;
  5382. return date;
  5383. case 'd':
  5384. return setJalaliDay(date, date.day + number);
  5385. default:
  5386. return date;
  5387. }
  5388. }
  5389. /**
  5390. * @param {?} date
  5391. * @param {?=} period
  5392. * @param {?=} number
  5393. * @return {?}
  5394. */
  5395. getPrev(date, period = 'd', number = 1) { return this.getNext(date, period, -number); }
  5396. /**
  5397. * @param {?} date
  5398. * @return {?}
  5399. */
  5400. getWeekday(date) {
  5401. /** @type {?} */
  5402. const day = toGregorian(date).getDay();
  5403. // in JS Date Sun=0, in ISO 8601 Sun=7
  5404. return day === 0 ? 7 : day;
  5405. }
  5406. /**
  5407. * @param {?} week
  5408. * @param {?} firstDayOfWeek
  5409. * @return {?}
  5410. */
  5411. getWeekNumber(week, firstDayOfWeek) {
  5412. // in JS Date Sun=0, in ISO 8601 Sun=7
  5413. if (firstDayOfWeek === 7) {
  5414. firstDayOfWeek = 0;
  5415. }
  5416. /** @type {?} */
  5417. const thursdayIndex = (4 + 7 - firstDayOfWeek) % 7;
  5418. /** @type {?} */
  5419. const date = week[thursdayIndex];
  5420. /** @type {?} */
  5421. const jsDate = toGregorian(date);
  5422. jsDate.setDate(jsDate.getDate() + 4 - (jsDate.getDay() || 7)); // Thursday
  5423. // Thursday
  5424. /** @type {?} */
  5425. const time = jsDate.getTime();
  5426. /** @type {?} */
  5427. const startDate = toGregorian(new NgbDate(date.year, 1, 1));
  5428. return Math.floor(Math.round((time - startDate.getTime()) / 86400000) / 7) + 1;
  5429. }
  5430. /**
  5431. * @return {?}
  5432. */
  5433. getToday() { return fromGregorian(new Date()); }
  5434. /**
  5435. * @param {?} date
  5436. * @return {?}
  5437. */
  5438. isValid(date) {
  5439. return date && isInteger(date.year) && isInteger(date.month) && isInteger(date.day) &&
  5440. !isNaN(toGregorian(date).getTime());
  5441. }
  5442. }
  5443. NgbCalendarPersian.decorators = [
  5444. { type: Injectable }
  5445. ];
  5446. /**
  5447. * @fileoverview added by tsickle
  5448. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5449. */
  5450. /** @type {?} */
  5451. const PARTS_PER_HOUR = 1080;
  5452. /** @type {?} */
  5453. const PARTS_PER_DAY = 24 * PARTS_PER_HOUR;
  5454. /** @type {?} */
  5455. const PARTS_FRACTIONAL_MONTH = 12 * PARTS_PER_HOUR + 793;
  5456. /** @type {?} */
  5457. const PARTS_PER_MONTH = 29 * PARTS_PER_DAY + PARTS_FRACTIONAL_MONTH;
  5458. /** @type {?} */
  5459. const BAHARAD = 11 * PARTS_PER_HOUR + 204;
  5460. /** @type {?} */
  5461. const HEBREW_DAY_ON_JAN_1_1970 = 2092591;
  5462. /** @type {?} */
  5463. const GREGORIAN_EPOCH$1 = 1721425.5;
  5464. /**
  5465. * @param {?} year
  5466. * @return {?}
  5467. */
  5468. function isGregorianLeapYear$1(year) {
  5469. return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
  5470. }
  5471. /**
  5472. * @param {?} year
  5473. * @return {?}
  5474. */
  5475. function numberOfFirstDayInYear(year) {
  5476. /** @type {?} */
  5477. let monthsBeforeYear = Math.floor((235 * year - 234) / 19);
  5478. /** @type {?} */
  5479. let fractionalMonthsBeforeYear = monthsBeforeYear * PARTS_FRACTIONAL_MONTH + BAHARAD;
  5480. /** @type {?} */
  5481. let dayNumber = monthsBeforeYear * 29 + Math.floor(fractionalMonthsBeforeYear / PARTS_PER_DAY);
  5482. /** @type {?} */
  5483. let timeOfDay = fractionalMonthsBeforeYear % PARTS_PER_DAY;
  5484. /** @type {?} */
  5485. let dayOfWeek = dayNumber % 7;
  5486. if (dayOfWeek === 2 || dayOfWeek === 4 || dayOfWeek === 6) {
  5487. dayNumber++;
  5488. dayOfWeek = dayNumber % 7;
  5489. }
  5490. if (dayOfWeek === 1 && timeOfDay > 15 * PARTS_PER_HOUR + 204 && !isHebrewLeapYear(year)) {
  5491. dayNumber += 2;
  5492. }
  5493. else if (dayOfWeek === 0 && timeOfDay > 21 * PARTS_PER_HOUR + 589 && isHebrewLeapYear(year - 1)) {
  5494. dayNumber++;
  5495. }
  5496. return dayNumber;
  5497. }
  5498. /**
  5499. * @param {?} month
  5500. * @param {?} year
  5501. * @return {?}
  5502. */
  5503. function getDaysInGregorianMonth(month, year) {
  5504. /** @type {?} */
  5505. let days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  5506. if (isGregorianLeapYear$1(year)) {
  5507. days[1]++;
  5508. }
  5509. return days[month - 1];
  5510. }
  5511. /**
  5512. * @param {?} year
  5513. * @return {?}
  5514. */
  5515. function getHebrewMonths(year) {
  5516. return isHebrewLeapYear(year) ? 13 : 12;
  5517. }
  5518. /**
  5519. * Returns the number of days in a specific Hebrew year.
  5520. * `year` is any Hebrew year.
  5521. * @param {?} year
  5522. * @return {?}
  5523. */
  5524. function getDaysInHebrewYear(year) {
  5525. return numberOfFirstDayInYear(year + 1) - numberOfFirstDayInYear(year);
  5526. }
  5527. /**
  5528. * @param {?} year
  5529. * @return {?}
  5530. */
  5531. function isHebrewLeapYear(year) {
  5532. /** @type {?} */
  5533. let b = (year * 12 + 17) % 19;
  5534. return b >= ((b < 0) ? -7 : 12);
  5535. }
  5536. /**
  5537. * Returns the number of days in a specific Hebrew month.
  5538. * `month` is 1 for Nisan, 2 for Iyar etc. Note: Hebrew leap year contains 13 months.
  5539. * `year` is any Hebrew year.
  5540. * @param {?} month
  5541. * @param {?} year
  5542. * @return {?}
  5543. */
  5544. function getDaysInHebrewMonth(month, year) {
  5545. /** @type {?} */
  5546. let yearLength = numberOfFirstDayInYear(year + 1) - numberOfFirstDayInYear(year);
  5547. /** @type {?} */
  5548. let yearType = (yearLength <= 380 ? yearLength : (yearLength - 30)) - 353;
  5549. /** @type {?} */
  5550. let leapYear = isHebrewLeapYear(year);
  5551. /** @type {?} */
  5552. let daysInMonth = leapYear ? [30, 29, 29, 29, 30, 30, 29, 30, 29, 30, 29, 30, 29] :
  5553. [30, 29, 29, 29, 30, 29, 30, 29, 30, 29, 30, 29];
  5554. if (yearType > 0) {
  5555. daysInMonth[2]++; // Kislev gets an extra day in normal or complete years.
  5556. }
  5557. if (yearType > 1) {
  5558. daysInMonth[1]++; // Heshvan gets an extra day in complete years only.
  5559. }
  5560. return daysInMonth[month - 1];
  5561. }
  5562. /**
  5563. * @param {?} date
  5564. * @return {?}
  5565. */
  5566. function getDayNumberInHebrewYear(date) {
  5567. /** @type {?} */
  5568. let numberOfDay = 0;
  5569. for (let i = 1; i < date.month; i++) {
  5570. numberOfDay += getDaysInHebrewMonth(i, date.year);
  5571. }
  5572. return numberOfDay + date.day;
  5573. }
  5574. /**
  5575. * @param {?} date
  5576. * @param {?} val
  5577. * @return {?}
  5578. */
  5579. function setHebrewMonth(date, val) {
  5580. /** @type {?} */
  5581. let after = val >= 0;
  5582. if (!after) {
  5583. val = -val;
  5584. }
  5585. while (val > 0) {
  5586. if (after) {
  5587. if (val > getHebrewMonths(date.year) - date.month) {
  5588. val -= getHebrewMonths(date.year) - date.month + 1;
  5589. date.year++;
  5590. date.month = 1;
  5591. }
  5592. else {
  5593. date.month += val;
  5594. val = 0;
  5595. }
  5596. }
  5597. else {
  5598. if (val >= date.month) {
  5599. date.year--;
  5600. val -= date.month;
  5601. date.month = getHebrewMonths(date.year);
  5602. }
  5603. else {
  5604. date.month -= val;
  5605. val = 0;
  5606. }
  5607. }
  5608. }
  5609. return date;
  5610. }
  5611. /**
  5612. * @param {?} date
  5613. * @param {?} val
  5614. * @return {?}
  5615. */
  5616. function setHebrewDay(date, val) {
  5617. /** @type {?} */
  5618. let after = val >= 0;
  5619. if (!after) {
  5620. val = -val;
  5621. }
  5622. while (val > 0) {
  5623. if (after) {
  5624. if (val > getDaysInHebrewYear(date.year) - getDayNumberInHebrewYear(date)) {
  5625. val -= getDaysInHebrewYear(date.year) - getDayNumberInHebrewYear(date) + 1;
  5626. date.year++;
  5627. date.month = 1;
  5628. date.day = 1;
  5629. }
  5630. else if (val > getDaysInHebrewMonth(date.month, date.year) - date.day) {
  5631. val -= getDaysInHebrewMonth(date.month, date.year) - date.day + 1;
  5632. date.month++;
  5633. date.day = 1;
  5634. }
  5635. else {
  5636. date.day += val;
  5637. val = 0;
  5638. }
  5639. }
  5640. else {
  5641. if (val >= date.day) {
  5642. val -= date.day;
  5643. date.month--;
  5644. if (date.month === 0) {
  5645. date.year--;
  5646. date.month = getHebrewMonths(date.year);
  5647. }
  5648. date.day = getDaysInHebrewMonth(date.month, date.year);
  5649. }
  5650. else {
  5651. date.day -= val;
  5652. val = 0;
  5653. }
  5654. }
  5655. }
  5656. return date;
  5657. }
  5658. /**
  5659. * Returns the equivalent Hebrew date value for a give input Gregorian date.
  5660. * `gdate` is a JS Date to be converted to Hebrew date.
  5661. * @param {?} gdate
  5662. * @return {?}
  5663. */
  5664. function fromGregorian$1(gdate) {
  5665. /** @type {?} */
  5666. const date = new Date(gdate);
  5667. /** @type {?} */
  5668. const gYear = date.getFullYear();
  5669. /** @type {?} */
  5670. const gMonth = date.getMonth();
  5671. /** @type {?} */
  5672. const gDay = date.getDate();
  5673. /** @type {?} */
  5674. let julianDay = GREGORIAN_EPOCH$1 - 1 + 365 * (gYear - 1) + Math.floor((gYear - 1) / 4) -
  5675. Math.floor((gYear - 1) / 100) + Math.floor((gYear - 1) / 400) +
  5676. Math.floor((367 * (gMonth + 1) - 362) / 12 + (gMonth + 1 <= 2 ? 0 : isGregorianLeapYear$1(gYear) ? -1 : -2) + gDay);
  5677. julianDay = Math.floor(julianDay + 0.5);
  5678. /** @type {?} */
  5679. let daysSinceHebEpoch = julianDay - 347997;
  5680. /** @type {?} */
  5681. let monthsSinceHebEpoch = Math.floor(daysSinceHebEpoch * PARTS_PER_DAY / PARTS_PER_MONTH);
  5682. /** @type {?} */
  5683. let hYear = Math.floor((monthsSinceHebEpoch * 19 + 234) / 235) + 1;
  5684. /** @type {?} */
  5685. let firstDayOfThisYear = numberOfFirstDayInYear(hYear);
  5686. /** @type {?} */
  5687. let dayOfYear = daysSinceHebEpoch - firstDayOfThisYear;
  5688. while (dayOfYear < 1) {
  5689. hYear--;
  5690. firstDayOfThisYear = numberOfFirstDayInYear(hYear);
  5691. dayOfYear = daysSinceHebEpoch - firstDayOfThisYear;
  5692. }
  5693. /** @type {?} */
  5694. let hMonth = 1;
  5695. /** @type {?} */
  5696. let hDay = dayOfYear;
  5697. while (hDay > getDaysInHebrewMonth(hMonth, hYear)) {
  5698. hDay -= getDaysInHebrewMonth(hMonth, hYear);
  5699. hMonth++;
  5700. }
  5701. return new NgbDate(hYear, hMonth, hDay);
  5702. }
  5703. /**
  5704. * Returns the equivalent JS date value for a given Hebrew date.
  5705. * `hebrewDate` is an Hebrew date to be converted to Gregorian.
  5706. * @param {?} hebrewDate
  5707. * @return {?}
  5708. */
  5709. function toGregorian$1(hebrewDate) {
  5710. /** @type {?} */
  5711. const hYear = hebrewDate.year;
  5712. /** @type {?} */
  5713. const hMonth = hebrewDate.month;
  5714. /** @type {?} */
  5715. const hDay = hebrewDate.day;
  5716. /** @type {?} */
  5717. let days = numberOfFirstDayInYear(hYear);
  5718. for (let i = 1; i < hMonth; i++) {
  5719. days += getDaysInHebrewMonth(i, hYear);
  5720. }
  5721. days += hDay;
  5722. /** @type {?} */
  5723. let diffDays = days - HEBREW_DAY_ON_JAN_1_1970;
  5724. /** @type {?} */
  5725. let after = diffDays >= 0;
  5726. if (!after) {
  5727. diffDays = -diffDays;
  5728. }
  5729. /** @type {?} */
  5730. let gYear = 1970;
  5731. /** @type {?} */
  5732. let gMonth = 1;
  5733. /** @type {?} */
  5734. let gDay = 1;
  5735. while (diffDays > 0) {
  5736. if (after) {
  5737. if (diffDays >= (isGregorianLeapYear$1(gYear) ? 366 : 365)) {
  5738. diffDays -= isGregorianLeapYear$1(gYear) ? 366 : 365;
  5739. gYear++;
  5740. }
  5741. else if (diffDays >= getDaysInGregorianMonth(gMonth, gYear)) {
  5742. diffDays -= getDaysInGregorianMonth(gMonth, gYear);
  5743. gMonth++;
  5744. }
  5745. else {
  5746. gDay += diffDays;
  5747. diffDays = 0;
  5748. }
  5749. }
  5750. else {
  5751. if (diffDays >= (isGregorianLeapYear$1(gYear - 1) ? 366 : 365)) {
  5752. diffDays -= isGregorianLeapYear$1(gYear - 1) ? 366 : 365;
  5753. gYear--;
  5754. }
  5755. else {
  5756. if (gMonth > 1) {
  5757. gMonth--;
  5758. }
  5759. else {
  5760. gMonth = 12;
  5761. gYear--;
  5762. }
  5763. if (diffDays >= getDaysInGregorianMonth(gMonth, gYear)) {
  5764. diffDays -= getDaysInGregorianMonth(gMonth, gYear);
  5765. }
  5766. else {
  5767. gDay = getDaysInGregorianMonth(gMonth, gYear) - diffDays + 1;
  5768. diffDays = 0;
  5769. }
  5770. }
  5771. }
  5772. }
  5773. return new Date(gYear, gMonth - 1, gDay);
  5774. }
  5775. /**
  5776. * @param {?} numerals
  5777. * @return {?}
  5778. */
  5779. function hebrewNumerals(numerals) {
  5780. if (!numerals) {
  5781. return '';
  5782. }
  5783. /** @type {?} */
  5784. const hArray0_9 = ['', '\u05d0', '\u05d1', '\u05d2', '\u05d3', '\u05d4', '\u05d5', '\u05d6', '\u05d7', '\u05d8'];
  5785. /** @type {?} */
  5786. const hArray10_19 = [
  5787. '\u05d9', '\u05d9\u05d0', '\u05d9\u05d1', '\u05d9\u05d2', '\u05d9\u05d3', '\u05d8\u05d5', '\u05d8\u05d6',
  5788. '\u05d9\u05d6', '\u05d9\u05d7', '\u05d9\u05d8'
  5789. ];
  5790. /** @type {?} */
  5791. const hArray20_90 = ['', '', '\u05db', '\u05dc', '\u05de', '\u05e0', '\u05e1', '\u05e2', '\u05e4', '\u05e6'];
  5792. /** @type {?} */
  5793. const hArray100_900 = [
  5794. '', '\u05e7', '\u05e8', '\u05e9', '\u05ea', '\u05ea\u05e7', '\u05ea\u05e8', '\u05ea\u05e9', '\u05ea\u05ea',
  5795. '\u05ea\u05ea\u05e7'
  5796. ];
  5797. /** @type {?} */
  5798. const hArray1000_9000 = [
  5799. '', '\u05d0', '\u05d1', '\u05d1\u05d0', '\u05d1\u05d1', '\u05d4', '\u05d4\u05d0', '\u05d4\u05d1',
  5800. '\u05d4\u05d1\u05d0', '\u05d4\u05d1\u05d1'
  5801. ];
  5802. /** @type {?} */
  5803. const geresh = '\u05f3';
  5804. /** @type {?} */
  5805. const gershaim = '\u05f4';
  5806. /** @type {?} */
  5807. let mem = 0;
  5808. /** @type {?} */
  5809. let result = [];
  5810. /** @type {?} */
  5811. let step = 0;
  5812. while (numerals > 0) {
  5813. /** @type {?} */
  5814. let m = numerals % 10;
  5815. if (step === 0) {
  5816. mem = m;
  5817. }
  5818. else if (step === 1) {
  5819. if (m !== 1) {
  5820. result.unshift(hArray20_90[m], hArray0_9[mem]);
  5821. }
  5822. else {
  5823. result.unshift(hArray10_19[mem]);
  5824. }
  5825. }
  5826. else if (step === 2) {
  5827. result.unshift(hArray100_900[m]);
  5828. }
  5829. else {
  5830. if (m !== 5) {
  5831. result.unshift(hArray1000_9000[m], geresh, ' ');
  5832. }
  5833. break;
  5834. }
  5835. numerals = Math.floor(numerals / 10);
  5836. if (step === 0 && numerals === 0) {
  5837. result.unshift(hArray0_9[m]);
  5838. }
  5839. step++;
  5840. }
  5841. result = result.join('').split('');
  5842. if (result.length === 1) {
  5843. result.push(geresh);
  5844. }
  5845. else if (result.length > 1) {
  5846. result.splice(result.length - 1, 0, gershaim);
  5847. }
  5848. return result.join('');
  5849. }
  5850. /**
  5851. * @fileoverview added by tsickle
  5852. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5853. */
  5854. /**
  5855. * \@since 3.2.0
  5856. */
  5857. class NgbCalendarHebrew extends NgbCalendar {
  5858. /**
  5859. * @return {?}
  5860. */
  5861. getDaysPerWeek() { return 7; }
  5862. /**
  5863. * @param {?=} year
  5864. * @return {?}
  5865. */
  5866. getMonths(year) {
  5867. if (year && isHebrewLeapYear(year)) {
  5868. return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
  5869. }
  5870. else {
  5871. return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
  5872. }
  5873. }
  5874. /**
  5875. * @return {?}
  5876. */
  5877. getWeeksPerMonth() { return 6; }
  5878. /**
  5879. * @param {?} date
  5880. * @return {?}
  5881. */
  5882. isValid(date) {
  5883. /** @type {?} */
  5884. let b = date && isNumber(date.year) && isNumber(date.month) && isNumber(date.day);
  5885. b = b && date.month > 0 && date.month <= (isHebrewLeapYear(date.year) ? 13 : 12);
  5886. b = b && date.day > 0 && date.day <= getDaysInHebrewMonth(date.month, date.year);
  5887. return b && !isNaN(toGregorian$1(date).getTime());
  5888. }
  5889. /**
  5890. * @param {?} date
  5891. * @param {?=} period
  5892. * @param {?=} number
  5893. * @return {?}
  5894. */
  5895. getNext(date, period = 'd', number = 1) {
  5896. date = new NgbDate(date.year, date.month, date.day);
  5897. switch (period) {
  5898. case 'y':
  5899. date.year += number;
  5900. date.month = 1;
  5901. date.day = 1;
  5902. return date;
  5903. case 'm':
  5904. date = setHebrewMonth(date, number);
  5905. date.day = 1;
  5906. return date;
  5907. case 'd':
  5908. return setHebrewDay(date, number);
  5909. default:
  5910. return date;
  5911. }
  5912. }
  5913. /**
  5914. * @param {?} date
  5915. * @param {?=} period
  5916. * @param {?=} number
  5917. * @return {?}
  5918. */
  5919. getPrev(date, period = 'd', number = 1) { return this.getNext(date, period, -number); }
  5920. /**
  5921. * @param {?} date
  5922. * @return {?}
  5923. */
  5924. getWeekday(date) {
  5925. /** @type {?} */
  5926. const day = toGregorian$1(date).getDay();
  5927. // in JS Date Sun=0, in ISO 8601 Sun=7
  5928. return day === 0 ? 7 : day;
  5929. }
  5930. /**
  5931. * @param {?} week
  5932. * @param {?} firstDayOfWeek
  5933. * @return {?}
  5934. */
  5935. getWeekNumber(week, firstDayOfWeek) {
  5936. /** @type {?} */
  5937. const date = week[week.length - 1];
  5938. return Math.ceil(getDayNumberInHebrewYear(date) / 7);
  5939. }
  5940. /**
  5941. * @return {?}
  5942. */
  5943. getToday() { return fromGregorian$1(new Date()); }
  5944. /**
  5945. * \@since 3.4.0
  5946. * @param {?} date
  5947. * @return {?}
  5948. */
  5949. toGregorian(date) { return fromJSDate(toGregorian$1(date)); }
  5950. /**
  5951. * \@since 3.4.0
  5952. * @param {?} date
  5953. * @return {?}
  5954. */
  5955. fromGregorian(date) { return fromGregorian$1(toJSDate(date)); }
  5956. }
  5957. NgbCalendarHebrew.decorators = [
  5958. { type: Injectable }
  5959. ];
  5960. /**
  5961. * @fileoverview added by tsickle
  5962. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  5963. */
  5964. /** @type {?} */
  5965. const WEEKDAYS = ['שני', 'שלישי', 'רביעי', 'חמישי', 'שישי', 'שבת', 'ראשון'];
  5966. /** @type {?} */
  5967. const MONTHS = ['תשרי', 'חשון', 'כסלו', 'טבת', 'שבט', 'אדר', 'ניסן', 'אייר', 'סיון', 'תמוז', 'אב', 'אלול'];
  5968. /** @type {?} */
  5969. const MONTHS_LEAP = ['תשרי', 'חשון', 'כסלו', 'טבת', 'שבט', 'אדר א׳', 'אדר ב׳', 'ניסן', 'אייר', 'סיון', 'תמוז', 'אב', 'אלול'];
  5970. /**
  5971. * \@since 3.2.0
  5972. */
  5973. class NgbDatepickerI18nHebrew extends NgbDatepickerI18n {
  5974. /**
  5975. * @param {?} month
  5976. * @param {?=} year
  5977. * @return {?}
  5978. */
  5979. getMonthShortName(month, year) { return this.getMonthFullName(month, year); }
  5980. /**
  5981. * @param {?} month
  5982. * @param {?=} year
  5983. * @return {?}
  5984. */
  5985. getMonthFullName(month, year) {
  5986. return isHebrewLeapYear(year) ? MONTHS_LEAP[month - 1] : MONTHS[month - 1];
  5987. }
  5988. /**
  5989. * @param {?} weekday
  5990. * @return {?}
  5991. */
  5992. getWeekdayShortName(weekday) { return WEEKDAYS[weekday - 1]; }
  5993. /**
  5994. * @param {?} date
  5995. * @return {?}
  5996. */
  5997. getDayAriaLabel(date) {
  5998. return `${hebrewNumerals(date.day)} ${this.getMonthFullName(date.month, date.year)} ${hebrewNumerals(date.year)}`;
  5999. }
  6000. /**
  6001. * @param {?} date
  6002. * @return {?}
  6003. */
  6004. getDayNumerals(date) { return hebrewNumerals(date.day); }
  6005. /**
  6006. * @param {?} weekNumber
  6007. * @return {?}
  6008. */
  6009. getWeekNumerals(weekNumber) { return hebrewNumerals(weekNumber); }
  6010. /**
  6011. * @param {?} year
  6012. * @return {?}
  6013. */
  6014. getYearNumerals(year) { return hebrewNumerals(year); }
  6015. }
  6016. NgbDatepickerI18nHebrew.decorators = [
  6017. { type: Injectable }
  6018. ];
  6019. /**
  6020. * @fileoverview added by tsickle
  6021. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6022. */
  6023. /**
  6024. * [`NgbDateAdapter`](#/components/datepicker/api#NgbDateAdapter) implementation that uses
  6025. * native javascript dates as a user date model.
  6026. */
  6027. class NgbDateNativeAdapter extends NgbDateAdapter {
  6028. /**
  6029. * Converts a native `Date` to a `NgbDateStruct`.
  6030. * @param {?} date
  6031. * @return {?}
  6032. */
  6033. fromModel(date) {
  6034. return (date instanceof Date && !isNaN(date.getTime())) ? this._fromNativeDate(date) : null;
  6035. }
  6036. /**
  6037. * Converts a `NgbDateStruct` to a native `Date`.
  6038. * @param {?} date
  6039. * @return {?}
  6040. */
  6041. toModel(date) {
  6042. return date && isInteger(date.year) && isInteger(date.month) && isInteger(date.day) ? this._toNativeDate(date) :
  6043. null;
  6044. }
  6045. /**
  6046. * @protected
  6047. * @param {?} date
  6048. * @return {?}
  6049. */
  6050. _fromNativeDate(date) {
  6051. return { year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate() };
  6052. }
  6053. /**
  6054. * @protected
  6055. * @param {?} date
  6056. * @return {?}
  6057. */
  6058. _toNativeDate(date) {
  6059. /** @type {?} */
  6060. const jsDate = new Date(date.year, date.month - 1, date.day, 12);
  6061. // avoid 30 -> 1930 conversion
  6062. jsDate.setFullYear(date.year);
  6063. return jsDate;
  6064. }
  6065. }
  6066. NgbDateNativeAdapter.decorators = [
  6067. { type: Injectable }
  6068. ];
  6069. /**
  6070. * @fileoverview added by tsickle
  6071. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6072. */
  6073. /**
  6074. * Same as [`NgbDateNativeAdapter`](#/components/datepicker/api#NgbDateNativeAdapter), but with UTC dates.
  6075. *
  6076. * \@since 3.2.0
  6077. */
  6078. class NgbDateNativeUTCAdapter extends NgbDateNativeAdapter {
  6079. /**
  6080. * @protected
  6081. * @param {?} date
  6082. * @return {?}
  6083. */
  6084. _fromNativeDate(date) {
  6085. return { year: date.getUTCFullYear(), month: date.getUTCMonth() + 1, day: date.getUTCDate() };
  6086. }
  6087. /**
  6088. * @protected
  6089. * @param {?} date
  6090. * @return {?}
  6091. */
  6092. _toNativeDate(date) {
  6093. /** @type {?} */
  6094. const jsDate = new Date(Date.UTC(date.year, date.month - 1, date.day));
  6095. // avoid 30 -> 1930 conversion
  6096. jsDate.setUTCFullYear(date.year);
  6097. return jsDate;
  6098. }
  6099. }
  6100. NgbDateNativeUTCAdapter.decorators = [
  6101. { type: Injectable }
  6102. ];
  6103. /**
  6104. * @fileoverview added by tsickle
  6105. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6106. */
  6107. class NgbDatepickerModule {
  6108. }
  6109. NgbDatepickerModule.decorators = [
  6110. { type: NgModule, args: [{
  6111. declarations: [
  6112. NgbDatepicker, NgbDatepickerMonthView, NgbDatepickerNavigation, NgbDatepickerNavigationSelect, NgbDatepickerDayView,
  6113. NgbInputDatepicker
  6114. ],
  6115. exports: [NgbDatepicker, NgbInputDatepicker],
  6116. imports: [CommonModule, FormsModule],
  6117. entryComponents: [NgbDatepicker]
  6118. },] }
  6119. ];
  6120. /**
  6121. * @fileoverview added by tsickle
  6122. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6123. */
  6124. /**
  6125. * A configuration service for the [`NgbDropdown`](#/components/dropdown/api#NgbDropdown) component.
  6126. *
  6127. * You can inject this service, typically in your root component, and customize the values of its properties in
  6128. * order to provide default values for all the dropdowns used in the application.
  6129. */
  6130. class NgbDropdownConfig {
  6131. constructor() {
  6132. this.autoClose = true;
  6133. this.placement = ['bottom-left', 'bottom-right', 'top-left', 'top-right'];
  6134. }
  6135. }
  6136. NgbDropdownConfig.decorators = [
  6137. { type: Injectable, args: [{ providedIn: 'root' },] }
  6138. ];
  6139. /** @nocollapse */ NgbDropdownConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbDropdownConfig_Factory() { return new NgbDropdownConfig(); }, token: NgbDropdownConfig, providedIn: "root" });
  6140. /**
  6141. * @fileoverview added by tsickle
  6142. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6143. */
  6144. class NgbNavbar {
  6145. }
  6146. NgbNavbar.decorators = [
  6147. { type: Directive, args: [{ selector: '.navbar' },] }
  6148. ];
  6149. /**
  6150. * A directive you should put on a dropdown item to enable keyboard navigation.
  6151. * Arrow keys will move focus between items marked with this directive.
  6152. *
  6153. * \@since 4.1.0
  6154. */
  6155. class NgbDropdownItem {
  6156. /**
  6157. * @param {?} elementRef
  6158. */
  6159. constructor(elementRef) {
  6160. this.elementRef = elementRef;
  6161. this._disabled = false;
  6162. }
  6163. /**
  6164. * @param {?} value
  6165. * @return {?}
  6166. */
  6167. set disabled(value) {
  6168. this._disabled = (/** @type {?} */ (value)) === '' || value === true; // accept an empty attribute as true
  6169. }
  6170. /**
  6171. * @return {?}
  6172. */
  6173. get disabled() { return this._disabled; }
  6174. }
  6175. NgbDropdownItem.decorators = [
  6176. { type: Directive, args: [{ selector: '[ngbDropdownItem]', host: { 'class': 'dropdown-item', '[class.disabled]': 'disabled' } },] }
  6177. ];
  6178. /** @nocollapse */
  6179. NgbDropdownItem.ctorParameters = () => [
  6180. { type: ElementRef }
  6181. ];
  6182. NgbDropdownItem.propDecorators = {
  6183. disabled: [{ type: Input }]
  6184. };
  6185. /**
  6186. * A directive that wraps dropdown menu content and dropdown items.
  6187. */
  6188. class NgbDropdownMenu {
  6189. /**
  6190. * @param {?} dropdown
  6191. */
  6192. constructor(dropdown) {
  6193. this.dropdown = dropdown;
  6194. this.placement = 'bottom';
  6195. this.isOpen = false;
  6196. }
  6197. }
  6198. NgbDropdownMenu.decorators = [
  6199. { type: Directive, args: [{
  6200. selector: '[ngbDropdownMenu]',
  6201. host: {
  6202. '[class.dropdown-menu]': 'true',
  6203. '[class.show]': 'dropdown.isOpen()',
  6204. '[attr.x-placement]': 'placement',
  6205. '(keydown.ArrowUp)': 'dropdown.onKeyDown($event)',
  6206. '(keydown.ArrowDown)': 'dropdown.onKeyDown($event)',
  6207. '(keydown.Home)': 'dropdown.onKeyDown($event)',
  6208. '(keydown.End)': 'dropdown.onKeyDown($event)',
  6209. '(keydown.Enter)': 'dropdown.onKeyDown($event)',
  6210. '(keydown.Space)': 'dropdown.onKeyDown($event)'
  6211. }
  6212. },] }
  6213. ];
  6214. /** @nocollapse */
  6215. NgbDropdownMenu.ctorParameters = () => [
  6216. { type: undefined, decorators: [{ type: Inject, args: [forwardRef((/**
  6217. * @return {?}
  6218. */
  6219. () => NgbDropdown)),] }] }
  6220. ];
  6221. NgbDropdownMenu.propDecorators = {
  6222. menuItems: [{ type: ContentChildren, args: [NgbDropdownItem,] }]
  6223. };
  6224. /**
  6225. * A directive to mark an element to which dropdown menu will be anchored.
  6226. *
  6227. * This is a simple version of the `NgbDropdownToggle` directive.
  6228. * It plays the same role, but doesn't listen to click events to toggle dropdown menu thus enabling support
  6229. * for events other than click.
  6230. *
  6231. * \@since 1.1.0
  6232. */
  6233. class NgbDropdownAnchor {
  6234. /**
  6235. * @param {?} dropdown
  6236. * @param {?} _elementRef
  6237. */
  6238. constructor(dropdown, _elementRef) {
  6239. this.dropdown = dropdown;
  6240. this._elementRef = _elementRef;
  6241. this.anchorEl = _elementRef.nativeElement;
  6242. }
  6243. /**
  6244. * @return {?}
  6245. */
  6246. getNativeElement() { return this._elementRef.nativeElement; }
  6247. }
  6248. NgbDropdownAnchor.decorators = [
  6249. { type: Directive, args: [{
  6250. selector: '[ngbDropdownAnchor]',
  6251. host: { 'class': 'dropdown-toggle', 'aria-haspopup': 'true', '[attr.aria-expanded]': 'dropdown.isOpen()' }
  6252. },] }
  6253. ];
  6254. /** @nocollapse */
  6255. NgbDropdownAnchor.ctorParameters = () => [
  6256. { type: undefined, decorators: [{ type: Inject, args: [forwardRef((/**
  6257. * @return {?}
  6258. */
  6259. () => NgbDropdown)),] }] },
  6260. { type: ElementRef }
  6261. ];
  6262. /**
  6263. * A directive to mark an element that will toggle dropdown via the `click` event.
  6264. *
  6265. * You can also use `NgbDropdownAnchor` as an alternative.
  6266. */
  6267. class NgbDropdownToggle extends NgbDropdownAnchor {
  6268. /**
  6269. * @param {?} dropdown
  6270. * @param {?} elementRef
  6271. */
  6272. constructor(dropdown, elementRef) {
  6273. super(dropdown, elementRef);
  6274. }
  6275. }
  6276. NgbDropdownToggle.decorators = [
  6277. { type: Directive, args: [{
  6278. selector: '[ngbDropdownToggle]',
  6279. host: {
  6280. 'class': 'dropdown-toggle',
  6281. 'aria-haspopup': 'true',
  6282. '[attr.aria-expanded]': 'dropdown.isOpen()',
  6283. '(click)': 'dropdown.toggle()',
  6284. '(keydown.ArrowUp)': 'dropdown.onKeyDown($event)',
  6285. '(keydown.ArrowDown)': 'dropdown.onKeyDown($event)',
  6286. '(keydown.Home)': 'dropdown.onKeyDown($event)',
  6287. '(keydown.End)': 'dropdown.onKeyDown($event)'
  6288. },
  6289. providers: [{ provide: NgbDropdownAnchor, useExisting: forwardRef((/**
  6290. * @return {?}
  6291. */
  6292. () => NgbDropdownToggle)) }]
  6293. },] }
  6294. ];
  6295. /** @nocollapse */
  6296. NgbDropdownToggle.ctorParameters = () => [
  6297. { type: undefined, decorators: [{ type: Inject, args: [forwardRef((/**
  6298. * @return {?}
  6299. */
  6300. () => NgbDropdown)),] }] },
  6301. { type: ElementRef }
  6302. ];
  6303. /**
  6304. * A directive that provides contextual overlays for displaying lists of links and more.
  6305. */
  6306. class NgbDropdown {
  6307. /**
  6308. * @param {?} _changeDetector
  6309. * @param {?} config
  6310. * @param {?} _document
  6311. * @param {?} _ngZone
  6312. * @param {?} _elementRef
  6313. * @param {?} _renderer
  6314. * @param {?} ngbNavbar
  6315. */
  6316. constructor(_changeDetector, config, _document, _ngZone, _elementRef, _renderer, ngbNavbar) {
  6317. this._changeDetector = _changeDetector;
  6318. this._document = _document;
  6319. this._ngZone = _ngZone;
  6320. this._elementRef = _elementRef;
  6321. this._renderer = _renderer;
  6322. this._closed$ = new Subject();
  6323. /**
  6324. * Defines whether or not the dropdown menu is opened initially.
  6325. */
  6326. this._open = false;
  6327. /**
  6328. * An event fired when the dropdown is opened or closed.
  6329. *
  6330. * The event payload is a `boolean`:
  6331. * * `true` - the dropdown was opened
  6332. * * `false` - the dropdown was closed
  6333. */
  6334. this.openChange = new EventEmitter();
  6335. this.placement = config.placement;
  6336. this.container = config.container;
  6337. this.autoClose = config.autoClose;
  6338. this.display = ngbNavbar ? 'static' : 'dynamic';
  6339. this._zoneSubscription = _ngZone.onStable.subscribe((/**
  6340. * @return {?}
  6341. */
  6342. () => { this._positionMenu(); }));
  6343. }
  6344. /**
  6345. * @return {?}
  6346. */
  6347. ngAfterContentInit() {
  6348. this._ngZone.onStable.pipe(take(1)).subscribe((/**
  6349. * @return {?}
  6350. */
  6351. () => {
  6352. this._applyPlacementClasses();
  6353. if (this._open) {
  6354. this._setCloseHandlers();
  6355. }
  6356. }));
  6357. }
  6358. /**
  6359. * @param {?} changes
  6360. * @return {?}
  6361. */
  6362. ngOnChanges(changes) {
  6363. if (changes.container && this._open) {
  6364. this._applyContainer(this.container);
  6365. }
  6366. if (changes.placement && !changes.placement.isFirstChange) {
  6367. this._applyPlacementClasses();
  6368. }
  6369. }
  6370. /**
  6371. * Checks if the dropdown menu is open.
  6372. * @return {?}
  6373. */
  6374. isOpen() { return this._open; }
  6375. /**
  6376. * Opens the dropdown menu.
  6377. * @return {?}
  6378. */
  6379. open() {
  6380. if (!this._open) {
  6381. this._open = true;
  6382. this._applyContainer(this.container);
  6383. this.openChange.emit(true);
  6384. this._setCloseHandlers();
  6385. }
  6386. }
  6387. /**
  6388. * @private
  6389. * @return {?}
  6390. */
  6391. _setCloseHandlers() {
  6392. /** @type {?} */
  6393. const anchor = this._anchor;
  6394. ngbAutoClose(this._ngZone, this._document, this.autoClose, (/**
  6395. * @return {?}
  6396. */
  6397. () => this.close()), this._closed$, this._menu ? [this._menuElement.nativeElement] : [], anchor ? [anchor.getNativeElement()] : [], '.dropdown-item,.dropdown-divider');
  6398. }
  6399. /**
  6400. * Closes the dropdown menu.
  6401. * @return {?}
  6402. */
  6403. close() {
  6404. if (this._open) {
  6405. this._open = false;
  6406. this._resetContainer();
  6407. this._closed$.next();
  6408. this.openChange.emit(false);
  6409. this._changeDetector.markForCheck();
  6410. }
  6411. }
  6412. /**
  6413. * Toggles the dropdown menu.
  6414. * @return {?}
  6415. */
  6416. toggle() {
  6417. if (this.isOpen()) {
  6418. this.close();
  6419. }
  6420. else {
  6421. this.open();
  6422. }
  6423. }
  6424. /**
  6425. * @return {?}
  6426. */
  6427. ngOnDestroy() {
  6428. this._resetContainer();
  6429. this._closed$.next();
  6430. this._zoneSubscription.unsubscribe();
  6431. }
  6432. /**
  6433. * @param {?} event
  6434. * @return {?}
  6435. */
  6436. onKeyDown(event) {
  6437. // tslint:disable-next-line:deprecation
  6438. /** @type {?} */
  6439. const key = event.which;
  6440. /** @type {?} */
  6441. const itemElements = this._getMenuElements();
  6442. /** @type {?} */
  6443. let position = -1;
  6444. /** @type {?} */
  6445. let isEventFromItems = false;
  6446. /** @type {?} */
  6447. let itemElement = null;
  6448. /** @type {?} */
  6449. const isEventFromToggle = this._isEventFromToggle(event);
  6450. if (!isEventFromToggle && itemElements.length) {
  6451. itemElements.forEach((/**
  6452. * @param {?} item
  6453. * @param {?} index
  6454. * @return {?}
  6455. */
  6456. (item, index) => {
  6457. if (item.contains((/** @type {?} */ (event.target)))) {
  6458. isEventFromItems = true;
  6459. itemElement = item;
  6460. }
  6461. if (item === this._document.activeElement) {
  6462. position = index;
  6463. }
  6464. }));
  6465. }
  6466. // closing on Enter / Space
  6467. if (key === Key.Space || key === Key.Enter) {
  6468. if (isEventFromItems && (this.autoClose === true || this.autoClose === 'inside')) {
  6469. // Item is either a button or a link, so click will be triggered by the browser on Enter or Space.
  6470. // So we have to register a one-time click handler that will fire after any user defined click handlers
  6471. // to close the dropdown
  6472. fromEvent(itemElement, 'click').pipe(take(1)).subscribe((/**
  6473. * @return {?}
  6474. */
  6475. () => this.close()));
  6476. }
  6477. return;
  6478. }
  6479. // opening / navigating
  6480. if (isEventFromToggle || isEventFromItems) {
  6481. this.open();
  6482. if (itemElements.length) {
  6483. switch (key) {
  6484. case Key.ArrowDown:
  6485. position = Math.min(position + 1, itemElements.length - 1);
  6486. break;
  6487. case Key.ArrowUp:
  6488. if (this._isDropup() && position === -1) {
  6489. position = itemElements.length - 1;
  6490. break;
  6491. }
  6492. position = Math.max(position - 1, 0);
  6493. break;
  6494. case Key.Home:
  6495. position = 0;
  6496. break;
  6497. case Key.End:
  6498. position = itemElements.length - 1;
  6499. break;
  6500. }
  6501. itemElements[position].focus();
  6502. }
  6503. event.preventDefault();
  6504. }
  6505. }
  6506. /**
  6507. * @private
  6508. * @return {?}
  6509. */
  6510. _isDropup() { return this._elementRef.nativeElement.classList.contains('dropup'); }
  6511. /**
  6512. * @private
  6513. * @param {?} event
  6514. * @return {?}
  6515. */
  6516. _isEventFromToggle(event) {
  6517. return this._anchor.getNativeElement().contains((/** @type {?} */ (event.target)));
  6518. }
  6519. /**
  6520. * @private
  6521. * @return {?}
  6522. */
  6523. _getMenuElements() {
  6524. /** @type {?} */
  6525. const menu = this._menu;
  6526. if (menu == null) {
  6527. return [];
  6528. }
  6529. return menu.menuItems.filter((/**
  6530. * @param {?} item
  6531. * @return {?}
  6532. */
  6533. item => !item.disabled)).map((/**
  6534. * @param {?} item
  6535. * @return {?}
  6536. */
  6537. item => item.elementRef.nativeElement));
  6538. }
  6539. /**
  6540. * @private
  6541. * @return {?}
  6542. */
  6543. _positionMenu() {
  6544. /** @type {?} */
  6545. const menu = this._menu;
  6546. if (this.isOpen() && menu) {
  6547. this._applyPlacementClasses(this.display === 'dynamic' ?
  6548. positionElements(this._anchor.anchorEl, this._bodyContainer || this._menuElement.nativeElement, this.placement, this.container === 'body') :
  6549. this._getFirstPlacement(this.placement));
  6550. }
  6551. }
  6552. /**
  6553. * @private
  6554. * @param {?} placement
  6555. * @return {?}
  6556. */
  6557. _getFirstPlacement(placement) {
  6558. return Array.isArray(placement) ? placement[0] : (/** @type {?} */ (placement.split(' ')[0]));
  6559. }
  6560. /**
  6561. * @private
  6562. * @return {?}
  6563. */
  6564. _resetContainer() {
  6565. /** @type {?} */
  6566. const renderer = this._renderer;
  6567. /** @type {?} */
  6568. const menuElement = this._menuElement;
  6569. if (menuElement) {
  6570. /** @type {?} */
  6571. const dropdownElement = this._elementRef.nativeElement;
  6572. /** @type {?} */
  6573. const dropdownMenuElement = menuElement.nativeElement;
  6574. renderer.appendChild(dropdownElement, dropdownMenuElement);
  6575. renderer.removeStyle(dropdownMenuElement, 'position');
  6576. renderer.removeStyle(dropdownMenuElement, 'transform');
  6577. }
  6578. if (this._bodyContainer) {
  6579. renderer.removeChild(this._document.body, this._bodyContainer);
  6580. this._bodyContainer = null;
  6581. }
  6582. }
  6583. /**
  6584. * @private
  6585. * @param {?=} container
  6586. * @return {?}
  6587. */
  6588. _applyContainer(container = null) {
  6589. this._resetContainer();
  6590. if (container === 'body') {
  6591. /** @type {?} */
  6592. const renderer = this._renderer;
  6593. /** @type {?} */
  6594. const dropdownMenuElement = this._menuElement.nativeElement;
  6595. /** @type {?} */
  6596. const bodyContainer = this._bodyContainer = this._bodyContainer || renderer.createElement('div');
  6597. // Override some styles to have the positionning working
  6598. renderer.setStyle(bodyContainer, 'position', 'absolute');
  6599. renderer.setStyle(dropdownMenuElement, 'position', 'static');
  6600. renderer.setStyle(bodyContainer, 'z-index', '1050');
  6601. renderer.appendChild(bodyContainer, dropdownMenuElement);
  6602. renderer.appendChild(this._document.body, bodyContainer);
  6603. }
  6604. }
  6605. /**
  6606. * @private
  6607. * @param {?=} placement
  6608. * @return {?}
  6609. */
  6610. _applyPlacementClasses(placement) {
  6611. /** @type {?} */
  6612. const menu = this._menu;
  6613. if (menu) {
  6614. if (!placement) {
  6615. placement = this._getFirstPlacement(this.placement);
  6616. }
  6617. /** @type {?} */
  6618. const renderer = this._renderer;
  6619. /** @type {?} */
  6620. const dropdownElement = this._elementRef.nativeElement;
  6621. // remove the current placement classes
  6622. renderer.removeClass(dropdownElement, 'dropup');
  6623. renderer.removeClass(dropdownElement, 'dropdown');
  6624. menu.placement = this.display === 'static' ? null : placement;
  6625. /*
  6626. * apply the new placement
  6627. * in case of top use up-arrow or down-arrow otherwise
  6628. */
  6629. /** @type {?} */
  6630. const dropdownClass = placement.search('^top') !== -1 ? 'dropup' : 'dropdown';
  6631. renderer.addClass(dropdownElement, dropdownClass);
  6632. /** @type {?} */
  6633. const bodyContainer = this._bodyContainer;
  6634. if (bodyContainer) {
  6635. renderer.removeClass(bodyContainer, 'dropup');
  6636. renderer.removeClass(bodyContainer, 'dropdown');
  6637. renderer.addClass(bodyContainer, dropdownClass);
  6638. }
  6639. }
  6640. }
  6641. }
  6642. NgbDropdown.decorators = [
  6643. { type: Directive, args: [{ selector: '[ngbDropdown]', exportAs: 'ngbDropdown', host: { '[class.show]': 'isOpen()' } },] }
  6644. ];
  6645. /** @nocollapse */
  6646. NgbDropdown.ctorParameters = () => [
  6647. { type: ChangeDetectorRef },
  6648. { type: NgbDropdownConfig },
  6649. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
  6650. { type: NgZone },
  6651. { type: ElementRef },
  6652. { type: Renderer2 },
  6653. { type: NgbNavbar, decorators: [{ type: Optional }] }
  6654. ];
  6655. NgbDropdown.propDecorators = {
  6656. _menu: [{ type: ContentChild, args: [NgbDropdownMenu, { static: false },] }],
  6657. _menuElement: [{ type: ContentChild, args: [NgbDropdownMenu, { read: ElementRef, static: false },] }],
  6658. _anchor: [{ type: ContentChild, args: [NgbDropdownAnchor, { static: false },] }],
  6659. autoClose: [{ type: Input }],
  6660. _open: [{ type: Input, args: ['open',] }],
  6661. placement: [{ type: Input }],
  6662. container: [{ type: Input }],
  6663. display: [{ type: Input }],
  6664. openChange: [{ type: Output }]
  6665. };
  6666. /**
  6667. * @fileoverview added by tsickle
  6668. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6669. */
  6670. /** @type {?} */
  6671. const NGB_DROPDOWN_DIRECTIVES = [NgbDropdown, NgbDropdownAnchor, NgbDropdownToggle, NgbDropdownMenu, NgbDropdownItem, NgbNavbar];
  6672. class NgbDropdownModule {
  6673. }
  6674. NgbDropdownModule.decorators = [
  6675. { type: NgModule, args: [{ declarations: NGB_DROPDOWN_DIRECTIVES, exports: NGB_DROPDOWN_DIRECTIVES },] }
  6676. ];
  6677. /**
  6678. * @fileoverview added by tsickle
  6679. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6680. */
  6681. /**
  6682. * A configuration service for the [`NgbModal`](#/components/modal/api#NgbModal) service.
  6683. *
  6684. * You can inject this service, typically in your root component, and customize the values of its properties in
  6685. * order to provide default values for all modals used in the application.
  6686. *
  6687. * \@since 3.1.0
  6688. */
  6689. class NgbModalConfig {
  6690. constructor() {
  6691. this.backdrop = true;
  6692. this.keyboard = true;
  6693. }
  6694. }
  6695. NgbModalConfig.decorators = [
  6696. { type: Injectable, args: [{ providedIn: 'root' },] }
  6697. ];
  6698. /** @nocollapse */ NgbModalConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbModalConfig_Factory() { return new NgbModalConfig(); }, token: NgbModalConfig, providedIn: "root" });
  6699. /**
  6700. * @fileoverview added by tsickle
  6701. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6702. */
  6703. class ContentRef {
  6704. /**
  6705. * @param {?} nodes
  6706. * @param {?=} viewRef
  6707. * @param {?=} componentRef
  6708. */
  6709. constructor(nodes, viewRef, componentRef) {
  6710. this.nodes = nodes;
  6711. this.viewRef = viewRef;
  6712. this.componentRef = componentRef;
  6713. }
  6714. }
  6715. /**
  6716. * @template T
  6717. */
  6718. class PopupService {
  6719. /**
  6720. * @param {?} _type
  6721. * @param {?} _injector
  6722. * @param {?} _viewContainerRef
  6723. * @param {?} _renderer
  6724. * @param {?} _componentFactoryResolver
  6725. * @param {?} _applicationRef
  6726. */
  6727. constructor(_type, _injector, _viewContainerRef, _renderer, _componentFactoryResolver, _applicationRef) {
  6728. this._type = _type;
  6729. this._injector = _injector;
  6730. this._viewContainerRef = _viewContainerRef;
  6731. this._renderer = _renderer;
  6732. this._componentFactoryResolver = _componentFactoryResolver;
  6733. this._applicationRef = _applicationRef;
  6734. }
  6735. /**
  6736. * @param {?=} content
  6737. * @param {?=} context
  6738. * @return {?}
  6739. */
  6740. open(content, context) {
  6741. if (!this._windowRef) {
  6742. this._contentRef = this._getContentRef(content, context);
  6743. this._windowRef = this._viewContainerRef.createComponent(this._componentFactoryResolver.resolveComponentFactory(this._type), 0, this._injector, this._contentRef.nodes);
  6744. }
  6745. return this._windowRef;
  6746. }
  6747. /**
  6748. * @return {?}
  6749. */
  6750. close() {
  6751. if (this._windowRef) {
  6752. this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._windowRef.hostView));
  6753. this._windowRef = null;
  6754. if (this._contentRef.viewRef) {
  6755. this._applicationRef.detachView(this._contentRef.viewRef);
  6756. this._contentRef.viewRef.destroy();
  6757. this._contentRef = null;
  6758. }
  6759. }
  6760. }
  6761. /**
  6762. * @private
  6763. * @param {?} content
  6764. * @param {?=} context
  6765. * @return {?}
  6766. */
  6767. _getContentRef(content, context) {
  6768. if (!content) {
  6769. return new ContentRef([]);
  6770. }
  6771. else if (content instanceof TemplateRef) {
  6772. /** @type {?} */
  6773. const viewRef = content.createEmbeddedView(context);
  6774. this._applicationRef.attachView(viewRef);
  6775. return new ContentRef([viewRef.rootNodes], viewRef);
  6776. }
  6777. else {
  6778. return new ContentRef([[this._renderer.createText(`${content}`)]]);
  6779. }
  6780. }
  6781. }
  6782. /**
  6783. * @fileoverview added by tsickle
  6784. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6785. */
  6786. /** @type {?} */
  6787. const noop = (/**
  6788. * @return {?}
  6789. */
  6790. () => { });
  6791. /**
  6792. * Utility to handle the scrollbar.
  6793. *
  6794. * It allows to compensate the lack of a vertical scrollbar by adding an
  6795. * equivalent padding on the right of the body, and to remove this compensation.
  6796. */
  6797. class ScrollBar {
  6798. /**
  6799. * @param {?} _document
  6800. */
  6801. constructor(_document) {
  6802. this._document = _document;
  6803. }
  6804. /**
  6805. * To be called right before a potential vertical scrollbar would be removed:
  6806. *
  6807. * - if there was a scrollbar, adds some compensation padding to the body
  6808. * to keep the same layout as when the scrollbar is there
  6809. * - if there was none, there is nothing to do
  6810. *
  6811. * @return {?} a callback used to revert the compensation (noop if there was none,
  6812. * otherwise a function removing the padding)
  6813. */
  6814. compensate() {
  6815. /** @type {?} */
  6816. const width = this._getWidth();
  6817. return !this._isPresent(width) ? noop : this._adjustBody(width);
  6818. }
  6819. /**
  6820. * Adds a padding of the given width on the right of the body.
  6821. *
  6822. * @private
  6823. * @param {?} scrollbarWidth
  6824. * @return {?} a callback used to revert the padding to its previous value
  6825. */
  6826. _adjustBody(scrollbarWidth) {
  6827. /** @type {?} */
  6828. const body = this._document.body;
  6829. /** @type {?} */
  6830. const userSetPaddingStyle = body.style.paddingRight;
  6831. /** @type {?} */
  6832. const actualPadding = parseFloat(window.getComputedStyle(body)['padding-right']);
  6833. body.style['padding-right'] = `${actualPadding + scrollbarWidth}px`;
  6834. return (/**
  6835. * @return {?}
  6836. */
  6837. () => body.style['padding-right'] = userSetPaddingStyle);
  6838. }
  6839. /**
  6840. * Tells whether a scrollbar is currently present on the body.
  6841. *
  6842. * @private
  6843. * @param {?} scrollbarWidth
  6844. * @return {?} true if scrollbar is present, false otherwise
  6845. */
  6846. _isPresent(scrollbarWidth) {
  6847. /** @type {?} */
  6848. const rect = this._document.body.getBoundingClientRect();
  6849. /** @type {?} */
  6850. const bodyToViewportGap = window.innerWidth - (rect.left + rect.right);
  6851. /** @type {?} */
  6852. const uncertainty = 0.1 * scrollbarWidth;
  6853. return bodyToViewportGap >= scrollbarWidth - uncertainty;
  6854. }
  6855. /**
  6856. * Calculates and returns the width of a scrollbar.
  6857. *
  6858. * @private
  6859. * @return {?} the width of a scrollbar on this page
  6860. */
  6861. _getWidth() {
  6862. /** @type {?} */
  6863. const measurer = this._document.createElement('div');
  6864. measurer.className = 'modal-scrollbar-measure';
  6865. /** @type {?} */
  6866. const body = this._document.body;
  6867. body.appendChild(measurer);
  6868. /** @type {?} */
  6869. const width = measurer.getBoundingClientRect().width - measurer.clientWidth;
  6870. body.removeChild(measurer);
  6871. return width;
  6872. }
  6873. }
  6874. ScrollBar.decorators = [
  6875. { type: Injectable, args: [{ providedIn: 'root' },] }
  6876. ];
  6877. /** @nocollapse */
  6878. ScrollBar.ctorParameters = () => [
  6879. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
  6880. ];
  6881. /** @nocollapse */ ScrollBar.ngInjectableDef = ɵɵdefineInjectable({ factory: function ScrollBar_Factory() { return new ScrollBar(ɵɵinject(DOCUMENT)); }, token: ScrollBar, providedIn: "root" });
  6882. /**
  6883. * @fileoverview added by tsickle
  6884. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6885. */
  6886. class NgbModalBackdrop {
  6887. }
  6888. NgbModalBackdrop.decorators = [
  6889. { type: Component, args: [{
  6890. selector: 'ngb-modal-backdrop',
  6891. encapsulation: ViewEncapsulation.None,
  6892. template: '',
  6893. host: { '[class]': '"modal-backdrop fade show" + (backdropClass ? " " + backdropClass : "")', 'style': 'z-index: 1050' }
  6894. }] }
  6895. ];
  6896. NgbModalBackdrop.propDecorators = {
  6897. backdropClass: [{ type: Input }]
  6898. };
  6899. /**
  6900. * @fileoverview added by tsickle
  6901. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  6902. */
  6903. /**
  6904. * A reference to the currently opened (active) modal.
  6905. *
  6906. * Instances of this class can be injected into your component passed as modal content.
  6907. * So you can `.close()` or `.dismiss()` the modal window from your component.
  6908. */
  6909. class NgbActiveModal {
  6910. /**
  6911. * Closes the modal with an optional `result` value.
  6912. *
  6913. * The `NgbMobalRef.result` promise will be resolved with the provided value.
  6914. * @param {?=} result
  6915. * @return {?}
  6916. */
  6917. close(result) { }
  6918. /**
  6919. * Dismisses the modal with an optional `reason` value.
  6920. *
  6921. * The `NgbModalRef.result` promise will be rejected with the provided value.
  6922. * @param {?=} reason
  6923. * @return {?}
  6924. */
  6925. dismiss(reason) { }
  6926. }
  6927. /**
  6928. * A reference to the newly opened modal returned by the `NgbModal.open()` method.
  6929. */
  6930. class NgbModalRef {
  6931. /**
  6932. * @param {?} _windowCmptRef
  6933. * @param {?} _contentRef
  6934. * @param {?=} _backdropCmptRef
  6935. * @param {?=} _beforeDismiss
  6936. */
  6937. constructor(_windowCmptRef, _contentRef, _backdropCmptRef, _beforeDismiss) {
  6938. this._windowCmptRef = _windowCmptRef;
  6939. this._contentRef = _contentRef;
  6940. this._backdropCmptRef = _backdropCmptRef;
  6941. this._beforeDismiss = _beforeDismiss;
  6942. _windowCmptRef.instance.dismissEvent.subscribe((/**
  6943. * @param {?} reason
  6944. * @return {?}
  6945. */
  6946. (reason) => { this.dismiss(reason); }));
  6947. this.result = new Promise((/**
  6948. * @param {?} resolve
  6949. * @param {?} reject
  6950. * @return {?}
  6951. */
  6952. (resolve, reject) => {
  6953. this._resolve = resolve;
  6954. this._reject = reject;
  6955. }));
  6956. this.result.then(null, (/**
  6957. * @return {?}
  6958. */
  6959. () => { }));
  6960. }
  6961. /**
  6962. * The instance of a component used for the modal content.
  6963. *
  6964. * When a `TemplateRef` is used as the content or when the modal is closed, will return `undefined`.
  6965. * @return {?}
  6966. */
  6967. get componentInstance() {
  6968. if (this._contentRef && this._contentRef.componentRef) {
  6969. return this._contentRef.componentRef.instance;
  6970. }
  6971. }
  6972. /**
  6973. * Closes the modal with an optional `result` value.
  6974. *
  6975. * The `NgbMobalRef.result` promise will be resolved with the provided value.
  6976. * @param {?=} result
  6977. * @return {?}
  6978. */
  6979. close(result) {
  6980. if (this._windowCmptRef) {
  6981. this._resolve(result);
  6982. this._removeModalElements();
  6983. }
  6984. }
  6985. /**
  6986. * @private
  6987. * @param {?=} reason
  6988. * @return {?}
  6989. */
  6990. _dismiss(reason) {
  6991. this._reject(reason);
  6992. this._removeModalElements();
  6993. }
  6994. /**
  6995. * Dismisses the modal with an optional `reason` value.
  6996. *
  6997. * The `NgbModalRef.result` promise will be rejected with the provided value.
  6998. * @param {?=} reason
  6999. * @return {?}
  7000. */
  7001. dismiss(reason) {
  7002. if (this._windowCmptRef) {
  7003. if (!this._beforeDismiss) {
  7004. this._dismiss(reason);
  7005. }
  7006. else {
  7007. /** @type {?} */
  7008. const dismiss = this._beforeDismiss();
  7009. if (dismiss && dismiss.then) {
  7010. dismiss.then((/**
  7011. * @param {?} result
  7012. * @return {?}
  7013. */
  7014. result => {
  7015. if (result !== false) {
  7016. this._dismiss(reason);
  7017. }
  7018. }), (/**
  7019. * @return {?}
  7020. */
  7021. () => { }));
  7022. }
  7023. else if (dismiss !== false) {
  7024. this._dismiss(reason);
  7025. }
  7026. }
  7027. }
  7028. }
  7029. /**
  7030. * @private
  7031. * @return {?}
  7032. */
  7033. _removeModalElements() {
  7034. /** @type {?} */
  7035. const windowNativeEl = this._windowCmptRef.location.nativeElement;
  7036. windowNativeEl.parentNode.removeChild(windowNativeEl);
  7037. this._windowCmptRef.destroy();
  7038. if (this._backdropCmptRef) {
  7039. /** @type {?} */
  7040. const backdropNativeEl = this._backdropCmptRef.location.nativeElement;
  7041. backdropNativeEl.parentNode.removeChild(backdropNativeEl);
  7042. this._backdropCmptRef.destroy();
  7043. }
  7044. if (this._contentRef && this._contentRef.viewRef) {
  7045. this._contentRef.viewRef.destroy();
  7046. }
  7047. this._windowCmptRef = null;
  7048. this._backdropCmptRef = null;
  7049. this._contentRef = null;
  7050. }
  7051. }
  7052. /**
  7053. * @fileoverview added by tsickle
  7054. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7055. */
  7056. /** @enum {number} */
  7057. const ModalDismissReasons = {
  7058. BACKDROP_CLICK: 0,
  7059. ESC: 1,
  7060. };
  7061. ModalDismissReasons[ModalDismissReasons.BACKDROP_CLICK] = 'BACKDROP_CLICK';
  7062. ModalDismissReasons[ModalDismissReasons.ESC] = 'ESC';
  7063. /**
  7064. * @fileoverview added by tsickle
  7065. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7066. */
  7067. class NgbModalWindow {
  7068. /**
  7069. * @param {?} _document
  7070. * @param {?} _elRef
  7071. * @param {?} _zone
  7072. */
  7073. constructor(_document, _elRef, _zone) {
  7074. this._document = _document;
  7075. this._elRef = _elRef;
  7076. this._zone = _zone;
  7077. this._closed$ = new Subject();
  7078. this.backdrop = true;
  7079. this.keyboard = true;
  7080. this.dismissEvent = new EventEmitter();
  7081. }
  7082. /**
  7083. * @param {?} reason
  7084. * @return {?}
  7085. */
  7086. dismiss(reason) { this.dismissEvent.emit(reason); }
  7087. /**
  7088. * @return {?}
  7089. */
  7090. ngOnInit() { this._elWithFocus = this._document.activeElement; }
  7091. /**
  7092. * @return {?}
  7093. */
  7094. ngAfterViewInit() {
  7095. const { nativeElement } = this._elRef;
  7096. this._zone.runOutsideAngular((/**
  7097. * @return {?}
  7098. */
  7099. () => {
  7100. fromEvent(nativeElement, 'keydown')
  7101. .pipe(takeUntil(this._closed$),
  7102. // tslint:disable-next-line:deprecation
  7103. filter((/**
  7104. * @param {?} e
  7105. * @return {?}
  7106. */
  7107. e => e.which === Key.Escape && this.keyboard)))
  7108. .subscribe((/**
  7109. * @param {?} event
  7110. * @return {?}
  7111. */
  7112. event => requestAnimationFrame((/**
  7113. * @return {?}
  7114. */
  7115. () => {
  7116. if (!event.defaultPrevented) {
  7117. this._zone.run((/**
  7118. * @return {?}
  7119. */
  7120. () => this.dismiss(ModalDismissReasons.ESC)));
  7121. }
  7122. }))));
  7123. // We're listening to 'mousedown' and 'mouseup' to prevent modal from closing when pressing the mouse
  7124. // inside the modal dialog and releasing it outside
  7125. /** @type {?} */
  7126. let preventClose = false;
  7127. fromEvent(this._dialogEl.nativeElement, 'mousedown')
  7128. .pipe(takeUntil(this._closed$), tap((/**
  7129. * @return {?}
  7130. */
  7131. () => preventClose = false)), switchMap((/**
  7132. * @return {?}
  7133. */
  7134. () => fromEvent(nativeElement, 'mouseup').pipe(takeUntil(this._closed$), take(1)))), filter((/**
  7135. * @param {?} __0
  7136. * @return {?}
  7137. */
  7138. ({ target }) => nativeElement === target)))
  7139. .subscribe((/**
  7140. * @return {?}
  7141. */
  7142. () => { preventClose = true; }));
  7143. // We're listening to 'click' to dismiss modal on modal window click, except when:
  7144. // 1. clicking on modal dialog itself
  7145. // 2. closing was prevented by mousedown/up handlers
  7146. // 3. clicking on scrollbar when the viewport is too small and modal doesn't fit (click is not triggered at all)
  7147. fromEvent(nativeElement, 'click').pipe(takeUntil(this._closed$)).subscribe((/**
  7148. * @param {?} __0
  7149. * @return {?}
  7150. */
  7151. ({ target }) => {
  7152. if (this.backdrop === true && nativeElement === target && !preventClose) {
  7153. this._zone.run((/**
  7154. * @return {?}
  7155. */
  7156. () => this.dismiss(ModalDismissReasons.BACKDROP_CLICK)));
  7157. }
  7158. preventClose = false;
  7159. }));
  7160. }));
  7161. if (!nativeElement.contains(document.activeElement)) {
  7162. /** @type {?} */
  7163. const autoFocusable = (/** @type {?} */ (nativeElement.querySelector(`[ngbAutofocus]`)));
  7164. /** @type {?} */
  7165. const firstFocusable = getFocusableBoundaryElements(nativeElement)[0];
  7166. /** @type {?} */
  7167. const elementToFocus = autoFocusable || firstFocusable || nativeElement;
  7168. elementToFocus.focus();
  7169. }
  7170. }
  7171. /**
  7172. * @return {?}
  7173. */
  7174. ngOnDestroy() {
  7175. /** @type {?} */
  7176. const body = this._document.body;
  7177. /** @type {?} */
  7178. const elWithFocus = this._elWithFocus;
  7179. /** @type {?} */
  7180. let elementToFocus;
  7181. if (elWithFocus && elWithFocus['focus'] && body.contains(elWithFocus)) {
  7182. elementToFocus = elWithFocus;
  7183. }
  7184. else {
  7185. elementToFocus = body;
  7186. }
  7187. this._zone.runOutsideAngular((/**
  7188. * @return {?}
  7189. */
  7190. () => {
  7191. setTimeout((/**
  7192. * @return {?}
  7193. */
  7194. () => elementToFocus.focus()));
  7195. this._elWithFocus = null;
  7196. }));
  7197. this._closed$.next();
  7198. }
  7199. }
  7200. NgbModalWindow.decorators = [
  7201. { type: Component, args: [{
  7202. selector: 'ngb-modal-window',
  7203. host: {
  7204. '[class]': '"modal fade show d-block" + (windowClass ? " " + windowClass : "")',
  7205. 'role': 'dialog',
  7206. 'tabindex': '-1',
  7207. '[attr.aria-modal]': 'true',
  7208. '[attr.aria-labelledby]': 'ariaLabelledBy',
  7209. },
  7210. template: `
  7211. <div #dialog [class]="'modal-dialog' + (size ? ' modal-' + size : '') + (centered ? ' modal-dialog-centered' : '') +
  7212. (scrollable ? ' modal-dialog-scrollable' : '')" role="document">
  7213. <div class="modal-content"><ng-content></ng-content></div>
  7214. </div>
  7215. `,
  7216. encapsulation: ViewEncapsulation.None,
  7217. styles: ["ngb-modal-window .component-host-scrollable{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;overflow:hidden}"]
  7218. }] }
  7219. ];
  7220. /** @nocollapse */
  7221. NgbModalWindow.ctorParameters = () => [
  7222. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
  7223. { type: ElementRef },
  7224. { type: NgZone }
  7225. ];
  7226. NgbModalWindow.propDecorators = {
  7227. _dialogEl: [{ type: ViewChild, args: ['dialog', { static: true },] }],
  7228. ariaLabelledBy: [{ type: Input }],
  7229. backdrop: [{ type: Input }],
  7230. centered: [{ type: Input }],
  7231. keyboard: [{ type: Input }],
  7232. scrollable: [{ type: Input }],
  7233. size: [{ type: Input }],
  7234. windowClass: [{ type: Input }],
  7235. dismissEvent: [{ type: Output, args: ['dismiss',] }]
  7236. };
  7237. /**
  7238. * @fileoverview added by tsickle
  7239. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7240. */
  7241. class NgbModalStack {
  7242. /**
  7243. * @param {?} _applicationRef
  7244. * @param {?} _injector
  7245. * @param {?} _document
  7246. * @param {?} _scrollBar
  7247. * @param {?} _rendererFactory
  7248. * @param {?} _ngZone
  7249. */
  7250. constructor(_applicationRef, _injector, _document, _scrollBar, _rendererFactory, _ngZone) {
  7251. this._applicationRef = _applicationRef;
  7252. this._injector = _injector;
  7253. this._document = _document;
  7254. this._scrollBar = _scrollBar;
  7255. this._rendererFactory = _rendererFactory;
  7256. this._ngZone = _ngZone;
  7257. this._activeWindowCmptHasChanged = new Subject();
  7258. this._ariaHiddenValues = new Map();
  7259. this._backdropAttributes = ['backdropClass'];
  7260. this._modalRefs = [];
  7261. this._windowAttributes = ['ariaLabelledBy', 'backdrop', 'centered', 'keyboard', 'scrollable', 'size', 'windowClass'];
  7262. this._windowCmpts = [];
  7263. // Trap focus on active WindowCmpt
  7264. this._activeWindowCmptHasChanged.subscribe((/**
  7265. * @return {?}
  7266. */
  7267. () => {
  7268. if (this._windowCmpts.length) {
  7269. /** @type {?} */
  7270. const activeWindowCmpt = this._windowCmpts[this._windowCmpts.length - 1];
  7271. ngbFocusTrap(this._ngZone, activeWindowCmpt.location.nativeElement, this._activeWindowCmptHasChanged);
  7272. this._revertAriaHidden();
  7273. this._setAriaHidden(activeWindowCmpt.location.nativeElement);
  7274. }
  7275. }));
  7276. }
  7277. /**
  7278. * @param {?} moduleCFR
  7279. * @param {?} contentInjector
  7280. * @param {?} content
  7281. * @param {?} options
  7282. * @return {?}
  7283. */
  7284. open(moduleCFR, contentInjector, content, options) {
  7285. /** @type {?} */
  7286. const containerEl = isDefined(options.container) ? this._document.querySelector(options.container) : this._document.body;
  7287. /** @type {?} */
  7288. const renderer = this._rendererFactory.createRenderer(null, null);
  7289. /** @type {?} */
  7290. const revertPaddingForScrollBar = this._scrollBar.compensate();
  7291. /** @type {?} */
  7292. const removeBodyClass = (/**
  7293. * @return {?}
  7294. */
  7295. () => {
  7296. if (!this._modalRefs.length) {
  7297. renderer.removeClass(this._document.body, 'modal-open');
  7298. this._revertAriaHidden();
  7299. }
  7300. });
  7301. if (!containerEl) {
  7302. throw new Error(`The specified modal container "${options.container || 'body'}" was not found in the DOM.`);
  7303. }
  7304. /** @type {?} */
  7305. const activeModal = new NgbActiveModal();
  7306. /** @type {?} */
  7307. const contentRef = this._getContentRef(moduleCFR, options.injector || contentInjector, content, activeModal, options);
  7308. /** @type {?} */
  7309. let backdropCmptRef = options.backdrop !== false ? this._attachBackdrop(moduleCFR, containerEl) : null;
  7310. /** @type {?} */
  7311. let windowCmptRef = this._attachWindowComponent(moduleCFR, containerEl, contentRef);
  7312. /** @type {?} */
  7313. let ngbModalRef = new NgbModalRef(windowCmptRef, contentRef, backdropCmptRef, options.beforeDismiss);
  7314. this._registerModalRef(ngbModalRef);
  7315. this._registerWindowCmpt(windowCmptRef);
  7316. ngbModalRef.result.then(revertPaddingForScrollBar, revertPaddingForScrollBar);
  7317. ngbModalRef.result.then(removeBodyClass, removeBodyClass);
  7318. activeModal.close = (/**
  7319. * @param {?} result
  7320. * @return {?}
  7321. */
  7322. (result) => { ngbModalRef.close(result); });
  7323. activeModal.dismiss = (/**
  7324. * @param {?} reason
  7325. * @return {?}
  7326. */
  7327. (reason) => { ngbModalRef.dismiss(reason); });
  7328. this._applyWindowOptions(windowCmptRef.instance, options);
  7329. if (this._modalRefs.length === 1) {
  7330. renderer.addClass(this._document.body, 'modal-open');
  7331. }
  7332. if (backdropCmptRef && backdropCmptRef.instance) {
  7333. this._applyBackdropOptions(backdropCmptRef.instance, options);
  7334. }
  7335. return ngbModalRef;
  7336. }
  7337. /**
  7338. * @param {?=} reason
  7339. * @return {?}
  7340. */
  7341. dismissAll(reason) { this._modalRefs.forEach((/**
  7342. * @param {?} ngbModalRef
  7343. * @return {?}
  7344. */
  7345. ngbModalRef => ngbModalRef.dismiss(reason))); }
  7346. /**
  7347. * @return {?}
  7348. */
  7349. hasOpenModals() { return this._modalRefs.length > 0; }
  7350. /**
  7351. * @private
  7352. * @param {?} moduleCFR
  7353. * @param {?} containerEl
  7354. * @return {?}
  7355. */
  7356. _attachBackdrop(moduleCFR, containerEl) {
  7357. /** @type {?} */
  7358. let backdropFactory = moduleCFR.resolveComponentFactory(NgbModalBackdrop);
  7359. /** @type {?} */
  7360. let backdropCmptRef = backdropFactory.create(this._injector);
  7361. this._applicationRef.attachView(backdropCmptRef.hostView);
  7362. containerEl.appendChild(backdropCmptRef.location.nativeElement);
  7363. return backdropCmptRef;
  7364. }
  7365. /**
  7366. * @private
  7367. * @param {?} moduleCFR
  7368. * @param {?} containerEl
  7369. * @param {?} contentRef
  7370. * @return {?}
  7371. */
  7372. _attachWindowComponent(moduleCFR, containerEl, contentRef) {
  7373. /** @type {?} */
  7374. let windowFactory = moduleCFR.resolveComponentFactory(NgbModalWindow);
  7375. /** @type {?} */
  7376. let windowCmptRef = windowFactory.create(this._injector, contentRef.nodes);
  7377. this._applicationRef.attachView(windowCmptRef.hostView);
  7378. containerEl.appendChild(windowCmptRef.location.nativeElement);
  7379. return windowCmptRef;
  7380. }
  7381. /**
  7382. * @private
  7383. * @param {?} windowInstance
  7384. * @param {?} options
  7385. * @return {?}
  7386. */
  7387. _applyWindowOptions(windowInstance, options) {
  7388. this._windowAttributes.forEach((/**
  7389. * @param {?} optionName
  7390. * @return {?}
  7391. */
  7392. (optionName) => {
  7393. if (isDefined(options[optionName])) {
  7394. windowInstance[optionName] = options[optionName];
  7395. }
  7396. }));
  7397. }
  7398. /**
  7399. * @private
  7400. * @param {?} backdropInstance
  7401. * @param {?} options
  7402. * @return {?}
  7403. */
  7404. _applyBackdropOptions(backdropInstance, options) {
  7405. this._backdropAttributes.forEach((/**
  7406. * @param {?} optionName
  7407. * @return {?}
  7408. */
  7409. (optionName) => {
  7410. if (isDefined(options[optionName])) {
  7411. backdropInstance[optionName] = options[optionName];
  7412. }
  7413. }));
  7414. }
  7415. /**
  7416. * @private
  7417. * @param {?} moduleCFR
  7418. * @param {?} contentInjector
  7419. * @param {?} content
  7420. * @param {?} activeModal
  7421. * @param {?} options
  7422. * @return {?}
  7423. */
  7424. _getContentRef(moduleCFR, contentInjector, content, activeModal, options) {
  7425. if (!content) {
  7426. return new ContentRef([]);
  7427. }
  7428. else if (content instanceof TemplateRef) {
  7429. return this._createFromTemplateRef(content, activeModal);
  7430. }
  7431. else if (isString(content)) {
  7432. return this._createFromString(content);
  7433. }
  7434. else {
  7435. return this._createFromComponent(moduleCFR, contentInjector, content, activeModal, options);
  7436. }
  7437. }
  7438. /**
  7439. * @private
  7440. * @param {?} content
  7441. * @param {?} activeModal
  7442. * @return {?}
  7443. */
  7444. _createFromTemplateRef(content, activeModal) {
  7445. /** @type {?} */
  7446. const context = {
  7447. $implicit: activeModal,
  7448. /**
  7449. * @param {?} result
  7450. * @return {?}
  7451. */
  7452. close(result) { activeModal.close(result); },
  7453. /**
  7454. * @param {?} reason
  7455. * @return {?}
  7456. */
  7457. dismiss(reason) { activeModal.dismiss(reason); }
  7458. };
  7459. /** @type {?} */
  7460. const viewRef = content.createEmbeddedView(context);
  7461. this._applicationRef.attachView(viewRef);
  7462. return new ContentRef([viewRef.rootNodes], viewRef);
  7463. }
  7464. /**
  7465. * @private
  7466. * @param {?} content
  7467. * @return {?}
  7468. */
  7469. _createFromString(content) {
  7470. /** @type {?} */
  7471. const component = this._document.createTextNode(`${content}`);
  7472. return new ContentRef([[component]]);
  7473. }
  7474. /**
  7475. * @private
  7476. * @param {?} moduleCFR
  7477. * @param {?} contentInjector
  7478. * @param {?} content
  7479. * @param {?} context
  7480. * @param {?} options
  7481. * @return {?}
  7482. */
  7483. _createFromComponent(moduleCFR, contentInjector, content, context, options) {
  7484. /** @type {?} */
  7485. const contentCmptFactory = moduleCFR.resolveComponentFactory(content);
  7486. /** @type {?} */
  7487. const modalContentInjector = Injector.create({ providers: [{ provide: NgbActiveModal, useValue: context }], parent: contentInjector });
  7488. /** @type {?} */
  7489. const componentRef = contentCmptFactory.create(modalContentInjector);
  7490. /** @type {?} */
  7491. const componentNativeEl = componentRef.location.nativeElement;
  7492. if (options.scrollable) {
  7493. ((/** @type {?} */ (componentNativeEl))).classList.add('component-host-scrollable');
  7494. }
  7495. this._applicationRef.attachView(componentRef.hostView);
  7496. // FIXME: we should here get rid of the component nativeElement
  7497. // and use `[Array.from(componentNativeEl.childNodes)]` instead and remove the above CSS class.
  7498. return new ContentRef([[componentNativeEl]], componentRef.hostView, componentRef);
  7499. }
  7500. /**
  7501. * @private
  7502. * @param {?} element
  7503. * @return {?}
  7504. */
  7505. _setAriaHidden(element) {
  7506. /** @type {?} */
  7507. const parent = element.parentElement;
  7508. if (parent && element !== this._document.body) {
  7509. Array.from(parent.children).forEach((/**
  7510. * @param {?} sibling
  7511. * @return {?}
  7512. */
  7513. sibling => {
  7514. if (sibling !== element && sibling.nodeName !== 'SCRIPT') {
  7515. this._ariaHiddenValues.set(sibling, sibling.getAttribute('aria-hidden'));
  7516. sibling.setAttribute('aria-hidden', 'true');
  7517. }
  7518. }));
  7519. this._setAriaHidden(parent);
  7520. }
  7521. }
  7522. /**
  7523. * @private
  7524. * @return {?}
  7525. */
  7526. _revertAriaHidden() {
  7527. this._ariaHiddenValues.forEach((/**
  7528. * @param {?} value
  7529. * @param {?} element
  7530. * @return {?}
  7531. */
  7532. (value, element) => {
  7533. if (value) {
  7534. element.setAttribute('aria-hidden', value);
  7535. }
  7536. else {
  7537. element.removeAttribute('aria-hidden');
  7538. }
  7539. }));
  7540. this._ariaHiddenValues.clear();
  7541. }
  7542. /**
  7543. * @private
  7544. * @param {?} ngbModalRef
  7545. * @return {?}
  7546. */
  7547. _registerModalRef(ngbModalRef) {
  7548. /** @type {?} */
  7549. const unregisterModalRef = (/**
  7550. * @return {?}
  7551. */
  7552. () => {
  7553. /** @type {?} */
  7554. const index = this._modalRefs.indexOf(ngbModalRef);
  7555. if (index > -1) {
  7556. this._modalRefs.splice(index, 1);
  7557. }
  7558. });
  7559. this._modalRefs.push(ngbModalRef);
  7560. ngbModalRef.result.then(unregisterModalRef, unregisterModalRef);
  7561. }
  7562. /**
  7563. * @private
  7564. * @param {?} ngbWindowCmpt
  7565. * @return {?}
  7566. */
  7567. _registerWindowCmpt(ngbWindowCmpt) {
  7568. this._windowCmpts.push(ngbWindowCmpt);
  7569. this._activeWindowCmptHasChanged.next();
  7570. ngbWindowCmpt.onDestroy((/**
  7571. * @return {?}
  7572. */
  7573. () => {
  7574. /** @type {?} */
  7575. const index = this._windowCmpts.indexOf(ngbWindowCmpt);
  7576. if (index > -1) {
  7577. this._windowCmpts.splice(index, 1);
  7578. this._activeWindowCmptHasChanged.next();
  7579. }
  7580. }));
  7581. }
  7582. }
  7583. NgbModalStack.decorators = [
  7584. { type: Injectable, args: [{ providedIn: 'root' },] }
  7585. ];
  7586. /** @nocollapse */
  7587. NgbModalStack.ctorParameters = () => [
  7588. { type: ApplicationRef },
  7589. { type: Injector },
  7590. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
  7591. { type: ScrollBar },
  7592. { type: RendererFactory2 },
  7593. { type: NgZone }
  7594. ];
  7595. /** @nocollapse */ NgbModalStack.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbModalStack_Factory() { return new NgbModalStack(ɵɵinject(ApplicationRef), ɵɵinject(INJECTOR), ɵɵinject(DOCUMENT), ɵɵinject(ScrollBar), ɵɵinject(RendererFactory2), ɵɵinject(NgZone)); }, token: NgbModalStack, providedIn: "root" });
  7596. /**
  7597. * @fileoverview added by tsickle
  7598. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7599. */
  7600. /**
  7601. * A service for opening modal windows.
  7602. *
  7603. * Creating a modal is straightforward: create a component or a template and pass it as an argument to
  7604. * the `.open()` method.
  7605. */
  7606. class NgbModal {
  7607. /**
  7608. * @param {?} _moduleCFR
  7609. * @param {?} _injector
  7610. * @param {?} _modalStack
  7611. * @param {?} _config
  7612. */
  7613. constructor(_moduleCFR, _injector, _modalStack, _config) {
  7614. this._moduleCFR = _moduleCFR;
  7615. this._injector = _injector;
  7616. this._modalStack = _modalStack;
  7617. this._config = _config;
  7618. }
  7619. /**
  7620. * Opens a new modal window with the specified content and supplied options.
  7621. *
  7622. * Content can be provided as a `TemplateRef` or a component type. If you pass a component type as content,
  7623. * then instances of those components can be injected with an instance of the `NgbActiveModal` class. You can then
  7624. * use `NgbActiveModal` methods to close / dismiss modals from "inside" of your component.
  7625. *
  7626. * Also see the [`NgbModalOptions`](#/components/modal/api#NgbModalOptions) for the list of supported options.
  7627. * @param {?} content
  7628. * @param {?=} options
  7629. * @return {?}
  7630. */
  7631. open(content, options = {}) {
  7632. /** @type {?} */
  7633. const combinedOptions = Object.assign({}, this._config, options);
  7634. return this._modalStack.open(this._moduleCFR, this._injector, content, combinedOptions);
  7635. }
  7636. /**
  7637. * Dismisses all currently displayed modal windows with the supplied reason.
  7638. *
  7639. * \@since 3.1.0
  7640. * @param {?=} reason
  7641. * @return {?}
  7642. */
  7643. dismissAll(reason) { this._modalStack.dismissAll(reason); }
  7644. /**
  7645. * Indicates if there are currently any open modal windows in the application.
  7646. *
  7647. * \@since 3.3.0
  7648. * @return {?}
  7649. */
  7650. hasOpenModals() { return this._modalStack.hasOpenModals(); }
  7651. }
  7652. NgbModal.decorators = [
  7653. { type: Injectable, args: [{ providedIn: 'root' },] }
  7654. ];
  7655. /** @nocollapse */
  7656. NgbModal.ctorParameters = () => [
  7657. { type: ComponentFactoryResolver },
  7658. { type: Injector },
  7659. { type: NgbModalStack },
  7660. { type: NgbModalConfig }
  7661. ];
  7662. /** @nocollapse */ NgbModal.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbModal_Factory() { return new NgbModal(ɵɵinject(ComponentFactoryResolver), ɵɵinject(INJECTOR), ɵɵinject(NgbModalStack), ɵɵinject(NgbModalConfig)); }, token: NgbModal, providedIn: "root" });
  7663. /**
  7664. * @fileoverview added by tsickle
  7665. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7666. */
  7667. class NgbModalModule {
  7668. }
  7669. NgbModalModule.decorators = [
  7670. { type: NgModule, args: [{
  7671. declarations: [NgbModalBackdrop, NgbModalWindow],
  7672. entryComponents: [NgbModalBackdrop, NgbModalWindow],
  7673. providers: [NgbModal]
  7674. },] }
  7675. ];
  7676. /**
  7677. * @fileoverview added by tsickle
  7678. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7679. */
  7680. /**
  7681. * A configuration service for the [`NgbNav`](#/components/nav/api#NgbNav) component.
  7682. *
  7683. * You can inject this service, typically in your root component, and customize the values of its properties in
  7684. * order to provide default values for all the navs used in the application.
  7685. *
  7686. * \@since 5.2.0
  7687. */
  7688. class NgbNavConfig {
  7689. constructor() {
  7690. this.destroyOnHide = true;
  7691. this.orientation = 'horizontal';
  7692. this.roles = 'tablist';
  7693. }
  7694. }
  7695. NgbNavConfig.decorators = [
  7696. { type: Injectable, args: [{ providedIn: 'root' },] }
  7697. ];
  7698. /** @nocollapse */ NgbNavConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbNavConfig_Factory() { return new NgbNavConfig(); }, token: NgbNavConfig, providedIn: "root" });
  7699. /**
  7700. * @fileoverview added by tsickle
  7701. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7702. */
  7703. /** @type {?} */
  7704. const isValidNavId = (/**
  7705. * @param {?} id
  7706. * @return {?}
  7707. */
  7708. (id) => isDefined(id) && id !== '');
  7709. /** @type {?} */
  7710. let navCounter = 0;
  7711. /**
  7712. * This directive must be used to wrap content to be displayed in the nav.
  7713. *
  7714. * \@since 5.2.0
  7715. */
  7716. class NgbNavContent {
  7717. /**
  7718. * @param {?} templateRef
  7719. */
  7720. constructor(templateRef) {
  7721. this.templateRef = templateRef;
  7722. }
  7723. }
  7724. NgbNavContent.decorators = [
  7725. { type: Directive, args: [{ selector: 'ng-template[ngbNavContent]' },] }
  7726. ];
  7727. /** @nocollapse */
  7728. NgbNavContent.ctorParameters = () => [
  7729. { type: TemplateRef }
  7730. ];
  7731. /**
  7732. * The directive used to group nav link and related nav content. As well as set nav identifier and some options.
  7733. *
  7734. * \@since 5.2.0
  7735. */
  7736. class NgbNavItem {
  7737. /**
  7738. * @param {?} nav
  7739. * @param {?} elementRef
  7740. */
  7741. constructor(nav, elementRef) {
  7742. this.elementRef = elementRef;
  7743. /**
  7744. * If `true`, the current nav item is disabled and can't be toggled by user.
  7745. *
  7746. * Nevertheless disabled nav can be selected programmatically via the `.select()` method and the `[activeId]` binding.
  7747. */
  7748. this.disabled = false;
  7749. // TODO: cf https://github.com/angular/angular/issues/30106
  7750. this._nav = nav;
  7751. }
  7752. /**
  7753. * @return {?}
  7754. */
  7755. ngAfterContentChecked() {
  7756. // We are using @ContentChildren instead of @ContentChild as in the Angular version being used
  7757. // only @ContentChildren allows us to specify the {descendants: false} option.
  7758. // Without {descendants: false} we are hitting bugs described in:
  7759. // https://github.com/ng-bootstrap/ng-bootstrap/issues/2240
  7760. this.contentTpl = this.contentTpls.first;
  7761. }
  7762. /**
  7763. * @return {?}
  7764. */
  7765. ngOnInit() {
  7766. if (!isDefined(this.domId)) {
  7767. this.domId = `ngb-nav-${navCounter++}`;
  7768. }
  7769. }
  7770. /**
  7771. * @return {?}
  7772. */
  7773. get active() { return this._nav.activeId === this.id; }
  7774. /**
  7775. * @return {?}
  7776. */
  7777. get id() { return isValidNavId(this._id) ? this._id : this.domId; }
  7778. /**
  7779. * @return {?}
  7780. */
  7781. get panelDomId() { return `${this.domId}-panel`; }
  7782. /**
  7783. * @return {?}
  7784. */
  7785. isPanelInDom() {
  7786. return (isDefined(this.destroyOnHide) ? !this.destroyOnHide : !this._nav.destroyOnHide) || this.active;
  7787. }
  7788. }
  7789. NgbNavItem.decorators = [
  7790. { type: Directive, args: [{ selector: '[ngbNavItem]', exportAs: 'ngbNavItem', host: { '[class.nav-item]': 'true' } },] }
  7791. ];
  7792. /** @nocollapse */
  7793. NgbNavItem.ctorParameters = () => [
  7794. { type: undefined, decorators: [{ type: Inject, args: [forwardRef((/**
  7795. * @return {?}
  7796. */
  7797. () => NgbNav)),] }] },
  7798. { type: ElementRef }
  7799. ];
  7800. NgbNavItem.propDecorators = {
  7801. destroyOnHide: [{ type: Input }],
  7802. disabled: [{ type: Input }],
  7803. domId: [{ type: Input }],
  7804. _id: [{ type: Input, args: ['ngbNavItem',] }],
  7805. contentTpls: [{ type: ContentChildren, args: [NgbNavContent, { descendants: false },] }]
  7806. };
  7807. /**
  7808. * A nav directive that helps with implementing tabbed navigation components.
  7809. *
  7810. * \@since 5.2.0
  7811. */
  7812. class NgbNav {
  7813. /**
  7814. * @param {?} role
  7815. * @param {?} config
  7816. * @param {?} _cd
  7817. */
  7818. constructor(role, config, _cd) {
  7819. this.role = role;
  7820. this._cd = _cd;
  7821. /**
  7822. * The event emitted after the active nav changes
  7823. * The payload of the event is the newly active nav id
  7824. *
  7825. * If you want to prevent nav change, you should use `(navChange)` event
  7826. */
  7827. this.activeIdChange = new EventEmitter();
  7828. /**
  7829. * The nav change event emitted right before the nav change happens on user click.
  7830. *
  7831. * This event won't be emitted if nav is changed programmatically via `[activeId]` or `.select()`.
  7832. *
  7833. * See [`NgbNavChangeEvent`](#/components/nav/api#NgbNavChangeEvent) for payload details.
  7834. */
  7835. this.navChange = new EventEmitter();
  7836. this.destroyOnHide = config.destroyOnHide;
  7837. this.orientation = config.orientation;
  7838. this.roles = config.roles;
  7839. }
  7840. /**
  7841. * @param {?} item
  7842. * @return {?}
  7843. */
  7844. click(item) {
  7845. if (!item.disabled) {
  7846. this._updateActiveId(item.id);
  7847. }
  7848. }
  7849. /**
  7850. * Selects the nav with the given id and shows its associated pane.
  7851. * Any other nav that was previously selected becomes unselected and its associated pane is hidden.
  7852. * @param {?} id
  7853. * @return {?}
  7854. */
  7855. select(id) { this._updateActiveId(id, false); }
  7856. /**
  7857. * @return {?}
  7858. */
  7859. ngAfterContentInit() {
  7860. if (!isDefined(this.activeId)) {
  7861. /** @type {?} */
  7862. const nextId = this.items.first ? this.items.first.id : null;
  7863. if (isValidNavId(nextId)) {
  7864. this._updateActiveId(nextId, false);
  7865. this._cd.detectChanges();
  7866. }
  7867. }
  7868. }
  7869. /**
  7870. * @private
  7871. * @param {?} nextId
  7872. * @param {?=} emitNavChange
  7873. * @return {?}
  7874. */
  7875. _updateActiveId(nextId, emitNavChange = true) {
  7876. if (this.activeId !== nextId) {
  7877. /** @type {?} */
  7878. let defaultPrevented = false;
  7879. if (emitNavChange) {
  7880. this.navChange.emit({ activeId: this.activeId, nextId, preventDefault: (/**
  7881. * @return {?}
  7882. */
  7883. () => { defaultPrevented = true; }) });
  7884. }
  7885. if (!defaultPrevented) {
  7886. this.activeId = nextId;
  7887. this.activeIdChange.emit(nextId);
  7888. }
  7889. }
  7890. }
  7891. }
  7892. NgbNav.decorators = [
  7893. { type: Directive, args: [{
  7894. selector: '[ngbNav]',
  7895. exportAs: 'ngbNav',
  7896. host: {
  7897. '[class.nav]': 'true',
  7898. '[class.flex-column]': `orientation === 'vertical'`,
  7899. '[attr.aria-orientation]': `orientation === 'vertical' && roles === 'tablist' ? 'vertical' : undefined`,
  7900. '[attr.role]': `role ? role : roles ? 'tablist' : undefined`,
  7901. }
  7902. },] }
  7903. ];
  7904. /** @nocollapse */
  7905. NgbNav.ctorParameters = () => [
  7906. { type: String, decorators: [{ type: Attribute, args: ['role',] }] },
  7907. { type: NgbNavConfig },
  7908. { type: ChangeDetectorRef }
  7909. ];
  7910. NgbNav.propDecorators = {
  7911. activeId: [{ type: Input }],
  7912. activeIdChange: [{ type: Output }],
  7913. destroyOnHide: [{ type: Input }],
  7914. orientation: [{ type: Input }],
  7915. roles: [{ type: Input }],
  7916. items: [{ type: ContentChildren, args: [NgbNavItem,] }],
  7917. navChange: [{ type: Output }]
  7918. };
  7919. /**
  7920. * A directive to put on the nav link.
  7921. *
  7922. * \@since 5.2.0
  7923. */
  7924. class NgbNavLink {
  7925. /**
  7926. * @param {?} role
  7927. * @param {?} navItem
  7928. * @param {?} nav
  7929. */
  7930. constructor(role, navItem, nav) {
  7931. this.role = role;
  7932. this.navItem = navItem;
  7933. this.nav = nav;
  7934. }
  7935. /**
  7936. * @return {?}
  7937. */
  7938. hasNavItemClass() {
  7939. // with alternative markup we have to add `.nav-item` class, because `ngbNavItem` is on the ng-container
  7940. return this.navItem.elementRef.nativeElement.nodeType === Node.COMMENT_NODE;
  7941. }
  7942. }
  7943. NgbNavLink.decorators = [
  7944. { type: Directive, args: [{
  7945. selector: 'a[ngbNavLink]',
  7946. host: {
  7947. '[id]': 'navItem.domId',
  7948. '[class.nav-link]': 'true',
  7949. '[class.nav-item]': 'hasNavItemClass()',
  7950. '[attr.role]': `role ? role : nav.roles ? 'tab' : undefined`,
  7951. 'href': '',
  7952. '[class.active]': 'navItem.active',
  7953. '[class.disabled]': 'navItem.disabled',
  7954. '[attr.tabindex]': 'navItem.disabled ? -1 : undefined',
  7955. '[attr.aria-controls]': 'navItem.isPanelInDom() ? navItem.panelDomId : null',
  7956. '[attr.aria-selected]': 'navItem.active',
  7957. '[attr.aria-disabled]': 'navItem.disabled',
  7958. '(click)': 'nav.click(navItem); $event.preventDefault()'
  7959. }
  7960. },] }
  7961. ];
  7962. /** @nocollapse */
  7963. NgbNavLink.ctorParameters = () => [
  7964. { type: String, decorators: [{ type: Attribute, args: ['role',] }] },
  7965. { type: NgbNavItem },
  7966. { type: NgbNav }
  7967. ];
  7968. /**
  7969. * @fileoverview added by tsickle
  7970. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  7971. */
  7972. /**
  7973. * The outlet where currently active nav content will be displayed.
  7974. *
  7975. * \@since 5.2.0
  7976. */
  7977. class NgbNavOutlet {
  7978. }
  7979. NgbNavOutlet.decorators = [
  7980. { type: Component, args: [{
  7981. selector: '[ngbNavOutlet]',
  7982. host: { '[class.tab-content]': 'true' },
  7983. encapsulation: ViewEncapsulation.None,
  7984. template: `
  7985. <ng-template ngFor let-item [ngForOf]="nav.items">
  7986. <div class="tab-pane"
  7987. *ngIf="item.isPanelInDom()"
  7988. [id]="item.panelDomId"
  7989. [class.active]="item.active"
  7990. [attr.role]="paneRole ? paneRole : nav.roles ? 'tabpanel' : undefined"
  7991. [attr.aria-labelledby]="item.domId">
  7992. <ng-template [ngTemplateOutlet]="item.contentTpl?.templateRef" [ngTemplateOutletContext]="{$implicit: item.active}"></ng-template>
  7993. </div>
  7994. </ng-template>
  7995. `
  7996. }] }
  7997. ];
  7998. NgbNavOutlet.propDecorators = {
  7999. paneRole: [{ type: Input }],
  8000. nav: [{ type: Input, args: ['ngbNavOutlet',] }]
  8001. };
  8002. /**
  8003. * @fileoverview added by tsickle
  8004. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8005. */
  8006. /** @type {?} */
  8007. const NGB_NAV_DIRECTIVES = [NgbNavContent, NgbNav, NgbNavItem, NgbNavLink, NgbNavOutlet];
  8008. class NgbNavModule {
  8009. }
  8010. NgbNavModule.decorators = [
  8011. { type: NgModule, args: [{ declarations: NGB_NAV_DIRECTIVES, exports: NGB_NAV_DIRECTIVES, imports: [CommonModule] },] }
  8012. ];
  8013. /**
  8014. * @fileoverview added by tsickle
  8015. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8016. */
  8017. /**
  8018. * A configuration service for the [`NgbPagination`](#/components/pagination/api#NgbPagination) component.
  8019. *
  8020. * You can inject this service, typically in your root component, and customize the values of its properties in
  8021. * order to provide default values for all the paginations used in the application.
  8022. */
  8023. class NgbPaginationConfig {
  8024. constructor() {
  8025. this.disabled = false;
  8026. this.boundaryLinks = false;
  8027. this.directionLinks = true;
  8028. this.ellipses = true;
  8029. this.maxSize = 0;
  8030. this.pageSize = 10;
  8031. this.rotate = false;
  8032. }
  8033. }
  8034. NgbPaginationConfig.decorators = [
  8035. { type: Injectable, args: [{ providedIn: 'root' },] }
  8036. ];
  8037. /** @nocollapse */ NgbPaginationConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbPaginationConfig_Factory() { return new NgbPaginationConfig(); }, token: NgbPaginationConfig, providedIn: "root" });
  8038. /**
  8039. * @fileoverview added by tsickle
  8040. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8041. */
  8042. /**
  8043. * A directive to match the 'ellipsis' link template
  8044. *
  8045. * \@since 4.1.0
  8046. */
  8047. class NgbPaginationEllipsis {
  8048. /**
  8049. * @param {?} templateRef
  8050. */
  8051. constructor(templateRef) {
  8052. this.templateRef = templateRef;
  8053. }
  8054. }
  8055. NgbPaginationEllipsis.decorators = [
  8056. { type: Directive, args: [{ selector: 'ng-template[ngbPaginationEllipsis]' },] }
  8057. ];
  8058. /** @nocollapse */
  8059. NgbPaginationEllipsis.ctorParameters = () => [
  8060. { type: TemplateRef }
  8061. ];
  8062. /**
  8063. * A directive to match the 'first' link template
  8064. *
  8065. * \@since 4.1.0
  8066. */
  8067. class NgbPaginationFirst {
  8068. /**
  8069. * @param {?} templateRef
  8070. */
  8071. constructor(templateRef) {
  8072. this.templateRef = templateRef;
  8073. }
  8074. }
  8075. NgbPaginationFirst.decorators = [
  8076. { type: Directive, args: [{ selector: 'ng-template[ngbPaginationFirst]' },] }
  8077. ];
  8078. /** @nocollapse */
  8079. NgbPaginationFirst.ctorParameters = () => [
  8080. { type: TemplateRef }
  8081. ];
  8082. /**
  8083. * A directive to match the 'last' link template
  8084. *
  8085. * \@since 4.1.0
  8086. */
  8087. class NgbPaginationLast {
  8088. /**
  8089. * @param {?} templateRef
  8090. */
  8091. constructor(templateRef) {
  8092. this.templateRef = templateRef;
  8093. }
  8094. }
  8095. NgbPaginationLast.decorators = [
  8096. { type: Directive, args: [{ selector: 'ng-template[ngbPaginationLast]' },] }
  8097. ];
  8098. /** @nocollapse */
  8099. NgbPaginationLast.ctorParameters = () => [
  8100. { type: TemplateRef }
  8101. ];
  8102. /**
  8103. * A directive to match the 'next' link template
  8104. *
  8105. * \@since 4.1.0
  8106. */
  8107. class NgbPaginationNext {
  8108. /**
  8109. * @param {?} templateRef
  8110. */
  8111. constructor(templateRef) {
  8112. this.templateRef = templateRef;
  8113. }
  8114. }
  8115. NgbPaginationNext.decorators = [
  8116. { type: Directive, args: [{ selector: 'ng-template[ngbPaginationNext]' },] }
  8117. ];
  8118. /** @nocollapse */
  8119. NgbPaginationNext.ctorParameters = () => [
  8120. { type: TemplateRef }
  8121. ];
  8122. /**
  8123. * A directive to match the page 'number' link template
  8124. *
  8125. * \@since 4.1.0
  8126. */
  8127. class NgbPaginationNumber {
  8128. /**
  8129. * @param {?} templateRef
  8130. */
  8131. constructor(templateRef) {
  8132. this.templateRef = templateRef;
  8133. }
  8134. }
  8135. NgbPaginationNumber.decorators = [
  8136. { type: Directive, args: [{ selector: 'ng-template[ngbPaginationNumber]' },] }
  8137. ];
  8138. /** @nocollapse */
  8139. NgbPaginationNumber.ctorParameters = () => [
  8140. { type: TemplateRef }
  8141. ];
  8142. /**
  8143. * A directive to match the 'previous' link template
  8144. *
  8145. * \@since 4.1.0
  8146. */
  8147. class NgbPaginationPrevious {
  8148. /**
  8149. * @param {?} templateRef
  8150. */
  8151. constructor(templateRef) {
  8152. this.templateRef = templateRef;
  8153. }
  8154. }
  8155. NgbPaginationPrevious.decorators = [
  8156. { type: Directive, args: [{ selector: 'ng-template[ngbPaginationPrevious]' },] }
  8157. ];
  8158. /** @nocollapse */
  8159. NgbPaginationPrevious.ctorParameters = () => [
  8160. { type: TemplateRef }
  8161. ];
  8162. /**
  8163. * A component that displays page numbers and allows to customize them in several ways.
  8164. */
  8165. class NgbPagination {
  8166. /**
  8167. * @param {?} config
  8168. */
  8169. constructor(config) {
  8170. this.pageCount = 0;
  8171. this.pages = [];
  8172. /**
  8173. * The current page.
  8174. *
  8175. * Page numbers start with `1`.
  8176. */
  8177. this.page = 1;
  8178. /**
  8179. * An event fired when the page is changed. Will fire only if collection size is set and all values are valid.
  8180. *
  8181. * Event payload is the number of the newly selected page.
  8182. *
  8183. * Page numbers start with `1`.
  8184. */
  8185. this.pageChange = new EventEmitter(true);
  8186. this.disabled = config.disabled;
  8187. this.boundaryLinks = config.boundaryLinks;
  8188. this.directionLinks = config.directionLinks;
  8189. this.ellipses = config.ellipses;
  8190. this.maxSize = config.maxSize;
  8191. this.pageSize = config.pageSize;
  8192. this.rotate = config.rotate;
  8193. this.size = config.size;
  8194. }
  8195. /**
  8196. * @return {?}
  8197. */
  8198. hasPrevious() { return this.page > 1; }
  8199. /**
  8200. * @return {?}
  8201. */
  8202. hasNext() { return this.page < this.pageCount; }
  8203. /**
  8204. * @return {?}
  8205. */
  8206. nextDisabled() { return !this.hasNext() || this.disabled; }
  8207. /**
  8208. * @return {?}
  8209. */
  8210. previousDisabled() { return !this.hasPrevious() || this.disabled; }
  8211. /**
  8212. * @param {?} pageNumber
  8213. * @return {?}
  8214. */
  8215. selectPage(pageNumber) { this._updatePages(pageNumber); }
  8216. /**
  8217. * @param {?} changes
  8218. * @return {?}
  8219. */
  8220. ngOnChanges(changes) { this._updatePages(this.page); }
  8221. /**
  8222. * @param {?} pageNumber
  8223. * @return {?}
  8224. */
  8225. isEllipsis(pageNumber) { return pageNumber === -1; }
  8226. /**
  8227. * Appends ellipses and first/last page number to the displayed pages
  8228. * @private
  8229. * @param {?} start
  8230. * @param {?} end
  8231. * @return {?}
  8232. */
  8233. _applyEllipses(start, end) {
  8234. if (this.ellipses) {
  8235. if (start > 0) {
  8236. // The first page will always be included. If the displayed range
  8237. // starts after the third page, then add ellipsis. But if the range
  8238. // starts on the third page, then add the second page instead of
  8239. // an ellipsis, because the ellipsis would only hide a single page.
  8240. if (start > 2) {
  8241. this.pages.unshift(-1);
  8242. }
  8243. else if (start === 2) {
  8244. this.pages.unshift(2);
  8245. }
  8246. this.pages.unshift(1);
  8247. }
  8248. if (end < this.pageCount) {
  8249. // The last page will always be included. If the displayed range
  8250. // ends before the third-last page, then add ellipsis. But if the range
  8251. // ends on third-last page, then add the second-last page instead of
  8252. // an ellipsis, because the ellipsis would only hide a single page.
  8253. if (end < (this.pageCount - 2)) {
  8254. this.pages.push(-1);
  8255. }
  8256. else if (end === (this.pageCount - 2)) {
  8257. this.pages.push(this.pageCount - 1);
  8258. }
  8259. this.pages.push(this.pageCount);
  8260. }
  8261. }
  8262. }
  8263. /**
  8264. * Rotates page numbers based on maxSize items visible.
  8265. * Currently selected page stays in the middle:
  8266. *
  8267. * Ex. for selected page = 6:
  8268. * [5,*6*,7] for maxSize = 3
  8269. * [4,5,*6*,7] for maxSize = 4
  8270. * @private
  8271. * @return {?}
  8272. */
  8273. _applyRotation() {
  8274. /** @type {?} */
  8275. let start = 0;
  8276. /** @type {?} */
  8277. let end = this.pageCount;
  8278. /** @type {?} */
  8279. let leftOffset = Math.floor(this.maxSize / 2);
  8280. /** @type {?} */
  8281. let rightOffset = this.maxSize % 2 === 0 ? leftOffset - 1 : leftOffset;
  8282. if (this.page <= leftOffset) {
  8283. // very beginning, no rotation -> [0..maxSize]
  8284. end = this.maxSize;
  8285. }
  8286. else if (this.pageCount - this.page < leftOffset) {
  8287. // very end, no rotation -> [len-maxSize..len]
  8288. start = this.pageCount - this.maxSize;
  8289. }
  8290. else {
  8291. // rotate
  8292. start = this.page - leftOffset - 1;
  8293. end = this.page + rightOffset;
  8294. }
  8295. return [start, end];
  8296. }
  8297. /**
  8298. * Paginates page numbers based on maxSize items per page.
  8299. * @private
  8300. * @return {?}
  8301. */
  8302. _applyPagination() {
  8303. /** @type {?} */
  8304. let page = Math.ceil(this.page / this.maxSize) - 1;
  8305. /** @type {?} */
  8306. let start = page * this.maxSize;
  8307. /** @type {?} */
  8308. let end = start + this.maxSize;
  8309. return [start, end];
  8310. }
  8311. /**
  8312. * @private
  8313. * @param {?} newPageNo
  8314. * @return {?}
  8315. */
  8316. _setPageInRange(newPageNo) {
  8317. /** @type {?} */
  8318. const prevPageNo = this.page;
  8319. this.page = getValueInRange(newPageNo, this.pageCount, 1);
  8320. if (this.page !== prevPageNo && isNumber(this.collectionSize)) {
  8321. this.pageChange.emit(this.page);
  8322. }
  8323. }
  8324. /**
  8325. * @private
  8326. * @param {?} newPage
  8327. * @return {?}
  8328. */
  8329. _updatePages(newPage) {
  8330. this.pageCount = Math.ceil(this.collectionSize / this.pageSize);
  8331. if (!isNumber(this.pageCount)) {
  8332. this.pageCount = 0;
  8333. }
  8334. // fill-in model needed to render pages
  8335. this.pages.length = 0;
  8336. for (let i = 1; i <= this.pageCount; i++) {
  8337. this.pages.push(i);
  8338. }
  8339. // set page within 1..max range
  8340. this._setPageInRange(newPage);
  8341. // apply maxSize if necessary
  8342. if (this.maxSize > 0 && this.pageCount > this.maxSize) {
  8343. /** @type {?} */
  8344. let start = 0;
  8345. /** @type {?} */
  8346. let end = this.pageCount;
  8347. // either paginating or rotating page numbers
  8348. if (this.rotate) {
  8349. [start, end] = this._applyRotation();
  8350. }
  8351. else {
  8352. [start, end] = this._applyPagination();
  8353. }
  8354. this.pages = this.pages.slice(start, end);
  8355. // adding ellipses
  8356. this._applyEllipses(start, end);
  8357. }
  8358. }
  8359. }
  8360. NgbPagination.decorators = [
  8361. { type: Component, args: [{
  8362. selector: 'ngb-pagination',
  8363. changeDetection: ChangeDetectionStrategy.OnPush,
  8364. host: { 'role': 'navigation' },
  8365. template: `
  8366. <ng-template #first><span aria-hidden="true" i18n="@@ngb.pagination.first">&laquo;&laquo;</span></ng-template>
  8367. <ng-template #previous><span aria-hidden="true" i18n="@@ngb.pagination.previous">&laquo;</span></ng-template>
  8368. <ng-template #next><span aria-hidden="true" i18n="@@ngb.pagination.next">&raquo;</span></ng-template>
  8369. <ng-template #last><span aria-hidden="true" i18n="@@ngb.pagination.last">&raquo;&raquo;</span></ng-template>
  8370. <ng-template #ellipsis>...</ng-template>
  8371. <ng-template #defaultNumber let-page let-currentPage="currentPage">
  8372. {{ page }}
  8373. <span *ngIf="page === currentPage" class="sr-only">(current)</span>
  8374. </ng-template>
  8375. <ul [class]="'pagination' + (size ? ' pagination-' + size : '')">
  8376. <li *ngIf="boundaryLinks" class="page-item"
  8377. [class.disabled]="previousDisabled()">
  8378. <a aria-label="First" i18n-aria-label="@@ngb.pagination.first-aria" class="page-link" href
  8379. (click)="selectPage(1); $event.preventDefault()" [attr.tabindex]="previousDisabled() ? '-1' : null"
  8380. [attr.aria-disabled]="previousDisabled() ? 'true' : null">
  8381. <ng-template [ngTemplateOutlet]="tplFirst?.templateRef || first"
  8382. [ngTemplateOutletContext]="{disabled: previousDisabled(), currentPage: page}"></ng-template>
  8383. </a>
  8384. </li>
  8385. <li *ngIf="directionLinks" class="page-item"
  8386. [class.disabled]="previousDisabled()">
  8387. <a aria-label="Previous" i18n-aria-label="@@ngb.pagination.previous-aria" class="page-link" href
  8388. (click)="selectPage(page-1); $event.preventDefault()" [attr.tabindex]="previousDisabled() ? '-1' : null"
  8389. [attr.aria-disabled]="previousDisabled() ? 'true' : null">
  8390. <ng-template [ngTemplateOutlet]="tplPrevious?.templateRef || previous"
  8391. [ngTemplateOutletContext]="{disabled: previousDisabled()}"></ng-template>
  8392. </a>
  8393. </li>
  8394. <li *ngFor="let pageNumber of pages" class="page-item" [class.active]="pageNumber === page"
  8395. [class.disabled]="isEllipsis(pageNumber) || disabled" [attr.aria-current]="(pageNumber === page ? 'page' : null)">
  8396. <a *ngIf="isEllipsis(pageNumber)" class="page-link" tabindex="-1" aria-disabled="true">
  8397. <ng-template [ngTemplateOutlet]="tplEllipsis?.templateRef || ellipsis"
  8398. [ngTemplateOutletContext]="{disabled: true, currentPage: page}"></ng-template>
  8399. </a>
  8400. <a *ngIf="!isEllipsis(pageNumber)" class="page-link" href (click)="selectPage(pageNumber); $event.preventDefault()" [attr.tabindex]="disabled ? '-1' : null"
  8401. [attr.aria-disabled]="disabled ? 'true' : null">
  8402. <ng-template [ngTemplateOutlet]="tplNumber?.templateRef || defaultNumber"
  8403. [ngTemplateOutletContext]="{disabled: disabled, $implicit: pageNumber, currentPage: page}"></ng-template>
  8404. </a>
  8405. </li>
  8406. <li *ngIf="directionLinks" class="page-item" [class.disabled]="nextDisabled()">
  8407. <a aria-label="Next" i18n-aria-label="@@ngb.pagination.next-aria" class="page-link" href
  8408. (click)="selectPage(page+1); $event.preventDefault()" [attr.tabindex]="nextDisabled() ? '-1' : null"
  8409. [attr.aria-disabled]="nextDisabled() ? 'true' : null">
  8410. <ng-template [ngTemplateOutlet]="tplNext?.templateRef || next"
  8411. [ngTemplateOutletContext]="{disabled: nextDisabled(), currentPage: page}"></ng-template>
  8412. </a>
  8413. </li>
  8414. <li *ngIf="boundaryLinks" class="page-item" [class.disabled]="nextDisabled()">
  8415. <a aria-label="Last" i18n-aria-label="@@ngb.pagination.last-aria" class="page-link" href
  8416. (click)="selectPage(pageCount); $event.preventDefault()" [attr.tabindex]="nextDisabled() ? '-1' : null"
  8417. [attr.aria-disabled]="nextDisabled() ? 'true' : null">
  8418. <ng-template [ngTemplateOutlet]="tplLast?.templateRef || last"
  8419. [ngTemplateOutletContext]="{disabled: nextDisabled(), currentPage: page}"></ng-template>
  8420. </a>
  8421. </li>
  8422. </ul>
  8423. `
  8424. }] }
  8425. ];
  8426. /** @nocollapse */
  8427. NgbPagination.ctorParameters = () => [
  8428. { type: NgbPaginationConfig }
  8429. ];
  8430. NgbPagination.propDecorators = {
  8431. tplEllipsis: [{ type: ContentChild, args: [NgbPaginationEllipsis, { static: false },] }],
  8432. tplFirst: [{ type: ContentChild, args: [NgbPaginationFirst, { static: false },] }],
  8433. tplLast: [{ type: ContentChild, args: [NgbPaginationLast, { static: false },] }],
  8434. tplNext: [{ type: ContentChild, args: [NgbPaginationNext, { static: false },] }],
  8435. tplNumber: [{ type: ContentChild, args: [NgbPaginationNumber, { static: false },] }],
  8436. tplPrevious: [{ type: ContentChild, args: [NgbPaginationPrevious, { static: false },] }],
  8437. disabled: [{ type: Input }],
  8438. boundaryLinks: [{ type: Input }],
  8439. directionLinks: [{ type: Input }],
  8440. ellipses: [{ type: Input }],
  8441. rotate: [{ type: Input }],
  8442. collectionSize: [{ type: Input }],
  8443. maxSize: [{ type: Input }],
  8444. page: [{ type: Input }],
  8445. pageSize: [{ type: Input }],
  8446. pageChange: [{ type: Output }],
  8447. size: [{ type: Input }]
  8448. };
  8449. /**
  8450. * @fileoverview added by tsickle
  8451. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8452. */
  8453. /** @type {?} */
  8454. const DIRECTIVES = [
  8455. NgbPagination, NgbPaginationEllipsis, NgbPaginationFirst, NgbPaginationLast, NgbPaginationNext, NgbPaginationNumber,
  8456. NgbPaginationPrevious
  8457. ];
  8458. class NgbPaginationModule {
  8459. }
  8460. NgbPaginationModule.decorators = [
  8461. { type: NgModule, args: [{ declarations: DIRECTIVES, exports: DIRECTIVES, imports: [CommonModule] },] }
  8462. ];
  8463. /**
  8464. * @fileoverview added by tsickle
  8465. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8466. */
  8467. class Trigger {
  8468. /**
  8469. * @param {?} open
  8470. * @param {?=} close
  8471. */
  8472. constructor(open, close) {
  8473. this.open = open;
  8474. this.close = close;
  8475. if (!close) {
  8476. this.close = open;
  8477. }
  8478. }
  8479. /**
  8480. * @return {?}
  8481. */
  8482. isManual() { return this.open === 'manual' || this.close === 'manual'; }
  8483. }
  8484. /** @type {?} */
  8485. const DEFAULT_ALIASES = {
  8486. 'hover': ['mouseenter', 'mouseleave'],
  8487. 'focus': ['focusin', 'focusout'],
  8488. };
  8489. /**
  8490. * @param {?} triggers
  8491. * @param {?=} aliases
  8492. * @return {?}
  8493. */
  8494. function parseTriggers(triggers, aliases = DEFAULT_ALIASES) {
  8495. /** @type {?} */
  8496. const trimmedTriggers = (triggers || '').trim();
  8497. if (trimmedTriggers.length === 0) {
  8498. return [];
  8499. }
  8500. /** @type {?} */
  8501. const parsedTriggers = trimmedTriggers.split(/\s+/).map((/**
  8502. * @param {?} trigger
  8503. * @return {?}
  8504. */
  8505. trigger => trigger.split(':'))).map((/**
  8506. * @param {?} triggerPair
  8507. * @return {?}
  8508. */
  8509. (triggerPair) => {
  8510. /** @type {?} */
  8511. let alias = aliases[triggerPair[0]] || triggerPair;
  8512. return new Trigger(alias[0], alias[1]);
  8513. }));
  8514. /** @type {?} */
  8515. const manualTriggers = parsedTriggers.filter((/**
  8516. * @param {?} triggerPair
  8517. * @return {?}
  8518. */
  8519. triggerPair => triggerPair.isManual()));
  8520. if (manualTriggers.length > 1) {
  8521. throw 'Triggers parse error: only one manual trigger is allowed';
  8522. }
  8523. if (manualTriggers.length === 1 && parsedTriggers.length > 1) {
  8524. throw 'Triggers parse error: manual trigger can\'t be mixed with other triggers';
  8525. }
  8526. return parsedTriggers;
  8527. }
  8528. /**
  8529. * @param {?} renderer
  8530. * @param {?} nativeElement
  8531. * @param {?} triggers
  8532. * @param {?} isOpenedFn
  8533. * @return {?}
  8534. */
  8535. function observeTriggers(renderer, nativeElement, triggers, isOpenedFn) {
  8536. return new Observable((/**
  8537. * @param {?} subscriber
  8538. * @return {?}
  8539. */
  8540. subscriber => {
  8541. /** @type {?} */
  8542. const listeners = [];
  8543. /** @type {?} */
  8544. const openFn = (/**
  8545. * @return {?}
  8546. */
  8547. () => subscriber.next(true));
  8548. /** @type {?} */
  8549. const closeFn = (/**
  8550. * @return {?}
  8551. */
  8552. () => subscriber.next(false));
  8553. /** @type {?} */
  8554. const toggleFn = (/**
  8555. * @return {?}
  8556. */
  8557. () => subscriber.next(!isOpenedFn()));
  8558. triggers.forEach((/**
  8559. * @param {?} trigger
  8560. * @return {?}
  8561. */
  8562. (trigger) => {
  8563. if (trigger.open === trigger.close) {
  8564. listeners.push(renderer.listen(nativeElement, trigger.open, toggleFn));
  8565. }
  8566. else {
  8567. listeners.push(renderer.listen(nativeElement, trigger.open, openFn), renderer.listen(nativeElement, trigger.close, closeFn));
  8568. }
  8569. }));
  8570. return (/**
  8571. * @return {?}
  8572. */
  8573. () => { listeners.forEach((/**
  8574. * @param {?} unsubscribeFn
  8575. * @return {?}
  8576. */
  8577. unsubscribeFn => unsubscribeFn())); });
  8578. }));
  8579. }
  8580. /** @type {?} */
  8581. const delayOrNoop = (/**
  8582. * @template T
  8583. * @param {?} time
  8584. * @return {?}
  8585. */
  8586. (time) => time > 0 ? delay(time) : (/**
  8587. * @param {?} a
  8588. * @return {?}
  8589. */
  8590. (a) => a));
  8591. /**
  8592. * @param {?} openDelay
  8593. * @param {?} closeDelay
  8594. * @param {?} isOpenedFn
  8595. * @return {?}
  8596. */
  8597. function triggerDelay(openDelay, closeDelay, isOpenedFn) {
  8598. return (/**
  8599. * @param {?} input$
  8600. * @return {?}
  8601. */
  8602. (input$) => {
  8603. /** @type {?} */
  8604. let pending = null;
  8605. /** @type {?} */
  8606. const filteredInput$ = input$.pipe(map((/**
  8607. * @param {?} open
  8608. * @return {?}
  8609. */
  8610. open => ({ open }))), filter((/**
  8611. * @param {?} event
  8612. * @return {?}
  8613. */
  8614. event => {
  8615. /** @type {?} */
  8616. const currentlyOpen = isOpenedFn();
  8617. if (currentlyOpen !== event.open && (!pending || pending.open === currentlyOpen)) {
  8618. pending = event;
  8619. return true;
  8620. }
  8621. if (pending && pending.open !== event.open) {
  8622. pending = null;
  8623. }
  8624. return false;
  8625. })), share());
  8626. /** @type {?} */
  8627. const delayedOpen$ = filteredInput$.pipe(filter((/**
  8628. * @param {?} event
  8629. * @return {?}
  8630. */
  8631. event => event.open)), delayOrNoop(openDelay));
  8632. /** @type {?} */
  8633. const delayedClose$ = filteredInput$.pipe(filter((/**
  8634. * @param {?} event
  8635. * @return {?}
  8636. */
  8637. event => !event.open)), delayOrNoop(closeDelay));
  8638. return merge(delayedOpen$, delayedClose$)
  8639. .pipe(filter((/**
  8640. * @param {?} event
  8641. * @return {?}
  8642. */
  8643. event => {
  8644. if (event === pending) {
  8645. pending = null;
  8646. return event.open !== isOpenedFn();
  8647. }
  8648. return false;
  8649. })), map((/**
  8650. * @param {?} event
  8651. * @return {?}
  8652. */
  8653. event => event.open)));
  8654. });
  8655. }
  8656. /**
  8657. * @param {?} renderer
  8658. * @param {?} nativeElement
  8659. * @param {?} triggers
  8660. * @param {?} isOpenedFn
  8661. * @param {?} openFn
  8662. * @param {?} closeFn
  8663. * @param {?=} openDelay
  8664. * @param {?=} closeDelay
  8665. * @return {?}
  8666. */
  8667. function listenToTriggers(renderer, nativeElement, triggers, isOpenedFn, openFn, closeFn, openDelay = 0, closeDelay = 0) {
  8668. /** @type {?} */
  8669. const parsedTriggers = parseTriggers(triggers);
  8670. if (parsedTriggers.length === 1 && parsedTriggers[0].isManual()) {
  8671. return (/**
  8672. * @return {?}
  8673. */
  8674. () => { });
  8675. }
  8676. /** @type {?} */
  8677. const subscription = observeTriggers(renderer, nativeElement, parsedTriggers, isOpenedFn)
  8678. .pipe(triggerDelay(openDelay, closeDelay, isOpenedFn))
  8679. .subscribe((/**
  8680. * @param {?} open
  8681. * @return {?}
  8682. */
  8683. open => (open ? openFn() : closeFn())));
  8684. return (/**
  8685. * @return {?}
  8686. */
  8687. () => subscription.unsubscribe());
  8688. }
  8689. /**
  8690. * @fileoverview added by tsickle
  8691. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8692. */
  8693. /**
  8694. * A configuration service for the [`NgbPopover`](#/components/popover/api#NgbPopover) component.
  8695. *
  8696. * You can inject this service, typically in your root component, and customize the values of its properties in
  8697. * order to provide default values for all the popovers used in the application.
  8698. */
  8699. class NgbPopoverConfig {
  8700. constructor() {
  8701. this.autoClose = true;
  8702. this.placement = 'auto';
  8703. this.triggers = 'click';
  8704. this.disablePopover = false;
  8705. this.openDelay = 0;
  8706. this.closeDelay = 0;
  8707. }
  8708. }
  8709. NgbPopoverConfig.decorators = [
  8710. { type: Injectable, args: [{ providedIn: 'root' },] }
  8711. ];
  8712. /** @nocollapse */ NgbPopoverConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbPopoverConfig_Factory() { return new NgbPopoverConfig(); }, token: NgbPopoverConfig, providedIn: "root" });
  8713. /**
  8714. * @fileoverview added by tsickle
  8715. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8716. */
  8717. /** @type {?} */
  8718. let nextId$3 = 0;
  8719. class NgbPopoverWindow {
  8720. /**
  8721. * @return {?}
  8722. */
  8723. isTitleTemplate() { return this.title instanceof TemplateRef; }
  8724. }
  8725. NgbPopoverWindow.decorators = [
  8726. { type: Component, args: [{
  8727. selector: 'ngb-popover-window',
  8728. changeDetection: ChangeDetectionStrategy.OnPush,
  8729. encapsulation: ViewEncapsulation.None,
  8730. host: { '[class]': '"popover" + (popoverClass ? " " + popoverClass : "")', 'role': 'tooltip', '[id]': 'id' },
  8731. template: `
  8732. <div class="arrow"></div>
  8733. <h3 class="popover-header" *ngIf="title != null">
  8734. <ng-template #simpleTitle>{{title}}</ng-template>
  8735. <ng-template [ngTemplateOutlet]="isTitleTemplate() ? title : simpleTitle" [ngTemplateOutletContext]="context"></ng-template>
  8736. </h3>
  8737. <div class="popover-body"><ng-content></ng-content></div>`,
  8738. styles: ["ngb-popover-window.bs-popover-bottom>.arrow,ngb-popover-window.bs-popover-top>.arrow{left:50%;margin-left:-.5rem}ngb-popover-window.bs-popover-bottom-left>.arrow,ngb-popover-window.bs-popover-top-left>.arrow{left:2em}ngb-popover-window.bs-popover-bottom-right>.arrow,ngb-popover-window.bs-popover-top-right>.arrow{left:auto;right:2em}ngb-popover-window.bs-popover-left>.arrow,ngb-popover-window.bs-popover-right>.arrow{top:50%;margin-top:-.5rem}ngb-popover-window.bs-popover-left-top>.arrow,ngb-popover-window.bs-popover-right-top>.arrow{top:.7em}ngb-popover-window.bs-popover-left-bottom>.arrow,ngb-popover-window.bs-popover-right-bottom>.arrow{top:auto;bottom:.7em}"]
  8739. }] }
  8740. ];
  8741. NgbPopoverWindow.propDecorators = {
  8742. title: [{ type: Input }],
  8743. id: [{ type: Input }],
  8744. popoverClass: [{ type: Input }],
  8745. context: [{ type: Input }]
  8746. };
  8747. /**
  8748. * A lightweight and extensible directive for fancy popover creation.
  8749. */
  8750. class NgbPopover {
  8751. /**
  8752. * @param {?} _elementRef
  8753. * @param {?} _renderer
  8754. * @param {?} injector
  8755. * @param {?} componentFactoryResolver
  8756. * @param {?} viewContainerRef
  8757. * @param {?} config
  8758. * @param {?} _ngZone
  8759. * @param {?} _document
  8760. * @param {?} _changeDetector
  8761. * @param {?} applicationRef
  8762. */
  8763. constructor(_elementRef, _renderer, injector, componentFactoryResolver, viewContainerRef, config, _ngZone, _document, _changeDetector, applicationRef) {
  8764. this._elementRef = _elementRef;
  8765. this._renderer = _renderer;
  8766. this._ngZone = _ngZone;
  8767. this._document = _document;
  8768. this._changeDetector = _changeDetector;
  8769. /**
  8770. * An event emitted when the popover is shown. Contains no payload.
  8771. */
  8772. this.shown = new EventEmitter();
  8773. /**
  8774. * An event emitted when the popover is hidden. Contains no payload.
  8775. */
  8776. this.hidden = new EventEmitter();
  8777. this._ngbPopoverWindowId = `ngb-popover-${nextId$3++}`;
  8778. this.autoClose = config.autoClose;
  8779. this.placement = config.placement;
  8780. this.triggers = config.triggers;
  8781. this.container = config.container;
  8782. this.disablePopover = config.disablePopover;
  8783. this.popoverClass = config.popoverClass;
  8784. this.openDelay = config.openDelay;
  8785. this.closeDelay = config.closeDelay;
  8786. this._popupService = new PopupService(NgbPopoverWindow, injector, viewContainerRef, _renderer, componentFactoryResolver, applicationRef);
  8787. this._zoneSubscription = _ngZone.onStable.subscribe((/**
  8788. * @return {?}
  8789. */
  8790. () => {
  8791. if (this._windowRef) {
  8792. positionElements(this._elementRef.nativeElement, this._windowRef.location.nativeElement, this.placement, this.container === 'body', 'bs-popover');
  8793. }
  8794. }));
  8795. }
  8796. /**
  8797. * @private
  8798. * @return {?}
  8799. */
  8800. _isDisabled() {
  8801. if (this.disablePopover) {
  8802. return true;
  8803. }
  8804. if (!this.ngbPopover && !this.popoverTitle) {
  8805. return true;
  8806. }
  8807. return false;
  8808. }
  8809. /**
  8810. * Opens the popover.
  8811. *
  8812. * This is considered to be a "manual" triggering.
  8813. * The `context` is an optional value to be injected into the popover template when it is created.
  8814. * @param {?=} context
  8815. * @return {?}
  8816. */
  8817. open(context) {
  8818. if (!this._windowRef && !this._isDisabled()) {
  8819. this._windowRef = this._popupService.open(this.ngbPopover, context);
  8820. this._windowRef.instance.title = this.popoverTitle;
  8821. this._windowRef.instance.context = context;
  8822. this._windowRef.instance.popoverClass = this.popoverClass;
  8823. this._windowRef.instance.id = this._ngbPopoverWindowId;
  8824. this._renderer.setAttribute(this._elementRef.nativeElement, 'aria-describedby', this._ngbPopoverWindowId);
  8825. if (this.container === 'body') {
  8826. this._document.querySelector(this.container).appendChild(this._windowRef.location.nativeElement);
  8827. }
  8828. // We need to detect changes, because we don't know where .open() might be called from.
  8829. // Ex. opening popover from one of lifecycle hooks that run after the CD
  8830. // (say from ngAfterViewInit) will result in 'ExpressionHasChanged' exception
  8831. this._windowRef.changeDetectorRef.detectChanges();
  8832. // We need to mark for check, because popover won't work inside the OnPush component.
  8833. // Ex. when we use expression like `{{ popover.isOpen() : 'opened' : 'closed' }}`
  8834. // inside the template of an OnPush component and we change the popover from
  8835. // open -> closed, the expression in question won't be updated unless we explicitly
  8836. // mark the parent component to be checked.
  8837. this._windowRef.changeDetectorRef.markForCheck();
  8838. ngbAutoClose(this._ngZone, this._document, this.autoClose, (/**
  8839. * @return {?}
  8840. */
  8841. () => this.close()), this.hidden, [this._windowRef.location.nativeElement]);
  8842. this.shown.emit();
  8843. }
  8844. }
  8845. /**
  8846. * Closes the popover.
  8847. *
  8848. * This is considered to be a "manual" triggering of the popover.
  8849. * @return {?}
  8850. */
  8851. close() {
  8852. if (this._windowRef) {
  8853. this._renderer.removeAttribute(this._elementRef.nativeElement, 'aria-describedby');
  8854. this._popupService.close();
  8855. this._windowRef = null;
  8856. this.hidden.emit();
  8857. this._changeDetector.markForCheck();
  8858. }
  8859. }
  8860. /**
  8861. * Toggles the popover.
  8862. *
  8863. * This is considered to be a "manual" triggering of the popover.
  8864. * @return {?}
  8865. */
  8866. toggle() {
  8867. if (this._windowRef) {
  8868. this.close();
  8869. }
  8870. else {
  8871. this.open();
  8872. }
  8873. }
  8874. /**
  8875. * Returns `true`, if the popover is currently shown.
  8876. * @return {?}
  8877. */
  8878. isOpen() { return this._windowRef != null; }
  8879. /**
  8880. * @return {?}
  8881. */
  8882. ngOnInit() {
  8883. this._unregisterListenersFn = listenToTriggers(this._renderer, this._elementRef.nativeElement, this.triggers, this.isOpen.bind(this), this.open.bind(this), this.close.bind(this), +this.openDelay, +this.closeDelay);
  8884. }
  8885. /**
  8886. * @param {?} __0
  8887. * @return {?}
  8888. */
  8889. ngOnChanges({ ngbPopover, popoverTitle, disablePopover, popoverClass }) {
  8890. if (popoverClass && this.isOpen()) {
  8891. this._windowRef.instance.popoverClass = popoverClass.currentValue;
  8892. }
  8893. // close popover if title and content become empty, or disablePopover set to true
  8894. if ((ngbPopover || popoverTitle || disablePopover) && this._isDisabled()) {
  8895. this.close();
  8896. }
  8897. }
  8898. /**
  8899. * @return {?}
  8900. */
  8901. ngOnDestroy() {
  8902. this.close();
  8903. // This check is needed as it might happen that ngOnDestroy is called before ngOnInit
  8904. // under certain conditions, see: https://github.com/ng-bootstrap/ng-bootstrap/issues/2199
  8905. if (this._unregisterListenersFn) {
  8906. this._unregisterListenersFn();
  8907. }
  8908. this._zoneSubscription.unsubscribe();
  8909. }
  8910. }
  8911. NgbPopover.decorators = [
  8912. { type: Directive, args: [{ selector: '[ngbPopover]', exportAs: 'ngbPopover' },] }
  8913. ];
  8914. /** @nocollapse */
  8915. NgbPopover.ctorParameters = () => [
  8916. { type: ElementRef },
  8917. { type: Renderer2 },
  8918. { type: Injector },
  8919. { type: ComponentFactoryResolver },
  8920. { type: ViewContainerRef },
  8921. { type: NgbPopoverConfig },
  8922. { type: NgZone },
  8923. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
  8924. { type: ChangeDetectorRef },
  8925. { type: ApplicationRef }
  8926. ];
  8927. NgbPopover.propDecorators = {
  8928. autoClose: [{ type: Input }],
  8929. ngbPopover: [{ type: Input }],
  8930. popoverTitle: [{ type: Input }],
  8931. placement: [{ type: Input }],
  8932. triggers: [{ type: Input }],
  8933. container: [{ type: Input }],
  8934. disablePopover: [{ type: Input }],
  8935. popoverClass: [{ type: Input }],
  8936. openDelay: [{ type: Input }],
  8937. closeDelay: [{ type: Input }],
  8938. shown: [{ type: Output }],
  8939. hidden: [{ type: Output }]
  8940. };
  8941. /**
  8942. * @fileoverview added by tsickle
  8943. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8944. */
  8945. class NgbPopoverModule {
  8946. }
  8947. NgbPopoverModule.decorators = [
  8948. { type: NgModule, args: [{
  8949. declarations: [NgbPopover, NgbPopoverWindow],
  8950. exports: [NgbPopover],
  8951. imports: [CommonModule],
  8952. entryComponents: [NgbPopoverWindow]
  8953. },] }
  8954. ];
  8955. /**
  8956. * @fileoverview added by tsickle
  8957. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8958. */
  8959. /**
  8960. * A configuration service for the [`NgbProgressbar`](#/components/progressbar/api#NgbProgressbar) component.
  8961. *
  8962. * You can inject this service, typically in your root component, and customize the values of its properties in
  8963. * order to provide default values for all the progress bars used in the application.
  8964. */
  8965. class NgbProgressbarConfig {
  8966. constructor() {
  8967. this.max = 100;
  8968. this.animated = false;
  8969. this.striped = false;
  8970. this.showValue = false;
  8971. }
  8972. }
  8973. NgbProgressbarConfig.decorators = [
  8974. { type: Injectable, args: [{ providedIn: 'root' },] }
  8975. ];
  8976. /** @nocollapse */ NgbProgressbarConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbProgressbarConfig_Factory() { return new NgbProgressbarConfig(); }, token: NgbProgressbarConfig, providedIn: "root" });
  8977. /**
  8978. * @fileoverview added by tsickle
  8979. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  8980. */
  8981. /**
  8982. * A directive that provides feedback on the progress of a workflow or an action.
  8983. */
  8984. class NgbProgressbar {
  8985. /**
  8986. * @param {?} config
  8987. */
  8988. constructor(config) {
  8989. /**
  8990. * The current value for the progress bar.
  8991. *
  8992. * Should be in the `[0, max]` range.
  8993. */
  8994. this.value = 0;
  8995. this.max = config.max;
  8996. this.animated = config.animated;
  8997. this.striped = config.striped;
  8998. this.textType = config.textType;
  8999. this.type = config.type;
  9000. this.showValue = config.showValue;
  9001. this.height = config.height;
  9002. }
  9003. /**
  9004. * The maximal value to be displayed in the progress bar.
  9005. *
  9006. * Should be a positive number. Will default to 100 otherwise.
  9007. * @param {?} max
  9008. * @return {?}
  9009. */
  9010. set max(max) {
  9011. this._max = !isNumber(max) || max <= 0 ? 100 : max;
  9012. }
  9013. /**
  9014. * @return {?}
  9015. */
  9016. get max() { return this._max; }
  9017. /**
  9018. * @return {?}
  9019. */
  9020. getValue() { return getValueInRange(this.value, this.max); }
  9021. /**
  9022. * @return {?}
  9023. */
  9024. getPercentValue() { return 100 * this.getValue() / this.max; }
  9025. }
  9026. NgbProgressbar.decorators = [
  9027. { type: Component, args: [{
  9028. selector: 'ngb-progressbar',
  9029. changeDetection: ChangeDetectionStrategy.OnPush,
  9030. encapsulation: ViewEncapsulation.None,
  9031. template: `
  9032. <div class="progress" [style.height]="height">
  9033. <div class="progress-bar{{type ? ' bg-' + type : ''}}{{textType ? ' text-' + textType : ''}}
  9034. {{animated ? ' progress-bar-animated' : ''}}{{striped ? ' progress-bar-striped' : ''}}" role="progressbar" [style.width.%]="getPercentValue()"
  9035. [attr.aria-valuenow]="getValue()" aria-valuemin="0" [attr.aria-valuemax]="max">
  9036. <span *ngIf="showValue" i18n="@@ngb.progressbar.value">{{getPercentValue()}}%</span><ng-content></ng-content>
  9037. </div>
  9038. </div>
  9039. `
  9040. }] }
  9041. ];
  9042. /** @nocollapse */
  9043. NgbProgressbar.ctorParameters = () => [
  9044. { type: NgbProgressbarConfig }
  9045. ];
  9046. NgbProgressbar.propDecorators = {
  9047. max: [{ type: Input }],
  9048. animated: [{ type: Input }],
  9049. striped: [{ type: Input }],
  9050. showValue: [{ type: Input }],
  9051. textType: [{ type: Input }],
  9052. type: [{ type: Input }],
  9053. value: [{ type: Input }],
  9054. height: [{ type: Input }]
  9055. };
  9056. /**
  9057. * @fileoverview added by tsickle
  9058. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9059. */
  9060. class NgbProgressbarModule {
  9061. }
  9062. NgbProgressbarModule.decorators = [
  9063. { type: NgModule, args: [{ declarations: [NgbProgressbar], exports: [NgbProgressbar], imports: [CommonModule] },] }
  9064. ];
  9065. /**
  9066. * @fileoverview added by tsickle
  9067. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9068. */
  9069. /**
  9070. * A configuration service for the [`NgbRating`](#/components/rating/api#NgbRating) component.
  9071. *
  9072. * You can inject this service, typically in your root component, and customize the values of its properties in
  9073. * order to provide default values for all the ratings used in the application.
  9074. */
  9075. class NgbRatingConfig {
  9076. constructor() {
  9077. this.max = 10;
  9078. this.readonly = false;
  9079. this.resettable = false;
  9080. }
  9081. }
  9082. NgbRatingConfig.decorators = [
  9083. { type: Injectable, args: [{ providedIn: 'root' },] }
  9084. ];
  9085. /** @nocollapse */ NgbRatingConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbRatingConfig_Factory() { return new NgbRatingConfig(); }, token: NgbRatingConfig, providedIn: "root" });
  9086. /**
  9087. * @fileoverview added by tsickle
  9088. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9089. */
  9090. /** @type {?} */
  9091. const NGB_RATING_VALUE_ACCESSOR = {
  9092. provide: NG_VALUE_ACCESSOR,
  9093. useExisting: forwardRef((/**
  9094. * @return {?}
  9095. */
  9096. () => NgbRating)),
  9097. multi: true
  9098. };
  9099. /**
  9100. * A directive that helps visualising and interacting with a star rating bar.
  9101. */
  9102. class NgbRating {
  9103. /**
  9104. * @param {?} config
  9105. * @param {?} _changeDetectorRef
  9106. */
  9107. constructor(config, _changeDetectorRef) {
  9108. this._changeDetectorRef = _changeDetectorRef;
  9109. this.contexts = [];
  9110. this.disabled = false;
  9111. /**
  9112. * An event emitted when the user is hovering over a given rating.
  9113. *
  9114. * Event payload equals to the rating being hovered over.
  9115. */
  9116. this.hover = new EventEmitter();
  9117. /**
  9118. * An event emitted when the user stops hovering over a given rating.
  9119. *
  9120. * Event payload equals to the rating of the last item being hovered over.
  9121. */
  9122. this.leave = new EventEmitter();
  9123. /**
  9124. * An event emitted when the user selects a new rating.
  9125. *
  9126. * Event payload equals to the newly selected rating.
  9127. */
  9128. this.rateChange = new EventEmitter(true);
  9129. this.onChange = (/**
  9130. * @param {?} _
  9131. * @return {?}
  9132. */
  9133. (_) => { });
  9134. this.onTouched = (/**
  9135. * @return {?}
  9136. */
  9137. () => { });
  9138. this.max = config.max;
  9139. this.readonly = config.readonly;
  9140. }
  9141. /**
  9142. * @return {?}
  9143. */
  9144. ariaValueText() { return `${this.nextRate} out of ${this.max}`; }
  9145. /**
  9146. * @param {?} value
  9147. * @return {?}
  9148. */
  9149. enter(value) {
  9150. if (!this.readonly && !this.disabled) {
  9151. this._updateState(value);
  9152. }
  9153. this.hover.emit(value);
  9154. }
  9155. /**
  9156. * @return {?}
  9157. */
  9158. handleBlur() { this.onTouched(); }
  9159. /**
  9160. * @param {?} value
  9161. * @return {?}
  9162. */
  9163. handleClick(value) { this.update(this.resettable && this.rate === value ? 0 : value); }
  9164. /**
  9165. * @param {?} event
  9166. * @return {?}
  9167. */
  9168. handleKeyDown(event) {
  9169. // tslint:disable-next-line:deprecation
  9170. switch (event.which) {
  9171. case Key.ArrowDown:
  9172. case Key.ArrowLeft:
  9173. this.update(this.rate - 1);
  9174. break;
  9175. case Key.ArrowUp:
  9176. case Key.ArrowRight:
  9177. this.update(this.rate + 1);
  9178. break;
  9179. case Key.Home:
  9180. this.update(0);
  9181. break;
  9182. case Key.End:
  9183. this.update(this.max);
  9184. break;
  9185. default:
  9186. return;
  9187. }
  9188. // note 'return' in default case
  9189. event.preventDefault();
  9190. }
  9191. /**
  9192. * @param {?} changes
  9193. * @return {?}
  9194. */
  9195. ngOnChanges(changes) {
  9196. if (changes['rate']) {
  9197. this.update(this.rate);
  9198. }
  9199. }
  9200. /**
  9201. * @return {?}
  9202. */
  9203. ngOnInit() {
  9204. this.contexts = Array.from({ length: this.max }, (/**
  9205. * @param {?} v
  9206. * @param {?} k
  9207. * @return {?}
  9208. */
  9209. (v, k) => ({ fill: 0, index: k })));
  9210. this._updateState(this.rate);
  9211. }
  9212. /**
  9213. * @param {?} fn
  9214. * @return {?}
  9215. */
  9216. registerOnChange(fn) { this.onChange = fn; }
  9217. /**
  9218. * @param {?} fn
  9219. * @return {?}
  9220. */
  9221. registerOnTouched(fn) { this.onTouched = fn; }
  9222. /**
  9223. * @return {?}
  9224. */
  9225. reset() {
  9226. this.leave.emit(this.nextRate);
  9227. this._updateState(this.rate);
  9228. }
  9229. /**
  9230. * @param {?} isDisabled
  9231. * @return {?}
  9232. */
  9233. setDisabledState(isDisabled) { this.disabled = isDisabled; }
  9234. /**
  9235. * @param {?} value
  9236. * @param {?=} internalChange
  9237. * @return {?}
  9238. */
  9239. update(value, internalChange = true) {
  9240. /** @type {?} */
  9241. const newRate = getValueInRange(value, this.max, 0);
  9242. if (!this.readonly && !this.disabled && this.rate !== newRate) {
  9243. this.rate = newRate;
  9244. this.rateChange.emit(this.rate);
  9245. }
  9246. if (internalChange) {
  9247. this.onChange(this.rate);
  9248. this.onTouched();
  9249. }
  9250. this._updateState(this.rate);
  9251. }
  9252. /**
  9253. * @param {?} value
  9254. * @return {?}
  9255. */
  9256. writeValue(value) {
  9257. this.update(value, false);
  9258. this._changeDetectorRef.markForCheck();
  9259. }
  9260. /**
  9261. * @private
  9262. * @param {?} index
  9263. * @return {?}
  9264. */
  9265. _getFillValue(index) {
  9266. /** @type {?} */
  9267. const diff = this.nextRate - index;
  9268. if (diff >= 1) {
  9269. return 100;
  9270. }
  9271. if (diff < 1 && diff > 0) {
  9272. return parseInt((diff * 100).toFixed(2), 10);
  9273. }
  9274. return 0;
  9275. }
  9276. /**
  9277. * @private
  9278. * @param {?} nextValue
  9279. * @return {?}
  9280. */
  9281. _updateState(nextValue) {
  9282. this.nextRate = nextValue;
  9283. this.contexts.forEach((/**
  9284. * @param {?} context
  9285. * @param {?} index
  9286. * @return {?}
  9287. */
  9288. (context, index) => context.fill = this._getFillValue(index)));
  9289. }
  9290. }
  9291. NgbRating.decorators = [
  9292. { type: Component, args: [{
  9293. selector: 'ngb-rating',
  9294. changeDetection: ChangeDetectionStrategy.OnPush,
  9295. encapsulation: ViewEncapsulation.None,
  9296. host: {
  9297. 'class': 'd-inline-flex',
  9298. 'tabindex': '0',
  9299. 'role': 'slider',
  9300. 'aria-valuemin': '0',
  9301. '[attr.aria-valuemax]': 'max',
  9302. '[attr.aria-valuenow]': 'nextRate',
  9303. '[attr.aria-valuetext]': 'ariaValueText()',
  9304. '[attr.aria-disabled]': 'readonly ? true : null',
  9305. '(blur)': 'handleBlur()',
  9306. '(keydown)': 'handleKeyDown($event)',
  9307. '(mouseleave)': 'reset()'
  9308. },
  9309. template: `
  9310. <ng-template #t let-fill="fill">{{ fill === 100 ? '&#9733;' : '&#9734;' }}</ng-template>
  9311. <ng-template ngFor [ngForOf]="contexts" let-index="index">
  9312. <span class="sr-only">({{ index < nextRate ? '*' : ' ' }})</span>
  9313. <span (mouseenter)="enter(index + 1)" (click)="handleClick(index + 1)" [style.cursor]="readonly || disabled ? 'default' : 'pointer'">
  9314. <ng-template [ngTemplateOutlet]="starTemplate || starTemplateFromContent || t" [ngTemplateOutletContext]="contexts[index]">
  9315. </ng-template>
  9316. </span>
  9317. </ng-template>
  9318. `,
  9319. providers: [NGB_RATING_VALUE_ACCESSOR]
  9320. }] }
  9321. ];
  9322. /** @nocollapse */
  9323. NgbRating.ctorParameters = () => [
  9324. { type: NgbRatingConfig },
  9325. { type: ChangeDetectorRef }
  9326. ];
  9327. NgbRating.propDecorators = {
  9328. max: [{ type: Input }],
  9329. rate: [{ type: Input }],
  9330. readonly: [{ type: Input }],
  9331. resettable: [{ type: Input }],
  9332. starTemplate: [{ type: Input }],
  9333. starTemplateFromContent: [{ type: ContentChild, args: [TemplateRef, { static: false },] }],
  9334. hover: [{ type: Output }],
  9335. leave: [{ type: Output }],
  9336. rateChange: [{ type: Output }]
  9337. };
  9338. /**
  9339. * @fileoverview added by tsickle
  9340. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9341. */
  9342. class NgbRatingModule {
  9343. }
  9344. NgbRatingModule.decorators = [
  9345. { type: NgModule, args: [{ declarations: [NgbRating], exports: [NgbRating], imports: [CommonModule] },] }
  9346. ];
  9347. /**
  9348. * @fileoverview added by tsickle
  9349. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9350. */
  9351. /**
  9352. * A configuration service for the [`NgbTabset`](#/components/tabset/api#NgbTabset) component.
  9353. *
  9354. * You can inject this service, typically in your root component, and customize the values of its properties in
  9355. * order to provide default values for all the tabsets used in the application.
  9356. */
  9357. class NgbTabsetConfig {
  9358. constructor() {
  9359. this.justify = 'start';
  9360. this.orientation = 'horizontal';
  9361. this.type = 'tabs';
  9362. }
  9363. }
  9364. NgbTabsetConfig.decorators = [
  9365. { type: Injectable, args: [{ providedIn: 'root' },] }
  9366. ];
  9367. /** @nocollapse */ NgbTabsetConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbTabsetConfig_Factory() { return new NgbTabsetConfig(); }, token: NgbTabsetConfig, providedIn: "root" });
  9368. /**
  9369. * @fileoverview added by tsickle
  9370. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9371. */
  9372. /** @type {?} */
  9373. let nextId$4 = 0;
  9374. /**
  9375. * A directive to wrap tab titles that need to contain HTML markup or other directives.
  9376. *
  9377. * Alternatively you could use the `NgbTab.title` input for string titles.
  9378. */
  9379. class NgbTabTitle {
  9380. /**
  9381. * @param {?} templateRef
  9382. */
  9383. constructor(templateRef) {
  9384. this.templateRef = templateRef;
  9385. }
  9386. }
  9387. NgbTabTitle.decorators = [
  9388. { type: Directive, args: [{ selector: 'ng-template[ngbTabTitle]' },] }
  9389. ];
  9390. /** @nocollapse */
  9391. NgbTabTitle.ctorParameters = () => [
  9392. { type: TemplateRef }
  9393. ];
  9394. /**
  9395. * A directive to wrap content to be displayed in a tab.
  9396. */
  9397. class NgbTabContent {
  9398. /**
  9399. * @param {?} templateRef
  9400. */
  9401. constructor(templateRef) {
  9402. this.templateRef = templateRef;
  9403. }
  9404. }
  9405. NgbTabContent.decorators = [
  9406. { type: Directive, args: [{ selector: 'ng-template[ngbTabContent]' },] }
  9407. ];
  9408. /** @nocollapse */
  9409. NgbTabContent.ctorParameters = () => [
  9410. { type: TemplateRef }
  9411. ];
  9412. /**
  9413. * A directive representing an individual tab.
  9414. */
  9415. class NgbTab {
  9416. constructor() {
  9417. /**
  9418. * The tab identifier.
  9419. *
  9420. * Must be unique for the entire document for proper accessibility support.
  9421. */
  9422. this.id = `ngb-tab-${nextId$4++}`;
  9423. /**
  9424. * If `true`, the current tab is disabled and can't be toggled.
  9425. */
  9426. this.disabled = false;
  9427. }
  9428. /**
  9429. * @return {?}
  9430. */
  9431. ngAfterContentChecked() {
  9432. // We are using @ContentChildren instead of @ContentChild as in the Angular version being used
  9433. // only @ContentChildren allows us to specify the {descendants: false} option.
  9434. // Without {descendants: false} we are hitting bugs described in:
  9435. // https://github.com/ng-bootstrap/ng-bootstrap/issues/2240
  9436. this.titleTpl = this.titleTpls.first;
  9437. this.contentTpl = this.contentTpls.first;
  9438. }
  9439. }
  9440. NgbTab.decorators = [
  9441. { type: Directive, args: [{ selector: 'ngb-tab' },] }
  9442. ];
  9443. NgbTab.propDecorators = {
  9444. id: [{ type: Input }],
  9445. title: [{ type: Input }],
  9446. disabled: [{ type: Input }],
  9447. titleTpls: [{ type: ContentChildren, args: [NgbTabTitle, { descendants: false },] }],
  9448. contentTpls: [{ type: ContentChildren, args: [NgbTabContent, { descendants: false },] }]
  9449. };
  9450. /**
  9451. * A component that makes it easy to create tabbed interface.
  9452. */
  9453. class NgbTabset {
  9454. /**
  9455. * @param {?} config
  9456. */
  9457. constructor(config) {
  9458. /**
  9459. * If `true`, non-visible tabs content will be removed from DOM. Otherwise it will just be hidden.
  9460. */
  9461. this.destroyOnHide = true;
  9462. /**
  9463. * A tab change event emitted right before the tab change happens.
  9464. *
  9465. * See [`NgbTabChangeEvent`](#/components/tabset/api#NgbTabChangeEvent) for payload details.
  9466. */
  9467. this.tabChange = new EventEmitter();
  9468. this.type = config.type;
  9469. this.justify = config.justify;
  9470. this.orientation = config.orientation;
  9471. }
  9472. /**
  9473. * The horizontal alignment of the tabs with flexbox utilities.
  9474. * @param {?} className
  9475. * @return {?}
  9476. */
  9477. set justify(className) {
  9478. if (className === 'fill' || className === 'justified') {
  9479. this.justifyClass = `nav-${className}`;
  9480. }
  9481. else {
  9482. this.justifyClass = `justify-content-${className}`;
  9483. }
  9484. }
  9485. /**
  9486. * Selects the tab with the given id and shows its associated content panel.
  9487. *
  9488. * Any other tab that was previously selected becomes unselected and its associated pane is removed from DOM or
  9489. * hidden depending on the `destroyOnHide` value.
  9490. * @param {?} tabId
  9491. * @return {?}
  9492. */
  9493. select(tabId) {
  9494. /** @type {?} */
  9495. let selectedTab = this._getTabById(tabId);
  9496. if (selectedTab && !selectedTab.disabled && this.activeId !== selectedTab.id) {
  9497. /** @type {?} */
  9498. let defaultPrevented = false;
  9499. this.tabChange.emit({ activeId: this.activeId, nextId: selectedTab.id, preventDefault: (/**
  9500. * @return {?}
  9501. */
  9502. () => { defaultPrevented = true; }) });
  9503. if (!defaultPrevented) {
  9504. this.activeId = selectedTab.id;
  9505. }
  9506. }
  9507. }
  9508. /**
  9509. * @return {?}
  9510. */
  9511. ngAfterContentChecked() {
  9512. // auto-correct activeId that might have been set incorrectly as input
  9513. /** @type {?} */
  9514. let activeTab = this._getTabById(this.activeId);
  9515. this.activeId = activeTab ? activeTab.id : (this.tabs.length ? this.tabs.first.id : null);
  9516. }
  9517. /**
  9518. * @private
  9519. * @param {?} id
  9520. * @return {?}
  9521. */
  9522. _getTabById(id) {
  9523. /** @type {?} */
  9524. let tabsWithId = this.tabs.filter((/**
  9525. * @param {?} tab
  9526. * @return {?}
  9527. */
  9528. tab => tab.id === id));
  9529. return tabsWithId.length ? tabsWithId[0] : null;
  9530. }
  9531. }
  9532. NgbTabset.decorators = [
  9533. { type: Component, args: [{
  9534. selector: 'ngb-tabset',
  9535. exportAs: 'ngbTabset',
  9536. encapsulation: ViewEncapsulation.None,
  9537. template: `
  9538. <ul [class]="'nav nav-' + type + (orientation == 'horizontal'? ' ' + justifyClass : ' flex-column')" role="tablist">
  9539. <li class="nav-item" *ngFor="let tab of tabs">
  9540. <a [id]="tab.id" class="nav-link" [class.active]="tab.id === activeId" [class.disabled]="tab.disabled"
  9541. href (click)="select(tab.id); $event.preventDefault()" role="tab" [attr.tabindex]="(tab.disabled ? '-1': undefined)"
  9542. [attr.aria-controls]="(!destroyOnHide || tab.id === activeId ? tab.id + '-panel' : null)"
  9543. [attr.aria-selected]="tab.id === activeId" [attr.aria-disabled]="tab.disabled">
  9544. {{tab.title}}<ng-template [ngTemplateOutlet]="tab.titleTpl?.templateRef"></ng-template>
  9545. </a>
  9546. </li>
  9547. </ul>
  9548. <div class="tab-content">
  9549. <ng-template ngFor let-tab [ngForOf]="tabs">
  9550. <div
  9551. class="tab-pane {{tab.id === activeId ? 'active' : null}}"
  9552. *ngIf="!destroyOnHide || tab.id === activeId"
  9553. role="tabpanel"
  9554. [attr.aria-labelledby]="tab.id" id="{{tab.id}}-panel">
  9555. <ng-template [ngTemplateOutlet]="tab.contentTpl?.templateRef"></ng-template>
  9556. </div>
  9557. </ng-template>
  9558. </div>
  9559. `
  9560. }] }
  9561. ];
  9562. /** @nocollapse */
  9563. NgbTabset.ctorParameters = () => [
  9564. { type: NgbTabsetConfig }
  9565. ];
  9566. NgbTabset.propDecorators = {
  9567. tabs: [{ type: ContentChildren, args: [NgbTab,] }],
  9568. activeId: [{ type: Input }],
  9569. destroyOnHide: [{ type: Input }],
  9570. justify: [{ type: Input }],
  9571. orientation: [{ type: Input }],
  9572. type: [{ type: Input }],
  9573. tabChange: [{ type: Output }]
  9574. };
  9575. /**
  9576. * @fileoverview added by tsickle
  9577. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9578. */
  9579. /** @type {?} */
  9580. const NGB_TABSET_DIRECTIVES = [NgbTabset, NgbTab, NgbTabContent, NgbTabTitle];
  9581. class NgbTabsetModule {
  9582. }
  9583. NgbTabsetModule.decorators = [
  9584. { type: NgModule, args: [{ declarations: NGB_TABSET_DIRECTIVES, exports: NGB_TABSET_DIRECTIVES, imports: [CommonModule, NgbNavModule] },] }
  9585. ];
  9586. /**
  9587. * @fileoverview added by tsickle
  9588. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9589. */
  9590. class NgbTime {
  9591. /**
  9592. * @param {?=} hour
  9593. * @param {?=} minute
  9594. * @param {?=} second
  9595. */
  9596. constructor(hour, minute, second) {
  9597. this.hour = toInteger(hour);
  9598. this.minute = toInteger(minute);
  9599. this.second = toInteger(second);
  9600. }
  9601. /**
  9602. * @param {?=} step
  9603. * @return {?}
  9604. */
  9605. changeHour(step = 1) { this.updateHour((isNaN(this.hour) ? 0 : this.hour) + step); }
  9606. /**
  9607. * @param {?} hour
  9608. * @return {?}
  9609. */
  9610. updateHour(hour) {
  9611. if (isNumber(hour)) {
  9612. this.hour = (hour < 0 ? 24 + hour : hour) % 24;
  9613. }
  9614. else {
  9615. this.hour = NaN;
  9616. }
  9617. }
  9618. /**
  9619. * @param {?=} step
  9620. * @return {?}
  9621. */
  9622. changeMinute(step = 1) { this.updateMinute((isNaN(this.minute) ? 0 : this.minute) + step); }
  9623. /**
  9624. * @param {?} minute
  9625. * @return {?}
  9626. */
  9627. updateMinute(minute) {
  9628. if (isNumber(minute)) {
  9629. this.minute = minute % 60 < 0 ? 60 + minute % 60 : minute % 60;
  9630. this.changeHour(Math.floor(minute / 60));
  9631. }
  9632. else {
  9633. this.minute = NaN;
  9634. }
  9635. }
  9636. /**
  9637. * @param {?=} step
  9638. * @return {?}
  9639. */
  9640. changeSecond(step = 1) { this.updateSecond((isNaN(this.second) ? 0 : this.second) + step); }
  9641. /**
  9642. * @param {?} second
  9643. * @return {?}
  9644. */
  9645. updateSecond(second) {
  9646. if (isNumber(second)) {
  9647. this.second = second < 0 ? 60 + second % 60 : second % 60;
  9648. this.changeMinute(Math.floor(second / 60));
  9649. }
  9650. else {
  9651. this.second = NaN;
  9652. }
  9653. }
  9654. /**
  9655. * @param {?=} checkSecs
  9656. * @return {?}
  9657. */
  9658. isValid(checkSecs = true) {
  9659. return isNumber(this.hour) && isNumber(this.minute) && (checkSecs ? isNumber(this.second) : true);
  9660. }
  9661. /**
  9662. * @return {?}
  9663. */
  9664. toString() { return `${this.hour || 0}:${this.minute || 0}:${this.second || 0}`; }
  9665. }
  9666. /**
  9667. * @fileoverview added by tsickle
  9668. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9669. */
  9670. /**
  9671. * A configuration service for the [`NgbTimepicker`](#/components/timepicker/api#NgbTimepicker) component.
  9672. *
  9673. * You can inject this service, typically in your root component, and customize the values of its properties in
  9674. * order to provide default values for all the timepickers used in the application.
  9675. */
  9676. class NgbTimepickerConfig {
  9677. constructor() {
  9678. this.meridian = false;
  9679. this.spinners = true;
  9680. this.seconds = false;
  9681. this.hourStep = 1;
  9682. this.minuteStep = 1;
  9683. this.secondStep = 1;
  9684. this.disabled = false;
  9685. this.readonlyInputs = false;
  9686. this.size = 'medium';
  9687. }
  9688. }
  9689. NgbTimepickerConfig.decorators = [
  9690. { type: Injectable, args: [{ providedIn: 'root' },] }
  9691. ];
  9692. /** @nocollapse */ NgbTimepickerConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbTimepickerConfig_Factory() { return new NgbTimepickerConfig(); }, token: NgbTimepickerConfig, providedIn: "root" });
  9693. /**
  9694. * @fileoverview added by tsickle
  9695. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9696. */
  9697. /**
  9698. * @return {?}
  9699. */
  9700. function NGB_DATEPICKER_TIME_ADAPTER_FACTORY() {
  9701. return new NgbTimeStructAdapter();
  9702. }
  9703. /**
  9704. * An abstract service that does the conversion between the internal timepicker `NgbTimeStruct` model and
  9705. * any provided user time model `T`, ex. a string, a native date, etc.
  9706. *
  9707. * The adapter is used **only** for conversion when binding timepicker to a form control,
  9708. * ex. `[(ngModel)]="userTimeModel"`. Here `userTimeModel` can be of any type.
  9709. *
  9710. * The default timepicker implementation assumes we use `NgbTimeStruct` as a user model.
  9711. *
  9712. * See the [custom time adapter demo](#/components/timepicker/examples#adapter) for an example.
  9713. *
  9714. * \@since 2.2.0
  9715. * @abstract
  9716. * @template T
  9717. */
  9718. class NgbTimeAdapter {
  9719. }
  9720. NgbTimeAdapter.decorators = [
  9721. { type: Injectable, args: [{ providedIn: 'root', useFactory: NGB_DATEPICKER_TIME_ADAPTER_FACTORY },] }
  9722. ];
  9723. /** @nocollapse */ NgbTimeAdapter.ngInjectableDef = ɵɵdefineInjectable({ factory: NGB_DATEPICKER_TIME_ADAPTER_FACTORY, token: NgbTimeAdapter, providedIn: "root" });
  9724. class NgbTimeStructAdapter extends NgbTimeAdapter {
  9725. /**
  9726. * Converts a NgbTimeStruct value into NgbTimeStruct value
  9727. * @param {?} time
  9728. * @return {?}
  9729. */
  9730. fromModel(time) {
  9731. return (time && isInteger(time.hour) && isInteger(time.minute)) ?
  9732. { hour: time.hour, minute: time.minute, second: isInteger(time.second) ? time.second : null } :
  9733. null;
  9734. }
  9735. /**
  9736. * Converts a NgbTimeStruct value into NgbTimeStruct value
  9737. * @param {?} time
  9738. * @return {?}
  9739. */
  9740. toModel(time) {
  9741. return (time && isInteger(time.hour) && isInteger(time.minute)) ?
  9742. { hour: time.hour, minute: time.minute, second: isInteger(time.second) ? time.second : null } :
  9743. null;
  9744. }
  9745. }
  9746. NgbTimeStructAdapter.decorators = [
  9747. { type: Injectable }
  9748. ];
  9749. /**
  9750. * @fileoverview added by tsickle
  9751. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9752. */
  9753. /**
  9754. * @param {?} locale
  9755. * @return {?}
  9756. */
  9757. function NGB_TIMEPICKER_I18N_FACTORY(locale) {
  9758. return new NgbTimepickerI18nDefault(locale);
  9759. }
  9760. /**
  9761. * Type of the service supplying day periods (for example, 'AM' and 'PM') to NgbTimepicker component.
  9762. * The default implementation of this service honors the Angular locale, and uses the registered locale data,
  9763. * as explained in the Angular i18n guide.
  9764. * @abstract
  9765. */
  9766. class NgbTimepickerI18n {
  9767. }
  9768. NgbTimepickerI18n.decorators = [
  9769. { type: Injectable, args: [{ providedIn: 'root', useFactory: NGB_TIMEPICKER_I18N_FACTORY, deps: [LOCALE_ID] },] }
  9770. ];
  9771. /** @nocollapse */ NgbTimepickerI18n.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbTimepickerI18n_Factory() { return NGB_TIMEPICKER_I18N_FACTORY(ɵɵinject(LOCALE_ID)); }, token: NgbTimepickerI18n, providedIn: "root" });
  9772. class NgbTimepickerI18nDefault extends NgbTimepickerI18n {
  9773. /**
  9774. * @param {?} locale
  9775. */
  9776. constructor(locale) {
  9777. super();
  9778. this._periods = getLocaleDayPeriods(locale, FormStyle.Standalone, TranslationWidth.Narrow);
  9779. }
  9780. /**
  9781. * @return {?}
  9782. */
  9783. getMorningPeriod() { return this._periods[0]; }
  9784. /**
  9785. * @return {?}
  9786. */
  9787. getAfternoonPeriod() { return this._periods[1]; }
  9788. }
  9789. NgbTimepickerI18nDefault.decorators = [
  9790. { type: Injectable }
  9791. ];
  9792. /** @nocollapse */
  9793. NgbTimepickerI18nDefault.ctorParameters = () => [
  9794. { type: String, decorators: [{ type: Inject, args: [LOCALE_ID,] }] }
  9795. ];
  9796. /**
  9797. * @fileoverview added by tsickle
  9798. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  9799. */
  9800. /** @type {?} */
  9801. const FILTER_REGEX = /[^0-9]/g;
  9802. /** @type {?} */
  9803. const NGB_TIMEPICKER_VALUE_ACCESSOR = {
  9804. provide: NG_VALUE_ACCESSOR,
  9805. useExisting: forwardRef((/**
  9806. * @return {?}
  9807. */
  9808. () => NgbTimepicker)),
  9809. multi: true
  9810. };
  9811. /**
  9812. * A directive that helps with wth picking hours, minutes and seconds.
  9813. */
  9814. class NgbTimepicker {
  9815. /**
  9816. * @param {?} _config
  9817. * @param {?} _ngbTimeAdapter
  9818. * @param {?} _cd
  9819. * @param {?} i18n
  9820. */
  9821. constructor(_config, _ngbTimeAdapter, _cd, i18n) {
  9822. this._config = _config;
  9823. this._ngbTimeAdapter = _ngbTimeAdapter;
  9824. this._cd = _cd;
  9825. this.i18n = i18n;
  9826. this.onChange = (/**
  9827. * @param {?} _
  9828. * @return {?}
  9829. */
  9830. (_) => { });
  9831. this.onTouched = (/**
  9832. * @return {?}
  9833. */
  9834. () => { });
  9835. this.meridian = _config.meridian;
  9836. this.spinners = _config.spinners;
  9837. this.seconds = _config.seconds;
  9838. this.hourStep = _config.hourStep;
  9839. this.minuteStep = _config.minuteStep;
  9840. this.secondStep = _config.secondStep;
  9841. this.disabled = _config.disabled;
  9842. this.readonlyInputs = _config.readonlyInputs;
  9843. this.size = _config.size;
  9844. }
  9845. /**
  9846. * The number of hours to add/subtract when clicking hour spinners.
  9847. * @param {?} step
  9848. * @return {?}
  9849. */
  9850. set hourStep(step) {
  9851. this._hourStep = isInteger(step) ? step : this._config.hourStep;
  9852. }
  9853. /**
  9854. * @return {?}
  9855. */
  9856. get hourStep() { return this._hourStep; }
  9857. /**
  9858. * The number of minutes to add/subtract when clicking minute spinners.
  9859. * @param {?} step
  9860. * @return {?}
  9861. */
  9862. set minuteStep(step) {
  9863. this._minuteStep = isInteger(step) ? step : this._config.minuteStep;
  9864. }
  9865. /**
  9866. * @return {?}
  9867. */
  9868. get minuteStep() { return this._minuteStep; }
  9869. /**
  9870. * The number of seconds to add/subtract when clicking second spinners.
  9871. * @param {?} step
  9872. * @return {?}
  9873. */
  9874. set secondStep(step) {
  9875. this._secondStep = isInteger(step) ? step : this._config.secondStep;
  9876. }
  9877. /**
  9878. * @return {?}
  9879. */
  9880. get secondStep() { return this._secondStep; }
  9881. /**
  9882. * @param {?} value
  9883. * @return {?}
  9884. */
  9885. writeValue(value) {
  9886. /** @type {?} */
  9887. const structValue = this._ngbTimeAdapter.fromModel(value);
  9888. this.model = structValue ? new NgbTime(structValue.hour, structValue.minute, structValue.second) : new NgbTime();
  9889. if (!this.seconds && (!structValue || !isNumber(structValue.second))) {
  9890. this.model.second = 0;
  9891. }
  9892. this._cd.markForCheck();
  9893. }
  9894. /**
  9895. * @param {?} fn
  9896. * @return {?}
  9897. */
  9898. registerOnChange(fn) { this.onChange = fn; }
  9899. /**
  9900. * @param {?} fn
  9901. * @return {?}
  9902. */
  9903. registerOnTouched(fn) { this.onTouched = fn; }
  9904. /**
  9905. * @param {?} isDisabled
  9906. * @return {?}
  9907. */
  9908. setDisabledState(isDisabled) { this.disabled = isDisabled; }
  9909. /**
  9910. * @param {?} step
  9911. * @return {?}
  9912. */
  9913. changeHour(step) {
  9914. this.model.changeHour(step);
  9915. this.propagateModelChange();
  9916. }
  9917. /**
  9918. * @param {?} step
  9919. * @return {?}
  9920. */
  9921. changeMinute(step) {
  9922. this.model.changeMinute(step);
  9923. this.propagateModelChange();
  9924. }
  9925. /**
  9926. * @param {?} step
  9927. * @return {?}
  9928. */
  9929. changeSecond(step) {
  9930. this.model.changeSecond(step);
  9931. this.propagateModelChange();
  9932. }
  9933. /**
  9934. * @param {?} newVal
  9935. * @return {?}
  9936. */
  9937. updateHour(newVal) {
  9938. /** @type {?} */
  9939. const isPM = this.model.hour >= 12;
  9940. /** @type {?} */
  9941. const enteredHour = toInteger(newVal);
  9942. if (this.meridian && (isPM && enteredHour < 12 || !isPM && enteredHour === 12)) {
  9943. this.model.updateHour(enteredHour + 12);
  9944. }
  9945. else {
  9946. this.model.updateHour(enteredHour);
  9947. }
  9948. this.propagateModelChange();
  9949. }
  9950. /**
  9951. * @param {?} newVal
  9952. * @return {?}
  9953. */
  9954. updateMinute(newVal) {
  9955. this.model.updateMinute(toInteger(newVal));
  9956. this.propagateModelChange();
  9957. }
  9958. /**
  9959. * @param {?} newVal
  9960. * @return {?}
  9961. */
  9962. updateSecond(newVal) {
  9963. this.model.updateSecond(toInteger(newVal));
  9964. this.propagateModelChange();
  9965. }
  9966. /**
  9967. * @return {?}
  9968. */
  9969. toggleMeridian() {
  9970. if (this.meridian) {
  9971. this.changeHour(12);
  9972. }
  9973. }
  9974. /**
  9975. * @param {?} input
  9976. * @return {?}
  9977. */
  9978. formatInput(input) { input.value = input.value.replace(FILTER_REGEX, ''); }
  9979. /**
  9980. * @param {?} value
  9981. * @return {?}
  9982. */
  9983. formatHour(value) {
  9984. if (isNumber(value)) {
  9985. if (this.meridian) {
  9986. return padNumber(value % 12 === 0 ? 12 : value % 12);
  9987. }
  9988. else {
  9989. return padNumber(value % 24);
  9990. }
  9991. }
  9992. else {
  9993. return padNumber(NaN);
  9994. }
  9995. }
  9996. /**
  9997. * @param {?} value
  9998. * @return {?}
  9999. */
  10000. formatMinSec(value) { return padNumber(value); }
  10001. /**
  10002. * @return {?}
  10003. */
  10004. get isSmallSize() { return this.size === 'small'; }
  10005. /**
  10006. * @return {?}
  10007. */
  10008. get isLargeSize() { return this.size === 'large'; }
  10009. /**
  10010. * @param {?} changes
  10011. * @return {?}
  10012. */
  10013. ngOnChanges(changes) {
  10014. if (changes['seconds'] && !this.seconds && this.model && !isNumber(this.model.second)) {
  10015. this.model.second = 0;
  10016. this.propagateModelChange(false);
  10017. }
  10018. }
  10019. /**
  10020. * @private
  10021. * @param {?=} touched
  10022. * @return {?}
  10023. */
  10024. propagateModelChange(touched = true) {
  10025. if (touched) {
  10026. this.onTouched();
  10027. }
  10028. if (this.model.isValid(this.seconds)) {
  10029. this.onChange(this._ngbTimeAdapter.toModel({ hour: this.model.hour, minute: this.model.minute, second: this.model.second }));
  10030. }
  10031. else {
  10032. this.onChange(this._ngbTimeAdapter.toModel(null));
  10033. }
  10034. }
  10035. }
  10036. NgbTimepicker.decorators = [
  10037. { type: Component, args: [{
  10038. selector: 'ngb-timepicker',
  10039. encapsulation: ViewEncapsulation.None,
  10040. template: `
  10041. <fieldset [disabled]="disabled" [class.disabled]="disabled">
  10042. <div class="ngb-tp">
  10043. <div class="ngb-tp-input-container ngb-tp-hour">
  10044. <button *ngIf="spinners" tabindex="-1" type="button" (click)="changeHour(hourStep)"
  10045. class="btn btn-link" [class.btn-sm]="isSmallSize" [class.btn-lg]="isLargeSize" [class.disabled]="disabled"
  10046. [disabled]="disabled">
  10047. <span class="chevron ngb-tp-chevron"></span>
  10048. <span class="sr-only" i18n="@@ngb.timepicker.increment-hours">Increment hours</span>
  10049. </button>
  10050. <input type="text" class="ngb-tp-input form-control" [class.form-control-sm]="isSmallSize"
  10051. [class.form-control-lg]="isLargeSize"
  10052. maxlength="2" inputmode="numeric" placeholder="HH" i18n-placeholder="@@ngb.timepicker.HH"
  10053. [value]="formatHour(model?.hour)" (change)="updateHour($event.target.value)"
  10054. [readOnly]="readonlyInputs" [disabled]="disabled" aria-label="Hours" i18n-aria-label="@@ngb.timepicker.hours"
  10055. (input)="formatInput($event.target)"
  10056. (keydown.ArrowUp)="changeHour(hourStep); $event.preventDefault()"
  10057. (keydown.ArrowDown)="changeHour(-hourStep); $event.preventDefault()">
  10058. <button *ngIf="spinners" tabindex="-1" type="button" (click)="changeHour(-hourStep)"
  10059. class="btn btn-link" [class.btn-sm]="isSmallSize" [class.btn-lg]="isLargeSize" [class.disabled]="disabled"
  10060. [disabled]="disabled">
  10061. <span class="chevron ngb-tp-chevron bottom"></span>
  10062. <span class="sr-only" i18n="@@ngb.timepicker.decrement-hours">Decrement hours</span>
  10063. </button>
  10064. </div>
  10065. <div class="ngb-tp-spacer">:</div>
  10066. <div class="ngb-tp-input-container ngb-tp-minute">
  10067. <button *ngIf="spinners" tabindex="-1" type="button" (click)="changeMinute(minuteStep)"
  10068. class="btn btn-link" [class.btn-sm]="isSmallSize" [class.btn-lg]="isLargeSize" [class.disabled]="disabled"
  10069. [disabled]="disabled">
  10070. <span class="chevron ngb-tp-chevron"></span>
  10071. <span class="sr-only" i18n="@@ngb.timepicker.increment-minutes">Increment minutes</span>
  10072. </button>
  10073. <input type="text" class="ngb-tp-input form-control" [class.form-control-sm]="isSmallSize" [class.form-control-lg]="isLargeSize"
  10074. maxlength="2" inputmode="numeric" placeholder="MM" i18n-placeholder="@@ngb.timepicker.MM"
  10075. [value]="formatMinSec(model?.minute)" (change)="updateMinute($event.target.value)"
  10076. [readOnly]="readonlyInputs" [disabled]="disabled" aria-label="Minutes" i18n-aria-label="@@ngb.timepicker.minutes"
  10077. (input)="formatInput($event.target)"
  10078. (keydown.ArrowUp)="changeMinute(minuteStep); $event.preventDefault()"
  10079. (keydown.ArrowDown)="changeMinute(-minuteStep); $event.preventDefault()">
  10080. <button *ngIf="spinners" tabindex="-1" type="button" (click)="changeMinute(-minuteStep)"
  10081. class="btn btn-link" [class.btn-sm]="isSmallSize" [class.btn-lg]="isLargeSize" [class.disabled]="disabled"
  10082. [disabled]="disabled">
  10083. <span class="chevron ngb-tp-chevron bottom"></span>
  10084. <span class="sr-only" i18n="@@ngb.timepicker.decrement-minutes">Decrement minutes</span>
  10085. </button>
  10086. </div>
  10087. <div *ngIf="seconds" class="ngb-tp-spacer">:</div>
  10088. <div *ngIf="seconds" class="ngb-tp-input-container ngb-tp-second">
  10089. <button *ngIf="spinners" tabindex="-1" type="button" (click)="changeSecond(secondStep)"
  10090. class="btn btn-link" [class.btn-sm]="isSmallSize" [class.btn-lg]="isLargeSize" [class.disabled]="disabled"
  10091. [disabled]="disabled">
  10092. <span class="chevron ngb-tp-chevron"></span>
  10093. <span class="sr-only" i18n="@@ngb.timepicker.increment-seconds">Increment seconds</span>
  10094. </button>
  10095. <input type="text" class="ngb-tp-input form-control" [class.form-control-sm]="isSmallSize" [class.form-control-lg]="isLargeSize"
  10096. maxlength="2" inputmode="numeric" placeholder="SS" i18n-placeholder="@@ngb.timepicker.SS"
  10097. [value]="formatMinSec(model?.second)" (change)="updateSecond($event.target.value)"
  10098. [readOnly]="readonlyInputs" [disabled]="disabled" aria-label="Seconds" i18n-aria-label="@@ngb.timepicker.seconds"
  10099. (input)="formatInput($event.target)"
  10100. (keydown.ArrowUp)="changeSecond(secondStep); $event.preventDefault()"
  10101. (keydown.ArrowDown)="changeSecond(-secondStep); $event.preventDefault()">
  10102. <button *ngIf="spinners" tabindex="-1" type="button" (click)="changeSecond(-secondStep)"
  10103. class="btn btn-link" [class.btn-sm]="isSmallSize" [class.btn-lg]="isLargeSize" [class.disabled]="disabled"
  10104. [disabled]="disabled">
  10105. <span class="chevron ngb-tp-chevron bottom"></span>
  10106. <span class="sr-only" i18n="@@ngb.timepicker.decrement-seconds">Decrement seconds</span>
  10107. </button>
  10108. </div>
  10109. <div *ngIf="meridian" class="ngb-tp-spacer"></div>
  10110. <div *ngIf="meridian" class="ngb-tp-meridian">
  10111. <button type="button" class="btn btn-outline-primary" [class.btn-sm]="isSmallSize" [class.btn-lg]="isLargeSize"
  10112. [disabled]="disabled" [class.disabled]="disabled"
  10113. (click)="toggleMeridian()">
  10114. <ng-container *ngIf="model?.hour >= 12; else am" i18n="@@ngb.timepicker.PM">{{ i18n.getAfternoonPeriod() }}</ng-container>
  10115. <ng-template #am i18n="@@ngb.timepicker.AM">{{ i18n.getMorningPeriod() }}</ng-template>
  10116. </button>
  10117. </div>
  10118. </div>
  10119. </fieldset>
  10120. `,
  10121. providers: [NGB_TIMEPICKER_VALUE_ACCESSOR],
  10122. styles: ["ngb-timepicker{font-size:1rem}.ngb-tp{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.ngb-tp-input-container{width:4em}.ngb-tp-chevron::before{border-style:solid;border-width:.29em .29em 0 0;content:\"\";display:inline-block;height:.69em;left:.05em;position:relative;top:.15em;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);vertical-align:middle;width:.69em}.ngb-tp-chevron.bottom:before{top:-.3em;-webkit-transform:rotate(135deg);transform:rotate(135deg)}.ngb-tp-input{text-align:center}.ngb-tp-hour,.ngb-tp-meridian,.ngb-tp-minute,.ngb-tp-second{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:center;align-items:center;-ms-flex-pack:distribute;justify-content:space-around}.ngb-tp-spacer{width:1em;text-align:center}"]
  10123. }] }
  10124. ];
  10125. /** @nocollapse */
  10126. NgbTimepicker.ctorParameters = () => [
  10127. { type: NgbTimepickerConfig },
  10128. { type: NgbTimeAdapter },
  10129. { type: ChangeDetectorRef },
  10130. { type: NgbTimepickerI18n }
  10131. ];
  10132. NgbTimepicker.propDecorators = {
  10133. meridian: [{ type: Input }],
  10134. spinners: [{ type: Input }],
  10135. seconds: [{ type: Input }],
  10136. hourStep: [{ type: Input }],
  10137. minuteStep: [{ type: Input }],
  10138. secondStep: [{ type: Input }],
  10139. readonlyInputs: [{ type: Input }],
  10140. size: [{ type: Input }]
  10141. };
  10142. /**
  10143. * @fileoverview added by tsickle
  10144. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10145. */
  10146. class NgbTimepickerModule {
  10147. }
  10148. NgbTimepickerModule.decorators = [
  10149. { type: NgModule, args: [{ declarations: [NgbTimepicker], exports: [NgbTimepicker], imports: [CommonModule] },] }
  10150. ];
  10151. /**
  10152. * @fileoverview added by tsickle
  10153. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10154. */
  10155. /**
  10156. * Configuration service for the NgbToast component. You can inject this service, typically in your root component,
  10157. * and customize the values of its properties in order to provide default values for all the toasts used in the
  10158. * application.
  10159. *
  10160. * \@since 5.0.0
  10161. */
  10162. class NgbToastConfig {
  10163. constructor() {
  10164. this.autohide = true;
  10165. this.delay = 500;
  10166. this.ariaLive = 'polite';
  10167. }
  10168. }
  10169. NgbToastConfig.decorators = [
  10170. { type: Injectable, args: [{ providedIn: 'root' },] }
  10171. ];
  10172. /** @nocollapse */ NgbToastConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbToastConfig_Factory() { return new NgbToastConfig(); }, token: NgbToastConfig, providedIn: "root" });
  10173. /**
  10174. * @fileoverview added by tsickle
  10175. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10176. */
  10177. /**
  10178. * This directive allows the usage of HTML markup or other directives
  10179. * inside of the toast's header.
  10180. *
  10181. * \@since 5.0.0
  10182. */
  10183. class NgbToastHeader {
  10184. }
  10185. NgbToastHeader.decorators = [
  10186. { type: Directive, args: [{ selector: '[ngbToastHeader]' },] }
  10187. ];
  10188. /**
  10189. * Toasts provide feedback messages as notifications to the user.
  10190. * Goal is to mimic the push notifications available both on mobile and desktop operating systems.
  10191. *
  10192. * \@since 5.0.0
  10193. */
  10194. class NgbToast {
  10195. /**
  10196. * @param {?} ariaLive
  10197. * @param {?} config
  10198. */
  10199. constructor(ariaLive, config) {
  10200. this.ariaLive = ariaLive;
  10201. /**
  10202. * A template like `<ng-template ngbToastHeader></ng-template>` can be
  10203. * used in the projected content to allow markup usage.
  10204. */
  10205. this.contentHeaderTpl = null;
  10206. /**
  10207. * An event fired immediately when toast's `hide()` method has been called.
  10208. * It can only occur in 2 different scenarios:
  10209. * - `autohide` timeout fires
  10210. * - user clicks on a closing cross (&times)
  10211. *
  10212. * Additionally this output is purely informative. The toast won't disappear. It's up to the user to take care of
  10213. * that.
  10214. */
  10215. this.hideOutput = new EventEmitter();
  10216. if (this.ariaLive == null) {
  10217. this.ariaLive = config.ariaLive;
  10218. }
  10219. this.delay = config.delay;
  10220. this.autohide = config.autohide;
  10221. }
  10222. /**
  10223. * @return {?}
  10224. */
  10225. ngAfterContentInit() { this._init(); }
  10226. /**
  10227. * @param {?} changes
  10228. * @return {?}
  10229. */
  10230. ngOnChanges(changes) {
  10231. if ('autohide' in changes) {
  10232. this._clearTimeout();
  10233. this._init();
  10234. }
  10235. }
  10236. /**
  10237. * @return {?}
  10238. */
  10239. hide() {
  10240. this._clearTimeout();
  10241. this.hideOutput.emit();
  10242. }
  10243. /**
  10244. * @private
  10245. * @return {?}
  10246. */
  10247. _init() {
  10248. if (this.autohide && !this._timeoutID) {
  10249. this._timeoutID = setTimeout((/**
  10250. * @return {?}
  10251. */
  10252. () => this.hide()), this.delay);
  10253. }
  10254. }
  10255. /**
  10256. * @private
  10257. * @return {?}
  10258. */
  10259. _clearTimeout() {
  10260. if (this._timeoutID) {
  10261. clearTimeout(this._timeoutID);
  10262. this._timeoutID = null;
  10263. }
  10264. }
  10265. }
  10266. NgbToast.decorators = [
  10267. { type: Component, args: [{
  10268. selector: 'ngb-toast',
  10269. exportAs: 'ngbToast',
  10270. encapsulation: ViewEncapsulation.None,
  10271. host: {
  10272. 'role': 'alert',
  10273. '[attr.aria-live]': 'ariaLive',
  10274. 'aria-atomic': 'true',
  10275. '[class.toast]': 'true',
  10276. '[class.show]': 'true',
  10277. },
  10278. template: `
  10279. <ng-template #headerTpl>
  10280. <strong class="mr-auto">{{header}}</strong>
  10281. </ng-template>
  10282. <ng-template [ngIf]="contentHeaderTpl || header">
  10283. <div class="toast-header">
  10284. <ng-template [ngTemplateOutlet]="contentHeaderTpl || headerTpl"></ng-template>
  10285. <button type="button" class="close" aria-label="Close" i18n-aria-label="@@ngb.toast.close-aria" (click)="hide()">
  10286. <span aria-hidden="true">&times;</span>
  10287. </button>
  10288. </div>
  10289. </ng-template>
  10290. <div class="toast-body">
  10291. <ng-content></ng-content>
  10292. </div>
  10293. `,
  10294. styles: [".ngb-toasts{position:fixed;top:0;right:0;margin:.5em;z-index:1200}ngb-toast .toast-header .close{margin-left:auto;margin-bottom:.25rem}"]
  10295. }] }
  10296. ];
  10297. /** @nocollapse */
  10298. NgbToast.ctorParameters = () => [
  10299. { type: String, decorators: [{ type: Attribute, args: ['aria-live',] }] },
  10300. { type: NgbToastConfig }
  10301. ];
  10302. NgbToast.propDecorators = {
  10303. delay: [{ type: Input }],
  10304. autohide: [{ type: Input }],
  10305. header: [{ type: Input }],
  10306. contentHeaderTpl: [{ type: ContentChild, args: [NgbToastHeader, { read: TemplateRef, static: true },] }],
  10307. hideOutput: [{ type: Output, args: ['hide',] }]
  10308. };
  10309. /**
  10310. * @fileoverview added by tsickle
  10311. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10312. */
  10313. class NgbToastModule {
  10314. }
  10315. NgbToastModule.decorators = [
  10316. { type: NgModule, args: [{ declarations: [NgbToast, NgbToastHeader], imports: [CommonModule], exports: [NgbToast, NgbToastHeader] },] }
  10317. ];
  10318. /**
  10319. * @fileoverview added by tsickle
  10320. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10321. */
  10322. /**
  10323. * A configuration service for the [`NgbTooltip`](#/components/tooltip/api#NgbTooltip) component.
  10324. *
  10325. * You can inject this service, typically in your root component, and customize the values of its properties in
  10326. * order to provide default values for all the tooltips used in the application.
  10327. */
  10328. class NgbTooltipConfig {
  10329. constructor() {
  10330. this.autoClose = true;
  10331. this.placement = 'auto';
  10332. this.triggers = 'hover focus';
  10333. this.disableTooltip = false;
  10334. this.openDelay = 0;
  10335. this.closeDelay = 0;
  10336. }
  10337. }
  10338. NgbTooltipConfig.decorators = [
  10339. { type: Injectable, args: [{ providedIn: 'root' },] }
  10340. ];
  10341. /** @nocollapse */ NgbTooltipConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbTooltipConfig_Factory() { return new NgbTooltipConfig(); }, token: NgbTooltipConfig, providedIn: "root" });
  10342. /**
  10343. * @fileoverview added by tsickle
  10344. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10345. */
  10346. /** @type {?} */
  10347. let nextId$5 = 0;
  10348. class NgbTooltipWindow {
  10349. }
  10350. NgbTooltipWindow.decorators = [
  10351. { type: Component, args: [{
  10352. selector: 'ngb-tooltip-window',
  10353. changeDetection: ChangeDetectionStrategy.OnPush,
  10354. encapsulation: ViewEncapsulation.None,
  10355. host: { '[class]': '"tooltip show" + (tooltipClass ? " " + tooltipClass : "")', 'role': 'tooltip', '[id]': 'id' },
  10356. template: `<div class="arrow"></div><div class="tooltip-inner"><ng-content></ng-content></div>`,
  10357. styles: ["ngb-tooltip-window.bs-tooltip-bottom .arrow,ngb-tooltip-window.bs-tooltip-top .arrow{left:calc(50% - .4rem)}ngb-tooltip-window.bs-tooltip-bottom-left .arrow,ngb-tooltip-window.bs-tooltip-top-left .arrow{left:1em}ngb-tooltip-window.bs-tooltip-bottom-right .arrow,ngb-tooltip-window.bs-tooltip-top-right .arrow{left:auto;right:.8rem}ngb-tooltip-window.bs-tooltip-left .arrow,ngb-tooltip-window.bs-tooltip-right .arrow{top:calc(50% - .4rem)}ngb-tooltip-window.bs-tooltip-left-top .arrow,ngb-tooltip-window.bs-tooltip-right-top .arrow{top:.4rem}ngb-tooltip-window.bs-tooltip-left-bottom .arrow,ngb-tooltip-window.bs-tooltip-right-bottom .arrow{top:auto;bottom:.4rem}"]
  10358. }] }
  10359. ];
  10360. NgbTooltipWindow.propDecorators = {
  10361. id: [{ type: Input }],
  10362. tooltipClass: [{ type: Input }]
  10363. };
  10364. /**
  10365. * A lightweight and extensible directive for fancy tooltip creation.
  10366. */
  10367. class NgbTooltip {
  10368. /**
  10369. * @param {?} _elementRef
  10370. * @param {?} _renderer
  10371. * @param {?} injector
  10372. * @param {?} componentFactoryResolver
  10373. * @param {?} viewContainerRef
  10374. * @param {?} config
  10375. * @param {?} _ngZone
  10376. * @param {?} _document
  10377. * @param {?} _changeDetector
  10378. * @param {?} applicationRef
  10379. */
  10380. constructor(_elementRef, _renderer, injector, componentFactoryResolver, viewContainerRef, config, _ngZone, _document, _changeDetector, applicationRef) {
  10381. this._elementRef = _elementRef;
  10382. this._renderer = _renderer;
  10383. this._ngZone = _ngZone;
  10384. this._document = _document;
  10385. this._changeDetector = _changeDetector;
  10386. /**
  10387. * An event emitted when the tooltip is shown. Contains no payload.
  10388. */
  10389. this.shown = new EventEmitter();
  10390. /**
  10391. * An event emitted when the popover is hidden. Contains no payload.
  10392. */
  10393. this.hidden = new EventEmitter();
  10394. this._ngbTooltipWindowId = `ngb-tooltip-${nextId$5++}`;
  10395. this.autoClose = config.autoClose;
  10396. this.placement = config.placement;
  10397. this.triggers = config.triggers;
  10398. this.container = config.container;
  10399. this.disableTooltip = config.disableTooltip;
  10400. this.tooltipClass = config.tooltipClass;
  10401. this.openDelay = config.openDelay;
  10402. this.closeDelay = config.closeDelay;
  10403. this._popupService = new PopupService(NgbTooltipWindow, injector, viewContainerRef, _renderer, componentFactoryResolver, applicationRef);
  10404. this._zoneSubscription = _ngZone.onStable.subscribe((/**
  10405. * @return {?}
  10406. */
  10407. () => {
  10408. if (this._windowRef) {
  10409. positionElements(this._elementRef.nativeElement, this._windowRef.location.nativeElement, this.placement, this.container === 'body', 'bs-tooltip');
  10410. }
  10411. }));
  10412. }
  10413. /**
  10414. * The string content or a `TemplateRef` for the content to be displayed in the tooltip.
  10415. *
  10416. * If the content if falsy, the tooltip won't open.
  10417. * @param {?} value
  10418. * @return {?}
  10419. */
  10420. set ngbTooltip(value) {
  10421. this._ngbTooltip = value;
  10422. if (!value && this._windowRef) {
  10423. this.close();
  10424. }
  10425. }
  10426. /**
  10427. * @return {?}
  10428. */
  10429. get ngbTooltip() { return this._ngbTooltip; }
  10430. /**
  10431. * Opens the tooltip.
  10432. *
  10433. * This is considered to be a "manual" triggering.
  10434. * The `context` is an optional value to be injected into the tooltip template when it is created.
  10435. * @param {?=} context
  10436. * @return {?}
  10437. */
  10438. open(context) {
  10439. if (!this._windowRef && this._ngbTooltip && !this.disableTooltip) {
  10440. this._windowRef = this._popupService.open(this._ngbTooltip, context);
  10441. this._windowRef.instance.tooltipClass = this.tooltipClass;
  10442. this._windowRef.instance.id = this._ngbTooltipWindowId;
  10443. this._renderer.setAttribute(this._elementRef.nativeElement, 'aria-describedby', this._ngbTooltipWindowId);
  10444. if (this.container === 'body') {
  10445. this._document.querySelector(this.container).appendChild(this._windowRef.location.nativeElement);
  10446. }
  10447. // We need to detect changes, because we don't know where .open() might be called from.
  10448. // Ex. opening tooltip from one of lifecycle hooks that run after the CD
  10449. // (say from ngAfterViewInit) will result in 'ExpressionHasChanged' exception
  10450. this._windowRef.changeDetectorRef.detectChanges();
  10451. // We need to mark for check, because tooltip won't work inside the OnPush component.
  10452. // Ex. when we use expression like `{{ tooltip.isOpen() : 'opened' : 'closed' }}`
  10453. // inside the template of an OnPush component and we change the tooltip from
  10454. // open -> closed, the expression in question won't be updated unless we explicitly
  10455. // mark the parent component to be checked.
  10456. this._windowRef.changeDetectorRef.markForCheck();
  10457. ngbAutoClose(this._ngZone, this._document, this.autoClose, (/**
  10458. * @return {?}
  10459. */
  10460. () => this.close()), this.hidden, [this._windowRef.location.nativeElement]);
  10461. this.shown.emit();
  10462. }
  10463. }
  10464. /**
  10465. * Closes the tooltip.
  10466. *
  10467. * This is considered to be a "manual" triggering of the tooltip.
  10468. * @return {?}
  10469. */
  10470. close() {
  10471. if (this._windowRef != null) {
  10472. this._renderer.removeAttribute(this._elementRef.nativeElement, 'aria-describedby');
  10473. this._popupService.close();
  10474. this._windowRef = null;
  10475. this.hidden.emit();
  10476. this._changeDetector.markForCheck();
  10477. }
  10478. }
  10479. /**
  10480. * Toggles the tooltip.
  10481. *
  10482. * This is considered to be a "manual" triggering of the tooltip.
  10483. * @return {?}
  10484. */
  10485. toggle() {
  10486. if (this._windowRef) {
  10487. this.close();
  10488. }
  10489. else {
  10490. this.open();
  10491. }
  10492. }
  10493. /**
  10494. * Returns `true`, if the popover is currently shown.
  10495. * @return {?}
  10496. */
  10497. isOpen() { return this._windowRef != null; }
  10498. /**
  10499. * @return {?}
  10500. */
  10501. ngOnInit() {
  10502. this._unregisterListenersFn = listenToTriggers(this._renderer, this._elementRef.nativeElement, this.triggers, this.isOpen.bind(this), this.open.bind(this), this.close.bind(this), +this.openDelay, +this.closeDelay);
  10503. }
  10504. /**
  10505. * @param {?} __0
  10506. * @return {?}
  10507. */
  10508. ngOnChanges({ tooltipClass }) {
  10509. if (tooltipClass && this.isOpen()) {
  10510. this._windowRef.instance.tooltipClass = tooltipClass.currentValue;
  10511. }
  10512. }
  10513. /**
  10514. * @return {?}
  10515. */
  10516. ngOnDestroy() {
  10517. this.close();
  10518. // This check is needed as it might happen that ngOnDestroy is called before ngOnInit
  10519. // under certain conditions, see: https://github.com/ng-bootstrap/ng-bootstrap/issues/2199
  10520. if (this._unregisterListenersFn) {
  10521. this._unregisterListenersFn();
  10522. }
  10523. this._zoneSubscription.unsubscribe();
  10524. }
  10525. }
  10526. NgbTooltip.decorators = [
  10527. { type: Directive, args: [{ selector: '[ngbTooltip]', exportAs: 'ngbTooltip' },] }
  10528. ];
  10529. /** @nocollapse */
  10530. NgbTooltip.ctorParameters = () => [
  10531. { type: ElementRef },
  10532. { type: Renderer2 },
  10533. { type: Injector },
  10534. { type: ComponentFactoryResolver },
  10535. { type: ViewContainerRef },
  10536. { type: NgbTooltipConfig },
  10537. { type: NgZone },
  10538. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
  10539. { type: ChangeDetectorRef },
  10540. { type: ApplicationRef }
  10541. ];
  10542. NgbTooltip.propDecorators = {
  10543. autoClose: [{ type: Input }],
  10544. placement: [{ type: Input }],
  10545. triggers: [{ type: Input }],
  10546. container: [{ type: Input }],
  10547. disableTooltip: [{ type: Input }],
  10548. tooltipClass: [{ type: Input }],
  10549. openDelay: [{ type: Input }],
  10550. closeDelay: [{ type: Input }],
  10551. shown: [{ type: Output }],
  10552. hidden: [{ type: Output }],
  10553. ngbTooltip: [{ type: Input }]
  10554. };
  10555. /**
  10556. * @fileoverview added by tsickle
  10557. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10558. */
  10559. class NgbTooltipModule {
  10560. }
  10561. NgbTooltipModule.decorators = [
  10562. { type: NgModule, args: [{ declarations: [NgbTooltip, NgbTooltipWindow], exports: [NgbTooltip], entryComponents: [NgbTooltipWindow] },] }
  10563. ];
  10564. /**
  10565. * @fileoverview added by tsickle
  10566. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10567. */
  10568. /**
  10569. * A component that helps with text highlighting.
  10570. *
  10571. * If splits the `result` text into parts that contain the searched `term` and generates the HTML markup to simplify
  10572. * highlighting:
  10573. *
  10574. * Ex. `result="Alaska"` and `term="as"` will produce `Al<span class="ngb-highlight">as</span>ka`.
  10575. */
  10576. class NgbHighlight {
  10577. constructor() {
  10578. /**
  10579. * The CSS class for `<span>` elements wrapping the `term` inside the `result`.
  10580. */
  10581. this.highlightClass = 'ngb-highlight';
  10582. }
  10583. /**
  10584. * @param {?} changes
  10585. * @return {?}
  10586. */
  10587. ngOnChanges(changes) {
  10588. /** @type {?} */
  10589. const result = toString(this.result);
  10590. /** @type {?} */
  10591. const terms = Array.isArray(this.term) ? this.term : [this.term];
  10592. /** @type {?} */
  10593. const escapedTerms = terms.map((/**
  10594. * @param {?} term
  10595. * @return {?}
  10596. */
  10597. term => regExpEscape(toString(term)))).filter((/**
  10598. * @param {?} term
  10599. * @return {?}
  10600. */
  10601. term => term));
  10602. this.parts = escapedTerms.length ? result.split(new RegExp(`(${escapedTerms.join('|')})`, 'gmi')) : [result];
  10603. }
  10604. }
  10605. NgbHighlight.decorators = [
  10606. { type: Component, args: [{
  10607. selector: 'ngb-highlight',
  10608. changeDetection: ChangeDetectionStrategy.OnPush,
  10609. encapsulation: ViewEncapsulation.None,
  10610. template: `<ng-template ngFor [ngForOf]="parts" let-part let-isOdd="odd">` +
  10611. `<span *ngIf="isOdd; else even" [class]="highlightClass">{{part}}</span><ng-template #even>{{part}}</ng-template>` +
  10612. `</ng-template>`,
  10613. styles: [".ngb-highlight{font-weight:700}"]
  10614. }] }
  10615. ];
  10616. NgbHighlight.propDecorators = {
  10617. highlightClass: [{ type: Input }],
  10618. result: [{ type: Input }],
  10619. term: [{ type: Input }]
  10620. };
  10621. /**
  10622. * @fileoverview added by tsickle
  10623. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10624. */
  10625. class NgbTypeaheadWindow {
  10626. constructor() {
  10627. this.activeIdx = 0;
  10628. /**
  10629. * Flag indicating if the first row should be active initially
  10630. */
  10631. this.focusFirst = true;
  10632. /**
  10633. * A function used to format a given result before display. This function should return a formatted string without any
  10634. * HTML markup
  10635. */
  10636. this.formatter = toString;
  10637. /**
  10638. * Event raised when user selects a particular result row
  10639. */
  10640. this.selectEvent = new EventEmitter();
  10641. this.activeChangeEvent = new EventEmitter();
  10642. }
  10643. /**
  10644. * @return {?}
  10645. */
  10646. hasActive() { return this.activeIdx > -1 && this.activeIdx < this.results.length; }
  10647. /**
  10648. * @return {?}
  10649. */
  10650. getActive() { return this.results[this.activeIdx]; }
  10651. /**
  10652. * @param {?} activeIdx
  10653. * @return {?}
  10654. */
  10655. markActive(activeIdx) {
  10656. this.activeIdx = activeIdx;
  10657. this._activeChanged();
  10658. }
  10659. /**
  10660. * @return {?}
  10661. */
  10662. next() {
  10663. if (this.activeIdx === this.results.length - 1) {
  10664. this.activeIdx = this.focusFirst ? (this.activeIdx + 1) % this.results.length : -1;
  10665. }
  10666. else {
  10667. this.activeIdx++;
  10668. }
  10669. this._activeChanged();
  10670. }
  10671. /**
  10672. * @return {?}
  10673. */
  10674. prev() {
  10675. if (this.activeIdx < 0) {
  10676. this.activeIdx = this.results.length - 1;
  10677. }
  10678. else if (this.activeIdx === 0) {
  10679. this.activeIdx = this.focusFirst ? this.results.length - 1 : -1;
  10680. }
  10681. else {
  10682. this.activeIdx--;
  10683. }
  10684. this._activeChanged();
  10685. }
  10686. /**
  10687. * @return {?}
  10688. */
  10689. resetActive() {
  10690. this.activeIdx = this.focusFirst ? 0 : -1;
  10691. this._activeChanged();
  10692. }
  10693. /**
  10694. * @param {?} item
  10695. * @return {?}
  10696. */
  10697. select(item) { this.selectEvent.emit(item); }
  10698. /**
  10699. * @return {?}
  10700. */
  10701. ngOnInit() { this.resetActive(); }
  10702. /**
  10703. * @private
  10704. * @return {?}
  10705. */
  10706. _activeChanged() {
  10707. this.activeChangeEvent.emit(this.activeIdx >= 0 ? this.id + '-' + this.activeIdx : undefined);
  10708. }
  10709. }
  10710. NgbTypeaheadWindow.decorators = [
  10711. { type: Component, args: [{
  10712. selector: 'ngb-typeahead-window',
  10713. exportAs: 'ngbTypeaheadWindow',
  10714. encapsulation: ViewEncapsulation.None,
  10715. host: { '(mousedown)': '$event.preventDefault()', 'class': 'dropdown-menu show', 'role': 'listbox', '[id]': 'id' },
  10716. template: `
  10717. <ng-template #rt let-result="result" let-term="term" let-formatter="formatter">
  10718. <ngb-highlight [result]="formatter(result)" [term]="term"></ngb-highlight>
  10719. </ng-template>
  10720. <ng-template ngFor [ngForOf]="results" let-result let-idx="index">
  10721. <button type="button" class="dropdown-item" role="option"
  10722. [id]="id + '-' + idx"
  10723. [class.active]="idx === activeIdx"
  10724. (mouseenter)="markActive(idx)"
  10725. (click)="select(result)">
  10726. <ng-template [ngTemplateOutlet]="resultTemplate || rt"
  10727. [ngTemplateOutletContext]="{result: result, term: term, formatter: formatter}"></ng-template>
  10728. </button>
  10729. </ng-template>
  10730. `
  10731. }] }
  10732. ];
  10733. NgbTypeaheadWindow.propDecorators = {
  10734. id: [{ type: Input }],
  10735. focusFirst: [{ type: Input }],
  10736. results: [{ type: Input }],
  10737. term: [{ type: Input }],
  10738. formatter: [{ type: Input }],
  10739. resultTemplate: [{ type: Input }],
  10740. selectEvent: [{ type: Output, args: ['select',] }],
  10741. activeChangeEvent: [{ type: Output, args: ['activeChange',] }]
  10742. };
  10743. /**
  10744. * @fileoverview added by tsickle
  10745. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10746. */
  10747. /** @type {?} */
  10748. const ARIA_LIVE_DELAY = new InjectionToken('live announcer delay', { providedIn: 'root', factory: ARIA_LIVE_DELAY_FACTORY });
  10749. /**
  10750. * @return {?}
  10751. */
  10752. function ARIA_LIVE_DELAY_FACTORY() {
  10753. return 100;
  10754. }
  10755. /**
  10756. * @param {?} document
  10757. * @param {?=} lazyCreate
  10758. * @return {?}
  10759. */
  10760. function getLiveElement(document, lazyCreate = false) {
  10761. /** @type {?} */
  10762. let element = (/** @type {?} */ (document.body.querySelector('#ngb-live')));
  10763. if (element == null && lazyCreate) {
  10764. element = document.createElement('div');
  10765. element.setAttribute('id', 'ngb-live');
  10766. element.setAttribute('aria-live', 'polite');
  10767. element.setAttribute('aria-atomic', 'true');
  10768. element.classList.add('sr-only');
  10769. document.body.appendChild(element);
  10770. }
  10771. return element;
  10772. }
  10773. class Live {
  10774. /**
  10775. * @param {?} _document
  10776. * @param {?} _delay
  10777. */
  10778. constructor(_document, _delay) {
  10779. this._document = _document;
  10780. this._delay = _delay;
  10781. }
  10782. /**
  10783. * @return {?}
  10784. */
  10785. ngOnDestroy() {
  10786. /** @type {?} */
  10787. const element = getLiveElement(this._document);
  10788. if (element) {
  10789. element.parentElement.removeChild(element);
  10790. }
  10791. }
  10792. /**
  10793. * @param {?} message
  10794. * @return {?}
  10795. */
  10796. say(message) {
  10797. /** @type {?} */
  10798. const element = getLiveElement(this._document, true);
  10799. /** @type {?} */
  10800. const delay = this._delay;
  10801. element.textContent = '';
  10802. /** @type {?} */
  10803. const setText = (/**
  10804. * @return {?}
  10805. */
  10806. () => element.textContent = message);
  10807. if (delay === null) {
  10808. setText();
  10809. }
  10810. else {
  10811. setTimeout(setText, delay);
  10812. }
  10813. }
  10814. }
  10815. Live.decorators = [
  10816. { type: Injectable, args: [{ providedIn: 'root' },] }
  10817. ];
  10818. /** @nocollapse */
  10819. Live.ctorParameters = () => [
  10820. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
  10821. { type: undefined, decorators: [{ type: Inject, args: [ARIA_LIVE_DELAY,] }] }
  10822. ];
  10823. /** @nocollapse */ Live.ngInjectableDef = ɵɵdefineInjectable({ factory: function Live_Factory() { return new Live(ɵɵinject(DOCUMENT), ɵɵinject(ARIA_LIVE_DELAY)); }, token: Live, providedIn: "root" });
  10824. /**
  10825. * @fileoverview added by tsickle
  10826. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10827. */
  10828. /**
  10829. * A configuration service for the [`NgbTypeahead`](#/components/typeahead/api#NgbTypeahead) component.
  10830. *
  10831. * You can inject this service, typically in your root component, and customize the values of its properties in
  10832. * order to provide default values for all the typeaheads used in the application.
  10833. */
  10834. class NgbTypeaheadConfig {
  10835. constructor() {
  10836. this.editable = true;
  10837. this.focusFirst = true;
  10838. this.showHint = false;
  10839. this.placement = ['bottom-left', 'bottom-right', 'top-left', 'top-right'];
  10840. }
  10841. }
  10842. NgbTypeaheadConfig.decorators = [
  10843. { type: Injectable, args: [{ providedIn: 'root' },] }
  10844. ];
  10845. /** @nocollapse */ NgbTypeaheadConfig.ngInjectableDef = ɵɵdefineInjectable({ factory: function NgbTypeaheadConfig_Factory() { return new NgbTypeaheadConfig(); }, token: NgbTypeaheadConfig, providedIn: "root" });
  10846. /**
  10847. * @fileoverview added by tsickle
  10848. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  10849. */
  10850. /** @type {?} */
  10851. const NGB_TYPEAHEAD_VALUE_ACCESSOR = {
  10852. provide: NG_VALUE_ACCESSOR,
  10853. useExisting: forwardRef((/**
  10854. * @return {?}
  10855. */
  10856. () => NgbTypeahead)),
  10857. multi: true
  10858. };
  10859. /** @type {?} */
  10860. let nextWindowId = 0;
  10861. /**
  10862. * A directive providing a simple way of creating powerful typeaheads from any text input.
  10863. */
  10864. class NgbTypeahead {
  10865. /**
  10866. * @param {?} _elementRef
  10867. * @param {?} viewContainerRef
  10868. * @param {?} _renderer
  10869. * @param {?} injector
  10870. * @param {?} componentFactoryResolver
  10871. * @param {?} config
  10872. * @param {?} ngZone
  10873. * @param {?} _live
  10874. * @param {?} _document
  10875. * @param {?} _ngZone
  10876. * @param {?} _changeDetector
  10877. * @param {?} applicationRef
  10878. */
  10879. constructor(_elementRef, viewContainerRef, _renderer, injector, componentFactoryResolver, config, ngZone, _live, _document, _ngZone, _changeDetector, applicationRef) {
  10880. this._elementRef = _elementRef;
  10881. this._renderer = _renderer;
  10882. this._live = _live;
  10883. this._document = _document;
  10884. this._ngZone = _ngZone;
  10885. this._changeDetector = _changeDetector;
  10886. this._closed$ = new Subject();
  10887. /**
  10888. * The value for the `autocomplete` attribute for the `<input>` element.
  10889. *
  10890. * Defaults to `"off"` to disable the native browser autocomplete, but you can override it if necessary.
  10891. *
  10892. * \@since 2.1.0
  10893. */
  10894. this.autocomplete = 'off';
  10895. /**
  10896. * The preferred placement of the typeahead.
  10897. *
  10898. * Possible values are `"top"`, `"top-left"`, `"top-right"`, `"bottom"`, `"bottom-left"`,
  10899. * `"bottom-right"`, `"left"`, `"left-top"`, `"left-bottom"`, `"right"`, `"right-top"`,
  10900. * `"right-bottom"`
  10901. *
  10902. * Accepts an array of strings or a string with space separated possible values.
  10903. *
  10904. * The default order of preference is `"bottom-left bottom-right top-left top-right"`
  10905. *
  10906. * Please see the [positioning overview](#/positioning) for more details.
  10907. */
  10908. this.placement = 'bottom-left';
  10909. /**
  10910. * An event emitted right before an item is selected from the result list.
  10911. *
  10912. * Event payload is of type [`NgbTypeaheadSelectItemEvent`](#/components/typeahead/api#NgbTypeaheadSelectItemEvent).
  10913. */
  10914. this.selectItem = new EventEmitter();
  10915. this.popupId = `ngb-typeahead-${nextWindowId++}`;
  10916. this._onTouched = (/**
  10917. * @return {?}
  10918. */
  10919. () => { });
  10920. this._onChange = (/**
  10921. * @param {?} _
  10922. * @return {?}
  10923. */
  10924. (_) => { });
  10925. this.container = config.container;
  10926. this.editable = config.editable;
  10927. this.focusFirst = config.focusFirst;
  10928. this.showHint = config.showHint;
  10929. this.placement = config.placement;
  10930. this._valueChanges = fromEvent(_elementRef.nativeElement, 'input')
  10931. .pipe(map((/**
  10932. * @param {?} $event
  10933. * @return {?}
  10934. */
  10935. $event => ((/** @type {?} */ ($event.target))).value)));
  10936. this._resubscribeTypeahead = new BehaviorSubject(null);
  10937. this._popupService = new PopupService(NgbTypeaheadWindow, injector, viewContainerRef, _renderer, componentFactoryResolver, applicationRef);
  10938. this._zoneSubscription = ngZone.onStable.subscribe((/**
  10939. * @return {?}
  10940. */
  10941. () => {
  10942. if (this.isPopupOpen()) {
  10943. positionElements(this._elementRef.nativeElement, this._windowRef.location.nativeElement, this.placement, this.container === 'body');
  10944. }
  10945. }));
  10946. }
  10947. /**
  10948. * @return {?}
  10949. */
  10950. ngOnInit() {
  10951. /** @type {?} */
  10952. const inputValues$ = this._valueChanges.pipe(tap((/**
  10953. * @param {?} value
  10954. * @return {?}
  10955. */
  10956. value => {
  10957. this._inputValueBackup = this.showHint ? value : null;
  10958. this._onChange(this.editable ? value : undefined);
  10959. })));
  10960. /** @type {?} */
  10961. const results$ = inputValues$.pipe(this.ngbTypeahead);
  10962. /** @type {?} */
  10963. const userInput$ = this._resubscribeTypeahead.pipe(switchMap((/**
  10964. * @return {?}
  10965. */
  10966. () => results$)));
  10967. this._subscription = this._subscribeToUserInput(userInput$);
  10968. }
  10969. /**
  10970. * @return {?}
  10971. */
  10972. ngOnDestroy() {
  10973. this._closePopup();
  10974. this._unsubscribeFromUserInput();
  10975. this._zoneSubscription.unsubscribe();
  10976. }
  10977. /**
  10978. * @param {?} fn
  10979. * @return {?}
  10980. */
  10981. registerOnChange(fn) { this._onChange = fn; }
  10982. /**
  10983. * @param {?} fn
  10984. * @return {?}
  10985. */
  10986. registerOnTouched(fn) { this._onTouched = fn; }
  10987. /**
  10988. * @param {?} value
  10989. * @return {?}
  10990. */
  10991. writeValue(value) {
  10992. this._writeInputValue(this._formatItemForInput(value));
  10993. if (this.showHint) {
  10994. this._inputValueBackup = value;
  10995. }
  10996. }
  10997. /**
  10998. * @param {?} isDisabled
  10999. * @return {?}
  11000. */
  11001. setDisabledState(isDisabled) {
  11002. this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
  11003. }
  11004. /**
  11005. * Dismisses typeahead popup window
  11006. * @return {?}
  11007. */
  11008. dismissPopup() {
  11009. if (this.isPopupOpen()) {
  11010. this._resubscribeTypeahead.next(null);
  11011. this._closePopup();
  11012. if (this.showHint && this._inputValueBackup !== null) {
  11013. this._writeInputValue(this._inputValueBackup);
  11014. }
  11015. this._changeDetector.markForCheck();
  11016. }
  11017. }
  11018. /**
  11019. * Returns true if the typeahead popup window is displayed
  11020. * @return {?}
  11021. */
  11022. isPopupOpen() { return this._windowRef != null; }
  11023. /**
  11024. * @return {?}
  11025. */
  11026. handleBlur() {
  11027. this._resubscribeTypeahead.next(null);
  11028. this._onTouched();
  11029. }
  11030. /**
  11031. * @param {?} event
  11032. * @return {?}
  11033. */
  11034. handleKeyDown(event) {
  11035. if (!this.isPopupOpen()) {
  11036. return;
  11037. }
  11038. // tslint:disable-next-line:deprecation
  11039. switch (event.which) {
  11040. case Key.ArrowDown:
  11041. event.preventDefault();
  11042. this._windowRef.instance.next();
  11043. this._showHint();
  11044. break;
  11045. case Key.ArrowUp:
  11046. event.preventDefault();
  11047. this._windowRef.instance.prev();
  11048. this._showHint();
  11049. break;
  11050. case Key.Enter:
  11051. case Key.Tab:
  11052. /** @type {?} */
  11053. const result = this._windowRef.instance.getActive();
  11054. if (isDefined(result)) {
  11055. event.preventDefault();
  11056. event.stopPropagation();
  11057. this._selectResult(result);
  11058. }
  11059. this._closePopup();
  11060. break;
  11061. }
  11062. }
  11063. /**
  11064. * @private
  11065. * @return {?}
  11066. */
  11067. _openPopup() {
  11068. if (!this.isPopupOpen()) {
  11069. this._inputValueBackup = this._elementRef.nativeElement.value;
  11070. this._windowRef = this._popupService.open();
  11071. this._windowRef.instance.id = this.popupId;
  11072. this._windowRef.instance.selectEvent.subscribe((/**
  11073. * @param {?} result
  11074. * @return {?}
  11075. */
  11076. (result) => this._selectResultClosePopup(result)));
  11077. this._windowRef.instance.activeChangeEvent.subscribe((/**
  11078. * @param {?} activeId
  11079. * @return {?}
  11080. */
  11081. (activeId) => this.activeDescendant = activeId));
  11082. if (this.container === 'body') {
  11083. window.document.querySelector(this.container).appendChild(this._windowRef.location.nativeElement);
  11084. }
  11085. this._changeDetector.markForCheck();
  11086. ngbAutoClose(this._ngZone, this._document, 'outside', (/**
  11087. * @return {?}
  11088. */
  11089. () => this.dismissPopup()), this._closed$, [this._elementRef.nativeElement, this._windowRef.location.nativeElement]);
  11090. }
  11091. }
  11092. /**
  11093. * @private
  11094. * @return {?}
  11095. */
  11096. _closePopup() {
  11097. this._closed$.next();
  11098. this._popupService.close();
  11099. this._windowRef = null;
  11100. this.activeDescendant = undefined;
  11101. }
  11102. /**
  11103. * @private
  11104. * @param {?} result
  11105. * @return {?}
  11106. */
  11107. _selectResult(result) {
  11108. /** @type {?} */
  11109. let defaultPrevented = false;
  11110. this.selectItem.emit({ item: result, preventDefault: (/**
  11111. * @return {?}
  11112. */
  11113. () => { defaultPrevented = true; }) });
  11114. this._resubscribeTypeahead.next(null);
  11115. if (!defaultPrevented) {
  11116. this.writeValue(result);
  11117. this._onChange(result);
  11118. }
  11119. }
  11120. /**
  11121. * @private
  11122. * @param {?} result
  11123. * @return {?}
  11124. */
  11125. _selectResultClosePopup(result) {
  11126. this._selectResult(result);
  11127. this._closePopup();
  11128. }
  11129. /**
  11130. * @private
  11131. * @return {?}
  11132. */
  11133. _showHint() {
  11134. if (this.showHint && this._windowRef.instance.hasActive() && this._inputValueBackup != null) {
  11135. /** @type {?} */
  11136. const userInputLowerCase = this._inputValueBackup.toLowerCase();
  11137. /** @type {?} */
  11138. const formattedVal = this._formatItemForInput(this._windowRef.instance.getActive());
  11139. if (userInputLowerCase === formattedVal.substr(0, this._inputValueBackup.length).toLowerCase()) {
  11140. this._writeInputValue(this._inputValueBackup + formattedVal.substr(this._inputValueBackup.length));
  11141. this._elementRef.nativeElement['setSelectionRange'].apply(this._elementRef.nativeElement, [this._inputValueBackup.length, formattedVal.length]);
  11142. }
  11143. else {
  11144. this._writeInputValue(formattedVal);
  11145. }
  11146. }
  11147. }
  11148. /**
  11149. * @private
  11150. * @param {?} item
  11151. * @return {?}
  11152. */
  11153. _formatItemForInput(item) {
  11154. return item != null && this.inputFormatter ? this.inputFormatter(item) : toString(item);
  11155. }
  11156. /**
  11157. * @private
  11158. * @param {?} value
  11159. * @return {?}
  11160. */
  11161. _writeInputValue(value) {
  11162. this._renderer.setProperty(this._elementRef.nativeElement, 'value', toString(value));
  11163. }
  11164. /**
  11165. * @private
  11166. * @param {?} userInput$
  11167. * @return {?}
  11168. */
  11169. _subscribeToUserInput(userInput$) {
  11170. return userInput$.subscribe((/**
  11171. * @param {?} results
  11172. * @return {?}
  11173. */
  11174. (results) => {
  11175. if (!results || results.length === 0) {
  11176. this._closePopup();
  11177. }
  11178. else {
  11179. this._openPopup();
  11180. this._windowRef.instance.focusFirst = this.focusFirst;
  11181. this._windowRef.instance.results = results;
  11182. this._windowRef.instance.term = this._elementRef.nativeElement.value;
  11183. if (this.resultFormatter) {
  11184. this._windowRef.instance.formatter = this.resultFormatter;
  11185. }
  11186. if (this.resultTemplate) {
  11187. this._windowRef.instance.resultTemplate = this.resultTemplate;
  11188. }
  11189. this._windowRef.instance.resetActive();
  11190. // The observable stream we are subscribing to might have async steps
  11191. // and if a component containing typeahead is using the OnPush strategy
  11192. // the change detection turn wouldn't be invoked automatically.
  11193. this._windowRef.changeDetectorRef.detectChanges();
  11194. this._showHint();
  11195. }
  11196. // live announcer
  11197. /** @type {?} */
  11198. const count = results ? results.length : 0;
  11199. this._live.say(count === 0 ? 'No results available' : `${count} result${count === 1 ? '' : 's'} available`);
  11200. }));
  11201. }
  11202. /**
  11203. * @private
  11204. * @return {?}
  11205. */
  11206. _unsubscribeFromUserInput() {
  11207. if (this._subscription) {
  11208. this._subscription.unsubscribe();
  11209. }
  11210. this._subscription = null;
  11211. }
  11212. }
  11213. NgbTypeahead.decorators = [
  11214. { type: Directive, args: [{
  11215. selector: 'input[ngbTypeahead]',
  11216. exportAs: 'ngbTypeahead',
  11217. host: {
  11218. '(blur)': 'handleBlur()',
  11219. '[class.open]': 'isPopupOpen()',
  11220. '(keydown)': 'handleKeyDown($event)',
  11221. '[autocomplete]': 'autocomplete',
  11222. 'autocapitalize': 'off',
  11223. 'autocorrect': 'off',
  11224. 'role': 'combobox',
  11225. 'aria-multiline': 'false',
  11226. '[attr.aria-autocomplete]': 'showHint ? "both" : "list"',
  11227. '[attr.aria-activedescendant]': 'activeDescendant',
  11228. '[attr.aria-owns]': 'isPopupOpen() ? popupId : null',
  11229. '[attr.aria-expanded]': 'isPopupOpen()'
  11230. },
  11231. providers: [NGB_TYPEAHEAD_VALUE_ACCESSOR]
  11232. },] }
  11233. ];
  11234. /** @nocollapse */
  11235. NgbTypeahead.ctorParameters = () => [
  11236. { type: ElementRef },
  11237. { type: ViewContainerRef },
  11238. { type: Renderer2 },
  11239. { type: Injector },
  11240. { type: ComponentFactoryResolver },
  11241. { type: NgbTypeaheadConfig },
  11242. { type: NgZone },
  11243. { type: Live },
  11244. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
  11245. { type: NgZone },
  11246. { type: ChangeDetectorRef },
  11247. { type: ApplicationRef }
  11248. ];
  11249. NgbTypeahead.propDecorators = {
  11250. autocomplete: [{ type: Input }],
  11251. container: [{ type: Input }],
  11252. editable: [{ type: Input }],
  11253. focusFirst: [{ type: Input }],
  11254. inputFormatter: [{ type: Input }],
  11255. ngbTypeahead: [{ type: Input }],
  11256. resultFormatter: [{ type: Input }],
  11257. resultTemplate: [{ type: Input }],
  11258. showHint: [{ type: Input }],
  11259. placement: [{ type: Input }],
  11260. selectItem: [{ type: Output }]
  11261. };
  11262. /**
  11263. * @fileoverview added by tsickle
  11264. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  11265. */
  11266. class NgbTypeaheadModule {
  11267. }
  11268. NgbTypeaheadModule.decorators = [
  11269. { type: NgModule, args: [{
  11270. declarations: [NgbTypeahead, NgbHighlight, NgbTypeaheadWindow],
  11271. exports: [NgbTypeahead, NgbHighlight],
  11272. imports: [CommonModule],
  11273. entryComponents: [NgbTypeaheadWindow]
  11274. },] }
  11275. ];
  11276. /**
  11277. * @fileoverview added by tsickle
  11278. * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  11279. */
  11280. /** @type {?} */
  11281. const NGB_MODULES = [
  11282. NgbAccordionModule, NgbAlertModule, NgbButtonsModule, NgbCarouselModule, NgbCollapseModule, NgbDatepickerModule,
  11283. NgbDropdownModule, NgbModalModule, NgbNavModule, NgbPaginationModule, NgbPopoverModule, NgbProgressbarModule,
  11284. NgbRatingModule, NgbTabsetModule, NgbTimepickerModule, NgbToastModule, NgbTooltipModule, NgbTypeaheadModule
  11285. ];
  11286. class NgbModule {
  11287. }
  11288. NgbModule.decorators = [
  11289. { type: NgModule, args: [{ imports: NGB_MODULES, exports: NGB_MODULES },] }
  11290. ];
  11291. export { ModalDismissReasons, NgbAccordion, NgbAccordionConfig, NgbAccordionModule, NgbActiveModal, NgbAlert, NgbAlertConfig, NgbAlertModule, NgbButtonLabel, NgbButtonsModule, NgbCalendar, NgbCalendarGregorian, NgbCalendarHebrew, NgbCalendarIslamicCivil, NgbCalendarIslamicUmalqura, NgbCalendarPersian, NgbCarousel, NgbCarouselConfig, NgbCarouselModule, NgbCheckBox, NgbCollapse, NgbCollapseModule, NgbDate, NgbDateAdapter, NgbDateNativeAdapter, NgbDateNativeUTCAdapter, NgbDateParserFormatter, NgbDatepicker, NgbDatepickerConfig, NgbDatepickerI18n, NgbDatepickerI18nHebrew, NgbDatepickerKeyboardService, NgbDatepickerModule, NgbDropdown, NgbDropdownAnchor, NgbDropdownConfig, NgbDropdownItem, NgbDropdownMenu, NgbDropdownModule, NgbDropdownToggle, NgbHighlight, NgbInputDatepicker, NgbInputDatepickerConfig, NgbModal, NgbModalConfig, NgbModalModule, NgbModalRef, NgbModule, NgbNav, NgbNavConfig, NgbNavContent, NgbNavItem, NgbNavLink, NgbNavModule, NgbNavOutlet, NgbNavbar, NgbPagination, NgbPaginationConfig, NgbPaginationEllipsis, NgbPaginationFirst, NgbPaginationLast, NgbPaginationModule, NgbPaginationNext, NgbPaginationNumber, NgbPaginationPrevious, NgbPanel, NgbPanelContent, NgbPanelHeader, NgbPanelTitle, NgbPanelToggle, NgbPopover, NgbPopoverConfig, NgbPopoverModule, NgbProgressbar, NgbProgressbarConfig, NgbProgressbarModule, NgbRadio, NgbRadioGroup, NgbRating, NgbRatingConfig, NgbRatingModule, NgbSlide, NgbSlideEventDirection, NgbSlideEventSource, NgbTab, NgbTabContent, NgbTabTitle, NgbTabset, NgbTabsetConfig, NgbTabsetModule, NgbTimeAdapter, NgbTimepicker, NgbTimepickerConfig, NgbTimepickerI18n, NgbTimepickerModule, NgbToast, NgbToastConfig, NgbToastHeader, NgbToastModule, NgbTooltip, NgbTooltipConfig, NgbTooltipModule, NgbTypeahead, NgbTypeaheadConfig, NgbTypeaheadModule, NGB_CAROUSEL_DIRECTIVES as ɵa, NGB_DATEPICKER_CALENDAR_FACTORY as ɵb, Live as ɵba, NgbCalendarHijri as ɵbb, ContentRef as ɵbc, NgbDatepickerMonthView as ɵc, NgbDatepickerDayView as ɵd, NgbDatepickerNavigation as ɵe, NgbDatepickerNavigationSelect as ɵf, NGB_DATEPICKER_18N_FACTORY as ɵg, NgbDatepickerI18nDefault as ɵh, NGB_DATEPICKER_DATE_ADAPTER_FACTORY as ɵi, NgbDateStructAdapter as ɵj, NGB_DATEPICKER_PARSER_FORMATTER_FACTORY as ɵk, NgbDateISOParserFormatter as ɵl, NgbPopoverWindow as ɵm, NGB_DATEPICKER_TIME_ADAPTER_FACTORY as ɵn, NgbTimeStructAdapter as ɵo, NGB_TIMEPICKER_I18N_FACTORY as ɵp, NgbTimepickerI18nDefault as ɵq, NgbTooltipWindow as ɵr, NgbTypeaheadWindow as ɵs, NgbDatepickerService as ɵt, NgbModalBackdrop as ɵu, NgbModalWindow as ɵv, NgbModalStack as ɵw, ScrollBar as ɵx, ARIA_LIVE_DELAY as ɵy, ARIA_LIVE_DELAY_FACTORY as ɵz };
  11292. //# sourceMappingURL=ng-bootstrap.js.map