forms.umd.js 263KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247
  1. /**
  2. * @license Angular v5.2.11
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/observable/forkJoin'), require('rxjs/observable/fromPromise'), require('rxjs/operator/map'), require('@angular/platform-browser')) :
  8. typeof define === 'function' && define.amd ? define('@angular/forms', ['exports', '@angular/core', 'rxjs/observable/forkJoin', 'rxjs/observable/fromPromise', 'rxjs/operator/map', '@angular/platform-browser'], factory) :
  9. (factory((global.ng = global.ng || {}, global.ng.forms = {}),global.ng.core,global.Rx.Observable,global.Rx.Observable,global.Rx.Observable.prototype,global.ng.platformBrowser));
  10. }(this, (function (exports,_angular_core,rxjs_observable_forkJoin,rxjs_observable_fromPromise,rxjs_operator_map,_angular_platformBrowser) { 'use strict';
  11. /*! *****************************************************************************
  12. Copyright (c) Microsoft Corporation. All rights reserved.
  13. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  14. this file except in compliance with the License. You may obtain a copy of the
  15. License at http://www.apache.org/licenses/LICENSE-2.0
  16. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  18. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  19. MERCHANTABLITY OR NON-INFRINGEMENT.
  20. See the Apache Version 2.0 License for specific language governing permissions
  21. and limitations under the License.
  22. ***************************************************************************** */
  23. /* global Reflect, Promise */
  24. var extendStatics = Object.setPrototypeOf ||
  25. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  26. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  27. function __extends(d, b) {
  28. extendStatics(d, b);
  29. function __() { this.constructor = d; }
  30. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  31. }
  32. var __assign = Object.assign || function __assign(t) {
  33. for (var s, i = 1, n = arguments.length; i < n; i++) {
  34. s = arguments[i];
  35. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  36. }
  37. return t;
  38. };
  39. /**
  40. * @license Angular v5.2.11
  41. * (c) 2010-2018 Google, Inc. https://angular.io/
  42. * License: MIT
  43. */
  44. /**
  45. * @fileoverview added by tsickle
  46. * @suppress {checkTypes} checked by tsc
  47. */
  48. /**
  49. * @license
  50. * Copyright Google Inc. All Rights Reserved.
  51. *
  52. * Use of this source code is governed by an MIT-style license that can be
  53. * found in the LICENSE file at https://angular.io/license
  54. */
  55. /**
  56. * Base class for control directives.
  57. *
  58. * Only used internally in the forms module.
  59. *
  60. * \@stable
  61. * @abstract
  62. */
  63. var AbstractControlDirective = /** @class */ (function () {
  64. function AbstractControlDirective() {
  65. }
  66. Object.defineProperty(AbstractControlDirective.prototype, "value", {
  67. /** The value of the control. */
  68. get: /**
  69. * The value of the control.
  70. * @return {?}
  71. */
  72. function () { return this.control ? this.control.value : null; },
  73. enumerable: true,
  74. configurable: true
  75. });
  76. Object.defineProperty(AbstractControlDirective.prototype, "valid", {
  77. /**
  78. * A control is `valid` when its `status === VALID`.
  79. *
  80. * In order to have this status, the control must have passed all its
  81. * validation checks.
  82. */
  83. get: /**
  84. * A control is `valid` when its `status === VALID`.
  85. *
  86. * In order to have this status, the control must have passed all its
  87. * validation checks.
  88. * @return {?}
  89. */
  90. function () { return this.control ? this.control.valid : null; },
  91. enumerable: true,
  92. configurable: true
  93. });
  94. Object.defineProperty(AbstractControlDirective.prototype, "invalid", {
  95. /**
  96. * A control is `invalid` when its `status === INVALID`.
  97. *
  98. * In order to have this status, the control must have failed
  99. * at least one of its validation checks.
  100. */
  101. get: /**
  102. * A control is `invalid` when its `status === INVALID`.
  103. *
  104. * In order to have this status, the control must have failed
  105. * at least one of its validation checks.
  106. * @return {?}
  107. */
  108. function () { return this.control ? this.control.invalid : null; },
  109. enumerable: true,
  110. configurable: true
  111. });
  112. Object.defineProperty(AbstractControlDirective.prototype, "pending", {
  113. /**
  114. * A control is `pending` when its `status === PENDING`.
  115. *
  116. * In order to have this status, the control must be in the
  117. * middle of conducting a validation check.
  118. */
  119. get: /**
  120. * A control is `pending` when its `status === PENDING`.
  121. *
  122. * In order to have this status, the control must be in the
  123. * middle of conducting a validation check.
  124. * @return {?}
  125. */
  126. function () { return this.control ? this.control.pending : null; },
  127. enumerable: true,
  128. configurable: true
  129. });
  130. Object.defineProperty(AbstractControlDirective.prototype, "disabled", {
  131. /**
  132. * A control is `disabled` when its `status === DISABLED`.
  133. *
  134. * Disabled controls are exempt from validation checks and
  135. * are not included in the aggregate value of their ancestor
  136. * controls.
  137. */
  138. get: /**
  139. * A control is `disabled` when its `status === DISABLED`.
  140. *
  141. * Disabled controls are exempt from validation checks and
  142. * are not included in the aggregate value of their ancestor
  143. * controls.
  144. * @return {?}
  145. */
  146. function () { return this.control ? this.control.disabled : null; },
  147. enumerable: true,
  148. configurable: true
  149. });
  150. Object.defineProperty(AbstractControlDirective.prototype, "enabled", {
  151. /**
  152. * A control is `enabled` as long as its `status !== DISABLED`.
  153. *
  154. * In other words, it has a status of `VALID`, `INVALID`, or
  155. * `PENDING`.
  156. */
  157. get: /**
  158. * A control is `enabled` as long as its `status !== DISABLED`.
  159. *
  160. * In other words, it has a status of `VALID`, `INVALID`, or
  161. * `PENDING`.
  162. * @return {?}
  163. */
  164. function () { return this.control ? this.control.enabled : null; },
  165. enumerable: true,
  166. configurable: true
  167. });
  168. Object.defineProperty(AbstractControlDirective.prototype, "errors", {
  169. /**
  170. * Returns any errors generated by failing validation. If there
  171. * are no errors, it will return null.
  172. */
  173. get: /**
  174. * Returns any errors generated by failing validation. If there
  175. * are no errors, it will return null.
  176. * @return {?}
  177. */
  178. function () { return this.control ? this.control.errors : null; },
  179. enumerable: true,
  180. configurable: true
  181. });
  182. Object.defineProperty(AbstractControlDirective.prototype, "pristine", {
  183. /**
  184. * A control is `pristine` if the user has not yet changed
  185. * the value in the UI.
  186. *
  187. * Note that programmatic changes to a control's value will
  188. * *not* mark it dirty.
  189. */
  190. get: /**
  191. * A control is `pristine` if the user has not yet changed
  192. * the value in the UI.
  193. *
  194. * Note that programmatic changes to a control's value will
  195. * *not* mark it dirty.
  196. * @return {?}
  197. */
  198. function () { return this.control ? this.control.pristine : null; },
  199. enumerable: true,
  200. configurable: true
  201. });
  202. Object.defineProperty(AbstractControlDirective.prototype, "dirty", {
  203. /**
  204. * A control is `dirty` if the user has changed the value
  205. * in the UI.
  206. *
  207. * Note that programmatic changes to a control's value will
  208. * *not* mark it dirty.
  209. */
  210. get: /**
  211. * A control is `dirty` if the user has changed the value
  212. * in the UI.
  213. *
  214. * Note that programmatic changes to a control's value will
  215. * *not* mark it dirty.
  216. * @return {?}
  217. */
  218. function () { return this.control ? this.control.dirty : null; },
  219. enumerable: true,
  220. configurable: true
  221. });
  222. Object.defineProperty(AbstractControlDirective.prototype, "touched", {
  223. /**
  224. * A control is marked `touched` once the user has triggered
  225. * a `blur` event on it.
  226. */
  227. get: /**
  228. * A control is marked `touched` once the user has triggered
  229. * a `blur` event on it.
  230. * @return {?}
  231. */
  232. function () { return this.control ? this.control.touched : null; },
  233. enumerable: true,
  234. configurable: true
  235. });
  236. Object.defineProperty(AbstractControlDirective.prototype, "status", {
  237. get: /**
  238. * @return {?}
  239. */
  240. function () { return this.control ? this.control.status : null; },
  241. enumerable: true,
  242. configurable: true
  243. });
  244. Object.defineProperty(AbstractControlDirective.prototype, "untouched", {
  245. /**
  246. * A control is `untouched` if the user has not yet triggered
  247. * a `blur` event on it.
  248. */
  249. get: /**
  250. * A control is `untouched` if the user has not yet triggered
  251. * a `blur` event on it.
  252. * @return {?}
  253. */
  254. function () { return this.control ? this.control.untouched : null; },
  255. enumerable: true,
  256. configurable: true
  257. });
  258. Object.defineProperty(AbstractControlDirective.prototype, "statusChanges", {
  259. /**
  260. * Emits an event every time the validation status of the control
  261. * is re-calculated.
  262. */
  263. get: /**
  264. * Emits an event every time the validation status of the control
  265. * is re-calculated.
  266. * @return {?}
  267. */
  268. function () {
  269. return this.control ? this.control.statusChanges : null;
  270. },
  271. enumerable: true,
  272. configurable: true
  273. });
  274. Object.defineProperty(AbstractControlDirective.prototype, "valueChanges", {
  275. /**
  276. * Emits an event every time the value of the control changes, in
  277. * the UI or programmatically.
  278. */
  279. get: /**
  280. * Emits an event every time the value of the control changes, in
  281. * the UI or programmatically.
  282. * @return {?}
  283. */
  284. function () {
  285. return this.control ? this.control.valueChanges : null;
  286. },
  287. enumerable: true,
  288. configurable: true
  289. });
  290. Object.defineProperty(AbstractControlDirective.prototype, "path", {
  291. /**
  292. * Returns an array that represents the path from the top-level form
  293. * to this control. Each index is the string name of the control on
  294. * that level.
  295. */
  296. get: /**
  297. * Returns an array that represents the path from the top-level form
  298. * to this control. Each index is the string name of the control on
  299. * that level.
  300. * @return {?}
  301. */
  302. function () { return null; },
  303. enumerable: true,
  304. configurable: true
  305. });
  306. /**
  307. * Resets the form control. This means by default:
  308. *
  309. * * it is marked as `pristine`
  310. * * it is marked as `untouched`
  311. * * value is set to null
  312. *
  313. * For more information, see {@link AbstractControl}.
  314. */
  315. /**
  316. * Resets the form control. This means by default:
  317. *
  318. * * it is marked as `pristine`
  319. * * it is marked as `untouched`
  320. * * value is set to null
  321. *
  322. * For more information, see {\@link AbstractControl}.
  323. * @param {?=} value
  324. * @return {?}
  325. */
  326. AbstractControlDirective.prototype.reset = /**
  327. * Resets the form control. This means by default:
  328. *
  329. * * it is marked as `pristine`
  330. * * it is marked as `untouched`
  331. * * value is set to null
  332. *
  333. * For more information, see {\@link AbstractControl}.
  334. * @param {?=} value
  335. * @return {?}
  336. */
  337. function (value) {
  338. if (value === void 0) { value = undefined; }
  339. if (this.control)
  340. this.control.reset(value);
  341. };
  342. /**
  343. * Returns true if the control with the given path has the error specified. Otherwise
  344. * returns false.
  345. *
  346. * If no path is given, it checks for the error on the present control.
  347. */
  348. /**
  349. * Returns true if the control with the given path has the error specified. Otherwise
  350. * returns false.
  351. *
  352. * If no path is given, it checks for the error on the present control.
  353. * @param {?} errorCode
  354. * @param {?=} path
  355. * @return {?}
  356. */
  357. AbstractControlDirective.prototype.hasError = /**
  358. * Returns true if the control with the given path has the error specified. Otherwise
  359. * returns false.
  360. *
  361. * If no path is given, it checks for the error on the present control.
  362. * @param {?} errorCode
  363. * @param {?=} path
  364. * @return {?}
  365. */
  366. function (errorCode, path) {
  367. return this.control ? this.control.hasError(errorCode, path) : false;
  368. };
  369. /**
  370. * Returns error data if the control with the given path has the error specified. Otherwise
  371. * returns null or undefined.
  372. *
  373. * If no path is given, it checks for the error on the present control.
  374. */
  375. /**
  376. * Returns error data if the control with the given path has the error specified. Otherwise
  377. * returns null or undefined.
  378. *
  379. * If no path is given, it checks for the error on the present control.
  380. * @param {?} errorCode
  381. * @param {?=} path
  382. * @return {?}
  383. */
  384. AbstractControlDirective.prototype.getError = /**
  385. * Returns error data if the control with the given path has the error specified. Otherwise
  386. * returns null or undefined.
  387. *
  388. * If no path is given, it checks for the error on the present control.
  389. * @param {?} errorCode
  390. * @param {?=} path
  391. * @return {?}
  392. */
  393. function (errorCode, path) {
  394. return this.control ? this.control.getError(errorCode, path) : null;
  395. };
  396. return AbstractControlDirective;
  397. }());
  398. /**
  399. * @fileoverview added by tsickle
  400. * @suppress {checkTypes} checked by tsc
  401. */
  402. /**
  403. * @license
  404. * Copyright Google Inc. All Rights Reserved.
  405. *
  406. * Use of this source code is governed by an MIT-style license that can be
  407. * found in the LICENSE file at https://angular.io/license
  408. */
  409. /**
  410. * A directive that contains multiple {\@link NgControl}s.
  411. *
  412. * Only used by the forms module.
  413. *
  414. * \@stable
  415. * @abstract
  416. */
  417. var ControlContainer = /** @class */ (function (_super) {
  418. __extends(ControlContainer, _super);
  419. function ControlContainer() {
  420. return _super !== null && _super.apply(this, arguments) || this;
  421. }
  422. Object.defineProperty(ControlContainer.prototype, "formDirective", {
  423. /**
  424. * Get the form to which this container belongs.
  425. */
  426. get: /**
  427. * Get the form to which this container belongs.
  428. * @return {?}
  429. */
  430. function () { return null; },
  431. enumerable: true,
  432. configurable: true
  433. });
  434. Object.defineProperty(ControlContainer.prototype, "path", {
  435. /**
  436. * Get the path to this container.
  437. */
  438. get: /**
  439. * Get the path to this container.
  440. * @return {?}
  441. */
  442. function () { return null; },
  443. enumerable: true,
  444. configurable: true
  445. });
  446. return ControlContainer;
  447. }(AbstractControlDirective));
  448. /**
  449. * @fileoverview added by tsickle
  450. * @suppress {checkTypes} checked by tsc
  451. */
  452. /**
  453. * @license
  454. * Copyright Google Inc. All Rights Reserved.
  455. *
  456. * Use of this source code is governed by an MIT-style license that can be
  457. * found in the LICENSE file at https://angular.io/license
  458. */
  459. /**
  460. * @param {?} value
  461. * @return {?}
  462. */
  463. function isEmptyInputValue(value) {
  464. // we don't check for string here so it also works with arrays
  465. return value == null || value.length === 0;
  466. }
  467. /**
  468. * Providers for validators to be used for {\@link FormControl}s in a form.
  469. *
  470. * Provide this using `multi: true` to add validators.
  471. *
  472. * ### Example
  473. *
  474. * ```typescript
  475. * \@Directive({
  476. * selector: '[custom-validator]',
  477. * providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}]
  478. * })
  479. * class CustomValidatorDirective implements Validator {
  480. * validate(control: AbstractControl): ValidationErrors | null {
  481. * return {"custom": true};
  482. * }
  483. * }
  484. * ```
  485. *
  486. * \@stable
  487. */
  488. var NG_VALIDATORS = new _angular_core.InjectionToken('NgValidators');
  489. /**
  490. * Providers for asynchronous validators to be used for {\@link FormControl}s
  491. * in a form.
  492. *
  493. * Provide this using `multi: true` to add validators.
  494. *
  495. * See {\@link NG_VALIDATORS} for more details.
  496. *
  497. * \@stable
  498. */
  499. var NG_ASYNC_VALIDATORS = new _angular_core.InjectionToken('NgAsyncValidators');
  500. var EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
  501. /**
  502. * Provides a set of validators used by form controls.
  503. *
  504. * A validator is a function that processes a {\@link FormControl} or collection of
  505. * controls and returns a map of errors. A null map means that validation has passed.
  506. *
  507. * ### Example
  508. *
  509. * ```typescript
  510. * var loginControl = new FormControl("", Validators.required)
  511. * ```
  512. *
  513. * \@stable
  514. */
  515. var Validators = /** @class */ (function () {
  516. function Validators() {
  517. }
  518. /**
  519. * Validator that requires controls to have a value greater than a number.
  520. *`min()` exists only as a function, not as a directive. For example,
  521. * `control = new FormControl('', Validators.min(3));`.
  522. */
  523. /**
  524. * Validator that requires controls to have a value greater than a number.
  525. * `min()` exists only as a function, not as a directive. For example,
  526. * `control = new FormControl('', Validators.min(3));`.
  527. * @param {?} min
  528. * @return {?}
  529. */
  530. Validators.min = /**
  531. * Validator that requires controls to have a value greater than a number.
  532. * `min()` exists only as a function, not as a directive. For example,
  533. * `control = new FormControl('', Validators.min(3));`.
  534. * @param {?} min
  535. * @return {?}
  536. */
  537. function (min) {
  538. return function (control) {
  539. if (isEmptyInputValue(control.value) || isEmptyInputValue(min)) {
  540. return null; // don't validate empty values to allow optional controls
  541. }
  542. var /** @type {?} */ value = parseFloat(control.value);
  543. // Controls with NaN values after parsing should be treated as not having a
  544. // minimum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-min
  545. return !isNaN(value) && value < min ? { 'min': { 'min': min, 'actual': control.value } } : null;
  546. };
  547. };
  548. /**
  549. * Validator that requires controls to have a value less than a number.
  550. * `max()` exists only as a function, not as a directive. For example,
  551. * `control = new FormControl('', Validators.max(15));`.
  552. */
  553. /**
  554. * Validator that requires controls to have a value less than a number.
  555. * `max()` exists only as a function, not as a directive. For example,
  556. * `control = new FormControl('', Validators.max(15));`.
  557. * @param {?} max
  558. * @return {?}
  559. */
  560. Validators.max = /**
  561. * Validator that requires controls to have a value less than a number.
  562. * `max()` exists only as a function, not as a directive. For example,
  563. * `control = new FormControl('', Validators.max(15));`.
  564. * @param {?} max
  565. * @return {?}
  566. */
  567. function (max) {
  568. return function (control) {
  569. if (isEmptyInputValue(control.value) || isEmptyInputValue(max)) {
  570. return null; // don't validate empty values to allow optional controls
  571. }
  572. var /** @type {?} */ value = parseFloat(control.value);
  573. // Controls with NaN values after parsing should be treated as not having a
  574. // maximum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-max
  575. return !isNaN(value) && value > max ? { 'max': { 'max': max, 'actual': control.value } } : null;
  576. };
  577. };
  578. /**
  579. * Validator that requires controls to have a non-empty value.
  580. */
  581. /**
  582. * Validator that requires controls to have a non-empty value.
  583. * @param {?} control
  584. * @return {?}
  585. */
  586. Validators.required = /**
  587. * Validator that requires controls to have a non-empty value.
  588. * @param {?} control
  589. * @return {?}
  590. */
  591. function (control) {
  592. return isEmptyInputValue(control.value) ? { 'required': true } : null;
  593. };
  594. /**
  595. * Validator that requires control value to be true.
  596. */
  597. /**
  598. * Validator that requires control value to be true.
  599. * @param {?} control
  600. * @return {?}
  601. */
  602. Validators.requiredTrue = /**
  603. * Validator that requires control value to be true.
  604. * @param {?} control
  605. * @return {?}
  606. */
  607. function (control) {
  608. return control.value === true ? null : { 'required': true };
  609. };
  610. /**
  611. * Validator that performs email validation.
  612. */
  613. /**
  614. * Validator that performs email validation.
  615. * @param {?} control
  616. * @return {?}
  617. */
  618. Validators.email = /**
  619. * Validator that performs email validation.
  620. * @param {?} control
  621. * @return {?}
  622. */
  623. function (control) {
  624. return EMAIL_REGEXP.test(control.value) ? null : { 'email': true };
  625. };
  626. /**
  627. * Validator that requires controls to have a value of a minimum length.
  628. */
  629. /**
  630. * Validator that requires controls to have a value of a minimum length.
  631. * @param {?} minLength
  632. * @return {?}
  633. */
  634. Validators.minLength = /**
  635. * Validator that requires controls to have a value of a minimum length.
  636. * @param {?} minLength
  637. * @return {?}
  638. */
  639. function (minLength) {
  640. return function (control) {
  641. if (isEmptyInputValue(control.value)) {
  642. return null; // don't validate empty values to allow optional controls
  643. }
  644. var /** @type {?} */ length = control.value ? control.value.length : 0;
  645. return length < minLength ?
  646. { 'minlength': { 'requiredLength': minLength, 'actualLength': length } } :
  647. null;
  648. };
  649. };
  650. /**
  651. * Validator that requires controls to have a value of a maximum length.
  652. */
  653. /**
  654. * Validator that requires controls to have a value of a maximum length.
  655. * @param {?} maxLength
  656. * @return {?}
  657. */
  658. Validators.maxLength = /**
  659. * Validator that requires controls to have a value of a maximum length.
  660. * @param {?} maxLength
  661. * @return {?}
  662. */
  663. function (maxLength) {
  664. return function (control) {
  665. var /** @type {?} */ length = control.value ? control.value.length : 0;
  666. return length > maxLength ?
  667. { 'maxlength': { 'requiredLength': maxLength, 'actualLength': length } } :
  668. null;
  669. };
  670. };
  671. /**
  672. * Validator that requires a control to match a regex to its value.
  673. */
  674. /**
  675. * Validator that requires a control to match a regex to its value.
  676. * @param {?} pattern
  677. * @return {?}
  678. */
  679. Validators.pattern = /**
  680. * Validator that requires a control to match a regex to its value.
  681. * @param {?} pattern
  682. * @return {?}
  683. */
  684. function (pattern) {
  685. if (!pattern)
  686. return Validators.nullValidator;
  687. var /** @type {?} */ regex;
  688. var /** @type {?} */ regexStr;
  689. if (typeof pattern === 'string') {
  690. regexStr = '';
  691. if (pattern.charAt(0) !== '^')
  692. regexStr += '^';
  693. regexStr += pattern;
  694. if (pattern.charAt(pattern.length - 1) !== '$')
  695. regexStr += '$';
  696. regex = new RegExp(regexStr);
  697. }
  698. else {
  699. regexStr = pattern.toString();
  700. regex = pattern;
  701. }
  702. return function (control) {
  703. if (isEmptyInputValue(control.value)) {
  704. return null; // don't validate empty values to allow optional controls
  705. }
  706. var /** @type {?} */ value = control.value;
  707. return regex.test(value) ? null :
  708. { 'pattern': { 'requiredPattern': regexStr, 'actualValue': value } };
  709. };
  710. };
  711. /**
  712. * No-op validator.
  713. */
  714. /**
  715. * No-op validator.
  716. * @param {?} c
  717. * @return {?}
  718. */
  719. Validators.nullValidator = /**
  720. * No-op validator.
  721. * @param {?} c
  722. * @return {?}
  723. */
  724. function (c) { return null; };
  725. /**
  726. * @param {?} validators
  727. * @return {?}
  728. */
  729. Validators.compose = /**
  730. * @param {?} validators
  731. * @return {?}
  732. */
  733. function (validators) {
  734. if (!validators)
  735. return null;
  736. var /** @type {?} */ presentValidators = /** @type {?} */ (validators.filter(isPresent));
  737. if (presentValidators.length == 0)
  738. return null;
  739. return function (control) {
  740. return _mergeErrors(_executeValidators(control, presentValidators));
  741. };
  742. };
  743. /**
  744. * @param {?} validators
  745. * @return {?}
  746. */
  747. Validators.composeAsync = /**
  748. * @param {?} validators
  749. * @return {?}
  750. */
  751. function (validators) {
  752. if (!validators)
  753. return null;
  754. var /** @type {?} */ presentValidators = /** @type {?} */ (validators.filter(isPresent));
  755. if (presentValidators.length == 0)
  756. return null;
  757. return function (control) {
  758. var /** @type {?} */ observables = _executeAsyncValidators(control, presentValidators).map(toObservable);
  759. return rxjs_operator_map.map.call(rxjs_observable_forkJoin.forkJoin(observables), _mergeErrors);
  760. };
  761. };
  762. return Validators;
  763. }());
  764. /**
  765. * @param {?} o
  766. * @return {?}
  767. */
  768. function isPresent(o) {
  769. return o != null;
  770. }
  771. /**
  772. * @param {?} r
  773. * @return {?}
  774. */
  775. function toObservable(r) {
  776. var /** @type {?} */ obs = _angular_core.ɵisPromise(r) ? rxjs_observable_fromPromise.fromPromise(r) : r;
  777. if (!(_angular_core.ɵisObservable(obs))) {
  778. throw new Error("Expected validator to return Promise or Observable.");
  779. }
  780. return obs;
  781. }
  782. /**
  783. * @param {?} control
  784. * @param {?} validators
  785. * @return {?}
  786. */
  787. function _executeValidators(control, validators) {
  788. return validators.map(function (v) { return v(control); });
  789. }
  790. /**
  791. * @param {?} control
  792. * @param {?} validators
  793. * @return {?}
  794. */
  795. function _executeAsyncValidators(control, validators) {
  796. return validators.map(function (v) { return v(control); });
  797. }
  798. /**
  799. * @param {?} arrayOfErrors
  800. * @return {?}
  801. */
  802. function _mergeErrors(arrayOfErrors) {
  803. var /** @type {?} */ res = arrayOfErrors.reduce(function (res, errors) {
  804. return errors != null ? __assign({}, /** @type {?} */ ((res)), errors) : /** @type {?} */ ((res));
  805. }, {});
  806. return Object.keys(res).length === 0 ? null : res;
  807. }
  808. /**
  809. * @fileoverview added by tsickle
  810. * @suppress {checkTypes} checked by tsc
  811. */
  812. /**
  813. * @license
  814. * Copyright Google Inc. All Rights Reserved.
  815. *
  816. * Use of this source code is governed by an MIT-style license that can be
  817. * found in the LICENSE file at https://angular.io/license
  818. */
  819. /**
  820. * A `ControlValueAccessor` acts as a bridge between the Angular forms API and a
  821. * native element in the DOM.
  822. *
  823. * Implement this interface if you want to create a custom form control directive
  824. * that integrates with Angular forms.
  825. *
  826. * \@stable
  827. * @record
  828. */
  829. /**
  830. * Used to provide a {\@link ControlValueAccessor} for form controls.
  831. *
  832. * See {\@link DefaultValueAccessor} for how to implement one.
  833. * \@stable
  834. */
  835. var NG_VALUE_ACCESSOR = new _angular_core.InjectionToken('NgValueAccessor');
  836. /**
  837. * @fileoverview added by tsickle
  838. * @suppress {checkTypes} checked by tsc
  839. */
  840. /**
  841. * @license
  842. * Copyright Google Inc. All Rights Reserved.
  843. *
  844. * Use of this source code is governed by an MIT-style license that can be
  845. * found in the LICENSE file at https://angular.io/license
  846. */
  847. var CHECKBOX_VALUE_ACCESSOR = {
  848. provide: NG_VALUE_ACCESSOR,
  849. useExisting: _angular_core.forwardRef(function () { return CheckboxControlValueAccessor; }),
  850. multi: true,
  851. };
  852. /**
  853. * The accessor for writing a value and listening to changes on a checkbox input element.
  854. *
  855. * ### Example
  856. * ```
  857. * <input type="checkbox" name="rememberLogin" ngModel>
  858. * ```
  859. *
  860. * \@stable
  861. */
  862. var CheckboxControlValueAccessor = /** @class */ (function () {
  863. function CheckboxControlValueAccessor(_renderer, _elementRef) {
  864. this._renderer = _renderer;
  865. this._elementRef = _elementRef;
  866. this.onChange = function (_) { };
  867. this.onTouched = function () { };
  868. }
  869. /**
  870. * @param {?} value
  871. * @return {?}
  872. */
  873. CheckboxControlValueAccessor.prototype.writeValue = /**
  874. * @param {?} value
  875. * @return {?}
  876. */
  877. function (value) {
  878. this._renderer.setProperty(this._elementRef.nativeElement, 'checked', value);
  879. };
  880. /**
  881. * @param {?} fn
  882. * @return {?}
  883. */
  884. CheckboxControlValueAccessor.prototype.registerOnChange = /**
  885. * @param {?} fn
  886. * @return {?}
  887. */
  888. function (fn) { this.onChange = fn; };
  889. /**
  890. * @param {?} fn
  891. * @return {?}
  892. */
  893. CheckboxControlValueAccessor.prototype.registerOnTouched = /**
  894. * @param {?} fn
  895. * @return {?}
  896. */
  897. function (fn) { this.onTouched = fn; };
  898. /**
  899. * @param {?} isDisabled
  900. * @return {?}
  901. */
  902. CheckboxControlValueAccessor.prototype.setDisabledState = /**
  903. * @param {?} isDisabled
  904. * @return {?}
  905. */
  906. function (isDisabled) {
  907. this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
  908. };
  909. CheckboxControlValueAccessor.decorators = [
  910. { type: _angular_core.Directive, args: [{
  911. selector: 'input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]',
  912. host: { '(change)': 'onChange($event.target.checked)', '(blur)': 'onTouched()' },
  913. providers: [CHECKBOX_VALUE_ACCESSOR]
  914. },] },
  915. ];
  916. /** @nocollapse */
  917. CheckboxControlValueAccessor.ctorParameters = function () { return [
  918. { type: _angular_core.Renderer2, },
  919. { type: _angular_core.ElementRef, },
  920. ]; };
  921. return CheckboxControlValueAccessor;
  922. }());
  923. /**
  924. * @fileoverview added by tsickle
  925. * @suppress {checkTypes} checked by tsc
  926. */
  927. /**
  928. * @license
  929. * Copyright Google Inc. All Rights Reserved.
  930. *
  931. * Use of this source code is governed by an MIT-style license that can be
  932. * found in the LICENSE file at https://angular.io/license
  933. */
  934. var DEFAULT_VALUE_ACCESSOR = {
  935. provide: NG_VALUE_ACCESSOR,
  936. useExisting: _angular_core.forwardRef(function () { return DefaultValueAccessor; }),
  937. multi: true
  938. };
  939. /**
  940. * We must check whether the agent is Android because composition events
  941. * behave differently between iOS and Android.
  942. * @return {?}
  943. */
  944. function _isAndroid() {
  945. var /** @type {?} */ userAgent = _angular_platformBrowser.ɵgetDOM() ? _angular_platformBrowser.ɵgetDOM().getUserAgent() : '';
  946. return /android (\d+)/.test(userAgent.toLowerCase());
  947. }
  948. /**
  949. * Turn this mode on if you want form directives to buffer IME input until compositionend
  950. * \@experimental
  951. */
  952. var COMPOSITION_BUFFER_MODE = new _angular_core.InjectionToken('CompositionEventMode');
  953. /**
  954. * The default accessor for writing a value and listening to changes that is used by the
  955. * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives.
  956. *
  957. * ### Example
  958. * ```
  959. * <input type="text" name="searchQuery" ngModel>
  960. * ```
  961. *
  962. * \@stable
  963. */
  964. var DefaultValueAccessor = /** @class */ (function () {
  965. function DefaultValueAccessor(_renderer, _elementRef, _compositionMode) {
  966. this._renderer = _renderer;
  967. this._elementRef = _elementRef;
  968. this._compositionMode = _compositionMode;
  969. this.onChange = function (_) { };
  970. this.onTouched = function () { };
  971. /**
  972. * Whether the user is creating a composition string (IME events).
  973. */
  974. this._composing = false;
  975. if (this._compositionMode == null) {
  976. this._compositionMode = !_isAndroid();
  977. }
  978. }
  979. /**
  980. * @param {?} value
  981. * @return {?}
  982. */
  983. DefaultValueAccessor.prototype.writeValue = /**
  984. * @param {?} value
  985. * @return {?}
  986. */
  987. function (value) {
  988. var /** @type {?} */ normalizedValue = value == null ? '' : value;
  989. this._renderer.setProperty(this._elementRef.nativeElement, 'value', normalizedValue);
  990. };
  991. /**
  992. * @param {?} fn
  993. * @return {?}
  994. */
  995. DefaultValueAccessor.prototype.registerOnChange = /**
  996. * @param {?} fn
  997. * @return {?}
  998. */
  999. function (fn) { this.onChange = fn; };
  1000. /**
  1001. * @param {?} fn
  1002. * @return {?}
  1003. */
  1004. DefaultValueAccessor.prototype.registerOnTouched = /**
  1005. * @param {?} fn
  1006. * @return {?}
  1007. */
  1008. function (fn) { this.onTouched = fn; };
  1009. /**
  1010. * @param {?} isDisabled
  1011. * @return {?}
  1012. */
  1013. DefaultValueAccessor.prototype.setDisabledState = /**
  1014. * @param {?} isDisabled
  1015. * @return {?}
  1016. */
  1017. function (isDisabled) {
  1018. this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
  1019. };
  1020. /** @internal */
  1021. /**
  1022. * \@internal
  1023. * @param {?} value
  1024. * @return {?}
  1025. */
  1026. DefaultValueAccessor.prototype._handleInput = /**
  1027. * \@internal
  1028. * @param {?} value
  1029. * @return {?}
  1030. */
  1031. function (value) {
  1032. if (!this._compositionMode || (this._compositionMode && !this._composing)) {
  1033. this.onChange(value);
  1034. }
  1035. };
  1036. /** @internal */
  1037. /**
  1038. * \@internal
  1039. * @return {?}
  1040. */
  1041. DefaultValueAccessor.prototype._compositionStart = /**
  1042. * \@internal
  1043. * @return {?}
  1044. */
  1045. function () { this._composing = true; };
  1046. /** @internal */
  1047. /**
  1048. * \@internal
  1049. * @param {?} value
  1050. * @return {?}
  1051. */
  1052. DefaultValueAccessor.prototype._compositionEnd = /**
  1053. * \@internal
  1054. * @param {?} value
  1055. * @return {?}
  1056. */
  1057. function (value) {
  1058. this._composing = false;
  1059. this._compositionMode && this.onChange(value);
  1060. };
  1061. DefaultValueAccessor.decorators = [
  1062. { type: _angular_core.Directive, args: [{
  1063. selector: 'input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]',
  1064. // TODO: vsavkin replace the above selector with the one below it once
  1065. // https://github.com/angular/angular/issues/3011 is implemented
  1066. // selector: '[ngModel],[formControl],[formControlName]',
  1067. host: {
  1068. '(input)': '$any(this)._handleInput($event.target.value)',
  1069. '(blur)': 'onTouched()',
  1070. '(compositionstart)': '$any(this)._compositionStart()',
  1071. '(compositionend)': '$any(this)._compositionEnd($event.target.value)'
  1072. },
  1073. providers: [DEFAULT_VALUE_ACCESSOR]
  1074. },] },
  1075. ];
  1076. /** @nocollapse */
  1077. DefaultValueAccessor.ctorParameters = function () { return [
  1078. { type: _angular_core.Renderer2, },
  1079. { type: _angular_core.ElementRef, },
  1080. { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [COMPOSITION_BUFFER_MODE,] },] },
  1081. ]; };
  1082. return DefaultValueAccessor;
  1083. }());
  1084. /**
  1085. * @fileoverview added by tsickle
  1086. * @suppress {checkTypes} checked by tsc
  1087. */
  1088. /**
  1089. * @license
  1090. * Copyright Google Inc. All Rights Reserved.
  1091. *
  1092. * Use of this source code is governed by an MIT-style license that can be
  1093. * found in the LICENSE file at https://angular.io/license
  1094. */
  1095. /**
  1096. * @param {?} validator
  1097. * @return {?}
  1098. */
  1099. function normalizeValidator(validator) {
  1100. if ((/** @type {?} */ (validator)).validate) {
  1101. return function (c) { return (/** @type {?} */ (validator)).validate(c); };
  1102. }
  1103. else {
  1104. return /** @type {?} */ (validator);
  1105. }
  1106. }
  1107. /**
  1108. * @param {?} validator
  1109. * @return {?}
  1110. */
  1111. function normalizeAsyncValidator(validator) {
  1112. if ((/** @type {?} */ (validator)).validate) {
  1113. return function (c) { return (/** @type {?} */ (validator)).validate(c); };
  1114. }
  1115. else {
  1116. return /** @type {?} */ (validator);
  1117. }
  1118. }
  1119. /**
  1120. * @fileoverview added by tsickle
  1121. * @suppress {checkTypes} checked by tsc
  1122. */
  1123. /**
  1124. * @license
  1125. * Copyright Google Inc. All Rights Reserved.
  1126. *
  1127. * Use of this source code is governed by an MIT-style license that can be
  1128. * found in the LICENSE file at https://angular.io/license
  1129. */
  1130. var NUMBER_VALUE_ACCESSOR = {
  1131. provide: NG_VALUE_ACCESSOR,
  1132. useExisting: _angular_core.forwardRef(function () { return NumberValueAccessor; }),
  1133. multi: true
  1134. };
  1135. /**
  1136. * The accessor for writing a number value and listening to changes that is used by the
  1137. * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives.
  1138. *
  1139. * ### Example
  1140. * ```
  1141. * <input type="number" [(ngModel)]="age">
  1142. * ```
  1143. */
  1144. var NumberValueAccessor = /** @class */ (function () {
  1145. function NumberValueAccessor(_renderer, _elementRef) {
  1146. this._renderer = _renderer;
  1147. this._elementRef = _elementRef;
  1148. this.onChange = function (_) { };
  1149. this.onTouched = function () { };
  1150. }
  1151. /**
  1152. * @param {?} value
  1153. * @return {?}
  1154. */
  1155. NumberValueAccessor.prototype.writeValue = /**
  1156. * @param {?} value
  1157. * @return {?}
  1158. */
  1159. function (value) {
  1160. // The value needs to be normalized for IE9, otherwise it is set to 'null' when null
  1161. var /** @type {?} */ normalizedValue = value == null ? '' : value;
  1162. this._renderer.setProperty(this._elementRef.nativeElement, 'value', normalizedValue);
  1163. };
  1164. /**
  1165. * @param {?} fn
  1166. * @return {?}
  1167. */
  1168. NumberValueAccessor.prototype.registerOnChange = /**
  1169. * @param {?} fn
  1170. * @return {?}
  1171. */
  1172. function (fn) {
  1173. this.onChange = function (value) { fn(value == '' ? null : parseFloat(value)); };
  1174. };
  1175. /**
  1176. * @param {?} fn
  1177. * @return {?}
  1178. */
  1179. NumberValueAccessor.prototype.registerOnTouched = /**
  1180. * @param {?} fn
  1181. * @return {?}
  1182. */
  1183. function (fn) { this.onTouched = fn; };
  1184. /**
  1185. * @param {?} isDisabled
  1186. * @return {?}
  1187. */
  1188. NumberValueAccessor.prototype.setDisabledState = /**
  1189. * @param {?} isDisabled
  1190. * @return {?}
  1191. */
  1192. function (isDisabled) {
  1193. this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
  1194. };
  1195. NumberValueAccessor.decorators = [
  1196. { type: _angular_core.Directive, args: [{
  1197. selector: 'input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]',
  1198. host: {
  1199. '(change)': 'onChange($event.target.value)',
  1200. '(input)': 'onChange($event.target.value)',
  1201. '(blur)': 'onTouched()'
  1202. },
  1203. providers: [NUMBER_VALUE_ACCESSOR]
  1204. },] },
  1205. ];
  1206. /** @nocollapse */
  1207. NumberValueAccessor.ctorParameters = function () { return [
  1208. { type: _angular_core.Renderer2, },
  1209. { type: _angular_core.ElementRef, },
  1210. ]; };
  1211. return NumberValueAccessor;
  1212. }());
  1213. /**
  1214. * @fileoverview added by tsickle
  1215. * @suppress {checkTypes} checked by tsc
  1216. */
  1217. /**
  1218. * @license
  1219. * Copyright Google Inc. All Rights Reserved.
  1220. *
  1221. * Use of this source code is governed by an MIT-style license that can be
  1222. * found in the LICENSE file at https://angular.io/license
  1223. */
  1224. /**
  1225. * @return {?}
  1226. */
  1227. function unimplemented() {
  1228. throw new Error('unimplemented');
  1229. }
  1230. /**
  1231. * A base class that all control directive extend.
  1232. * It binds a {\@link FormControl} object to a DOM element.
  1233. *
  1234. * Used internally by Angular forms.
  1235. *
  1236. * \@stable
  1237. * @abstract
  1238. */
  1239. var NgControl = /** @class */ (function (_super) {
  1240. __extends(NgControl, _super);
  1241. function NgControl() {
  1242. var _this = _super !== null && _super.apply(this, arguments) || this;
  1243. /**
  1244. * \@internal
  1245. */
  1246. _this._parent = null;
  1247. _this.name = null;
  1248. _this.valueAccessor = null;
  1249. /**
  1250. * \@internal
  1251. */
  1252. _this._rawValidators = [];
  1253. /**
  1254. * \@internal
  1255. */
  1256. _this._rawAsyncValidators = [];
  1257. return _this;
  1258. }
  1259. Object.defineProperty(NgControl.prototype, "validator", {
  1260. get: /**
  1261. * @return {?}
  1262. */
  1263. function () { return /** @type {?} */ (unimplemented()); },
  1264. enumerable: true,
  1265. configurable: true
  1266. });
  1267. Object.defineProperty(NgControl.prototype, "asyncValidator", {
  1268. get: /**
  1269. * @return {?}
  1270. */
  1271. function () { return /** @type {?} */ (unimplemented()); },
  1272. enumerable: true,
  1273. configurable: true
  1274. });
  1275. return NgControl;
  1276. }(AbstractControlDirective));
  1277. /**
  1278. * @fileoverview added by tsickle
  1279. * @suppress {checkTypes} checked by tsc
  1280. */
  1281. /**
  1282. * @license
  1283. * Copyright Google Inc. All Rights Reserved.
  1284. *
  1285. * Use of this source code is governed by an MIT-style license that can be
  1286. * found in the LICENSE file at https://angular.io/license
  1287. */
  1288. var RADIO_VALUE_ACCESSOR = {
  1289. provide: NG_VALUE_ACCESSOR,
  1290. useExisting: _angular_core.forwardRef(function () { return RadioControlValueAccessor; }),
  1291. multi: true
  1292. };
  1293. /**
  1294. * Internal class used by Angular to uncheck radio buttons with the matching name.
  1295. */
  1296. var RadioControlRegistry = /** @class */ (function () {
  1297. function RadioControlRegistry() {
  1298. this._accessors = [];
  1299. }
  1300. /**
  1301. * @param {?} control
  1302. * @param {?} accessor
  1303. * @return {?}
  1304. */
  1305. RadioControlRegistry.prototype.add = /**
  1306. * @param {?} control
  1307. * @param {?} accessor
  1308. * @return {?}
  1309. */
  1310. function (control, accessor) {
  1311. this._accessors.push([control, accessor]);
  1312. };
  1313. /**
  1314. * @param {?} accessor
  1315. * @return {?}
  1316. */
  1317. RadioControlRegistry.prototype.remove = /**
  1318. * @param {?} accessor
  1319. * @return {?}
  1320. */
  1321. function (accessor) {
  1322. for (var /** @type {?} */ i = this._accessors.length - 1; i >= 0; --i) {
  1323. if (this._accessors[i][1] === accessor) {
  1324. this._accessors.splice(i, 1);
  1325. return;
  1326. }
  1327. }
  1328. };
  1329. /**
  1330. * @param {?} accessor
  1331. * @return {?}
  1332. */
  1333. RadioControlRegistry.prototype.select = /**
  1334. * @param {?} accessor
  1335. * @return {?}
  1336. */
  1337. function (accessor) {
  1338. var _this = this;
  1339. this._accessors.forEach(function (c) {
  1340. if (_this._isSameGroup(c, accessor) && c[1] !== accessor) {
  1341. c[1].fireUncheck(accessor.value);
  1342. }
  1343. });
  1344. };
  1345. /**
  1346. * @param {?} controlPair
  1347. * @param {?} accessor
  1348. * @return {?}
  1349. */
  1350. RadioControlRegistry.prototype._isSameGroup = /**
  1351. * @param {?} controlPair
  1352. * @param {?} accessor
  1353. * @return {?}
  1354. */
  1355. function (controlPair, accessor) {
  1356. if (!controlPair[0].control)
  1357. return false;
  1358. return controlPair[0]._parent === accessor._control._parent &&
  1359. controlPair[1].name === accessor.name;
  1360. };
  1361. RadioControlRegistry.decorators = [
  1362. { type: _angular_core.Injectable },
  1363. ];
  1364. /** @nocollapse */
  1365. RadioControlRegistry.ctorParameters = function () { return []; };
  1366. return RadioControlRegistry;
  1367. }());
  1368. /**
  1369. * \@whatItDoes Writes radio control values and listens to radio control changes.
  1370. *
  1371. * Used by {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName}
  1372. * to keep the view synced with the {\@link FormControl} model.
  1373. *
  1374. * \@howToUse
  1375. *
  1376. * If you have imported the {\@link FormsModule} or the {\@link ReactiveFormsModule}, this
  1377. * value accessor will be active on any radio control that has a form directive. You do
  1378. * **not** need to add a special selector to activate it.
  1379. *
  1380. * ### How to use radio buttons with form directives
  1381. *
  1382. * To use radio buttons in a template-driven form, you'll want to ensure that radio buttons
  1383. * in the same group have the same `name` attribute. Radio buttons with different `name`
  1384. * attributes do not affect each other.
  1385. *
  1386. * {\@example forms/ts/radioButtons/radio_button_example.ts region='TemplateDriven'}
  1387. *
  1388. * When using radio buttons in a reactive form, radio buttons in the same group should have the
  1389. * same `formControlName`. You can also add a `name` attribute, but it's optional.
  1390. *
  1391. * {\@example forms/ts/reactiveRadioButtons/reactive_radio_button_example.ts region='Reactive'}
  1392. *
  1393. * * **npm package**: `\@angular/forms`
  1394. *
  1395. * \@stable
  1396. */
  1397. var RadioControlValueAccessor = /** @class */ (function () {
  1398. function RadioControlValueAccessor(_renderer, _elementRef, _registry, _injector) {
  1399. this._renderer = _renderer;
  1400. this._elementRef = _elementRef;
  1401. this._registry = _registry;
  1402. this._injector = _injector;
  1403. this.onChange = function () { };
  1404. this.onTouched = function () { };
  1405. }
  1406. /**
  1407. * @return {?}
  1408. */
  1409. RadioControlValueAccessor.prototype.ngOnInit = /**
  1410. * @return {?}
  1411. */
  1412. function () {
  1413. this._control = this._injector.get(NgControl);
  1414. this._checkName();
  1415. this._registry.add(this._control, this);
  1416. };
  1417. /**
  1418. * @return {?}
  1419. */
  1420. RadioControlValueAccessor.prototype.ngOnDestroy = /**
  1421. * @return {?}
  1422. */
  1423. function () { this._registry.remove(this); };
  1424. /**
  1425. * @param {?} value
  1426. * @return {?}
  1427. */
  1428. RadioControlValueAccessor.prototype.writeValue = /**
  1429. * @param {?} value
  1430. * @return {?}
  1431. */
  1432. function (value) {
  1433. this._state = value === this.value;
  1434. this._renderer.setProperty(this._elementRef.nativeElement, 'checked', this._state);
  1435. };
  1436. /**
  1437. * @param {?} fn
  1438. * @return {?}
  1439. */
  1440. RadioControlValueAccessor.prototype.registerOnChange = /**
  1441. * @param {?} fn
  1442. * @return {?}
  1443. */
  1444. function (fn) {
  1445. var _this = this;
  1446. this._fn = fn;
  1447. this.onChange = function () {
  1448. fn(_this.value);
  1449. _this._registry.select(_this);
  1450. };
  1451. };
  1452. /**
  1453. * @param {?} value
  1454. * @return {?}
  1455. */
  1456. RadioControlValueAccessor.prototype.fireUncheck = /**
  1457. * @param {?} value
  1458. * @return {?}
  1459. */
  1460. function (value) { this.writeValue(value); };
  1461. /**
  1462. * @param {?} fn
  1463. * @return {?}
  1464. */
  1465. RadioControlValueAccessor.prototype.registerOnTouched = /**
  1466. * @param {?} fn
  1467. * @return {?}
  1468. */
  1469. function (fn) { this.onTouched = fn; };
  1470. /**
  1471. * @param {?} isDisabled
  1472. * @return {?}
  1473. */
  1474. RadioControlValueAccessor.prototype.setDisabledState = /**
  1475. * @param {?} isDisabled
  1476. * @return {?}
  1477. */
  1478. function (isDisabled) {
  1479. this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
  1480. };
  1481. /**
  1482. * @return {?}
  1483. */
  1484. RadioControlValueAccessor.prototype._checkName = /**
  1485. * @return {?}
  1486. */
  1487. function () {
  1488. if (this.name && this.formControlName && this.name !== this.formControlName) {
  1489. this._throwNameError();
  1490. }
  1491. if (!this.name && this.formControlName)
  1492. this.name = this.formControlName;
  1493. };
  1494. /**
  1495. * @return {?}
  1496. */
  1497. RadioControlValueAccessor.prototype._throwNameError = /**
  1498. * @return {?}
  1499. */
  1500. function () {
  1501. throw new Error("\n If you define both a name and a formControlName attribute on your radio button, their values\n must match. Ex: <input type=\"radio\" formControlName=\"food\" name=\"food\">\n ");
  1502. };
  1503. RadioControlValueAccessor.decorators = [
  1504. { type: _angular_core.Directive, args: [{
  1505. selector: 'input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]',
  1506. host: { '(change)': 'onChange()', '(blur)': 'onTouched()' },
  1507. providers: [RADIO_VALUE_ACCESSOR]
  1508. },] },
  1509. ];
  1510. /** @nocollapse */
  1511. RadioControlValueAccessor.ctorParameters = function () { return [
  1512. { type: _angular_core.Renderer2, },
  1513. { type: _angular_core.ElementRef, },
  1514. { type: RadioControlRegistry, },
  1515. { type: _angular_core.Injector, },
  1516. ]; };
  1517. RadioControlValueAccessor.propDecorators = {
  1518. "name": [{ type: _angular_core.Input },],
  1519. "formControlName": [{ type: _angular_core.Input },],
  1520. "value": [{ type: _angular_core.Input },],
  1521. };
  1522. return RadioControlValueAccessor;
  1523. }());
  1524. /**
  1525. * @fileoverview added by tsickle
  1526. * @suppress {checkTypes} checked by tsc
  1527. */
  1528. /**
  1529. * @license
  1530. * Copyright Google Inc. All Rights Reserved.
  1531. *
  1532. * Use of this source code is governed by an MIT-style license that can be
  1533. * found in the LICENSE file at https://angular.io/license
  1534. */
  1535. var RANGE_VALUE_ACCESSOR = {
  1536. provide: NG_VALUE_ACCESSOR,
  1537. useExisting: _angular_core.forwardRef(function () { return RangeValueAccessor; }),
  1538. multi: true
  1539. };
  1540. /**
  1541. * The accessor for writing a range value and listening to changes that is used by the
  1542. * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives.
  1543. *
  1544. * ### Example
  1545. * ```
  1546. * <input type="range" [(ngModel)]="age" >
  1547. * ```
  1548. */
  1549. var RangeValueAccessor = /** @class */ (function () {
  1550. function RangeValueAccessor(_renderer, _elementRef) {
  1551. this._renderer = _renderer;
  1552. this._elementRef = _elementRef;
  1553. this.onChange = function (_) { };
  1554. this.onTouched = function () { };
  1555. }
  1556. /**
  1557. * @param {?} value
  1558. * @return {?}
  1559. */
  1560. RangeValueAccessor.prototype.writeValue = /**
  1561. * @param {?} value
  1562. * @return {?}
  1563. */
  1564. function (value) {
  1565. this._renderer.setProperty(this._elementRef.nativeElement, 'value', parseFloat(value));
  1566. };
  1567. /**
  1568. * @param {?} fn
  1569. * @return {?}
  1570. */
  1571. RangeValueAccessor.prototype.registerOnChange = /**
  1572. * @param {?} fn
  1573. * @return {?}
  1574. */
  1575. function (fn) {
  1576. this.onChange = function (value) { fn(value == '' ? null : parseFloat(value)); };
  1577. };
  1578. /**
  1579. * @param {?} fn
  1580. * @return {?}
  1581. */
  1582. RangeValueAccessor.prototype.registerOnTouched = /**
  1583. * @param {?} fn
  1584. * @return {?}
  1585. */
  1586. function (fn) { this.onTouched = fn; };
  1587. /**
  1588. * @param {?} isDisabled
  1589. * @return {?}
  1590. */
  1591. RangeValueAccessor.prototype.setDisabledState = /**
  1592. * @param {?} isDisabled
  1593. * @return {?}
  1594. */
  1595. function (isDisabled) {
  1596. this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
  1597. };
  1598. RangeValueAccessor.decorators = [
  1599. { type: _angular_core.Directive, args: [{
  1600. selector: 'input[type=range][formControlName],input[type=range][formControl],input[type=range][ngModel]',
  1601. host: {
  1602. '(change)': 'onChange($event.target.value)',
  1603. '(input)': 'onChange($event.target.value)',
  1604. '(blur)': 'onTouched()'
  1605. },
  1606. providers: [RANGE_VALUE_ACCESSOR]
  1607. },] },
  1608. ];
  1609. /** @nocollapse */
  1610. RangeValueAccessor.ctorParameters = function () { return [
  1611. { type: _angular_core.Renderer2, },
  1612. { type: _angular_core.ElementRef, },
  1613. ]; };
  1614. return RangeValueAccessor;
  1615. }());
  1616. /**
  1617. * @fileoverview added by tsickle
  1618. * @suppress {checkTypes} checked by tsc
  1619. */
  1620. /**
  1621. * @license
  1622. * Copyright Google Inc. All Rights Reserved.
  1623. *
  1624. * Use of this source code is governed by an MIT-style license that can be
  1625. * found in the LICENSE file at https://angular.io/license
  1626. */
  1627. var SELECT_VALUE_ACCESSOR = {
  1628. provide: NG_VALUE_ACCESSOR,
  1629. useExisting: _angular_core.forwardRef(function () { return SelectControlValueAccessor; }),
  1630. multi: true
  1631. };
  1632. /**
  1633. * @param {?} id
  1634. * @param {?} value
  1635. * @return {?}
  1636. */
  1637. function _buildValueString(id, value) {
  1638. if (id == null)
  1639. return "" + value;
  1640. if (value && typeof value === 'object')
  1641. value = 'Object';
  1642. return (id + ": " + value).slice(0, 50);
  1643. }
  1644. /**
  1645. * @param {?} valueString
  1646. * @return {?}
  1647. */
  1648. function _extractId(valueString) {
  1649. return valueString.split(':')[0];
  1650. }
  1651. /**
  1652. * \@whatItDoes Writes values and listens to changes on a select element.
  1653. *
  1654. * Used by {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName}
  1655. * to keep the view synced with the {\@link FormControl} model.
  1656. *
  1657. * \@howToUse
  1658. *
  1659. * If you have imported the {\@link FormsModule} or the {\@link ReactiveFormsModule}, this
  1660. * value accessor will be active on any select control that has a form directive. You do
  1661. * **not** need to add a special selector to activate it.
  1662. *
  1663. * ### How to use select controls with form directives
  1664. *
  1665. * To use a select in a template-driven form, simply add an `ngModel` and a `name`
  1666. * attribute to the main `<select>` tag.
  1667. *
  1668. * If your option values are simple strings, you can bind to the normal `value` property
  1669. * on the option. If your option values happen to be objects (and you'd like to save the
  1670. * selection in your form as an object), use `ngValue` instead:
  1671. *
  1672. * {\@example forms/ts/selectControl/select_control_example.ts region='Component'}
  1673. *
  1674. * In reactive forms, you'll also want to add your form directive (`formControlName` or
  1675. * `formControl`) on the main `<select>` tag. Like in the former example, you have the
  1676. * choice of binding to the `value` or `ngValue` property on the select's options.
  1677. *
  1678. * {\@example forms/ts/reactiveSelectControl/reactive_select_control_example.ts region='Component'}
  1679. *
  1680. * ### Caveat: Option selection
  1681. *
  1682. * Angular uses object identity to select option. It's possible for the identities of items
  1683. * to change while the data does not. This can happen, for example, if the items are produced
  1684. * from an RPC to the server, and that RPC is re-run. Even if the data hasn't changed, the
  1685. * second response will produce objects with different identities.
  1686. *
  1687. * To customize the default option comparison algorithm, `<select>` supports `compareWith` input.
  1688. * `compareWith` takes a **function** which has two arguments: `option1` and `option2`.
  1689. * If `compareWith` is given, Angular selects option by the return value of the function.
  1690. *
  1691. * #### Syntax
  1692. *
  1693. * ```
  1694. * <select [compareWith]="compareFn" [(ngModel)]="selectedCountries">
  1695. * <option *ngFor="let country of countries" [ngValue]="country">
  1696. * {{country.name}}
  1697. * </option>
  1698. * </select>
  1699. *
  1700. * compareFn(c1: Country, c2: Country): boolean {
  1701. * return c1 && c2 ? c1.id === c2.id : c1 === c2;
  1702. * }
  1703. * ```
  1704. *
  1705. * Note: We listen to the 'change' event because 'input' events aren't fired
  1706. * for selects in Firefox and IE:
  1707. * https://bugzilla.mozilla.org/show_bug.cgi?id=1024350
  1708. * https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/4660045/
  1709. *
  1710. * * **npm package**: `\@angular/forms`
  1711. *
  1712. * \@stable
  1713. */
  1714. var SelectControlValueAccessor = /** @class */ (function () {
  1715. function SelectControlValueAccessor(_renderer, _elementRef) {
  1716. this._renderer = _renderer;
  1717. this._elementRef = _elementRef;
  1718. /**
  1719. * \@internal
  1720. */
  1721. this._optionMap = new Map();
  1722. /**
  1723. * \@internal
  1724. */
  1725. this._idCounter = 0;
  1726. this.onChange = function (_) { };
  1727. this.onTouched = function () { };
  1728. this._compareWith = _angular_core.ɵlooseIdentical;
  1729. }
  1730. Object.defineProperty(SelectControlValueAccessor.prototype, "compareWith", {
  1731. set: /**
  1732. * @param {?} fn
  1733. * @return {?}
  1734. */
  1735. function (fn) {
  1736. if (typeof fn !== 'function') {
  1737. throw new Error("compareWith must be a function, but received " + JSON.stringify(fn));
  1738. }
  1739. this._compareWith = fn;
  1740. },
  1741. enumerable: true,
  1742. configurable: true
  1743. });
  1744. /**
  1745. * @param {?} value
  1746. * @return {?}
  1747. */
  1748. SelectControlValueAccessor.prototype.writeValue = /**
  1749. * @param {?} value
  1750. * @return {?}
  1751. */
  1752. function (value) {
  1753. this.value = value;
  1754. var /** @type {?} */ id = this._getOptionId(value);
  1755. if (id == null) {
  1756. this._renderer.setProperty(this._elementRef.nativeElement, 'selectedIndex', -1);
  1757. }
  1758. var /** @type {?} */ valueString = _buildValueString(id, value);
  1759. this._renderer.setProperty(this._elementRef.nativeElement, 'value', valueString);
  1760. };
  1761. /**
  1762. * @param {?} fn
  1763. * @return {?}
  1764. */
  1765. SelectControlValueAccessor.prototype.registerOnChange = /**
  1766. * @param {?} fn
  1767. * @return {?}
  1768. */
  1769. function (fn) {
  1770. var _this = this;
  1771. this.onChange = function (valueString) {
  1772. _this.value = _this._getOptionValue(valueString);
  1773. fn(_this.value);
  1774. };
  1775. };
  1776. /**
  1777. * @param {?} fn
  1778. * @return {?}
  1779. */
  1780. SelectControlValueAccessor.prototype.registerOnTouched = /**
  1781. * @param {?} fn
  1782. * @return {?}
  1783. */
  1784. function (fn) { this.onTouched = fn; };
  1785. /**
  1786. * @param {?} isDisabled
  1787. * @return {?}
  1788. */
  1789. SelectControlValueAccessor.prototype.setDisabledState = /**
  1790. * @param {?} isDisabled
  1791. * @return {?}
  1792. */
  1793. function (isDisabled) {
  1794. this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
  1795. };
  1796. /** @internal */
  1797. /**
  1798. * \@internal
  1799. * @return {?}
  1800. */
  1801. SelectControlValueAccessor.prototype._registerOption = /**
  1802. * \@internal
  1803. * @return {?}
  1804. */
  1805. function () { return (this._idCounter++).toString(); };
  1806. /** @internal */
  1807. /**
  1808. * \@internal
  1809. * @param {?} value
  1810. * @return {?}
  1811. */
  1812. SelectControlValueAccessor.prototype._getOptionId = /**
  1813. * \@internal
  1814. * @param {?} value
  1815. * @return {?}
  1816. */
  1817. function (value) {
  1818. for (var _i = 0, _a = Array.from(this._optionMap.keys()); _i < _a.length; _i++) {
  1819. var id = _a[_i];
  1820. if (this._compareWith(this._optionMap.get(id), value))
  1821. return id;
  1822. }
  1823. return null;
  1824. };
  1825. /** @internal */
  1826. /**
  1827. * \@internal
  1828. * @param {?} valueString
  1829. * @return {?}
  1830. */
  1831. SelectControlValueAccessor.prototype._getOptionValue = /**
  1832. * \@internal
  1833. * @param {?} valueString
  1834. * @return {?}
  1835. */
  1836. function (valueString) {
  1837. var /** @type {?} */ id = _extractId(valueString);
  1838. return this._optionMap.has(id) ? this._optionMap.get(id) : valueString;
  1839. };
  1840. SelectControlValueAccessor.decorators = [
  1841. { type: _angular_core.Directive, args: [{
  1842. selector: 'select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]',
  1843. host: { '(change)': 'onChange($event.target.value)', '(blur)': 'onTouched()' },
  1844. providers: [SELECT_VALUE_ACCESSOR]
  1845. },] },
  1846. ];
  1847. /** @nocollapse */
  1848. SelectControlValueAccessor.ctorParameters = function () { return [
  1849. { type: _angular_core.Renderer2, },
  1850. { type: _angular_core.ElementRef, },
  1851. ]; };
  1852. SelectControlValueAccessor.propDecorators = {
  1853. "compareWith": [{ type: _angular_core.Input },],
  1854. };
  1855. return SelectControlValueAccessor;
  1856. }());
  1857. /**
  1858. * \@whatItDoes Marks `<option>` as dynamic, so Angular can be notified when options change.
  1859. *
  1860. * \@howToUse
  1861. *
  1862. * See docs for {\@link SelectControlValueAccessor} for usage examples.
  1863. *
  1864. * \@stable
  1865. */
  1866. var NgSelectOption = /** @class */ (function () {
  1867. function NgSelectOption(_element, _renderer, _select) {
  1868. this._element = _element;
  1869. this._renderer = _renderer;
  1870. this._select = _select;
  1871. if (this._select)
  1872. this.id = this._select._registerOption();
  1873. }
  1874. Object.defineProperty(NgSelectOption.prototype, "ngValue", {
  1875. set: /**
  1876. * @param {?} value
  1877. * @return {?}
  1878. */
  1879. function (value) {
  1880. if (this._select == null)
  1881. return;
  1882. this._select._optionMap.set(this.id, value);
  1883. this._setElementValue(_buildValueString(this.id, value));
  1884. this._select.writeValue(this._select.value);
  1885. },
  1886. enumerable: true,
  1887. configurable: true
  1888. });
  1889. Object.defineProperty(NgSelectOption.prototype, "value", {
  1890. set: /**
  1891. * @param {?} value
  1892. * @return {?}
  1893. */
  1894. function (value) {
  1895. this._setElementValue(value);
  1896. if (this._select)
  1897. this._select.writeValue(this._select.value);
  1898. },
  1899. enumerable: true,
  1900. configurable: true
  1901. });
  1902. /** @internal */
  1903. /**
  1904. * \@internal
  1905. * @param {?} value
  1906. * @return {?}
  1907. */
  1908. NgSelectOption.prototype._setElementValue = /**
  1909. * \@internal
  1910. * @param {?} value
  1911. * @return {?}
  1912. */
  1913. function (value) {
  1914. this._renderer.setProperty(this._element.nativeElement, 'value', value);
  1915. };
  1916. /**
  1917. * @return {?}
  1918. */
  1919. NgSelectOption.prototype.ngOnDestroy = /**
  1920. * @return {?}
  1921. */
  1922. function () {
  1923. if (this._select) {
  1924. this._select._optionMap.delete(this.id);
  1925. this._select.writeValue(this._select.value);
  1926. }
  1927. };
  1928. NgSelectOption.decorators = [
  1929. { type: _angular_core.Directive, args: [{ selector: 'option' },] },
  1930. ];
  1931. /** @nocollapse */
  1932. NgSelectOption.ctorParameters = function () { return [
  1933. { type: _angular_core.ElementRef, },
  1934. { type: _angular_core.Renderer2, },
  1935. { type: SelectControlValueAccessor, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host },] },
  1936. ]; };
  1937. NgSelectOption.propDecorators = {
  1938. "ngValue": [{ type: _angular_core.Input, args: ['ngValue',] },],
  1939. "value": [{ type: _angular_core.Input, args: ['value',] },],
  1940. };
  1941. return NgSelectOption;
  1942. }());
  1943. /**
  1944. * @fileoverview added by tsickle
  1945. * @suppress {checkTypes} checked by tsc
  1946. */
  1947. /**
  1948. * @license
  1949. * Copyright Google Inc. All Rights Reserved.
  1950. *
  1951. * Use of this source code is governed by an MIT-style license that can be
  1952. * found in the LICENSE file at https://angular.io/license
  1953. */
  1954. var SELECT_MULTIPLE_VALUE_ACCESSOR = {
  1955. provide: NG_VALUE_ACCESSOR,
  1956. useExisting: _angular_core.forwardRef(function () { return SelectMultipleControlValueAccessor; }),
  1957. multi: true
  1958. };
  1959. /**
  1960. * @param {?} id
  1961. * @param {?} value
  1962. * @return {?}
  1963. */
  1964. function _buildValueString$1(id, value) {
  1965. if (id == null)
  1966. return "" + value;
  1967. if (typeof value === 'string')
  1968. value = "'" + value + "'";
  1969. if (value && typeof value === 'object')
  1970. value = 'Object';
  1971. return (id + ": " + value).slice(0, 50);
  1972. }
  1973. /**
  1974. * @param {?} valueString
  1975. * @return {?}
  1976. */
  1977. function _extractId$1(valueString) {
  1978. return valueString.split(':')[0];
  1979. }
  1980. /**
  1981. * The accessor for writing a value and listening to changes on a select element.
  1982. *
  1983. * ### Caveat: Options selection
  1984. *
  1985. * Angular uses object identity to select options. It's possible for the identities of items
  1986. * to change while the data does not. This can happen, for example, if the items are produced
  1987. * from an RPC to the server, and that RPC is re-run. Even if the data hasn't changed, the
  1988. * second response will produce objects with different identities.
  1989. *
  1990. * To customize the default option comparison algorithm, `<select multiple>` supports `compareWith`
  1991. * input. `compareWith` takes a **function** which has two arguments: `option1` and `option2`.
  1992. * If `compareWith` is given, Angular selects options by the return value of the function.
  1993. *
  1994. * #### Syntax
  1995. *
  1996. * ```
  1997. * <select multiple [compareWith]="compareFn" [(ngModel)]="selectedCountries">
  1998. * <option *ngFor="let country of countries" [ngValue]="country">
  1999. * {{country.name}}
  2000. * </option>
  2001. * </select>
  2002. *
  2003. * compareFn(c1: Country, c2: Country): boolean {
  2004. * return c1 && c2 ? c1.id === c2.id : c1 === c2;
  2005. * }
  2006. * ```
  2007. *
  2008. * \@stable
  2009. */
  2010. var SelectMultipleControlValueAccessor = /** @class */ (function () {
  2011. function SelectMultipleControlValueAccessor(_renderer, _elementRef) {
  2012. this._renderer = _renderer;
  2013. this._elementRef = _elementRef;
  2014. /**
  2015. * \@internal
  2016. */
  2017. this._optionMap = new Map();
  2018. /**
  2019. * \@internal
  2020. */
  2021. this._idCounter = 0;
  2022. this.onChange = function (_) { };
  2023. this.onTouched = function () { };
  2024. this._compareWith = _angular_core.ɵlooseIdentical;
  2025. }
  2026. Object.defineProperty(SelectMultipleControlValueAccessor.prototype, "compareWith", {
  2027. set: /**
  2028. * @param {?} fn
  2029. * @return {?}
  2030. */
  2031. function (fn) {
  2032. if (typeof fn !== 'function') {
  2033. throw new Error("compareWith must be a function, but received " + JSON.stringify(fn));
  2034. }
  2035. this._compareWith = fn;
  2036. },
  2037. enumerable: true,
  2038. configurable: true
  2039. });
  2040. /**
  2041. * @param {?} value
  2042. * @return {?}
  2043. */
  2044. SelectMultipleControlValueAccessor.prototype.writeValue = /**
  2045. * @param {?} value
  2046. * @return {?}
  2047. */
  2048. function (value) {
  2049. var _this = this;
  2050. this.value = value;
  2051. var /** @type {?} */ optionSelectedStateSetter;
  2052. if (Array.isArray(value)) {
  2053. // convert values to ids
  2054. var /** @type {?} */ ids_1 = value.map(function (v) { return _this._getOptionId(v); });
  2055. optionSelectedStateSetter = function (opt, o) { opt._setSelected(ids_1.indexOf(o.toString()) > -1); };
  2056. }
  2057. else {
  2058. optionSelectedStateSetter = function (opt, o) { opt._setSelected(false); };
  2059. }
  2060. this._optionMap.forEach(optionSelectedStateSetter);
  2061. };
  2062. /**
  2063. * @param {?} fn
  2064. * @return {?}
  2065. */
  2066. SelectMultipleControlValueAccessor.prototype.registerOnChange = /**
  2067. * @param {?} fn
  2068. * @return {?}
  2069. */
  2070. function (fn) {
  2071. var _this = this;
  2072. this.onChange = function (_) {
  2073. var /** @type {?} */ selected = [];
  2074. if (_.hasOwnProperty('selectedOptions')) {
  2075. var /** @type {?} */ options = _.selectedOptions;
  2076. for (var /** @type {?} */ i = 0; i < options.length; i++) {
  2077. var /** @type {?} */ opt = options.item(i);
  2078. var /** @type {?} */ val = _this._getOptionValue(opt.value);
  2079. selected.push(val);
  2080. }
  2081. }
  2082. else {
  2083. var /** @type {?} */ options = /** @type {?} */ (_.options);
  2084. for (var /** @type {?} */ i = 0; i < options.length; i++) {
  2085. var /** @type {?} */ opt = options.item(i);
  2086. if (opt.selected) {
  2087. var /** @type {?} */ val = _this._getOptionValue(opt.value);
  2088. selected.push(val);
  2089. }
  2090. }
  2091. }
  2092. _this.value = selected;
  2093. fn(selected);
  2094. };
  2095. };
  2096. /**
  2097. * @param {?} fn
  2098. * @return {?}
  2099. */
  2100. SelectMultipleControlValueAccessor.prototype.registerOnTouched = /**
  2101. * @param {?} fn
  2102. * @return {?}
  2103. */
  2104. function (fn) { this.onTouched = fn; };
  2105. /**
  2106. * @param {?} isDisabled
  2107. * @return {?}
  2108. */
  2109. SelectMultipleControlValueAccessor.prototype.setDisabledState = /**
  2110. * @param {?} isDisabled
  2111. * @return {?}
  2112. */
  2113. function (isDisabled) {
  2114. this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
  2115. };
  2116. /** @internal */
  2117. /**
  2118. * \@internal
  2119. * @param {?} value
  2120. * @return {?}
  2121. */
  2122. SelectMultipleControlValueAccessor.prototype._registerOption = /**
  2123. * \@internal
  2124. * @param {?} value
  2125. * @return {?}
  2126. */
  2127. function (value) {
  2128. var /** @type {?} */ id = (this._idCounter++).toString();
  2129. this._optionMap.set(id, value);
  2130. return id;
  2131. };
  2132. /** @internal */
  2133. /**
  2134. * \@internal
  2135. * @param {?} value
  2136. * @return {?}
  2137. */
  2138. SelectMultipleControlValueAccessor.prototype._getOptionId = /**
  2139. * \@internal
  2140. * @param {?} value
  2141. * @return {?}
  2142. */
  2143. function (value) {
  2144. for (var _i = 0, _a = Array.from(this._optionMap.keys()); _i < _a.length; _i++) {
  2145. var id = _a[_i];
  2146. if (this._compareWith(/** @type {?} */ ((this._optionMap.get(id)))._value, value))
  2147. return id;
  2148. }
  2149. return null;
  2150. };
  2151. /** @internal */
  2152. /**
  2153. * \@internal
  2154. * @param {?} valueString
  2155. * @return {?}
  2156. */
  2157. SelectMultipleControlValueAccessor.prototype._getOptionValue = /**
  2158. * \@internal
  2159. * @param {?} valueString
  2160. * @return {?}
  2161. */
  2162. function (valueString) {
  2163. var /** @type {?} */ id = _extractId$1(valueString);
  2164. return this._optionMap.has(id) ? /** @type {?} */ ((this._optionMap.get(id)))._value : valueString;
  2165. };
  2166. SelectMultipleControlValueAccessor.decorators = [
  2167. { type: _angular_core.Directive, args: [{
  2168. selector: 'select[multiple][formControlName],select[multiple][formControl],select[multiple][ngModel]',
  2169. host: { '(change)': 'onChange($event.target)', '(blur)': 'onTouched()' },
  2170. providers: [SELECT_MULTIPLE_VALUE_ACCESSOR]
  2171. },] },
  2172. ];
  2173. /** @nocollapse */
  2174. SelectMultipleControlValueAccessor.ctorParameters = function () { return [
  2175. { type: _angular_core.Renderer2, },
  2176. { type: _angular_core.ElementRef, },
  2177. ]; };
  2178. SelectMultipleControlValueAccessor.propDecorators = {
  2179. "compareWith": [{ type: _angular_core.Input },],
  2180. };
  2181. return SelectMultipleControlValueAccessor;
  2182. }());
  2183. /**
  2184. * Marks `<option>` as dynamic, so Angular can be notified when options change.
  2185. *
  2186. * ### Example
  2187. *
  2188. * ```
  2189. * <select multiple name="city" ngModel>
  2190. * <option *ngFor="let c of cities" [value]="c"></option>
  2191. * </select>
  2192. * ```
  2193. */
  2194. var NgSelectMultipleOption = /** @class */ (function () {
  2195. function NgSelectMultipleOption(_element, _renderer, _select) {
  2196. this._element = _element;
  2197. this._renderer = _renderer;
  2198. this._select = _select;
  2199. if (this._select) {
  2200. this.id = this._select._registerOption(this);
  2201. }
  2202. }
  2203. Object.defineProperty(NgSelectMultipleOption.prototype, "ngValue", {
  2204. set: /**
  2205. * @param {?} value
  2206. * @return {?}
  2207. */
  2208. function (value) {
  2209. if (this._select == null)
  2210. return;
  2211. this._value = value;
  2212. this._setElementValue(_buildValueString$1(this.id, value));
  2213. this._select.writeValue(this._select.value);
  2214. },
  2215. enumerable: true,
  2216. configurable: true
  2217. });
  2218. Object.defineProperty(NgSelectMultipleOption.prototype, "value", {
  2219. set: /**
  2220. * @param {?} value
  2221. * @return {?}
  2222. */
  2223. function (value) {
  2224. if (this._select) {
  2225. this._value = value;
  2226. this._setElementValue(_buildValueString$1(this.id, value));
  2227. this._select.writeValue(this._select.value);
  2228. }
  2229. else {
  2230. this._setElementValue(value);
  2231. }
  2232. },
  2233. enumerable: true,
  2234. configurable: true
  2235. });
  2236. /** @internal */
  2237. /**
  2238. * \@internal
  2239. * @param {?} value
  2240. * @return {?}
  2241. */
  2242. NgSelectMultipleOption.prototype._setElementValue = /**
  2243. * \@internal
  2244. * @param {?} value
  2245. * @return {?}
  2246. */
  2247. function (value) {
  2248. this._renderer.setProperty(this._element.nativeElement, 'value', value);
  2249. };
  2250. /** @internal */
  2251. /**
  2252. * \@internal
  2253. * @param {?} selected
  2254. * @return {?}
  2255. */
  2256. NgSelectMultipleOption.prototype._setSelected = /**
  2257. * \@internal
  2258. * @param {?} selected
  2259. * @return {?}
  2260. */
  2261. function (selected) {
  2262. this._renderer.setProperty(this._element.nativeElement, 'selected', selected);
  2263. };
  2264. /**
  2265. * @return {?}
  2266. */
  2267. NgSelectMultipleOption.prototype.ngOnDestroy = /**
  2268. * @return {?}
  2269. */
  2270. function () {
  2271. if (this._select) {
  2272. this._select._optionMap.delete(this.id);
  2273. this._select.writeValue(this._select.value);
  2274. }
  2275. };
  2276. NgSelectMultipleOption.decorators = [
  2277. { type: _angular_core.Directive, args: [{ selector: 'option' },] },
  2278. ];
  2279. /** @nocollapse */
  2280. NgSelectMultipleOption.ctorParameters = function () { return [
  2281. { type: _angular_core.ElementRef, },
  2282. { type: _angular_core.Renderer2, },
  2283. { type: SelectMultipleControlValueAccessor, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host },] },
  2284. ]; };
  2285. NgSelectMultipleOption.propDecorators = {
  2286. "ngValue": [{ type: _angular_core.Input, args: ['ngValue',] },],
  2287. "value": [{ type: _angular_core.Input, args: ['value',] },],
  2288. };
  2289. return NgSelectMultipleOption;
  2290. }());
  2291. /**
  2292. * @fileoverview added by tsickle
  2293. * @suppress {checkTypes} checked by tsc
  2294. */
  2295. /**
  2296. * @license
  2297. * Copyright Google Inc. All Rights Reserved.
  2298. *
  2299. * Use of this source code is governed by an MIT-style license that can be
  2300. * found in the LICENSE file at https://angular.io/license
  2301. */
  2302. /**
  2303. * @param {?} name
  2304. * @param {?} parent
  2305. * @return {?}
  2306. */
  2307. function controlPath(name, parent) {
  2308. return /** @type {?} */ ((parent.path)).concat([name]);
  2309. }
  2310. /**
  2311. * @param {?} control
  2312. * @param {?} dir
  2313. * @return {?}
  2314. */
  2315. function setUpControl(control, dir) {
  2316. if (!control)
  2317. _throwError(dir, 'Cannot find control with');
  2318. if (!dir.valueAccessor)
  2319. _throwError(dir, 'No value accessor for form control with');
  2320. control.validator = Validators.compose([/** @type {?} */ ((control.validator)), dir.validator]);
  2321. control.asyncValidator = Validators.composeAsync([/** @type {?} */ ((control.asyncValidator)), dir.asyncValidator]); /** @type {?} */
  2322. ((dir.valueAccessor)).writeValue(control.value);
  2323. setUpViewChangePipeline(control, dir);
  2324. setUpModelChangePipeline(control, dir);
  2325. setUpBlurPipeline(control, dir);
  2326. if (/** @type {?} */ ((dir.valueAccessor)).setDisabledState) {
  2327. control.registerOnDisabledChange(function (isDisabled) { /** @type {?} */ ((/** @type {?} */ ((dir.valueAccessor)).setDisabledState))(isDisabled); });
  2328. }
  2329. // re-run validation when validator binding changes, e.g. minlength=3 -> minlength=4
  2330. dir._rawValidators.forEach(function (validator) {
  2331. if ((/** @type {?} */ (validator)).registerOnValidatorChange)
  2332. /** @type {?} */ (((/** @type {?} */ (validator)).registerOnValidatorChange))(function () { return control.updateValueAndValidity(); });
  2333. });
  2334. dir._rawAsyncValidators.forEach(function (validator) {
  2335. if ((/** @type {?} */ (validator)).registerOnValidatorChange)
  2336. /** @type {?} */ (((/** @type {?} */ (validator)).registerOnValidatorChange))(function () { return control.updateValueAndValidity(); });
  2337. });
  2338. }
  2339. /**
  2340. * @param {?} control
  2341. * @param {?} dir
  2342. * @return {?}
  2343. */
  2344. function cleanUpControl(control, dir) {
  2345. /** @type {?} */ ((dir.valueAccessor)).registerOnChange(function () { return _noControlError(dir); }); /** @type {?} */
  2346. ((dir.valueAccessor)).registerOnTouched(function () { return _noControlError(dir); });
  2347. dir._rawValidators.forEach(function (validator) {
  2348. if (validator.registerOnValidatorChange) {
  2349. validator.registerOnValidatorChange(null);
  2350. }
  2351. });
  2352. dir._rawAsyncValidators.forEach(function (validator) {
  2353. if (validator.registerOnValidatorChange) {
  2354. validator.registerOnValidatorChange(null);
  2355. }
  2356. });
  2357. if (control)
  2358. control._clearChangeFns();
  2359. }
  2360. /**
  2361. * @param {?} control
  2362. * @param {?} dir
  2363. * @return {?}
  2364. */
  2365. function setUpViewChangePipeline(control, dir) {
  2366. /** @type {?} */ ((dir.valueAccessor)).registerOnChange(function (newValue) {
  2367. control._pendingValue = newValue;
  2368. control._pendingChange = true;
  2369. control._pendingDirty = true;
  2370. if (control.updateOn === 'change')
  2371. updateControl(control, dir);
  2372. });
  2373. }
  2374. /**
  2375. * @param {?} control
  2376. * @param {?} dir
  2377. * @return {?}
  2378. */
  2379. function setUpBlurPipeline(control, dir) {
  2380. /** @type {?} */ ((dir.valueAccessor)).registerOnTouched(function () {
  2381. control._pendingTouched = true;
  2382. if (control.updateOn === 'blur' && control._pendingChange)
  2383. updateControl(control, dir);
  2384. if (control.updateOn !== 'submit')
  2385. control.markAsTouched();
  2386. });
  2387. }
  2388. /**
  2389. * @param {?} control
  2390. * @param {?} dir
  2391. * @return {?}
  2392. */
  2393. function updateControl(control, dir) {
  2394. dir.viewToModelUpdate(control._pendingValue);
  2395. if (control._pendingDirty)
  2396. control.markAsDirty();
  2397. control.setValue(control._pendingValue, { emitModelToViewChange: false });
  2398. control._pendingChange = false;
  2399. }
  2400. /**
  2401. * @param {?} control
  2402. * @param {?} dir
  2403. * @return {?}
  2404. */
  2405. function setUpModelChangePipeline(control, dir) {
  2406. control.registerOnChange(function (newValue, emitModelEvent) {
  2407. /** @type {?} */ ((
  2408. // control -> view
  2409. dir.valueAccessor)).writeValue(newValue);
  2410. // control -> ngModel
  2411. if (emitModelEvent)
  2412. dir.viewToModelUpdate(newValue);
  2413. });
  2414. }
  2415. /**
  2416. * @param {?} control
  2417. * @param {?} dir
  2418. * @return {?}
  2419. */
  2420. function setUpFormContainer(control, dir) {
  2421. if (control == null)
  2422. _throwError(dir, 'Cannot find control with');
  2423. control.validator = Validators.compose([control.validator, dir.validator]);
  2424. control.asyncValidator = Validators.composeAsync([control.asyncValidator, dir.asyncValidator]);
  2425. }
  2426. /**
  2427. * @param {?} dir
  2428. * @return {?}
  2429. */
  2430. function _noControlError(dir) {
  2431. return _throwError(dir, 'There is no FormControl instance attached to form control element with');
  2432. }
  2433. /**
  2434. * @param {?} dir
  2435. * @param {?} message
  2436. * @return {?}
  2437. */
  2438. function _throwError(dir, message) {
  2439. var /** @type {?} */ messageEnd;
  2440. if (/** @type {?} */ ((dir.path)).length > 1) {
  2441. messageEnd = "path: '" + (/** @type {?} */ ((dir.path))).join(' -> ') + "'";
  2442. }
  2443. else if (/** @type {?} */ ((dir.path))[0]) {
  2444. messageEnd = "name: '" + dir.path + "'";
  2445. }
  2446. else {
  2447. messageEnd = 'unspecified name attribute';
  2448. }
  2449. throw new Error(message + " " + messageEnd);
  2450. }
  2451. /**
  2452. * @param {?} validators
  2453. * @return {?}
  2454. */
  2455. function composeValidators(validators) {
  2456. return validators != null ? Validators.compose(validators.map(normalizeValidator)) : null;
  2457. }
  2458. /**
  2459. * @param {?} validators
  2460. * @return {?}
  2461. */
  2462. function composeAsyncValidators(validators) {
  2463. return validators != null ? Validators.composeAsync(validators.map(normalizeAsyncValidator)) :
  2464. null;
  2465. }
  2466. /**
  2467. * @param {?} changes
  2468. * @param {?} viewModel
  2469. * @return {?}
  2470. */
  2471. function isPropertyUpdated(changes, viewModel) {
  2472. if (!changes.hasOwnProperty('model'))
  2473. return false;
  2474. var /** @type {?} */ change = changes['model'];
  2475. if (change.isFirstChange())
  2476. return true;
  2477. return !_angular_core.ɵlooseIdentical(viewModel, change.currentValue);
  2478. }
  2479. var BUILTIN_ACCESSORS = [
  2480. CheckboxControlValueAccessor,
  2481. RangeValueAccessor,
  2482. NumberValueAccessor,
  2483. SelectControlValueAccessor,
  2484. SelectMultipleControlValueAccessor,
  2485. RadioControlValueAccessor,
  2486. ];
  2487. /**
  2488. * @param {?} valueAccessor
  2489. * @return {?}
  2490. */
  2491. function isBuiltInAccessor(valueAccessor) {
  2492. return BUILTIN_ACCESSORS.some(function (a) { return valueAccessor.constructor === a; });
  2493. }
  2494. /**
  2495. * @param {?} form
  2496. * @param {?} directives
  2497. * @return {?}
  2498. */
  2499. function syncPendingControls(form, directives) {
  2500. form._syncPendingControls();
  2501. directives.forEach(function (dir) {
  2502. var /** @type {?} */ control = /** @type {?} */ (dir.control);
  2503. if (control.updateOn === 'submit' && control._pendingChange) {
  2504. dir.viewToModelUpdate(control._pendingValue);
  2505. control._pendingChange = false;
  2506. }
  2507. });
  2508. }
  2509. /**
  2510. * @param {?} dir
  2511. * @param {?} valueAccessors
  2512. * @return {?}
  2513. */
  2514. function selectValueAccessor(dir, valueAccessors) {
  2515. if (!valueAccessors)
  2516. return null;
  2517. if (!Array.isArray(valueAccessors))
  2518. _throwError(dir, 'Value accessor was not provided as an array for form control with');
  2519. var /** @type {?} */ defaultAccessor = undefined;
  2520. var /** @type {?} */ builtinAccessor = undefined;
  2521. var /** @type {?} */ customAccessor = undefined;
  2522. valueAccessors.forEach(function (v) {
  2523. if (v.constructor === DefaultValueAccessor) {
  2524. defaultAccessor = v;
  2525. }
  2526. else if (isBuiltInAccessor(v)) {
  2527. if (builtinAccessor)
  2528. _throwError(dir, 'More than one built-in value accessor matches form control with');
  2529. builtinAccessor = v;
  2530. }
  2531. else {
  2532. if (customAccessor)
  2533. _throwError(dir, 'More than one custom value accessor matches form control with');
  2534. customAccessor = v;
  2535. }
  2536. });
  2537. if (customAccessor)
  2538. return customAccessor;
  2539. if (builtinAccessor)
  2540. return builtinAccessor;
  2541. if (defaultAccessor)
  2542. return defaultAccessor;
  2543. _throwError(dir, 'No valid value accessor for form control with');
  2544. return null;
  2545. }
  2546. /**
  2547. * @template T
  2548. * @param {?} list
  2549. * @param {?} el
  2550. * @return {?}
  2551. */
  2552. function removeDir(list, el) {
  2553. var /** @type {?} */ index = list.indexOf(el);
  2554. if (index > -1)
  2555. list.splice(index, 1);
  2556. }
  2557. /**
  2558. * @fileoverview added by tsickle
  2559. * @suppress {checkTypes} checked by tsc
  2560. */
  2561. /**
  2562. * @license
  2563. * Copyright Google Inc. All Rights Reserved.
  2564. *
  2565. * Use of this source code is governed by an MIT-style license that can be
  2566. * found in the LICENSE file at https://angular.io/license
  2567. */
  2568. /**
  2569. * This is a base class for code shared between {\@link NgModelGroup} and {\@link FormGroupName}.
  2570. *
  2571. * \@stable
  2572. */
  2573. var AbstractFormGroupDirective = /** @class */ (function (_super) {
  2574. __extends(AbstractFormGroupDirective, _super);
  2575. function AbstractFormGroupDirective() {
  2576. return _super !== null && _super.apply(this, arguments) || this;
  2577. }
  2578. /**
  2579. * @return {?}
  2580. */
  2581. AbstractFormGroupDirective.prototype.ngOnInit = /**
  2582. * @return {?}
  2583. */
  2584. function () {
  2585. this._checkParentType(); /** @type {?} */
  2586. ((this.formDirective)).addFormGroup(this);
  2587. };
  2588. /**
  2589. * @return {?}
  2590. */
  2591. AbstractFormGroupDirective.prototype.ngOnDestroy = /**
  2592. * @return {?}
  2593. */
  2594. function () {
  2595. if (this.formDirective) {
  2596. this.formDirective.removeFormGroup(this);
  2597. }
  2598. };
  2599. Object.defineProperty(AbstractFormGroupDirective.prototype, "control", {
  2600. /**
  2601. * Get the {@link FormGroup} backing this binding.
  2602. */
  2603. get: /**
  2604. * Get the {\@link FormGroup} backing this binding.
  2605. * @return {?}
  2606. */
  2607. function () { return /** @type {?} */ ((this.formDirective)).getFormGroup(this); },
  2608. enumerable: true,
  2609. configurable: true
  2610. });
  2611. Object.defineProperty(AbstractFormGroupDirective.prototype, "path", {
  2612. /**
  2613. * Get the path to this control group.
  2614. */
  2615. get: /**
  2616. * Get the path to this control group.
  2617. * @return {?}
  2618. */
  2619. function () { return controlPath(this.name, this._parent); },
  2620. enumerable: true,
  2621. configurable: true
  2622. });
  2623. Object.defineProperty(AbstractFormGroupDirective.prototype, "formDirective", {
  2624. /**
  2625. * Get the {@link Form} to which this group belongs.
  2626. */
  2627. get: /**
  2628. * Get the {\@link Form} to which this group belongs.
  2629. * @return {?}
  2630. */
  2631. function () { return this._parent ? this._parent.formDirective : null; },
  2632. enumerable: true,
  2633. configurable: true
  2634. });
  2635. Object.defineProperty(AbstractFormGroupDirective.prototype, "validator", {
  2636. get: /**
  2637. * @return {?}
  2638. */
  2639. function () { return composeValidators(this._validators); },
  2640. enumerable: true,
  2641. configurable: true
  2642. });
  2643. Object.defineProperty(AbstractFormGroupDirective.prototype, "asyncValidator", {
  2644. get: /**
  2645. * @return {?}
  2646. */
  2647. function () {
  2648. return composeAsyncValidators(this._asyncValidators);
  2649. },
  2650. enumerable: true,
  2651. configurable: true
  2652. });
  2653. /** @internal */
  2654. /**
  2655. * \@internal
  2656. * @return {?}
  2657. */
  2658. AbstractFormGroupDirective.prototype._checkParentType = /**
  2659. * \@internal
  2660. * @return {?}
  2661. */
  2662. function () { };
  2663. return AbstractFormGroupDirective;
  2664. }(ControlContainer));
  2665. /**
  2666. * @fileoverview added by tsickle
  2667. * @suppress {checkTypes} checked by tsc
  2668. */
  2669. /**
  2670. * @license
  2671. * Copyright Google Inc. All Rights Reserved.
  2672. *
  2673. * Use of this source code is governed by an MIT-style license that can be
  2674. * found in the LICENSE file at https://angular.io/license
  2675. */
  2676. var AbstractControlStatus = /** @class */ (function () {
  2677. function AbstractControlStatus(cd) {
  2678. this._cd = cd;
  2679. }
  2680. Object.defineProperty(AbstractControlStatus.prototype, "ngClassUntouched", {
  2681. get: /**
  2682. * @return {?}
  2683. */
  2684. function () { return this._cd.control ? this._cd.control.untouched : false; },
  2685. enumerable: true,
  2686. configurable: true
  2687. });
  2688. Object.defineProperty(AbstractControlStatus.prototype, "ngClassTouched", {
  2689. get: /**
  2690. * @return {?}
  2691. */
  2692. function () { return this._cd.control ? this._cd.control.touched : false; },
  2693. enumerable: true,
  2694. configurable: true
  2695. });
  2696. Object.defineProperty(AbstractControlStatus.prototype, "ngClassPristine", {
  2697. get: /**
  2698. * @return {?}
  2699. */
  2700. function () { return this._cd.control ? this._cd.control.pristine : false; },
  2701. enumerable: true,
  2702. configurable: true
  2703. });
  2704. Object.defineProperty(AbstractControlStatus.prototype, "ngClassDirty", {
  2705. get: /**
  2706. * @return {?}
  2707. */
  2708. function () { return this._cd.control ? this._cd.control.dirty : false; },
  2709. enumerable: true,
  2710. configurable: true
  2711. });
  2712. Object.defineProperty(AbstractControlStatus.prototype, "ngClassValid", {
  2713. get: /**
  2714. * @return {?}
  2715. */
  2716. function () { return this._cd.control ? this._cd.control.valid : false; },
  2717. enumerable: true,
  2718. configurable: true
  2719. });
  2720. Object.defineProperty(AbstractControlStatus.prototype, "ngClassInvalid", {
  2721. get: /**
  2722. * @return {?}
  2723. */
  2724. function () { return this._cd.control ? this._cd.control.invalid : false; },
  2725. enumerable: true,
  2726. configurable: true
  2727. });
  2728. Object.defineProperty(AbstractControlStatus.prototype, "ngClassPending", {
  2729. get: /**
  2730. * @return {?}
  2731. */
  2732. function () { return this._cd.control ? this._cd.control.pending : false; },
  2733. enumerable: true,
  2734. configurable: true
  2735. });
  2736. return AbstractControlStatus;
  2737. }());
  2738. var ngControlStatusHost = {
  2739. '[class.ng-untouched]': 'ngClassUntouched',
  2740. '[class.ng-touched]': 'ngClassTouched',
  2741. '[class.ng-pristine]': 'ngClassPristine',
  2742. '[class.ng-dirty]': 'ngClassDirty',
  2743. '[class.ng-valid]': 'ngClassValid',
  2744. '[class.ng-invalid]': 'ngClassInvalid',
  2745. '[class.ng-pending]': 'ngClassPending',
  2746. };
  2747. /**
  2748. * Directive automatically applied to Angular form controls that sets CSS classes
  2749. * based on control status. The following classes are applied as the properties
  2750. * become true:
  2751. *
  2752. * * ng-valid
  2753. * * ng-invalid
  2754. * * ng-pending
  2755. * * ng-pristine
  2756. * * ng-dirty
  2757. * * ng-untouched
  2758. * * ng-touched
  2759. *
  2760. * \@stable
  2761. */
  2762. var NgControlStatus = /** @class */ (function (_super) {
  2763. __extends(NgControlStatus, _super);
  2764. function NgControlStatus(cd) {
  2765. return _super.call(this, cd) || this;
  2766. }
  2767. NgControlStatus.decorators = [
  2768. { type: _angular_core.Directive, args: [{ selector: '[formControlName],[ngModel],[formControl]', host: ngControlStatusHost },] },
  2769. ];
  2770. /** @nocollapse */
  2771. NgControlStatus.ctorParameters = function () { return [
  2772. { type: NgControl, decorators: [{ type: _angular_core.Self },] },
  2773. ]; };
  2774. return NgControlStatus;
  2775. }(AbstractControlStatus));
  2776. /**
  2777. * Directive automatically applied to Angular form groups that sets CSS classes
  2778. * based on control status (valid/invalid/dirty/etc).
  2779. *
  2780. * \@stable
  2781. */
  2782. var NgControlStatusGroup = /** @class */ (function (_super) {
  2783. __extends(NgControlStatusGroup, _super);
  2784. function NgControlStatusGroup(cd) {
  2785. return _super.call(this, cd) || this;
  2786. }
  2787. NgControlStatusGroup.decorators = [
  2788. { type: _angular_core.Directive, args: [{
  2789. selector: '[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]',
  2790. host: ngControlStatusHost
  2791. },] },
  2792. ];
  2793. /** @nocollapse */
  2794. NgControlStatusGroup.ctorParameters = function () { return [
  2795. { type: ControlContainer, decorators: [{ type: _angular_core.Self },] },
  2796. ]; };
  2797. return NgControlStatusGroup;
  2798. }(AbstractControlStatus));
  2799. /**
  2800. * @fileoverview added by tsickle
  2801. * @suppress {checkTypes} checked by tsc
  2802. */
  2803. /**
  2804. * @license
  2805. * Copyright Google Inc. All Rights Reserved.
  2806. *
  2807. * Use of this source code is governed by an MIT-style license that can be
  2808. * found in the LICENSE file at https://angular.io/license
  2809. */
  2810. /**
  2811. * Indicates that a FormControl is valid, i.e. that no errors exist in the input value.
  2812. */
  2813. var VALID = 'VALID';
  2814. /**
  2815. * Indicates that a FormControl is invalid, i.e. that an error exists in the input value.
  2816. */
  2817. var INVALID = 'INVALID';
  2818. /**
  2819. * Indicates that a FormControl is pending, i.e. that async validation is occurring and
  2820. * errors are not yet available for the input value.
  2821. */
  2822. var PENDING = 'PENDING';
  2823. /**
  2824. * Indicates that a FormControl is disabled, i.e. that the control is exempt from ancestor
  2825. * calculations of validity or value.
  2826. */
  2827. var DISABLED = 'DISABLED';
  2828. /**
  2829. * @param {?} control
  2830. * @param {?} path
  2831. * @param {?} delimiter
  2832. * @return {?}
  2833. */
  2834. function _find(control, path, delimiter) {
  2835. if (path == null)
  2836. return null;
  2837. if (!(path instanceof Array)) {
  2838. path = (/** @type {?} */ (path)).split(delimiter);
  2839. }
  2840. if (path instanceof Array && (path.length === 0))
  2841. return null;
  2842. return (/** @type {?} */ (path)).reduce(function (v, name) {
  2843. if (v instanceof FormGroup) {
  2844. return v.controls[name] || null;
  2845. }
  2846. if (v instanceof FormArray) {
  2847. return v.at(/** @type {?} */ (name)) || null;
  2848. }
  2849. return null;
  2850. }, control);
  2851. }
  2852. /**
  2853. * @param {?=} validatorOrOpts
  2854. * @return {?}
  2855. */
  2856. function coerceToValidator(validatorOrOpts) {
  2857. var /** @type {?} */ validator = /** @type {?} */ ((isOptionsObj(validatorOrOpts) ? (/** @type {?} */ (validatorOrOpts)).validators :
  2858. validatorOrOpts));
  2859. return Array.isArray(validator) ? composeValidators(validator) : validator || null;
  2860. }
  2861. /**
  2862. * @param {?=} asyncValidator
  2863. * @param {?=} validatorOrOpts
  2864. * @return {?}
  2865. */
  2866. function coerceToAsyncValidator(asyncValidator, validatorOrOpts) {
  2867. var /** @type {?} */ origAsyncValidator = /** @type {?} */ ((isOptionsObj(validatorOrOpts) ? (/** @type {?} */ (validatorOrOpts)).asyncValidators :
  2868. asyncValidator));
  2869. return Array.isArray(origAsyncValidator) ? composeAsyncValidators(origAsyncValidator) :
  2870. origAsyncValidator || null;
  2871. }
  2872. /**
  2873. * @record
  2874. */
  2875. /**
  2876. * @param {?=} validatorOrOpts
  2877. * @return {?}
  2878. */
  2879. function isOptionsObj(validatorOrOpts) {
  2880. return validatorOrOpts != null && !Array.isArray(validatorOrOpts) &&
  2881. typeof validatorOrOpts === 'object';
  2882. }
  2883. /**
  2884. * \@whatItDoes This is the base class for {\@link FormControl}, {\@link FormGroup}, and
  2885. * {\@link FormArray}.
  2886. *
  2887. * It provides some of the shared behavior that all controls and groups of controls have, like
  2888. * running validators, calculating status, and resetting state. It also defines the properties
  2889. * that are shared between all sub-classes, like `value`, `valid`, and `dirty`. It shouldn't be
  2890. * instantiated directly.
  2891. *
  2892. * \@stable
  2893. * @abstract
  2894. */
  2895. var AbstractControl = /** @class */ (function () {
  2896. function AbstractControl(validator, asyncValidator) {
  2897. this.validator = validator;
  2898. this.asyncValidator = asyncValidator;
  2899. /**
  2900. * \@internal
  2901. */
  2902. this._onCollectionChange = function () { };
  2903. /**
  2904. * A control is `pristine` if the user has not yet changed
  2905. * the value in the UI.
  2906. *
  2907. * Note that programmatic changes to a control's value will
  2908. * *not* mark it dirty.
  2909. */
  2910. this.pristine = true;
  2911. /**
  2912. * A control is marked `touched` once the user has triggered
  2913. * a `blur` event on it.
  2914. */
  2915. this.touched = false;
  2916. /**
  2917. * \@internal
  2918. */
  2919. this._onDisabledChange = [];
  2920. }
  2921. Object.defineProperty(AbstractControl.prototype, "parent", {
  2922. /**
  2923. * The parent control.
  2924. */
  2925. get: /**
  2926. * The parent control.
  2927. * @return {?}
  2928. */
  2929. function () { return this._parent; },
  2930. enumerable: true,
  2931. configurable: true
  2932. });
  2933. Object.defineProperty(AbstractControl.prototype, "valid", {
  2934. /**
  2935. * A control is `valid` when its `status === VALID`.
  2936. *
  2937. * In order to have this status, the control must have passed all its
  2938. * validation checks.
  2939. */
  2940. get: /**
  2941. * A control is `valid` when its `status === VALID`.
  2942. *
  2943. * In order to have this status, the control must have passed all its
  2944. * validation checks.
  2945. * @return {?}
  2946. */
  2947. function () { return this.status === VALID; },
  2948. enumerable: true,
  2949. configurable: true
  2950. });
  2951. Object.defineProperty(AbstractControl.prototype, "invalid", {
  2952. /**
  2953. * A control is `invalid` when its `status === INVALID`.
  2954. *
  2955. * In order to have this status, the control must have failed
  2956. * at least one of its validation checks.
  2957. */
  2958. get: /**
  2959. * A control is `invalid` when its `status === INVALID`.
  2960. *
  2961. * In order to have this status, the control must have failed
  2962. * at least one of its validation checks.
  2963. * @return {?}
  2964. */
  2965. function () { return this.status === INVALID; },
  2966. enumerable: true,
  2967. configurable: true
  2968. });
  2969. Object.defineProperty(AbstractControl.prototype, "pending", {
  2970. /**
  2971. * A control is `pending` when its `status === PENDING`.
  2972. *
  2973. * In order to have this status, the control must be in the
  2974. * middle of conducting a validation check.
  2975. */
  2976. get: /**
  2977. * A control is `pending` when its `status === PENDING`.
  2978. *
  2979. * In order to have this status, the control must be in the
  2980. * middle of conducting a validation check.
  2981. * @return {?}
  2982. */
  2983. function () { return this.status == PENDING; },
  2984. enumerable: true,
  2985. configurable: true
  2986. });
  2987. Object.defineProperty(AbstractControl.prototype, "disabled", {
  2988. /**
  2989. * A control is `disabled` when its `status === DISABLED`.
  2990. *
  2991. * Disabled controls are exempt from validation checks and
  2992. * are not included in the aggregate value of their ancestor
  2993. * controls.
  2994. */
  2995. get: /**
  2996. * A control is `disabled` when its `status === DISABLED`.
  2997. *
  2998. * Disabled controls are exempt from validation checks and
  2999. * are not included in the aggregate value of their ancestor
  3000. * controls.
  3001. * @return {?}
  3002. */
  3003. function () { return this.status === DISABLED; },
  3004. enumerable: true,
  3005. configurable: true
  3006. });
  3007. Object.defineProperty(AbstractControl.prototype, "enabled", {
  3008. /**
  3009. * A control is `enabled` as long as its `status !== DISABLED`.
  3010. *
  3011. * In other words, it has a status of `VALID`, `INVALID`, or
  3012. * `PENDING`.
  3013. */
  3014. get: /**
  3015. * A control is `enabled` as long as its `status !== DISABLED`.
  3016. *
  3017. * In other words, it has a status of `VALID`, `INVALID`, or
  3018. * `PENDING`.
  3019. * @return {?}
  3020. */
  3021. function () { return this.status !== DISABLED; },
  3022. enumerable: true,
  3023. configurable: true
  3024. });
  3025. Object.defineProperty(AbstractControl.prototype, "dirty", {
  3026. /**
  3027. * A control is `dirty` if the user has changed the value
  3028. * in the UI.
  3029. *
  3030. * Note that programmatic changes to a control's value will
  3031. * *not* mark it dirty.
  3032. */
  3033. get: /**
  3034. * A control is `dirty` if the user has changed the value
  3035. * in the UI.
  3036. *
  3037. * Note that programmatic changes to a control's value will
  3038. * *not* mark it dirty.
  3039. * @return {?}
  3040. */
  3041. function () { return !this.pristine; },
  3042. enumerable: true,
  3043. configurable: true
  3044. });
  3045. Object.defineProperty(AbstractControl.prototype, "untouched", {
  3046. /**
  3047. * A control is `untouched` if the user has not yet triggered
  3048. * a `blur` event on it.
  3049. */
  3050. get: /**
  3051. * A control is `untouched` if the user has not yet triggered
  3052. * a `blur` event on it.
  3053. * @return {?}
  3054. */
  3055. function () { return !this.touched; },
  3056. enumerable: true,
  3057. configurable: true
  3058. });
  3059. Object.defineProperty(AbstractControl.prototype, "updateOn", {
  3060. /**
  3061. * Returns the update strategy of the `AbstractControl` (i.e.
  3062. * the event on which the control will update itself).
  3063. * Possible values: `'change'` (default) | `'blur'` | `'submit'`
  3064. */
  3065. get: /**
  3066. * Returns the update strategy of the `AbstractControl` (i.e.
  3067. * the event on which the control will update itself).
  3068. * Possible values: `'change'` (default) | `'blur'` | `'submit'`
  3069. * @return {?}
  3070. */
  3071. function () {
  3072. return this._updateOn ? this._updateOn : (this.parent ? this.parent.updateOn : 'change');
  3073. },
  3074. enumerable: true,
  3075. configurable: true
  3076. });
  3077. /**
  3078. * Sets the synchronous validators that are active on this control. Calling
  3079. * this will overwrite any existing sync validators.
  3080. */
  3081. /**
  3082. * Sets the synchronous validators that are active on this control. Calling
  3083. * this will overwrite any existing sync validators.
  3084. * @param {?} newValidator
  3085. * @return {?}
  3086. */
  3087. AbstractControl.prototype.setValidators = /**
  3088. * Sets the synchronous validators that are active on this control. Calling
  3089. * this will overwrite any existing sync validators.
  3090. * @param {?} newValidator
  3091. * @return {?}
  3092. */
  3093. function (newValidator) {
  3094. this.validator = coerceToValidator(newValidator);
  3095. };
  3096. /**
  3097. * Sets the async validators that are active on this control. Calling this
  3098. * will overwrite any existing async validators.
  3099. */
  3100. /**
  3101. * Sets the async validators that are active on this control. Calling this
  3102. * will overwrite any existing async validators.
  3103. * @param {?} newValidator
  3104. * @return {?}
  3105. */
  3106. AbstractControl.prototype.setAsyncValidators = /**
  3107. * Sets the async validators that are active on this control. Calling this
  3108. * will overwrite any existing async validators.
  3109. * @param {?} newValidator
  3110. * @return {?}
  3111. */
  3112. function (newValidator) {
  3113. this.asyncValidator = coerceToAsyncValidator(newValidator);
  3114. };
  3115. /**
  3116. * Empties out the sync validator list.
  3117. */
  3118. /**
  3119. * Empties out the sync validator list.
  3120. * @return {?}
  3121. */
  3122. AbstractControl.prototype.clearValidators = /**
  3123. * Empties out the sync validator list.
  3124. * @return {?}
  3125. */
  3126. function () { this.validator = null; };
  3127. /**
  3128. * Empties out the async validator list.
  3129. */
  3130. /**
  3131. * Empties out the async validator list.
  3132. * @return {?}
  3133. */
  3134. AbstractControl.prototype.clearAsyncValidators = /**
  3135. * Empties out the async validator list.
  3136. * @return {?}
  3137. */
  3138. function () { this.asyncValidator = null; };
  3139. /**
  3140. * Marks the control as `touched`.
  3141. *
  3142. * This will also mark all direct ancestors as `touched` to maintain
  3143. * the model.
  3144. */
  3145. /**
  3146. * Marks the control as `touched`.
  3147. *
  3148. * This will also mark all direct ancestors as `touched` to maintain
  3149. * the model.
  3150. * @param {?=} opts
  3151. * @return {?}
  3152. */
  3153. AbstractControl.prototype.markAsTouched = /**
  3154. * Marks the control as `touched`.
  3155. *
  3156. * This will also mark all direct ancestors as `touched` to maintain
  3157. * the model.
  3158. * @param {?=} opts
  3159. * @return {?}
  3160. */
  3161. function (opts) {
  3162. if (opts === void 0) { opts = {}; }
  3163. (/** @type {?} */ (this)).touched = true;
  3164. if (this._parent && !opts.onlySelf) {
  3165. this._parent.markAsTouched(opts);
  3166. }
  3167. };
  3168. /**
  3169. * Marks the control as `untouched`.
  3170. *
  3171. * If the control has any children, it will also mark all children as `untouched`
  3172. * to maintain the model, and re-calculate the `touched` status of all parent
  3173. * controls.
  3174. */
  3175. /**
  3176. * Marks the control as `untouched`.
  3177. *
  3178. * If the control has any children, it will also mark all children as `untouched`
  3179. * to maintain the model, and re-calculate the `touched` status of all parent
  3180. * controls.
  3181. * @param {?=} opts
  3182. * @return {?}
  3183. */
  3184. AbstractControl.prototype.markAsUntouched = /**
  3185. * Marks the control as `untouched`.
  3186. *
  3187. * If the control has any children, it will also mark all children as `untouched`
  3188. * to maintain the model, and re-calculate the `touched` status of all parent
  3189. * controls.
  3190. * @param {?=} opts
  3191. * @return {?}
  3192. */
  3193. function (opts) {
  3194. if (opts === void 0) { opts = {}; }
  3195. (/** @type {?} */ (this)).touched = false;
  3196. this._pendingTouched = false;
  3197. this._forEachChild(function (control) { control.markAsUntouched({ onlySelf: true }); });
  3198. if (this._parent && !opts.onlySelf) {
  3199. this._parent._updateTouched(opts);
  3200. }
  3201. };
  3202. /**
  3203. * Marks the control as `dirty`.
  3204. *
  3205. * This will also mark all direct ancestors as `dirty` to maintain
  3206. * the model.
  3207. */
  3208. /**
  3209. * Marks the control as `dirty`.
  3210. *
  3211. * This will also mark all direct ancestors as `dirty` to maintain
  3212. * the model.
  3213. * @param {?=} opts
  3214. * @return {?}
  3215. */
  3216. AbstractControl.prototype.markAsDirty = /**
  3217. * Marks the control as `dirty`.
  3218. *
  3219. * This will also mark all direct ancestors as `dirty` to maintain
  3220. * the model.
  3221. * @param {?=} opts
  3222. * @return {?}
  3223. */
  3224. function (opts) {
  3225. if (opts === void 0) { opts = {}; }
  3226. (/** @type {?} */ (this)).pristine = false;
  3227. if (this._parent && !opts.onlySelf) {
  3228. this._parent.markAsDirty(opts);
  3229. }
  3230. };
  3231. /**
  3232. * Marks the control as `pristine`.
  3233. *
  3234. * If the control has any children, it will also mark all children as `pristine`
  3235. * to maintain the model, and re-calculate the `pristine` status of all parent
  3236. * controls.
  3237. */
  3238. /**
  3239. * Marks the control as `pristine`.
  3240. *
  3241. * If the control has any children, it will also mark all children as `pristine`
  3242. * to maintain the model, and re-calculate the `pristine` status of all parent
  3243. * controls.
  3244. * @param {?=} opts
  3245. * @return {?}
  3246. */
  3247. AbstractControl.prototype.markAsPristine = /**
  3248. * Marks the control as `pristine`.
  3249. *
  3250. * If the control has any children, it will also mark all children as `pristine`
  3251. * to maintain the model, and re-calculate the `pristine` status of all parent
  3252. * controls.
  3253. * @param {?=} opts
  3254. * @return {?}
  3255. */
  3256. function (opts) {
  3257. if (opts === void 0) { opts = {}; }
  3258. (/** @type {?} */ (this)).pristine = true;
  3259. this._pendingDirty = false;
  3260. this._forEachChild(function (control) { control.markAsPristine({ onlySelf: true }); });
  3261. if (this._parent && !opts.onlySelf) {
  3262. this._parent._updatePristine(opts);
  3263. }
  3264. };
  3265. /**
  3266. * Marks the control as `pending`.
  3267. */
  3268. /**
  3269. * Marks the control as `pending`.
  3270. * @param {?=} opts
  3271. * @return {?}
  3272. */
  3273. AbstractControl.prototype.markAsPending = /**
  3274. * Marks the control as `pending`.
  3275. * @param {?=} opts
  3276. * @return {?}
  3277. */
  3278. function (opts) {
  3279. if (opts === void 0) { opts = {}; }
  3280. (/** @type {?} */ (this)).status = PENDING;
  3281. if (this._parent && !opts.onlySelf) {
  3282. this._parent.markAsPending(opts);
  3283. }
  3284. };
  3285. /**
  3286. * Disables the control. This means the control will be exempt from validation checks and
  3287. * excluded from the aggregate value of any parent. Its status is `DISABLED`.
  3288. *
  3289. * If the control has children, all children will be disabled to maintain the model.
  3290. */
  3291. /**
  3292. * Disables the control. This means the control will be exempt from validation checks and
  3293. * excluded from the aggregate value of any parent. Its status is `DISABLED`.
  3294. *
  3295. * If the control has children, all children will be disabled to maintain the model.
  3296. * @param {?=} opts
  3297. * @return {?}
  3298. */
  3299. AbstractControl.prototype.disable = /**
  3300. * Disables the control. This means the control will be exempt from validation checks and
  3301. * excluded from the aggregate value of any parent. Its status is `DISABLED`.
  3302. *
  3303. * If the control has children, all children will be disabled to maintain the model.
  3304. * @param {?=} opts
  3305. * @return {?}
  3306. */
  3307. function (opts) {
  3308. if (opts === void 0) { opts = {}; }
  3309. (/** @type {?} */ (this)).status = DISABLED;
  3310. (/** @type {?} */ (this)).errors = null;
  3311. this._forEachChild(function (control) { control.disable(__assign({}, opts, { onlySelf: true })); });
  3312. this._updateValue();
  3313. if (opts.emitEvent !== false) {
  3314. (/** @type {?} */ (this.valueChanges)).emit(this.value);
  3315. (/** @type {?} */ (this.statusChanges)).emit(this.status);
  3316. }
  3317. this._updateAncestors(opts);
  3318. this._onDisabledChange.forEach(function (changeFn) { return changeFn(true); });
  3319. };
  3320. /**
  3321. * Enables the control. This means the control will be included in validation checks and
  3322. * the aggregate value of its parent. Its status is re-calculated based on its value and
  3323. * its validators.
  3324. *
  3325. * If the control has children, all children will be enabled.
  3326. */
  3327. /**
  3328. * Enables the control. This means the control will be included in validation checks and
  3329. * the aggregate value of its parent. Its status is re-calculated based on its value and
  3330. * its validators.
  3331. *
  3332. * If the control has children, all children will be enabled.
  3333. * @param {?=} opts
  3334. * @return {?}
  3335. */
  3336. AbstractControl.prototype.enable = /**
  3337. * Enables the control. This means the control will be included in validation checks and
  3338. * the aggregate value of its parent. Its status is re-calculated based on its value and
  3339. * its validators.
  3340. *
  3341. * If the control has children, all children will be enabled.
  3342. * @param {?=} opts
  3343. * @return {?}
  3344. */
  3345. function (opts) {
  3346. if (opts === void 0) { opts = {}; }
  3347. (/** @type {?} */ (this)).status = VALID;
  3348. this._forEachChild(function (control) { control.enable(__assign({}, opts, { onlySelf: true })); });
  3349. this.updateValueAndValidity({ onlySelf: true, emitEvent: opts.emitEvent });
  3350. this._updateAncestors(opts);
  3351. this._onDisabledChange.forEach(function (changeFn) { return changeFn(false); });
  3352. };
  3353. /**
  3354. * @param {?} opts
  3355. * @return {?}
  3356. */
  3357. AbstractControl.prototype._updateAncestors = /**
  3358. * @param {?} opts
  3359. * @return {?}
  3360. */
  3361. function (opts) {
  3362. if (this._parent && !opts.onlySelf) {
  3363. this._parent.updateValueAndValidity(opts);
  3364. this._parent._updatePristine();
  3365. this._parent._updateTouched();
  3366. }
  3367. };
  3368. /**
  3369. * @param {?} parent
  3370. * @return {?}
  3371. */
  3372. AbstractControl.prototype.setParent = /**
  3373. * @param {?} parent
  3374. * @return {?}
  3375. */
  3376. function (parent) { this._parent = parent; };
  3377. /**
  3378. * Re-calculates the value and validation status of the control.
  3379. *
  3380. * By default, it will also update the value and validity of its ancestors.
  3381. */
  3382. /**
  3383. * Re-calculates the value and validation status of the control.
  3384. *
  3385. * By default, it will also update the value and validity of its ancestors.
  3386. * @param {?=} opts
  3387. * @return {?}
  3388. */
  3389. AbstractControl.prototype.updateValueAndValidity = /**
  3390. * Re-calculates the value and validation status of the control.
  3391. *
  3392. * By default, it will also update the value and validity of its ancestors.
  3393. * @param {?=} opts
  3394. * @return {?}
  3395. */
  3396. function (opts) {
  3397. if (opts === void 0) { opts = {}; }
  3398. this._setInitialStatus();
  3399. this._updateValue();
  3400. if (this.enabled) {
  3401. this._cancelExistingSubscription();
  3402. (/** @type {?} */ (this)).errors = this._runValidator();
  3403. (/** @type {?} */ (this)).status = this._calculateStatus();
  3404. if (this.status === VALID || this.status === PENDING) {
  3405. this._runAsyncValidator(opts.emitEvent);
  3406. }
  3407. }
  3408. if (opts.emitEvent !== false) {
  3409. (/** @type {?} */ (this.valueChanges)).emit(this.value);
  3410. (/** @type {?} */ (this.statusChanges)).emit(this.status);
  3411. }
  3412. if (this._parent && !opts.onlySelf) {
  3413. this._parent.updateValueAndValidity(opts);
  3414. }
  3415. };
  3416. /** @internal */
  3417. /**
  3418. * \@internal
  3419. * @param {?=} opts
  3420. * @return {?}
  3421. */
  3422. AbstractControl.prototype._updateTreeValidity = /**
  3423. * \@internal
  3424. * @param {?=} opts
  3425. * @return {?}
  3426. */
  3427. function (opts) {
  3428. if (opts === void 0) { opts = { emitEvent: true }; }
  3429. this._forEachChild(function (ctrl) { return ctrl._updateTreeValidity(opts); });
  3430. this.updateValueAndValidity({ onlySelf: true, emitEvent: opts.emitEvent });
  3431. };
  3432. /**
  3433. * @return {?}
  3434. */
  3435. AbstractControl.prototype._setInitialStatus = /**
  3436. * @return {?}
  3437. */
  3438. function () {
  3439. (/** @type {?} */ (this)).status = this._allControlsDisabled() ? DISABLED : VALID;
  3440. };
  3441. /**
  3442. * @return {?}
  3443. */
  3444. AbstractControl.prototype._runValidator = /**
  3445. * @return {?}
  3446. */
  3447. function () {
  3448. return this.validator ? this.validator(this) : null;
  3449. };
  3450. /**
  3451. * @param {?=} emitEvent
  3452. * @return {?}
  3453. */
  3454. AbstractControl.prototype._runAsyncValidator = /**
  3455. * @param {?=} emitEvent
  3456. * @return {?}
  3457. */
  3458. function (emitEvent) {
  3459. var _this = this;
  3460. if (this.asyncValidator) {
  3461. (/** @type {?} */ (this)).status = PENDING;
  3462. var /** @type {?} */ obs = toObservable(this.asyncValidator(this));
  3463. this._asyncValidationSubscription =
  3464. obs.subscribe(function (errors) { return _this.setErrors(errors, { emitEvent: emitEvent }); });
  3465. }
  3466. };
  3467. /**
  3468. * @return {?}
  3469. */
  3470. AbstractControl.prototype._cancelExistingSubscription = /**
  3471. * @return {?}
  3472. */
  3473. function () {
  3474. if (this._asyncValidationSubscription) {
  3475. this._asyncValidationSubscription.unsubscribe();
  3476. }
  3477. };
  3478. /**
  3479. * Sets errors on a form control.
  3480. *
  3481. * This is used when validations are run manually by the user, rather than automatically.
  3482. *
  3483. * Calling `setErrors` will also update the validity of the parent control.
  3484. *
  3485. * ### Example
  3486. *
  3487. * ```
  3488. * const login = new FormControl("someLogin");
  3489. * login.setErrors({
  3490. * "notUnique": true
  3491. * });
  3492. *
  3493. * expect(login.valid).toEqual(false);
  3494. * expect(login.errors).toEqual({"notUnique": true});
  3495. *
  3496. * login.setValue("someOtherLogin");
  3497. *
  3498. * expect(login.valid).toEqual(true);
  3499. * ```
  3500. */
  3501. /**
  3502. * Sets errors on a form control.
  3503. *
  3504. * This is used when validations are run manually by the user, rather than automatically.
  3505. *
  3506. * Calling `setErrors` will also update the validity of the parent control.
  3507. *
  3508. * ### Example
  3509. *
  3510. * ```
  3511. * const login = new FormControl("someLogin");
  3512. * login.setErrors({
  3513. * "notUnique": true
  3514. * });
  3515. *
  3516. * expect(login.valid).toEqual(false);
  3517. * expect(login.errors).toEqual({"notUnique": true});
  3518. *
  3519. * login.setValue("someOtherLogin");
  3520. *
  3521. * expect(login.valid).toEqual(true);
  3522. * ```
  3523. * @param {?} errors
  3524. * @param {?=} opts
  3525. * @return {?}
  3526. */
  3527. AbstractControl.prototype.setErrors = /**
  3528. * Sets errors on a form control.
  3529. *
  3530. * This is used when validations are run manually by the user, rather than automatically.
  3531. *
  3532. * Calling `setErrors` will also update the validity of the parent control.
  3533. *
  3534. * ### Example
  3535. *
  3536. * ```
  3537. * const login = new FormControl("someLogin");
  3538. * login.setErrors({
  3539. * "notUnique": true
  3540. * });
  3541. *
  3542. * expect(login.valid).toEqual(false);
  3543. * expect(login.errors).toEqual({"notUnique": true});
  3544. *
  3545. * login.setValue("someOtherLogin");
  3546. *
  3547. * expect(login.valid).toEqual(true);
  3548. * ```
  3549. * @param {?} errors
  3550. * @param {?=} opts
  3551. * @return {?}
  3552. */
  3553. function (errors, opts) {
  3554. if (opts === void 0) { opts = {}; }
  3555. (/** @type {?} */ (this)).errors = errors;
  3556. this._updateControlsErrors(opts.emitEvent !== false);
  3557. };
  3558. /**
  3559. * Retrieves a child control given the control's name or path.
  3560. *
  3561. * Paths can be passed in as an array or a string delimited by a dot.
  3562. *
  3563. * To get a control nested within a `person` sub-group:
  3564. *
  3565. * * `this.form.get('person.name');`
  3566. *
  3567. * -OR-
  3568. *
  3569. * * `this.form.get(['person', 'name']);`
  3570. */
  3571. /**
  3572. * Retrieves a child control given the control's name or path.
  3573. *
  3574. * Paths can be passed in as an array or a string delimited by a dot.
  3575. *
  3576. * To get a control nested within a `person` sub-group:
  3577. *
  3578. * * `this.form.get('person.name');`
  3579. *
  3580. * -OR-
  3581. *
  3582. * * `this.form.get(['person', 'name']);`
  3583. * @param {?} path
  3584. * @return {?}
  3585. */
  3586. AbstractControl.prototype.get = /**
  3587. * Retrieves a child control given the control's name or path.
  3588. *
  3589. * Paths can be passed in as an array or a string delimited by a dot.
  3590. *
  3591. * To get a control nested within a `person` sub-group:
  3592. *
  3593. * * `this.form.get('person.name');`
  3594. *
  3595. * -OR-
  3596. *
  3597. * * `this.form.get(['person', 'name']);`
  3598. * @param {?} path
  3599. * @return {?}
  3600. */
  3601. function (path) { return _find(this, path, '.'); };
  3602. /**
  3603. * Returns error data if the control with the given path has the error specified. Otherwise
  3604. * returns null or undefined.
  3605. *
  3606. * If no path is given, it checks for the error on the present control.
  3607. */
  3608. /**
  3609. * Returns error data if the control with the given path has the error specified. Otherwise
  3610. * returns null or undefined.
  3611. *
  3612. * If no path is given, it checks for the error on the present control.
  3613. * @param {?} errorCode
  3614. * @param {?=} path
  3615. * @return {?}
  3616. */
  3617. AbstractControl.prototype.getError = /**
  3618. * Returns error data if the control with the given path has the error specified. Otherwise
  3619. * returns null or undefined.
  3620. *
  3621. * If no path is given, it checks for the error on the present control.
  3622. * @param {?} errorCode
  3623. * @param {?=} path
  3624. * @return {?}
  3625. */
  3626. function (errorCode, path) {
  3627. var /** @type {?} */ control = path ? this.get(path) : this;
  3628. return control && control.errors ? control.errors[errorCode] : null;
  3629. };
  3630. /**
  3631. * Returns true if the control with the given path has the error specified. Otherwise
  3632. * returns false.
  3633. *
  3634. * If no path is given, it checks for the error on the present control.
  3635. */
  3636. /**
  3637. * Returns true if the control with the given path has the error specified. Otherwise
  3638. * returns false.
  3639. *
  3640. * If no path is given, it checks for the error on the present control.
  3641. * @param {?} errorCode
  3642. * @param {?=} path
  3643. * @return {?}
  3644. */
  3645. AbstractControl.prototype.hasError = /**
  3646. * Returns true if the control with the given path has the error specified. Otherwise
  3647. * returns false.
  3648. *
  3649. * If no path is given, it checks for the error on the present control.
  3650. * @param {?} errorCode
  3651. * @param {?=} path
  3652. * @return {?}
  3653. */
  3654. function (errorCode, path) { return !!this.getError(errorCode, path); };
  3655. Object.defineProperty(AbstractControl.prototype, "root", {
  3656. /**
  3657. * Retrieves the top-level ancestor of this control.
  3658. */
  3659. get: /**
  3660. * Retrieves the top-level ancestor of this control.
  3661. * @return {?}
  3662. */
  3663. function () {
  3664. var /** @type {?} */ x = this;
  3665. while (x._parent) {
  3666. x = x._parent;
  3667. }
  3668. return x;
  3669. },
  3670. enumerable: true,
  3671. configurable: true
  3672. });
  3673. /** @internal */
  3674. /**
  3675. * \@internal
  3676. * @param {?} emitEvent
  3677. * @return {?}
  3678. */
  3679. AbstractControl.prototype._updateControlsErrors = /**
  3680. * \@internal
  3681. * @param {?} emitEvent
  3682. * @return {?}
  3683. */
  3684. function (emitEvent) {
  3685. (/** @type {?} */ (this)).status = this._calculateStatus();
  3686. if (emitEvent) {
  3687. (/** @type {?} */ (this.statusChanges)).emit(this.status);
  3688. }
  3689. if (this._parent) {
  3690. this._parent._updateControlsErrors(emitEvent);
  3691. }
  3692. };
  3693. /** @internal */
  3694. /**
  3695. * \@internal
  3696. * @return {?}
  3697. */
  3698. AbstractControl.prototype._initObservables = /**
  3699. * \@internal
  3700. * @return {?}
  3701. */
  3702. function () {
  3703. (/** @type {?} */ (this)).valueChanges = new _angular_core.EventEmitter();
  3704. (/** @type {?} */ (this)).statusChanges = new _angular_core.EventEmitter();
  3705. };
  3706. /**
  3707. * @return {?}
  3708. */
  3709. AbstractControl.prototype._calculateStatus = /**
  3710. * @return {?}
  3711. */
  3712. function () {
  3713. if (this._allControlsDisabled())
  3714. return DISABLED;
  3715. if (this.errors)
  3716. return INVALID;
  3717. if (this._anyControlsHaveStatus(PENDING))
  3718. return PENDING;
  3719. if (this._anyControlsHaveStatus(INVALID))
  3720. return INVALID;
  3721. return VALID;
  3722. };
  3723. /** @internal */
  3724. /**
  3725. * \@internal
  3726. * @param {?} status
  3727. * @return {?}
  3728. */
  3729. AbstractControl.prototype._anyControlsHaveStatus = /**
  3730. * \@internal
  3731. * @param {?} status
  3732. * @return {?}
  3733. */
  3734. function (status) {
  3735. return this._anyControls(function (control) { return control.status === status; });
  3736. };
  3737. /** @internal */
  3738. /**
  3739. * \@internal
  3740. * @return {?}
  3741. */
  3742. AbstractControl.prototype._anyControlsDirty = /**
  3743. * \@internal
  3744. * @return {?}
  3745. */
  3746. function () {
  3747. return this._anyControls(function (control) { return control.dirty; });
  3748. };
  3749. /** @internal */
  3750. /**
  3751. * \@internal
  3752. * @return {?}
  3753. */
  3754. AbstractControl.prototype._anyControlsTouched = /**
  3755. * \@internal
  3756. * @return {?}
  3757. */
  3758. function () {
  3759. return this._anyControls(function (control) { return control.touched; });
  3760. };
  3761. /** @internal */
  3762. /**
  3763. * \@internal
  3764. * @param {?=} opts
  3765. * @return {?}
  3766. */
  3767. AbstractControl.prototype._updatePristine = /**
  3768. * \@internal
  3769. * @param {?=} opts
  3770. * @return {?}
  3771. */
  3772. function (opts) {
  3773. if (opts === void 0) { opts = {}; }
  3774. (/** @type {?} */ (this)).pristine = !this._anyControlsDirty();
  3775. if (this._parent && !opts.onlySelf) {
  3776. this._parent._updatePristine(opts);
  3777. }
  3778. };
  3779. /** @internal */
  3780. /**
  3781. * \@internal
  3782. * @param {?=} opts
  3783. * @return {?}
  3784. */
  3785. AbstractControl.prototype._updateTouched = /**
  3786. * \@internal
  3787. * @param {?=} opts
  3788. * @return {?}
  3789. */
  3790. function (opts) {
  3791. if (opts === void 0) { opts = {}; }
  3792. (/** @type {?} */ (this)).touched = this._anyControlsTouched();
  3793. if (this._parent && !opts.onlySelf) {
  3794. this._parent._updateTouched(opts);
  3795. }
  3796. };
  3797. /** @internal */
  3798. /**
  3799. * \@internal
  3800. * @param {?} formState
  3801. * @return {?}
  3802. */
  3803. AbstractControl.prototype._isBoxedValue = /**
  3804. * \@internal
  3805. * @param {?} formState
  3806. * @return {?}
  3807. */
  3808. function (formState) {
  3809. return typeof formState === 'object' && formState !== null &&
  3810. Object.keys(formState).length === 2 && 'value' in formState && 'disabled' in formState;
  3811. };
  3812. /** @internal */
  3813. /**
  3814. * \@internal
  3815. * @param {?} fn
  3816. * @return {?}
  3817. */
  3818. AbstractControl.prototype._registerOnCollectionChange = /**
  3819. * \@internal
  3820. * @param {?} fn
  3821. * @return {?}
  3822. */
  3823. function (fn) { this._onCollectionChange = fn; };
  3824. /** @internal */
  3825. /**
  3826. * \@internal
  3827. * @param {?=} opts
  3828. * @return {?}
  3829. */
  3830. AbstractControl.prototype._setUpdateStrategy = /**
  3831. * \@internal
  3832. * @param {?=} opts
  3833. * @return {?}
  3834. */
  3835. function (opts) {
  3836. if (isOptionsObj(opts) && (/** @type {?} */ (opts)).updateOn != null) {
  3837. this._updateOn = /** @type {?} */ (((/** @type {?} */ (opts)).updateOn));
  3838. }
  3839. };
  3840. return AbstractControl;
  3841. }());
  3842. /**
  3843. * \@whatItDoes Tracks the value and validation status of an individual form control.
  3844. *
  3845. * It is one of the three fundamental building blocks of Angular forms, along with
  3846. * {\@link FormGroup} and {\@link FormArray}.
  3847. *
  3848. * \@howToUse
  3849. *
  3850. * When instantiating a {\@link FormControl}, you can pass in an initial value as the
  3851. * first argument. Example:
  3852. *
  3853. * ```ts
  3854. * const ctrl = new FormControl('some value');
  3855. * console.log(ctrl.value); // 'some value'
  3856. * ```
  3857. *
  3858. * You can also initialize the control with a form state object on instantiation,
  3859. * which includes both the value and whether or not the control is disabled.
  3860. * You can't use the value key without the disabled key; both are required
  3861. * to use this way of initialization.
  3862. *
  3863. * ```ts
  3864. * const ctrl = new FormControl({value: 'n/a', disabled: true});
  3865. * console.log(ctrl.value); // 'n/a'
  3866. * console.log(ctrl.status); // 'DISABLED'
  3867. * ```
  3868. *
  3869. * The second {\@link FormControl} argument can accept one of three things:
  3870. * * a sync validator function
  3871. * * an array of sync validator functions
  3872. * * an options object containing validator and/or async validator functions
  3873. *
  3874. * Example of a single sync validator function:
  3875. *
  3876. * ```ts
  3877. * const ctrl = new FormControl('', Validators.required);
  3878. * console.log(ctrl.value); // ''
  3879. * console.log(ctrl.status); // 'INVALID'
  3880. * ```
  3881. *
  3882. * Example using options object:
  3883. *
  3884. * ```ts
  3885. * const ctrl = new FormControl('', {
  3886. * validators: Validators.required,
  3887. * asyncValidators: myAsyncValidator
  3888. * });
  3889. * ```
  3890. *
  3891. * The options object can also be used to define when the control should update.
  3892. * By default, the value and validity of a control updates whenever the value
  3893. * changes. You can configure it to update on the blur event instead by setting
  3894. * the `updateOn` option to `'blur'`.
  3895. *
  3896. * ```ts
  3897. * const c = new FormControl('', { updateOn: 'blur' });
  3898. * ```
  3899. *
  3900. * You can also set `updateOn` to `'submit'`, which will delay value and validity
  3901. * updates until the parent form of the control fires a submit event.
  3902. *
  3903. * See its superclass, {\@link AbstractControl}, for more properties and methods.
  3904. *
  3905. * * **npm package**: `\@angular/forms`
  3906. *
  3907. * \@stable
  3908. */
  3909. var FormControl = /** @class */ (function (_super) {
  3910. __extends(FormControl, _super);
  3911. function FormControl(formState, validatorOrOpts, asyncValidator) {
  3912. if (formState === void 0) { formState = null; }
  3913. var _this = _super.call(this, coerceToValidator(validatorOrOpts), coerceToAsyncValidator(asyncValidator, validatorOrOpts)) || this;
  3914. /**
  3915. * \@internal
  3916. */
  3917. _this._onChange = [];
  3918. _this._applyFormState(formState);
  3919. _this._setUpdateStrategy(validatorOrOpts);
  3920. _this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
  3921. _this._initObservables();
  3922. return _this;
  3923. }
  3924. /**
  3925. * Set the value of the form control to `value`.
  3926. *
  3927. * If `onlySelf` is `true`, this change will only affect the validation of this `FormControl`
  3928. * and not its parent component. This defaults to false.
  3929. *
  3930. * If `emitEvent` is `true`, this
  3931. * change will cause a `valueChanges` event on the `FormControl` to be emitted. This defaults
  3932. * to true (as it falls through to `updateValueAndValidity`).
  3933. *
  3934. * If `emitModelToViewChange` is `true`, the view will be notified about the new value
  3935. * via an `onChange` event. This is the default behavior if `emitModelToViewChange` is not
  3936. * specified.
  3937. *
  3938. * If `emitViewToModelChange` is `true`, an ngModelChange event will be fired to update the
  3939. * model. This is the default behavior if `emitViewToModelChange` is not specified.
  3940. */
  3941. /**
  3942. * Set the value of the form control to `value`.
  3943. *
  3944. * If `onlySelf` is `true`, this change will only affect the validation of this `FormControl`
  3945. * and not its parent component. This defaults to false.
  3946. *
  3947. * If `emitEvent` is `true`, this
  3948. * change will cause a `valueChanges` event on the `FormControl` to be emitted. This defaults
  3949. * to true (as it falls through to `updateValueAndValidity`).
  3950. *
  3951. * If `emitModelToViewChange` is `true`, the view will be notified about the new value
  3952. * via an `onChange` event. This is the default behavior if `emitModelToViewChange` is not
  3953. * specified.
  3954. *
  3955. * If `emitViewToModelChange` is `true`, an ngModelChange event will be fired to update the
  3956. * model. This is the default behavior if `emitViewToModelChange` is not specified.
  3957. * @param {?} value
  3958. * @param {?=} options
  3959. * @return {?}
  3960. */
  3961. FormControl.prototype.setValue = /**
  3962. * Set the value of the form control to `value`.
  3963. *
  3964. * If `onlySelf` is `true`, this change will only affect the validation of this `FormControl`
  3965. * and not its parent component. This defaults to false.
  3966. *
  3967. * If `emitEvent` is `true`, this
  3968. * change will cause a `valueChanges` event on the `FormControl` to be emitted. This defaults
  3969. * to true (as it falls through to `updateValueAndValidity`).
  3970. *
  3971. * If `emitModelToViewChange` is `true`, the view will be notified about the new value
  3972. * via an `onChange` event. This is the default behavior if `emitModelToViewChange` is not
  3973. * specified.
  3974. *
  3975. * If `emitViewToModelChange` is `true`, an ngModelChange event will be fired to update the
  3976. * model. This is the default behavior if `emitViewToModelChange` is not specified.
  3977. * @param {?} value
  3978. * @param {?=} options
  3979. * @return {?}
  3980. */
  3981. function (value, options) {
  3982. var _this = this;
  3983. if (options === void 0) { options = {}; }
  3984. (/** @type {?} */ (this)).value = this._pendingValue = value;
  3985. if (this._onChange.length && options.emitModelToViewChange !== false) {
  3986. this._onChange.forEach(function (changeFn) { return changeFn(_this.value, options.emitViewToModelChange !== false); });
  3987. }
  3988. this.updateValueAndValidity(options);
  3989. };
  3990. /**
  3991. * Patches the value of a control.
  3992. *
  3993. * This function is functionally the same as {@link FormControl#setValue setValue} at this level.
  3994. * It exists for symmetry with {@link FormGroup#patchValue patchValue} on `FormGroups` and
  3995. * `FormArrays`, where it does behave differently.
  3996. */
  3997. /**
  3998. * Patches the value of a control.
  3999. *
  4000. * This function is functionally the same as {\@link FormControl#setValue setValue} at this level.
  4001. * It exists for symmetry with {\@link FormGroup#patchValue patchValue} on `FormGroups` and
  4002. * `FormArrays`, where it does behave differently.
  4003. * @param {?} value
  4004. * @param {?=} options
  4005. * @return {?}
  4006. */
  4007. FormControl.prototype.patchValue = /**
  4008. * Patches the value of a control.
  4009. *
  4010. * This function is functionally the same as {\@link FormControl#setValue setValue} at this level.
  4011. * It exists for symmetry with {\@link FormGroup#patchValue patchValue} on `FormGroups` and
  4012. * `FormArrays`, where it does behave differently.
  4013. * @param {?} value
  4014. * @param {?=} options
  4015. * @return {?}
  4016. */
  4017. function (value, options) {
  4018. if (options === void 0) { options = {}; }
  4019. this.setValue(value, options);
  4020. };
  4021. /**
  4022. * Resets the form control. This means by default:
  4023. *
  4024. * * it is marked as `pristine`
  4025. * * it is marked as `untouched`
  4026. * * value is set to null
  4027. *
  4028. * You can also reset to a specific form state by passing through a standalone
  4029. * value or a form state object that contains both a value and a disabled state
  4030. * (these are the only two properties that cannot be calculated).
  4031. *
  4032. * Ex:
  4033. *
  4034. * ```ts
  4035. * this.control.reset('Nancy');
  4036. *
  4037. * console.log(this.control.value); // 'Nancy'
  4038. * ```
  4039. *
  4040. * OR
  4041. *
  4042. * ```
  4043. * this.control.reset({value: 'Nancy', disabled: true});
  4044. *
  4045. * console.log(this.control.value); // 'Nancy'
  4046. * console.log(this.control.status); // 'DISABLED'
  4047. * ```
  4048. */
  4049. /**
  4050. * Resets the form control. This means by default:
  4051. *
  4052. * * it is marked as `pristine`
  4053. * * it is marked as `untouched`
  4054. * * value is set to null
  4055. *
  4056. * You can also reset to a specific form state by passing through a standalone
  4057. * value or a form state object that contains both a value and a disabled state
  4058. * (these are the only two properties that cannot be calculated).
  4059. *
  4060. * Ex:
  4061. *
  4062. * ```ts
  4063. * this.control.reset('Nancy');
  4064. *
  4065. * console.log(this.control.value); // 'Nancy'
  4066. * ```
  4067. *
  4068. * OR
  4069. *
  4070. * ```
  4071. * this.control.reset({value: 'Nancy', disabled: true});
  4072. *
  4073. * console.log(this.control.value); // 'Nancy'
  4074. * console.log(this.control.status); // 'DISABLED'
  4075. * ```
  4076. * @param {?=} formState
  4077. * @param {?=} options
  4078. * @return {?}
  4079. */
  4080. FormControl.prototype.reset = /**
  4081. * Resets the form control. This means by default:
  4082. *
  4083. * * it is marked as `pristine`
  4084. * * it is marked as `untouched`
  4085. * * value is set to null
  4086. *
  4087. * You can also reset to a specific form state by passing through a standalone
  4088. * value or a form state object that contains both a value and a disabled state
  4089. * (these are the only two properties that cannot be calculated).
  4090. *
  4091. * Ex:
  4092. *
  4093. * ```ts
  4094. * this.control.reset('Nancy');
  4095. *
  4096. * console.log(this.control.value); // 'Nancy'
  4097. * ```
  4098. *
  4099. * OR
  4100. *
  4101. * ```
  4102. * this.control.reset({value: 'Nancy', disabled: true});
  4103. *
  4104. * console.log(this.control.value); // 'Nancy'
  4105. * console.log(this.control.status); // 'DISABLED'
  4106. * ```
  4107. * @param {?=} formState
  4108. * @param {?=} options
  4109. * @return {?}
  4110. */
  4111. function (formState, options) {
  4112. if (formState === void 0) { formState = null; }
  4113. if (options === void 0) { options = {}; }
  4114. this._applyFormState(formState);
  4115. this.markAsPristine(options);
  4116. this.markAsUntouched(options);
  4117. this.setValue(this.value, options);
  4118. this._pendingChange = false;
  4119. };
  4120. /**
  4121. * @internal
  4122. */
  4123. /**
  4124. * \@internal
  4125. * @return {?}
  4126. */
  4127. FormControl.prototype._updateValue = /**
  4128. * \@internal
  4129. * @return {?}
  4130. */
  4131. function () { };
  4132. /**
  4133. * @internal
  4134. */
  4135. /**
  4136. * \@internal
  4137. * @param {?} condition
  4138. * @return {?}
  4139. */
  4140. FormControl.prototype._anyControls = /**
  4141. * \@internal
  4142. * @param {?} condition
  4143. * @return {?}
  4144. */
  4145. function (condition) { return false; };
  4146. /**
  4147. * @internal
  4148. */
  4149. /**
  4150. * \@internal
  4151. * @return {?}
  4152. */
  4153. FormControl.prototype._allControlsDisabled = /**
  4154. * \@internal
  4155. * @return {?}
  4156. */
  4157. function () { return this.disabled; };
  4158. /**
  4159. * Register a listener for change events.
  4160. */
  4161. /**
  4162. * Register a listener for change events.
  4163. * @param {?} fn
  4164. * @return {?}
  4165. */
  4166. FormControl.prototype.registerOnChange = /**
  4167. * Register a listener for change events.
  4168. * @param {?} fn
  4169. * @return {?}
  4170. */
  4171. function (fn) { this._onChange.push(fn); };
  4172. /**
  4173. * @internal
  4174. */
  4175. /**
  4176. * \@internal
  4177. * @return {?}
  4178. */
  4179. FormControl.prototype._clearChangeFns = /**
  4180. * \@internal
  4181. * @return {?}
  4182. */
  4183. function () {
  4184. this._onChange = [];
  4185. this._onDisabledChange = [];
  4186. this._onCollectionChange = function () { };
  4187. };
  4188. /**
  4189. * Register a listener for disabled events.
  4190. */
  4191. /**
  4192. * Register a listener for disabled events.
  4193. * @param {?} fn
  4194. * @return {?}
  4195. */
  4196. FormControl.prototype.registerOnDisabledChange = /**
  4197. * Register a listener for disabled events.
  4198. * @param {?} fn
  4199. * @return {?}
  4200. */
  4201. function (fn) {
  4202. this._onDisabledChange.push(fn);
  4203. };
  4204. /**
  4205. * @internal
  4206. */
  4207. /**
  4208. * \@internal
  4209. * @param {?} cb
  4210. * @return {?}
  4211. */
  4212. FormControl.prototype._forEachChild = /**
  4213. * \@internal
  4214. * @param {?} cb
  4215. * @return {?}
  4216. */
  4217. function (cb) { };
  4218. /** @internal */
  4219. /**
  4220. * \@internal
  4221. * @return {?}
  4222. */
  4223. FormControl.prototype._syncPendingControls = /**
  4224. * \@internal
  4225. * @return {?}
  4226. */
  4227. function () {
  4228. if (this.updateOn === 'submit') {
  4229. if (this._pendingDirty)
  4230. this.markAsDirty();
  4231. if (this._pendingTouched)
  4232. this.markAsTouched();
  4233. if (this._pendingChange) {
  4234. this.setValue(this._pendingValue, { onlySelf: true, emitModelToViewChange: false });
  4235. return true;
  4236. }
  4237. }
  4238. return false;
  4239. };
  4240. /**
  4241. * @param {?} formState
  4242. * @return {?}
  4243. */
  4244. FormControl.prototype._applyFormState = /**
  4245. * @param {?} formState
  4246. * @return {?}
  4247. */
  4248. function (formState) {
  4249. if (this._isBoxedValue(formState)) {
  4250. (/** @type {?} */ (this)).value = this._pendingValue = formState.value;
  4251. formState.disabled ? this.disable({ onlySelf: true, emitEvent: false }) :
  4252. this.enable({ onlySelf: true, emitEvent: false });
  4253. }
  4254. else {
  4255. (/** @type {?} */ (this)).value = this._pendingValue = formState;
  4256. }
  4257. };
  4258. return FormControl;
  4259. }(AbstractControl));
  4260. /**
  4261. * \@whatItDoes Tracks the value and validity state of a group of {\@link FormControl}
  4262. * instances.
  4263. *
  4264. * A `FormGroup` aggregates the values of each child {\@link FormControl} into one object,
  4265. * with each control name as the key. It calculates its status by reducing the statuses
  4266. * of its children. For example, if one of the controls in a group is invalid, the entire
  4267. * group becomes invalid.
  4268. *
  4269. * `FormGroup` is one of the three fundamental building blocks used to define forms in Angular,
  4270. * along with {\@link FormControl} and {\@link FormArray}.
  4271. *
  4272. * \@howToUse
  4273. *
  4274. * When instantiating a {\@link FormGroup}, pass in a collection of child controls as the first
  4275. * argument. The key for each child will be the name under which it is registered.
  4276. *
  4277. * ### Example
  4278. *
  4279. * ```
  4280. * const form = new FormGroup({
  4281. * first: new FormControl('Nancy', Validators.minLength(2)),
  4282. * last: new FormControl('Drew'),
  4283. * });
  4284. *
  4285. * console.log(form.value); // {first: 'Nancy', last; 'Drew'}
  4286. * console.log(form.status); // 'VALID'
  4287. * ```
  4288. *
  4289. * You can also include group-level validators as the second arg, or group-level async
  4290. * validators as the third arg. These come in handy when you want to perform validation
  4291. * that considers the value of more than one child control.
  4292. *
  4293. * ### Example
  4294. *
  4295. * ```
  4296. * const form = new FormGroup({
  4297. * password: new FormControl('', Validators.minLength(2)),
  4298. * passwordConfirm: new FormControl('', Validators.minLength(2)),
  4299. * }, passwordMatchValidator);
  4300. *
  4301. *
  4302. * function passwordMatchValidator(g: FormGroup) {
  4303. * return g.get('password').value === g.get('passwordConfirm').value
  4304. * ? null : {'mismatch': true};
  4305. * }
  4306. * ```
  4307. *
  4308. * Like {\@link FormControl} instances, you can alternatively choose to pass in
  4309. * validators and async validators as part of an options object.
  4310. *
  4311. * ```
  4312. * const form = new FormGroup({
  4313. * password: new FormControl('')
  4314. * passwordConfirm: new FormControl('')
  4315. * }, {validators: passwordMatchValidator, asyncValidators: otherValidator});
  4316. * ```
  4317. *
  4318. * The options object can also be used to set a default value for each child
  4319. * control's `updateOn` property. If you set `updateOn` to `'blur'` at the
  4320. * group level, all child controls will default to 'blur', unless the child
  4321. * has explicitly specified a different `updateOn` value.
  4322. *
  4323. * ```ts
  4324. * const c = new FormGroup({
  4325. * one: new FormControl()
  4326. * }, {updateOn: 'blur'});
  4327. * ```
  4328. *
  4329. * * **npm package**: `\@angular/forms`
  4330. *
  4331. * \@stable
  4332. */
  4333. var FormGroup = /** @class */ (function (_super) {
  4334. __extends(FormGroup, _super);
  4335. function FormGroup(controls, validatorOrOpts, asyncValidator) {
  4336. var _this = _super.call(this, coerceToValidator(validatorOrOpts), coerceToAsyncValidator(asyncValidator, validatorOrOpts)) || this;
  4337. _this.controls = controls;
  4338. _this._initObservables();
  4339. _this._setUpdateStrategy(validatorOrOpts);
  4340. _this._setUpControls();
  4341. _this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
  4342. return _this;
  4343. }
  4344. /**
  4345. * Registers a control with the group's list of controls.
  4346. *
  4347. * This method does not update the value or validity of the control, so for most cases you'll want
  4348. * to use {@link FormGroup#addControl addControl} instead.
  4349. */
  4350. /**
  4351. * Registers a control with the group's list of controls.
  4352. *
  4353. * This method does not update the value or validity of the control, so for most cases you'll want
  4354. * to use {\@link FormGroup#addControl addControl} instead.
  4355. * @param {?} name
  4356. * @param {?} control
  4357. * @return {?}
  4358. */
  4359. FormGroup.prototype.registerControl = /**
  4360. * Registers a control with the group's list of controls.
  4361. *
  4362. * This method does not update the value or validity of the control, so for most cases you'll want
  4363. * to use {\@link FormGroup#addControl addControl} instead.
  4364. * @param {?} name
  4365. * @param {?} control
  4366. * @return {?}
  4367. */
  4368. function (name, control) {
  4369. if (this.controls[name])
  4370. return this.controls[name];
  4371. this.controls[name] = control;
  4372. control.setParent(this);
  4373. control._registerOnCollectionChange(this._onCollectionChange);
  4374. return control;
  4375. };
  4376. /**
  4377. * Add a control to this group.
  4378. */
  4379. /**
  4380. * Add a control to this group.
  4381. * @param {?} name
  4382. * @param {?} control
  4383. * @return {?}
  4384. */
  4385. FormGroup.prototype.addControl = /**
  4386. * Add a control to this group.
  4387. * @param {?} name
  4388. * @param {?} control
  4389. * @return {?}
  4390. */
  4391. function (name, control) {
  4392. this.registerControl(name, control);
  4393. this.updateValueAndValidity();
  4394. this._onCollectionChange();
  4395. };
  4396. /**
  4397. * Remove a control from this group.
  4398. */
  4399. /**
  4400. * Remove a control from this group.
  4401. * @param {?} name
  4402. * @return {?}
  4403. */
  4404. FormGroup.prototype.removeControl = /**
  4405. * Remove a control from this group.
  4406. * @param {?} name
  4407. * @return {?}
  4408. */
  4409. function (name) {
  4410. if (this.controls[name])
  4411. this.controls[name]._registerOnCollectionChange(function () { });
  4412. delete (this.controls[name]);
  4413. this.updateValueAndValidity();
  4414. this._onCollectionChange();
  4415. };
  4416. /**
  4417. * Replace an existing control.
  4418. */
  4419. /**
  4420. * Replace an existing control.
  4421. * @param {?} name
  4422. * @param {?} control
  4423. * @return {?}
  4424. */
  4425. FormGroup.prototype.setControl = /**
  4426. * Replace an existing control.
  4427. * @param {?} name
  4428. * @param {?} control
  4429. * @return {?}
  4430. */
  4431. function (name, control) {
  4432. if (this.controls[name])
  4433. this.controls[name]._registerOnCollectionChange(function () { });
  4434. delete (this.controls[name]);
  4435. if (control)
  4436. this.registerControl(name, control);
  4437. this.updateValueAndValidity();
  4438. this._onCollectionChange();
  4439. };
  4440. /**
  4441. * Check whether there is an enabled control with the given name in the group.
  4442. *
  4443. * It will return false for disabled controls. If you'd like to check for existence in the group
  4444. * only, use {@link AbstractControl#get get} instead.
  4445. */
  4446. /**
  4447. * Check whether there is an enabled control with the given name in the group.
  4448. *
  4449. * It will return false for disabled controls. If you'd like to check for existence in the group
  4450. * only, use {\@link AbstractControl#get get} instead.
  4451. * @param {?} controlName
  4452. * @return {?}
  4453. */
  4454. FormGroup.prototype.contains = /**
  4455. * Check whether there is an enabled control with the given name in the group.
  4456. *
  4457. * It will return false for disabled controls. If you'd like to check for existence in the group
  4458. * only, use {\@link AbstractControl#get get} instead.
  4459. * @param {?} controlName
  4460. * @return {?}
  4461. */
  4462. function (controlName) {
  4463. return this.controls.hasOwnProperty(controlName) && this.controls[controlName].enabled;
  4464. };
  4465. /**
  4466. * Sets the value of the {@link FormGroup}. It accepts an object that matches
  4467. * the structure of the group, with control names as keys.
  4468. *
  4469. * This method performs strict checks, so it will throw an error if you try
  4470. * to set the value of a control that doesn't exist or if you exclude the
  4471. * value of a control.
  4472. *
  4473. * ### Example
  4474. *
  4475. * ```
  4476. * const form = new FormGroup({
  4477. * first: new FormControl(),
  4478. * last: new FormControl()
  4479. * });
  4480. * console.log(form.value); // {first: null, last: null}
  4481. *
  4482. * form.setValue({first: 'Nancy', last: 'Drew'});
  4483. * console.log(form.value); // {first: 'Nancy', last: 'Drew'}
  4484. *
  4485. * ```
  4486. */
  4487. /**
  4488. * Sets the value of the {\@link FormGroup}. It accepts an object that matches
  4489. * the structure of the group, with control names as keys.
  4490. *
  4491. * This method performs strict checks, so it will throw an error if you try
  4492. * to set the value of a control that doesn't exist or if you exclude the
  4493. * value of a control.
  4494. *
  4495. * ### Example
  4496. *
  4497. * ```
  4498. * const form = new FormGroup({
  4499. * first: new FormControl(),
  4500. * last: new FormControl()
  4501. * });
  4502. * console.log(form.value); // {first: null, last: null}
  4503. *
  4504. * form.setValue({first: 'Nancy', last: 'Drew'});
  4505. * console.log(form.value); // {first: 'Nancy', last: 'Drew'}
  4506. *
  4507. * ```
  4508. * @param {?} value
  4509. * @param {?=} options
  4510. * @return {?}
  4511. */
  4512. FormGroup.prototype.setValue = /**
  4513. * Sets the value of the {\@link FormGroup}. It accepts an object that matches
  4514. * the structure of the group, with control names as keys.
  4515. *
  4516. * This method performs strict checks, so it will throw an error if you try
  4517. * to set the value of a control that doesn't exist or if you exclude the
  4518. * value of a control.
  4519. *
  4520. * ### Example
  4521. *
  4522. * ```
  4523. * const form = new FormGroup({
  4524. * first: new FormControl(),
  4525. * last: new FormControl()
  4526. * });
  4527. * console.log(form.value); // {first: null, last: null}
  4528. *
  4529. * form.setValue({first: 'Nancy', last: 'Drew'});
  4530. * console.log(form.value); // {first: 'Nancy', last: 'Drew'}
  4531. *
  4532. * ```
  4533. * @param {?} value
  4534. * @param {?=} options
  4535. * @return {?}
  4536. */
  4537. function (value, options) {
  4538. var _this = this;
  4539. if (options === void 0) { options = {}; }
  4540. this._checkAllValuesPresent(value);
  4541. Object.keys(value).forEach(function (name) {
  4542. _this._throwIfControlMissing(name);
  4543. _this.controls[name].setValue(value[name], { onlySelf: true, emitEvent: options.emitEvent });
  4544. });
  4545. this.updateValueAndValidity(options);
  4546. };
  4547. /**
  4548. * Patches the value of the {@link FormGroup}. It accepts an object with control
  4549. * names as keys, and will do its best to match the values to the correct controls
  4550. * in the group.
  4551. *
  4552. * It accepts both super-sets and sub-sets of the group without throwing an error.
  4553. *
  4554. * ### Example
  4555. *
  4556. * ```
  4557. * const form = new FormGroup({
  4558. * first: new FormControl(),
  4559. * last: new FormControl()
  4560. * });
  4561. * console.log(form.value); // {first: null, last: null}
  4562. *
  4563. * form.patchValue({first: 'Nancy'});
  4564. * console.log(form.value); // {first: 'Nancy', last: null}
  4565. *
  4566. * ```
  4567. */
  4568. /**
  4569. * Patches the value of the {\@link FormGroup}. It accepts an object with control
  4570. * names as keys, and will do its best to match the values to the correct controls
  4571. * in the group.
  4572. *
  4573. * It accepts both super-sets and sub-sets of the group without throwing an error.
  4574. *
  4575. * ### Example
  4576. *
  4577. * ```
  4578. * const form = new FormGroup({
  4579. * first: new FormControl(),
  4580. * last: new FormControl()
  4581. * });
  4582. * console.log(form.value); // {first: null, last: null}
  4583. *
  4584. * form.patchValue({first: 'Nancy'});
  4585. * console.log(form.value); // {first: 'Nancy', last: null}
  4586. *
  4587. * ```
  4588. * @param {?} value
  4589. * @param {?=} options
  4590. * @return {?}
  4591. */
  4592. FormGroup.prototype.patchValue = /**
  4593. * Patches the value of the {\@link FormGroup}. It accepts an object with control
  4594. * names as keys, and will do its best to match the values to the correct controls
  4595. * in the group.
  4596. *
  4597. * It accepts both super-sets and sub-sets of the group without throwing an error.
  4598. *
  4599. * ### Example
  4600. *
  4601. * ```
  4602. * const form = new FormGroup({
  4603. * first: new FormControl(),
  4604. * last: new FormControl()
  4605. * });
  4606. * console.log(form.value); // {first: null, last: null}
  4607. *
  4608. * form.patchValue({first: 'Nancy'});
  4609. * console.log(form.value); // {first: 'Nancy', last: null}
  4610. *
  4611. * ```
  4612. * @param {?} value
  4613. * @param {?=} options
  4614. * @return {?}
  4615. */
  4616. function (value, options) {
  4617. var _this = this;
  4618. if (options === void 0) { options = {}; }
  4619. Object.keys(value).forEach(function (name) {
  4620. if (_this.controls[name]) {
  4621. _this.controls[name].patchValue(value[name], { onlySelf: true, emitEvent: options.emitEvent });
  4622. }
  4623. });
  4624. this.updateValueAndValidity(options);
  4625. };
  4626. /**
  4627. * Resets the {@link FormGroup}. This means by default:
  4628. *
  4629. * * The group and all descendants are marked `pristine`
  4630. * * The group and all descendants are marked `untouched`
  4631. * * The value of all descendants will be null or null maps
  4632. *
  4633. * You can also reset to a specific form state by passing in a map of states
  4634. * that matches the structure of your form, with control names as keys. The state
  4635. * can be a standalone value or a form state object with both a value and a disabled
  4636. * status.
  4637. *
  4638. * ### Example
  4639. *
  4640. * ```ts
  4641. * this.form.reset({first: 'name', last: 'last name'});
  4642. *
  4643. * console.log(this.form.value); // {first: 'name', last: 'last name'}
  4644. * ```
  4645. *
  4646. * - OR -
  4647. *
  4648. * ```
  4649. * this.form.reset({
  4650. * first: {value: 'name', disabled: true},
  4651. * last: 'last'
  4652. * });
  4653. *
  4654. * console.log(this.form.value); // {first: 'name', last: 'last name'}
  4655. * console.log(this.form.get('first').status); // 'DISABLED'
  4656. * ```
  4657. */
  4658. /**
  4659. * Resets the {\@link FormGroup}. This means by default:
  4660. *
  4661. * * The group and all descendants are marked `pristine`
  4662. * * The group and all descendants are marked `untouched`
  4663. * * The value of all descendants will be null or null maps
  4664. *
  4665. * You can also reset to a specific form state by passing in a map of states
  4666. * that matches the structure of your form, with control names as keys. The state
  4667. * can be a standalone value or a form state object with both a value and a disabled
  4668. * status.
  4669. *
  4670. * ### Example
  4671. *
  4672. * ```ts
  4673. * this.form.reset({first: 'name', last: 'last name'});
  4674. *
  4675. * console.log(this.form.value); // {first: 'name', last: 'last name'}
  4676. * ```
  4677. *
  4678. * - OR -
  4679. *
  4680. * ```
  4681. * this.form.reset({
  4682. * first: {value: 'name', disabled: true},
  4683. * last: 'last'
  4684. * });
  4685. *
  4686. * console.log(this.form.value); // {first: 'name', last: 'last name'}
  4687. * console.log(this.form.get('first').status); // 'DISABLED'
  4688. * ```
  4689. * @param {?=} value
  4690. * @param {?=} options
  4691. * @return {?}
  4692. */
  4693. FormGroup.prototype.reset = /**
  4694. * Resets the {\@link FormGroup}. This means by default:
  4695. *
  4696. * * The group and all descendants are marked `pristine`
  4697. * * The group and all descendants are marked `untouched`
  4698. * * The value of all descendants will be null or null maps
  4699. *
  4700. * You can also reset to a specific form state by passing in a map of states
  4701. * that matches the structure of your form, with control names as keys. The state
  4702. * can be a standalone value or a form state object with both a value and a disabled
  4703. * status.
  4704. *
  4705. * ### Example
  4706. *
  4707. * ```ts
  4708. * this.form.reset({first: 'name', last: 'last name'});
  4709. *
  4710. * console.log(this.form.value); // {first: 'name', last: 'last name'}
  4711. * ```
  4712. *
  4713. * - OR -
  4714. *
  4715. * ```
  4716. * this.form.reset({
  4717. * first: {value: 'name', disabled: true},
  4718. * last: 'last'
  4719. * });
  4720. *
  4721. * console.log(this.form.value); // {first: 'name', last: 'last name'}
  4722. * console.log(this.form.get('first').status); // 'DISABLED'
  4723. * ```
  4724. * @param {?=} value
  4725. * @param {?=} options
  4726. * @return {?}
  4727. */
  4728. function (value, options) {
  4729. if (value === void 0) { value = {}; }
  4730. if (options === void 0) { options = {}; }
  4731. this._forEachChild(function (control, name) {
  4732. control.reset(value[name], { onlySelf: true, emitEvent: options.emitEvent });
  4733. });
  4734. this.updateValueAndValidity(options);
  4735. this._updatePristine(options);
  4736. this._updateTouched(options);
  4737. };
  4738. /**
  4739. * The aggregate value of the {@link FormGroup}, including any disabled controls.
  4740. *
  4741. * If you'd like to include all values regardless of disabled status, use this method.
  4742. * Otherwise, the `value` property is the best way to get the value of the group.
  4743. */
  4744. /**
  4745. * The aggregate value of the {\@link FormGroup}, including any disabled controls.
  4746. *
  4747. * If you'd like to include all values regardless of disabled status, use this method.
  4748. * Otherwise, the `value` property is the best way to get the value of the group.
  4749. * @return {?}
  4750. */
  4751. FormGroup.prototype.getRawValue = /**
  4752. * The aggregate value of the {\@link FormGroup}, including any disabled controls.
  4753. *
  4754. * If you'd like to include all values regardless of disabled status, use this method.
  4755. * Otherwise, the `value` property is the best way to get the value of the group.
  4756. * @return {?}
  4757. */
  4758. function () {
  4759. return this._reduceChildren({}, function (acc, control, name) {
  4760. acc[name] = control instanceof FormControl ? control.value : (/** @type {?} */ (control)).getRawValue();
  4761. return acc;
  4762. });
  4763. };
  4764. /** @internal */
  4765. /**
  4766. * \@internal
  4767. * @return {?}
  4768. */
  4769. FormGroup.prototype._syncPendingControls = /**
  4770. * \@internal
  4771. * @return {?}
  4772. */
  4773. function () {
  4774. var /** @type {?} */ subtreeUpdated = this._reduceChildren(false, function (updated, child) {
  4775. return child._syncPendingControls() ? true : updated;
  4776. });
  4777. if (subtreeUpdated)
  4778. this.updateValueAndValidity({ onlySelf: true });
  4779. return subtreeUpdated;
  4780. };
  4781. /** @internal */
  4782. /**
  4783. * \@internal
  4784. * @param {?} name
  4785. * @return {?}
  4786. */
  4787. FormGroup.prototype._throwIfControlMissing = /**
  4788. * \@internal
  4789. * @param {?} name
  4790. * @return {?}
  4791. */
  4792. function (name) {
  4793. if (!Object.keys(this.controls).length) {
  4794. throw new Error("\n There are no form controls registered with this group yet. If you're using ngModel,\n you may want to check next tick (e.g. use setTimeout).\n ");
  4795. }
  4796. if (!this.controls[name]) {
  4797. throw new Error("Cannot find form control with name: " + name + ".");
  4798. }
  4799. };
  4800. /** @internal */
  4801. /**
  4802. * \@internal
  4803. * @param {?} cb
  4804. * @return {?}
  4805. */
  4806. FormGroup.prototype._forEachChild = /**
  4807. * \@internal
  4808. * @param {?} cb
  4809. * @return {?}
  4810. */
  4811. function (cb) {
  4812. var _this = this;
  4813. Object.keys(this.controls).forEach(function (k) { return cb(_this.controls[k], k); });
  4814. };
  4815. /** @internal */
  4816. /**
  4817. * \@internal
  4818. * @return {?}
  4819. */
  4820. FormGroup.prototype._setUpControls = /**
  4821. * \@internal
  4822. * @return {?}
  4823. */
  4824. function () {
  4825. var _this = this;
  4826. this._forEachChild(function (control) {
  4827. control.setParent(_this);
  4828. control._registerOnCollectionChange(_this._onCollectionChange);
  4829. });
  4830. };
  4831. /** @internal */
  4832. /**
  4833. * \@internal
  4834. * @return {?}
  4835. */
  4836. FormGroup.prototype._updateValue = /**
  4837. * \@internal
  4838. * @return {?}
  4839. */
  4840. function () { (/** @type {?} */ (this)).value = this._reduceValue(); };
  4841. /** @internal */
  4842. /**
  4843. * \@internal
  4844. * @param {?} condition
  4845. * @return {?}
  4846. */
  4847. FormGroup.prototype._anyControls = /**
  4848. * \@internal
  4849. * @param {?} condition
  4850. * @return {?}
  4851. */
  4852. function (condition) {
  4853. var _this = this;
  4854. var /** @type {?} */ res = false;
  4855. this._forEachChild(function (control, name) {
  4856. res = res || (_this.contains(name) && condition(control));
  4857. });
  4858. return res;
  4859. };
  4860. /** @internal */
  4861. /**
  4862. * \@internal
  4863. * @return {?}
  4864. */
  4865. FormGroup.prototype._reduceValue = /**
  4866. * \@internal
  4867. * @return {?}
  4868. */
  4869. function () {
  4870. var _this = this;
  4871. return this._reduceChildren({}, function (acc, control, name) {
  4872. if (control.enabled || _this.disabled) {
  4873. acc[name] = control.value;
  4874. }
  4875. return acc;
  4876. });
  4877. };
  4878. /** @internal */
  4879. /**
  4880. * \@internal
  4881. * @param {?} initValue
  4882. * @param {?} fn
  4883. * @return {?}
  4884. */
  4885. FormGroup.prototype._reduceChildren = /**
  4886. * \@internal
  4887. * @param {?} initValue
  4888. * @param {?} fn
  4889. * @return {?}
  4890. */
  4891. function (initValue, fn) {
  4892. var /** @type {?} */ res = initValue;
  4893. this._forEachChild(function (control, name) { res = fn(res, control, name); });
  4894. return res;
  4895. };
  4896. /** @internal */
  4897. /**
  4898. * \@internal
  4899. * @return {?}
  4900. */
  4901. FormGroup.prototype._allControlsDisabled = /**
  4902. * \@internal
  4903. * @return {?}
  4904. */
  4905. function () {
  4906. for (var _i = 0, _a = Object.keys(this.controls); _i < _a.length; _i++) {
  4907. var controlName = _a[_i];
  4908. if (this.controls[controlName].enabled) {
  4909. return false;
  4910. }
  4911. }
  4912. return Object.keys(this.controls).length > 0 || this.disabled;
  4913. };
  4914. /** @internal */
  4915. /**
  4916. * \@internal
  4917. * @param {?} value
  4918. * @return {?}
  4919. */
  4920. FormGroup.prototype._checkAllValuesPresent = /**
  4921. * \@internal
  4922. * @param {?} value
  4923. * @return {?}
  4924. */
  4925. function (value) {
  4926. this._forEachChild(function (control, name) {
  4927. if (value[name] === undefined) {
  4928. throw new Error("Must supply a value for form control with name: '" + name + "'.");
  4929. }
  4930. });
  4931. };
  4932. return FormGroup;
  4933. }(AbstractControl));
  4934. /**
  4935. * \@whatItDoes Tracks the value and validity state of an array of {\@link FormControl},
  4936. * {\@link FormGroup} or {\@link FormArray} instances.
  4937. *
  4938. * A `FormArray` aggregates the values of each child {\@link FormControl} into an array.
  4939. * It calculates its status by reducing the statuses of its children. For example, if one of
  4940. * the controls in a `FormArray` is invalid, the entire array becomes invalid.
  4941. *
  4942. * `FormArray` is one of the three fundamental building blocks used to define forms in Angular,
  4943. * along with {\@link FormControl} and {\@link FormGroup}.
  4944. *
  4945. * \@howToUse
  4946. *
  4947. * When instantiating a {\@link FormArray}, pass in an array of child controls as the first
  4948. * argument.
  4949. *
  4950. * ### Example
  4951. *
  4952. * ```
  4953. * const arr = new FormArray([
  4954. * new FormControl('Nancy', Validators.minLength(2)),
  4955. * new FormControl('Drew'),
  4956. * ]);
  4957. *
  4958. * console.log(arr.value); // ['Nancy', 'Drew']
  4959. * console.log(arr.status); // 'VALID'
  4960. * ```
  4961. *
  4962. * You can also include array-level validators and async validators. These come in handy
  4963. * when you want to perform validation that considers the value of more than one child
  4964. * control.
  4965. *
  4966. * The two types of validators can be passed in separately as the second and third arg
  4967. * respectively, or together as part of an options object.
  4968. *
  4969. * ```
  4970. * const arr = new FormArray([
  4971. * new FormControl('Nancy'),
  4972. * new FormControl('Drew')
  4973. * ], {validators: myValidator, asyncValidators: myAsyncValidator});
  4974. * ```
  4975. *
  4976. * The options object can also be used to set a default value for each child
  4977. * control's `updateOn` property. If you set `updateOn` to `'blur'` at the
  4978. * array level, all child controls will default to 'blur', unless the child
  4979. * has explicitly specified a different `updateOn` value.
  4980. *
  4981. * ```ts
  4982. * const c = new FormArray([
  4983. * new FormControl()
  4984. * ], {updateOn: 'blur'});
  4985. * ```
  4986. *
  4987. * ### Adding or removing controls
  4988. *
  4989. * To change the controls in the array, use the `push`, `insert`, or `removeAt` methods
  4990. * in `FormArray` itself. These methods ensure the controls are properly tracked in the
  4991. * form's hierarchy. Do not modify the array of `AbstractControl`s used to instantiate
  4992. * the `FormArray` directly, as that will result in strange and unexpected behavior such
  4993. * as broken change detection.
  4994. *
  4995. * * **npm package**: `\@angular/forms`
  4996. *
  4997. * \@stable
  4998. */
  4999. var FormArray = /** @class */ (function (_super) {
  5000. __extends(FormArray, _super);
  5001. function FormArray(controls, validatorOrOpts, asyncValidator) {
  5002. var _this = _super.call(this, coerceToValidator(validatorOrOpts), coerceToAsyncValidator(asyncValidator, validatorOrOpts)) || this;
  5003. _this.controls = controls;
  5004. _this._initObservables();
  5005. _this._setUpdateStrategy(validatorOrOpts);
  5006. _this._setUpControls();
  5007. _this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
  5008. return _this;
  5009. }
  5010. /**
  5011. * Get the {@link AbstractControl} at the given `index` in the array.
  5012. */
  5013. /**
  5014. * Get the {\@link AbstractControl} at the given `index` in the array.
  5015. * @param {?} index
  5016. * @return {?}
  5017. */
  5018. FormArray.prototype.at = /**
  5019. * Get the {\@link AbstractControl} at the given `index` in the array.
  5020. * @param {?} index
  5021. * @return {?}
  5022. */
  5023. function (index) { return this.controls[index]; };
  5024. /**
  5025. * Insert a new {@link AbstractControl} at the end of the array.
  5026. */
  5027. /**
  5028. * Insert a new {\@link AbstractControl} at the end of the array.
  5029. * @param {?} control
  5030. * @return {?}
  5031. */
  5032. FormArray.prototype.push = /**
  5033. * Insert a new {\@link AbstractControl} at the end of the array.
  5034. * @param {?} control
  5035. * @return {?}
  5036. */
  5037. function (control) {
  5038. this.controls.push(control);
  5039. this._registerControl(control);
  5040. this.updateValueAndValidity();
  5041. this._onCollectionChange();
  5042. };
  5043. /** Insert a new {@link AbstractControl} at the given `index` in the array. */
  5044. /**
  5045. * Insert a new {\@link AbstractControl} at the given `index` in the array.
  5046. * @param {?} index
  5047. * @param {?} control
  5048. * @return {?}
  5049. */
  5050. FormArray.prototype.insert = /**
  5051. * Insert a new {\@link AbstractControl} at the given `index` in the array.
  5052. * @param {?} index
  5053. * @param {?} control
  5054. * @return {?}
  5055. */
  5056. function (index, control) {
  5057. this.controls.splice(index, 0, control);
  5058. this._registerControl(control);
  5059. this.updateValueAndValidity();
  5060. };
  5061. /** Remove the control at the given `index` in the array. */
  5062. /**
  5063. * Remove the control at the given `index` in the array.
  5064. * @param {?} index
  5065. * @return {?}
  5066. */
  5067. FormArray.prototype.removeAt = /**
  5068. * Remove the control at the given `index` in the array.
  5069. * @param {?} index
  5070. * @return {?}
  5071. */
  5072. function (index) {
  5073. if (this.controls[index])
  5074. this.controls[index]._registerOnCollectionChange(function () { });
  5075. this.controls.splice(index, 1);
  5076. this.updateValueAndValidity();
  5077. };
  5078. /**
  5079. * Replace an existing control.
  5080. */
  5081. /**
  5082. * Replace an existing control.
  5083. * @param {?} index
  5084. * @param {?} control
  5085. * @return {?}
  5086. */
  5087. FormArray.prototype.setControl = /**
  5088. * Replace an existing control.
  5089. * @param {?} index
  5090. * @param {?} control
  5091. * @return {?}
  5092. */
  5093. function (index, control) {
  5094. if (this.controls[index])
  5095. this.controls[index]._registerOnCollectionChange(function () { });
  5096. this.controls.splice(index, 1);
  5097. if (control) {
  5098. this.controls.splice(index, 0, control);
  5099. this._registerControl(control);
  5100. }
  5101. this.updateValueAndValidity();
  5102. this._onCollectionChange();
  5103. };
  5104. Object.defineProperty(FormArray.prototype, "length", {
  5105. /**
  5106. * Length of the control array.
  5107. */
  5108. get: /**
  5109. * Length of the control array.
  5110. * @return {?}
  5111. */
  5112. function () { return this.controls.length; },
  5113. enumerable: true,
  5114. configurable: true
  5115. });
  5116. /**
  5117. * Sets the value of the {@link FormArray}. It accepts an array that matches
  5118. * the structure of the control.
  5119. *
  5120. * This method performs strict checks, so it will throw an error if you try
  5121. * to set the value of a control that doesn't exist or if you exclude the
  5122. * value of a control.
  5123. *
  5124. * ### Example
  5125. *
  5126. * ```
  5127. * const arr = new FormArray([
  5128. * new FormControl(),
  5129. * new FormControl()
  5130. * ]);
  5131. * console.log(arr.value); // [null, null]
  5132. *
  5133. * arr.setValue(['Nancy', 'Drew']);
  5134. * console.log(arr.value); // ['Nancy', 'Drew']
  5135. * ```
  5136. */
  5137. /**
  5138. * Sets the value of the {\@link FormArray}. It accepts an array that matches
  5139. * the structure of the control.
  5140. *
  5141. * This method performs strict checks, so it will throw an error if you try
  5142. * to set the value of a control that doesn't exist or if you exclude the
  5143. * value of a control.
  5144. *
  5145. * ### Example
  5146. *
  5147. * ```
  5148. * const arr = new FormArray([
  5149. * new FormControl(),
  5150. * new FormControl()
  5151. * ]);
  5152. * console.log(arr.value); // [null, null]
  5153. *
  5154. * arr.setValue(['Nancy', 'Drew']);
  5155. * console.log(arr.value); // ['Nancy', 'Drew']
  5156. * ```
  5157. * @param {?} value
  5158. * @param {?=} options
  5159. * @return {?}
  5160. */
  5161. FormArray.prototype.setValue = /**
  5162. * Sets the value of the {\@link FormArray}. It accepts an array that matches
  5163. * the structure of the control.
  5164. *
  5165. * This method performs strict checks, so it will throw an error if you try
  5166. * to set the value of a control that doesn't exist or if you exclude the
  5167. * value of a control.
  5168. *
  5169. * ### Example
  5170. *
  5171. * ```
  5172. * const arr = new FormArray([
  5173. * new FormControl(),
  5174. * new FormControl()
  5175. * ]);
  5176. * console.log(arr.value); // [null, null]
  5177. *
  5178. * arr.setValue(['Nancy', 'Drew']);
  5179. * console.log(arr.value); // ['Nancy', 'Drew']
  5180. * ```
  5181. * @param {?} value
  5182. * @param {?=} options
  5183. * @return {?}
  5184. */
  5185. function (value, options) {
  5186. var _this = this;
  5187. if (options === void 0) { options = {}; }
  5188. this._checkAllValuesPresent(value);
  5189. value.forEach(function (newValue, index) {
  5190. _this._throwIfControlMissing(index);
  5191. _this.at(index).setValue(newValue, { onlySelf: true, emitEvent: options.emitEvent });
  5192. });
  5193. this.updateValueAndValidity(options);
  5194. };
  5195. /**
  5196. * Patches the value of the {@link FormArray}. It accepts an array that matches the
  5197. * structure of the control, and will do its best to match the values to the correct
  5198. * controls in the group.
  5199. *
  5200. * It accepts both super-sets and sub-sets of the array without throwing an error.
  5201. *
  5202. * ### Example
  5203. *
  5204. * ```
  5205. * const arr = new FormArray([
  5206. * new FormControl(),
  5207. * new FormControl()
  5208. * ]);
  5209. * console.log(arr.value); // [null, null]
  5210. *
  5211. * arr.patchValue(['Nancy']);
  5212. * console.log(arr.value); // ['Nancy', null]
  5213. * ```
  5214. */
  5215. /**
  5216. * Patches the value of the {\@link FormArray}. It accepts an array that matches the
  5217. * structure of the control, and will do its best to match the values to the correct
  5218. * controls in the group.
  5219. *
  5220. * It accepts both super-sets and sub-sets of the array without throwing an error.
  5221. *
  5222. * ### Example
  5223. *
  5224. * ```
  5225. * const arr = new FormArray([
  5226. * new FormControl(),
  5227. * new FormControl()
  5228. * ]);
  5229. * console.log(arr.value); // [null, null]
  5230. *
  5231. * arr.patchValue(['Nancy']);
  5232. * console.log(arr.value); // ['Nancy', null]
  5233. * ```
  5234. * @param {?} value
  5235. * @param {?=} options
  5236. * @return {?}
  5237. */
  5238. FormArray.prototype.patchValue = /**
  5239. * Patches the value of the {\@link FormArray}. It accepts an array that matches the
  5240. * structure of the control, and will do its best to match the values to the correct
  5241. * controls in the group.
  5242. *
  5243. * It accepts both super-sets and sub-sets of the array without throwing an error.
  5244. *
  5245. * ### Example
  5246. *
  5247. * ```
  5248. * const arr = new FormArray([
  5249. * new FormControl(),
  5250. * new FormControl()
  5251. * ]);
  5252. * console.log(arr.value); // [null, null]
  5253. *
  5254. * arr.patchValue(['Nancy']);
  5255. * console.log(arr.value); // ['Nancy', null]
  5256. * ```
  5257. * @param {?} value
  5258. * @param {?=} options
  5259. * @return {?}
  5260. */
  5261. function (value, options) {
  5262. var _this = this;
  5263. if (options === void 0) { options = {}; }
  5264. value.forEach(function (newValue, index) {
  5265. if (_this.at(index)) {
  5266. _this.at(index).patchValue(newValue, { onlySelf: true, emitEvent: options.emitEvent });
  5267. }
  5268. });
  5269. this.updateValueAndValidity(options);
  5270. };
  5271. /**
  5272. * Resets the {@link FormArray}. This means by default:
  5273. *
  5274. * * The array and all descendants are marked `pristine`
  5275. * * The array and all descendants are marked `untouched`
  5276. * * The value of all descendants will be null or null maps
  5277. *
  5278. * You can also reset to a specific form state by passing in an array of states
  5279. * that matches the structure of the control. The state can be a standalone value
  5280. * or a form state object with both a value and a disabled status.
  5281. *
  5282. * ### Example
  5283. *
  5284. * ```ts
  5285. * this.arr.reset(['name', 'last name']);
  5286. *
  5287. * console.log(this.arr.value); // ['name', 'last name']
  5288. * ```
  5289. *
  5290. * - OR -
  5291. *
  5292. * ```
  5293. * this.arr.reset([
  5294. * {value: 'name', disabled: true},
  5295. * 'last'
  5296. * ]);
  5297. *
  5298. * console.log(this.arr.value); // ['name', 'last name']
  5299. * console.log(this.arr.get(0).status); // 'DISABLED'
  5300. * ```
  5301. */
  5302. /**
  5303. * Resets the {\@link FormArray}. This means by default:
  5304. *
  5305. * * The array and all descendants are marked `pristine`
  5306. * * The array and all descendants are marked `untouched`
  5307. * * The value of all descendants will be null or null maps
  5308. *
  5309. * You can also reset to a specific form state by passing in an array of states
  5310. * that matches the structure of the control. The state can be a standalone value
  5311. * or a form state object with both a value and a disabled status.
  5312. *
  5313. * ### Example
  5314. *
  5315. * ```ts
  5316. * this.arr.reset(['name', 'last name']);
  5317. *
  5318. * console.log(this.arr.value); // ['name', 'last name']
  5319. * ```
  5320. *
  5321. * - OR -
  5322. *
  5323. * ```
  5324. * this.arr.reset([
  5325. * {value: 'name', disabled: true},
  5326. * 'last'
  5327. * ]);
  5328. *
  5329. * console.log(this.arr.value); // ['name', 'last name']
  5330. * console.log(this.arr.get(0).status); // 'DISABLED'
  5331. * ```
  5332. * @param {?=} value
  5333. * @param {?=} options
  5334. * @return {?}
  5335. */
  5336. FormArray.prototype.reset = /**
  5337. * Resets the {\@link FormArray}. This means by default:
  5338. *
  5339. * * The array and all descendants are marked `pristine`
  5340. * * The array and all descendants are marked `untouched`
  5341. * * The value of all descendants will be null or null maps
  5342. *
  5343. * You can also reset to a specific form state by passing in an array of states
  5344. * that matches the structure of the control. The state can be a standalone value
  5345. * or a form state object with both a value and a disabled status.
  5346. *
  5347. * ### Example
  5348. *
  5349. * ```ts
  5350. * this.arr.reset(['name', 'last name']);
  5351. *
  5352. * console.log(this.arr.value); // ['name', 'last name']
  5353. * ```
  5354. *
  5355. * - OR -
  5356. *
  5357. * ```
  5358. * this.arr.reset([
  5359. * {value: 'name', disabled: true},
  5360. * 'last'
  5361. * ]);
  5362. *
  5363. * console.log(this.arr.value); // ['name', 'last name']
  5364. * console.log(this.arr.get(0).status); // 'DISABLED'
  5365. * ```
  5366. * @param {?=} value
  5367. * @param {?=} options
  5368. * @return {?}
  5369. */
  5370. function (value, options) {
  5371. if (value === void 0) { value = []; }
  5372. if (options === void 0) { options = {}; }
  5373. this._forEachChild(function (control, index) {
  5374. control.reset(value[index], { onlySelf: true, emitEvent: options.emitEvent });
  5375. });
  5376. this.updateValueAndValidity(options);
  5377. this._updatePristine(options);
  5378. this._updateTouched(options);
  5379. };
  5380. /**
  5381. * The aggregate value of the array, including any disabled controls.
  5382. *
  5383. * If you'd like to include all values regardless of disabled status, use this method.
  5384. * Otherwise, the `value` property is the best way to get the value of the array.
  5385. */
  5386. /**
  5387. * The aggregate value of the array, including any disabled controls.
  5388. *
  5389. * If you'd like to include all values regardless of disabled status, use this method.
  5390. * Otherwise, the `value` property is the best way to get the value of the array.
  5391. * @return {?}
  5392. */
  5393. FormArray.prototype.getRawValue = /**
  5394. * The aggregate value of the array, including any disabled controls.
  5395. *
  5396. * If you'd like to include all values regardless of disabled status, use this method.
  5397. * Otherwise, the `value` property is the best way to get the value of the array.
  5398. * @return {?}
  5399. */
  5400. function () {
  5401. return this.controls.map(function (control) {
  5402. return control instanceof FormControl ? control.value : (/** @type {?} */ (control)).getRawValue();
  5403. });
  5404. };
  5405. /** @internal */
  5406. /**
  5407. * \@internal
  5408. * @return {?}
  5409. */
  5410. FormArray.prototype._syncPendingControls = /**
  5411. * \@internal
  5412. * @return {?}
  5413. */
  5414. function () {
  5415. var /** @type {?} */ subtreeUpdated = this.controls.reduce(function (updated, child) {
  5416. return child._syncPendingControls() ? true : updated;
  5417. }, false);
  5418. if (subtreeUpdated)
  5419. this.updateValueAndValidity({ onlySelf: true });
  5420. return subtreeUpdated;
  5421. };
  5422. /** @internal */
  5423. /**
  5424. * \@internal
  5425. * @param {?} index
  5426. * @return {?}
  5427. */
  5428. FormArray.prototype._throwIfControlMissing = /**
  5429. * \@internal
  5430. * @param {?} index
  5431. * @return {?}
  5432. */
  5433. function (index) {
  5434. if (!this.controls.length) {
  5435. throw new Error("\n There are no form controls registered with this array yet. If you're using ngModel,\n you may want to check next tick (e.g. use setTimeout).\n ");
  5436. }
  5437. if (!this.at(index)) {
  5438. throw new Error("Cannot find form control at index " + index);
  5439. }
  5440. };
  5441. /** @internal */
  5442. /**
  5443. * \@internal
  5444. * @param {?} cb
  5445. * @return {?}
  5446. */
  5447. FormArray.prototype._forEachChild = /**
  5448. * \@internal
  5449. * @param {?} cb
  5450. * @return {?}
  5451. */
  5452. function (cb) {
  5453. this.controls.forEach(function (control, index) { cb(control, index); });
  5454. };
  5455. /** @internal */
  5456. /**
  5457. * \@internal
  5458. * @return {?}
  5459. */
  5460. FormArray.prototype._updateValue = /**
  5461. * \@internal
  5462. * @return {?}
  5463. */
  5464. function () {
  5465. var _this = this;
  5466. (/** @type {?} */ (this)).value =
  5467. this.controls.filter(function (control) { return control.enabled || _this.disabled; })
  5468. .map(function (control) { return control.value; });
  5469. };
  5470. /** @internal */
  5471. /**
  5472. * \@internal
  5473. * @param {?} condition
  5474. * @return {?}
  5475. */
  5476. FormArray.prototype._anyControls = /**
  5477. * \@internal
  5478. * @param {?} condition
  5479. * @return {?}
  5480. */
  5481. function (condition) {
  5482. return this.controls.some(function (control) { return control.enabled && condition(control); });
  5483. };
  5484. /** @internal */
  5485. /**
  5486. * \@internal
  5487. * @return {?}
  5488. */
  5489. FormArray.prototype._setUpControls = /**
  5490. * \@internal
  5491. * @return {?}
  5492. */
  5493. function () {
  5494. var _this = this;
  5495. this._forEachChild(function (control) { return _this._registerControl(control); });
  5496. };
  5497. /** @internal */
  5498. /**
  5499. * \@internal
  5500. * @param {?} value
  5501. * @return {?}
  5502. */
  5503. FormArray.prototype._checkAllValuesPresent = /**
  5504. * \@internal
  5505. * @param {?} value
  5506. * @return {?}
  5507. */
  5508. function (value) {
  5509. this._forEachChild(function (control, i) {
  5510. if (value[i] === undefined) {
  5511. throw new Error("Must supply a value for form control at index: " + i + ".");
  5512. }
  5513. });
  5514. };
  5515. /** @internal */
  5516. /**
  5517. * \@internal
  5518. * @return {?}
  5519. */
  5520. FormArray.prototype._allControlsDisabled = /**
  5521. * \@internal
  5522. * @return {?}
  5523. */
  5524. function () {
  5525. for (var _i = 0, _a = this.controls; _i < _a.length; _i++) {
  5526. var control = _a[_i];
  5527. if (control.enabled)
  5528. return false;
  5529. }
  5530. return this.controls.length > 0 || this.disabled;
  5531. };
  5532. /**
  5533. * @param {?} control
  5534. * @return {?}
  5535. */
  5536. FormArray.prototype._registerControl = /**
  5537. * @param {?} control
  5538. * @return {?}
  5539. */
  5540. function (control) {
  5541. control.setParent(this);
  5542. control._registerOnCollectionChange(this._onCollectionChange);
  5543. };
  5544. return FormArray;
  5545. }(AbstractControl));
  5546. /**
  5547. * @fileoverview added by tsickle
  5548. * @suppress {checkTypes} checked by tsc
  5549. */
  5550. /**
  5551. * @license
  5552. * Copyright Google Inc. All Rights Reserved.
  5553. *
  5554. * Use of this source code is governed by an MIT-style license that can be
  5555. * found in the LICENSE file at https://angular.io/license
  5556. */
  5557. var formDirectiveProvider = {
  5558. provide: ControlContainer,
  5559. useExisting: _angular_core.forwardRef(function () { return NgForm; })
  5560. };
  5561. var resolvedPromise = Promise.resolve(null);
  5562. /**
  5563. * \@whatItDoes Creates a top-level {\@link FormGroup} instance and binds it to a form
  5564. * to track aggregate form value and validation status.
  5565. *
  5566. * \@howToUse
  5567. *
  5568. * As soon as you import the `FormsModule`, this directive becomes active by default on
  5569. * all `<form>` tags. You don't need to add a special selector.
  5570. *
  5571. * You can export the directive into a local template variable using `ngForm` as the key
  5572. * (ex: `#myForm="ngForm"`). This is optional, but useful. Many properties from the underlying
  5573. * {\@link FormGroup} instance are duplicated on the directive itself, so a reference to it
  5574. * will give you access to the aggregate value and validity status of the form, as well as
  5575. * user interaction properties like `dirty` and `touched`.
  5576. *
  5577. * To register child controls with the form, you'll want to use {\@link NgModel} with a
  5578. * `name` attribute. You can also use {\@link NgModelGroup} if you'd like to create
  5579. * sub-groups within the form.
  5580. *
  5581. * You can listen to the directive's `ngSubmit` event to be notified when the user has
  5582. * triggered a form submission. The `ngSubmit` event will be emitted with the original form
  5583. * submission event.
  5584. *
  5585. * In template driven forms, all `<form>` tags are automatically tagged as `NgForm`.
  5586. * If you want to import the `FormsModule` but skip its usage in some forms,
  5587. * for example, to use native HTML5 validation, you can add `ngNoForm` and the `<form>`
  5588. * tags won't create an `NgForm` directive. In reactive forms, using `ngNoForm` is
  5589. * unnecessary because the `<form>` tags are inert. In that case, you would
  5590. * refrain from using the `formGroup` directive.
  5591. *
  5592. * {\@example forms/ts/simpleForm/simple_form_example.ts region='Component'}
  5593. *
  5594. * * **npm package**: `\@angular/forms`
  5595. *
  5596. * * **NgModule**: `FormsModule`
  5597. *
  5598. * \@stable
  5599. */
  5600. var NgForm = /** @class */ (function (_super) {
  5601. __extends(NgForm, _super);
  5602. function NgForm(validators, asyncValidators) {
  5603. var _this = _super.call(this) || this;
  5604. _this.submitted = false;
  5605. _this._directives = [];
  5606. _this.ngSubmit = new _angular_core.EventEmitter();
  5607. _this.form =
  5608. new FormGroup({}, composeValidators(validators), composeAsyncValidators(asyncValidators));
  5609. return _this;
  5610. }
  5611. /**
  5612. * @return {?}
  5613. */
  5614. NgForm.prototype.ngAfterViewInit = /**
  5615. * @return {?}
  5616. */
  5617. function () { this._setUpdateStrategy(); };
  5618. Object.defineProperty(NgForm.prototype, "formDirective", {
  5619. get: /**
  5620. * @return {?}
  5621. */
  5622. function () { return this; },
  5623. enumerable: true,
  5624. configurable: true
  5625. });
  5626. Object.defineProperty(NgForm.prototype, "control", {
  5627. get: /**
  5628. * @return {?}
  5629. */
  5630. function () { return this.form; },
  5631. enumerable: true,
  5632. configurable: true
  5633. });
  5634. Object.defineProperty(NgForm.prototype, "path", {
  5635. get: /**
  5636. * @return {?}
  5637. */
  5638. function () { return []; },
  5639. enumerable: true,
  5640. configurable: true
  5641. });
  5642. Object.defineProperty(NgForm.prototype, "controls", {
  5643. get: /**
  5644. * @return {?}
  5645. */
  5646. function () { return this.form.controls; },
  5647. enumerable: true,
  5648. configurable: true
  5649. });
  5650. /**
  5651. * @param {?} dir
  5652. * @return {?}
  5653. */
  5654. NgForm.prototype.addControl = /**
  5655. * @param {?} dir
  5656. * @return {?}
  5657. */
  5658. function (dir) {
  5659. var _this = this;
  5660. resolvedPromise.then(function () {
  5661. var /** @type {?} */ container = _this._findContainer(dir.path);
  5662. (/** @type {?} */ (dir)).control = /** @type {?} */ (container.registerControl(dir.name, dir.control));
  5663. setUpControl(dir.control, dir);
  5664. dir.control.updateValueAndValidity({ emitEvent: false });
  5665. _this._directives.push(dir);
  5666. });
  5667. };
  5668. /**
  5669. * @param {?} dir
  5670. * @return {?}
  5671. */
  5672. NgForm.prototype.getControl = /**
  5673. * @param {?} dir
  5674. * @return {?}
  5675. */
  5676. function (dir) { return /** @type {?} */ (this.form.get(dir.path)); };
  5677. /**
  5678. * @param {?} dir
  5679. * @return {?}
  5680. */
  5681. NgForm.prototype.removeControl = /**
  5682. * @param {?} dir
  5683. * @return {?}
  5684. */
  5685. function (dir) {
  5686. var _this = this;
  5687. resolvedPromise.then(function () {
  5688. var /** @type {?} */ container = _this._findContainer(dir.path);
  5689. if (container) {
  5690. container.removeControl(dir.name);
  5691. }
  5692. removeDir(_this._directives, dir);
  5693. });
  5694. };
  5695. /**
  5696. * @param {?} dir
  5697. * @return {?}
  5698. */
  5699. NgForm.prototype.addFormGroup = /**
  5700. * @param {?} dir
  5701. * @return {?}
  5702. */
  5703. function (dir) {
  5704. var _this = this;
  5705. resolvedPromise.then(function () {
  5706. var /** @type {?} */ container = _this._findContainer(dir.path);
  5707. var /** @type {?} */ group = new FormGroup({});
  5708. setUpFormContainer(group, dir);
  5709. container.registerControl(dir.name, group);
  5710. group.updateValueAndValidity({ emitEvent: false });
  5711. });
  5712. };
  5713. /**
  5714. * @param {?} dir
  5715. * @return {?}
  5716. */
  5717. NgForm.prototype.removeFormGroup = /**
  5718. * @param {?} dir
  5719. * @return {?}
  5720. */
  5721. function (dir) {
  5722. var _this = this;
  5723. resolvedPromise.then(function () {
  5724. var /** @type {?} */ container = _this._findContainer(dir.path);
  5725. if (container) {
  5726. container.removeControl(dir.name);
  5727. }
  5728. });
  5729. };
  5730. /**
  5731. * @param {?} dir
  5732. * @return {?}
  5733. */
  5734. NgForm.prototype.getFormGroup = /**
  5735. * @param {?} dir
  5736. * @return {?}
  5737. */
  5738. function (dir) { return /** @type {?} */ (this.form.get(dir.path)); };
  5739. /**
  5740. * @param {?} dir
  5741. * @param {?} value
  5742. * @return {?}
  5743. */
  5744. NgForm.prototype.updateModel = /**
  5745. * @param {?} dir
  5746. * @param {?} value
  5747. * @return {?}
  5748. */
  5749. function (dir, value) {
  5750. var _this = this;
  5751. resolvedPromise.then(function () {
  5752. var /** @type {?} */ ctrl = /** @type {?} */ (_this.form.get(/** @type {?} */ ((dir.path))));
  5753. ctrl.setValue(value);
  5754. });
  5755. };
  5756. /**
  5757. * @param {?} value
  5758. * @return {?}
  5759. */
  5760. NgForm.prototype.setValue = /**
  5761. * @param {?} value
  5762. * @return {?}
  5763. */
  5764. function (value) { this.control.setValue(value); };
  5765. /**
  5766. * @param {?} $event
  5767. * @return {?}
  5768. */
  5769. NgForm.prototype.onSubmit = /**
  5770. * @param {?} $event
  5771. * @return {?}
  5772. */
  5773. function ($event) {
  5774. (/** @type {?} */ (this)).submitted = true;
  5775. syncPendingControls(this.form, this._directives);
  5776. this.ngSubmit.emit($event);
  5777. return false;
  5778. };
  5779. /**
  5780. * @return {?}
  5781. */
  5782. NgForm.prototype.onReset = /**
  5783. * @return {?}
  5784. */
  5785. function () { this.resetForm(); };
  5786. /**
  5787. * @param {?=} value
  5788. * @return {?}
  5789. */
  5790. NgForm.prototype.resetForm = /**
  5791. * @param {?=} value
  5792. * @return {?}
  5793. */
  5794. function (value) {
  5795. if (value === void 0) { value = undefined; }
  5796. this.form.reset(value);
  5797. (/** @type {?} */ (this)).submitted = false;
  5798. };
  5799. /**
  5800. * @return {?}
  5801. */
  5802. NgForm.prototype._setUpdateStrategy = /**
  5803. * @return {?}
  5804. */
  5805. function () {
  5806. if (this.options && this.options.updateOn != null) {
  5807. this.form._updateOn = this.options.updateOn;
  5808. }
  5809. };
  5810. /** @internal */
  5811. /**
  5812. * \@internal
  5813. * @param {?} path
  5814. * @return {?}
  5815. */
  5816. NgForm.prototype._findContainer = /**
  5817. * \@internal
  5818. * @param {?} path
  5819. * @return {?}
  5820. */
  5821. function (path) {
  5822. path.pop();
  5823. return path.length ? /** @type {?} */ (this.form.get(path)) : this.form;
  5824. };
  5825. NgForm.decorators = [
  5826. { type: _angular_core.Directive, args: [{
  5827. selector: 'form:not([ngNoForm]):not([formGroup]),ngForm,[ngForm]',
  5828. providers: [formDirectiveProvider],
  5829. host: { '(submit)': 'onSubmit($event)', '(reset)': 'onReset()' },
  5830. outputs: ['ngSubmit'],
  5831. exportAs: 'ngForm'
  5832. },] },
  5833. ];
  5834. /** @nocollapse */
  5835. NgForm.ctorParameters = function () { return [
  5836. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
  5837. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
  5838. ]; };
  5839. NgForm.propDecorators = {
  5840. "options": [{ type: _angular_core.Input, args: ['ngFormOptions',] },],
  5841. };
  5842. return NgForm;
  5843. }(ControlContainer));
  5844. /**
  5845. * @fileoverview added by tsickle
  5846. * @suppress {checkTypes} checked by tsc
  5847. */
  5848. /**
  5849. * @license
  5850. * Copyright Google Inc. All Rights Reserved.
  5851. *
  5852. * Use of this source code is governed by an MIT-style license that can be
  5853. * found in the LICENSE file at https://angular.io/license
  5854. */
  5855. var FormErrorExamples = {
  5856. formControlName: "\n <div [formGroup]=\"myGroup\">\n <input formControlName=\"firstName\">\n </div>\n\n In your class:\n\n this.myGroup = new FormGroup({\n firstName: new FormControl()\n });",
  5857. formGroupName: "\n <div [formGroup]=\"myGroup\">\n <div formGroupName=\"person\">\n <input formControlName=\"firstName\">\n </div>\n </div>\n\n In your class:\n\n this.myGroup = new FormGroup({\n person: new FormGroup({ firstName: new FormControl() })\n });",
  5858. formArrayName: "\n <div [formGroup]=\"myGroup\">\n <div formArrayName=\"cities\">\n <div *ngFor=\"let city of cityArray.controls; index as i\">\n <input [formControlName]=\"i\">\n </div>\n </div>\n </div>\n\n In your class:\n\n this.cityArray = new FormArray([new FormControl('SF')]);\n this.myGroup = new FormGroup({\n cities: this.cityArray\n });",
  5859. ngModelGroup: "\n <form>\n <div ngModelGroup=\"person\">\n <input [(ngModel)]=\"person.name\" name=\"firstName\">\n </div>\n </form>",
  5860. ngModelWithFormGroup: "\n <div [formGroup]=\"myGroup\">\n <input formControlName=\"firstName\">\n <input [(ngModel)]=\"showMoreControls\" [ngModelOptions]=\"{standalone: true}\">\n </div>\n "
  5861. };
  5862. /**
  5863. * @fileoverview added by tsickle
  5864. * @suppress {checkTypes} checked by tsc
  5865. */
  5866. /**
  5867. * @license
  5868. * Copyright Google Inc. All Rights Reserved.
  5869. *
  5870. * Use of this source code is governed by an MIT-style license that can be
  5871. * found in the LICENSE file at https://angular.io/license
  5872. */
  5873. var TemplateDrivenErrors = /** @class */ (function () {
  5874. function TemplateDrivenErrors() {
  5875. }
  5876. /**
  5877. * @return {?}
  5878. */
  5879. TemplateDrivenErrors.modelParentException = /**
  5880. * @return {?}
  5881. */
  5882. function () {
  5883. throw new Error("\n ngModel cannot be used to register form controls with a parent formGroup directive. Try using\n formGroup's partner directive \"formControlName\" instead. Example:\n\n " + FormErrorExamples.formControlName + "\n\n Or, if you'd like to avoid registering this form control, indicate that it's standalone in ngModelOptions:\n\n Example:\n\n " + FormErrorExamples.ngModelWithFormGroup);
  5884. };
  5885. /**
  5886. * @return {?}
  5887. */
  5888. TemplateDrivenErrors.formGroupNameException = /**
  5889. * @return {?}
  5890. */
  5891. function () {
  5892. throw new Error("\n ngModel cannot be used to register form controls with a parent formGroupName or formArrayName directive.\n\n Option 1: Use formControlName instead of ngModel (reactive strategy):\n\n " + FormErrorExamples.formGroupName + "\n\n Option 2: Update ngModel's parent be ngModelGroup (template-driven strategy):\n\n " + FormErrorExamples.ngModelGroup);
  5893. };
  5894. /**
  5895. * @return {?}
  5896. */
  5897. TemplateDrivenErrors.missingNameException = /**
  5898. * @return {?}
  5899. */
  5900. function () {
  5901. throw new Error("If ngModel is used within a form tag, either the name attribute must be set or the form\n control must be defined as 'standalone' in ngModelOptions.\n\n Example 1: <input [(ngModel)]=\"person.firstName\" name=\"first\">\n Example 2: <input [(ngModel)]=\"person.firstName\" [ngModelOptions]=\"{standalone: true}\">");
  5902. };
  5903. /**
  5904. * @return {?}
  5905. */
  5906. TemplateDrivenErrors.modelGroupParentException = /**
  5907. * @return {?}
  5908. */
  5909. function () {
  5910. throw new Error("\n ngModelGroup cannot be used with a parent formGroup directive.\n\n Option 1: Use formGroupName instead of ngModelGroup (reactive strategy):\n\n " + FormErrorExamples.formGroupName + "\n\n Option 2: Use a regular form tag instead of the formGroup directive (template-driven strategy):\n\n " + FormErrorExamples.ngModelGroup);
  5911. };
  5912. return TemplateDrivenErrors;
  5913. }());
  5914. /**
  5915. * @fileoverview added by tsickle
  5916. * @suppress {checkTypes} checked by tsc
  5917. */
  5918. /**
  5919. * @license
  5920. * Copyright Google Inc. All Rights Reserved.
  5921. *
  5922. * Use of this source code is governed by an MIT-style license that can be
  5923. * found in the LICENSE file at https://angular.io/license
  5924. */
  5925. var modelGroupProvider = {
  5926. provide: ControlContainer,
  5927. useExisting: _angular_core.forwardRef(function () { return NgModelGroup; })
  5928. };
  5929. /**
  5930. * \@whatItDoes Creates and binds a {\@link FormGroup} instance to a DOM element.
  5931. *
  5932. * \@howToUse
  5933. *
  5934. * This directive can only be used as a child of {\@link NgForm} (or in other words,
  5935. * within `<form>` tags).
  5936. *
  5937. * Use this directive if you'd like to create a sub-group within a form. This can
  5938. * come in handy if you want to validate a sub-group of your form separately from
  5939. * the rest of your form, or if some values in your domain model make more sense to
  5940. * consume together in a nested object.
  5941. *
  5942. * Pass in the name you'd like this sub-group to have and it will become the key
  5943. * for the sub-group in the form's full value. You can also export the directive into
  5944. * a local template variable using `ngModelGroup` (ex: `#myGroup="ngModelGroup"`).
  5945. *
  5946. * {\@example forms/ts/ngModelGroup/ng_model_group_example.ts region='Component'}
  5947. *
  5948. * * **npm package**: `\@angular/forms`
  5949. *
  5950. * * **NgModule**: `FormsModule`
  5951. *
  5952. * \@stable
  5953. */
  5954. var NgModelGroup = /** @class */ (function (_super) {
  5955. __extends(NgModelGroup, _super);
  5956. function NgModelGroup(parent, validators, asyncValidators) {
  5957. var _this = _super.call(this) || this;
  5958. _this._parent = parent;
  5959. _this._validators = validators;
  5960. _this._asyncValidators = asyncValidators;
  5961. return _this;
  5962. }
  5963. /** @internal */
  5964. /**
  5965. * \@internal
  5966. * @return {?}
  5967. */
  5968. NgModelGroup.prototype._checkParentType = /**
  5969. * \@internal
  5970. * @return {?}
  5971. */
  5972. function () {
  5973. if (!(this._parent instanceof NgModelGroup) && !(this._parent instanceof NgForm)) {
  5974. TemplateDrivenErrors.modelGroupParentException();
  5975. }
  5976. };
  5977. NgModelGroup.decorators = [
  5978. { type: _angular_core.Directive, args: [{ selector: '[ngModelGroup]', providers: [modelGroupProvider], exportAs: 'ngModelGroup' },] },
  5979. ];
  5980. /** @nocollapse */
  5981. NgModelGroup.ctorParameters = function () { return [
  5982. { type: ControlContainer, decorators: [{ type: _angular_core.Host }, { type: _angular_core.SkipSelf },] },
  5983. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
  5984. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
  5985. ]; };
  5986. NgModelGroup.propDecorators = {
  5987. "name": [{ type: _angular_core.Input, args: ['ngModelGroup',] },],
  5988. };
  5989. return NgModelGroup;
  5990. }(AbstractFormGroupDirective));
  5991. /**
  5992. * @fileoverview added by tsickle
  5993. * @suppress {checkTypes} checked by tsc
  5994. */
  5995. /**
  5996. * @license
  5997. * Copyright Google Inc. All Rights Reserved.
  5998. *
  5999. * Use of this source code is governed by an MIT-style license that can be
  6000. * found in the LICENSE file at https://angular.io/license
  6001. */
  6002. var formControlBinding = {
  6003. provide: NgControl,
  6004. useExisting: _angular_core.forwardRef(function () { return NgModel; })
  6005. };
  6006. /**
  6007. * `ngModel` forces an additional change detection run when its inputs change:
  6008. * E.g.:
  6009. * ```
  6010. * <div>{{myModel.valid}}</div>
  6011. * <input [(ngModel)]="myValue" #myModel="ngModel">
  6012. * ```
  6013. * I.e. `ngModel` can export itself on the element and then be used in the template.
  6014. * Normally, this would result in expressions before the `input` that use the exported directive
  6015. * to have and old value as they have been
  6016. * dirty checked before. As this is a very common case for `ngModel`, we added this second change
  6017. * detection run.
  6018. *
  6019. * Notes:
  6020. * - this is just one extra run no matter how many `ngModel` have been changed.
  6021. * - this is a general problem when using `exportAs` for directives!
  6022. */
  6023. var resolvedPromise$1 = Promise.resolve(null);
  6024. /**
  6025. * \@whatItDoes Creates a {\@link FormControl} instance from a domain model and binds it
  6026. * to a form control element.
  6027. *
  6028. * The {\@link FormControl} instance will track the value, user interaction, and
  6029. * validation status of the control and keep the view synced with the model. If used
  6030. * within a parent form, the directive will also register itself with the form as a child
  6031. * control.
  6032. *
  6033. * \@howToUse
  6034. *
  6035. * This directive can be used by itself or as part of a larger form. All you need is the
  6036. * `ngModel` selector to activate it.
  6037. *
  6038. * It accepts a domain model as an optional {\@link Input}. If you have a one-way binding
  6039. * to `ngModel` with `[]` syntax, changing the value of the domain model in the component
  6040. * class will set the value in the view. If you have a two-way binding with `[()]` syntax
  6041. * (also known as 'banana-box syntax'), the value in the UI will always be synced back to
  6042. * the domain model in your class as well.
  6043. *
  6044. * If you wish to inspect the properties of the associated {\@link FormControl} (like
  6045. * validity state), you can also export the directive into a local template variable using
  6046. * `ngModel` as the key (ex: `#myVar="ngModel"`). You can then access the control using the
  6047. * directive's `control` property, but most properties you'll need (like `valid` and `dirty`)
  6048. * will fall through to the control anyway, so you can access them directly. You can see a
  6049. * full list of properties directly available in {\@link AbstractControlDirective}.
  6050. *
  6051. * The following is an example of a simple standalone control using `ngModel`:
  6052. *
  6053. * {\@example forms/ts/simpleNgModel/simple_ng_model_example.ts region='Component'}
  6054. *
  6055. * When using the `ngModel` within `<form>` tags, you'll also need to supply a `name` attribute
  6056. * so that the control can be registered with the parent form under that name.
  6057. *
  6058. * It's worth noting that in the context of a parent form, you often can skip one-way or
  6059. * two-way binding because the parent form will sync the value for you. You can access
  6060. * its properties by exporting it into a local template variable using `ngForm` (ex:
  6061. * `#f="ngForm"`). Then you can pass it where it needs to go on submit.
  6062. *
  6063. * If you do need to populate initial values into your form, using a one-way binding for
  6064. * `ngModel` tends to be sufficient as long as you use the exported form's value rather
  6065. * than the domain model's value on submit.
  6066. *
  6067. * Take a look at an example of using `ngModel` within a form:
  6068. *
  6069. * {\@example forms/ts/simpleForm/simple_form_example.ts region='Component'}
  6070. *
  6071. * To see `ngModel` examples with different form control types, see:
  6072. *
  6073. * * Radio buttons: {\@link RadioControlValueAccessor}
  6074. * * Selects: {\@link SelectControlValueAccessor}
  6075. *
  6076. * **npm package**: `\@angular/forms`
  6077. *
  6078. * **NgModule**: `FormsModule`
  6079. *
  6080. * \@stable
  6081. */
  6082. var NgModel = /** @class */ (function (_super) {
  6083. __extends(NgModel, _super);
  6084. function NgModel(parent, validators, asyncValidators, valueAccessors) {
  6085. var _this = _super.call(this) || this;
  6086. _this.control = new FormControl();
  6087. /**
  6088. * \@internal
  6089. */
  6090. _this._registered = false;
  6091. _this.update = new _angular_core.EventEmitter();
  6092. _this._parent = parent;
  6093. _this._rawValidators = validators || [];
  6094. _this._rawAsyncValidators = asyncValidators || [];
  6095. _this.valueAccessor = selectValueAccessor(_this, valueAccessors);
  6096. return _this;
  6097. }
  6098. /**
  6099. * @param {?} changes
  6100. * @return {?}
  6101. */
  6102. NgModel.prototype.ngOnChanges = /**
  6103. * @param {?} changes
  6104. * @return {?}
  6105. */
  6106. function (changes) {
  6107. this._checkForErrors();
  6108. if (!this._registered)
  6109. this._setUpControl();
  6110. if ('isDisabled' in changes) {
  6111. this._updateDisabled(changes);
  6112. }
  6113. if (isPropertyUpdated(changes, this.viewModel)) {
  6114. this._updateValue(this.model);
  6115. this.viewModel = this.model;
  6116. }
  6117. };
  6118. /**
  6119. * @return {?}
  6120. */
  6121. NgModel.prototype.ngOnDestroy = /**
  6122. * @return {?}
  6123. */
  6124. function () { this.formDirective && this.formDirective.removeControl(this); };
  6125. Object.defineProperty(NgModel.prototype, "path", {
  6126. get: /**
  6127. * @return {?}
  6128. */
  6129. function () {
  6130. return this._parent ? controlPath(this.name, this._parent) : [this.name];
  6131. },
  6132. enumerable: true,
  6133. configurable: true
  6134. });
  6135. Object.defineProperty(NgModel.prototype, "formDirective", {
  6136. get: /**
  6137. * @return {?}
  6138. */
  6139. function () { return this._parent ? this._parent.formDirective : null; },
  6140. enumerable: true,
  6141. configurable: true
  6142. });
  6143. Object.defineProperty(NgModel.prototype, "validator", {
  6144. get: /**
  6145. * @return {?}
  6146. */
  6147. function () { return composeValidators(this._rawValidators); },
  6148. enumerable: true,
  6149. configurable: true
  6150. });
  6151. Object.defineProperty(NgModel.prototype, "asyncValidator", {
  6152. get: /**
  6153. * @return {?}
  6154. */
  6155. function () {
  6156. return composeAsyncValidators(this._rawAsyncValidators);
  6157. },
  6158. enumerable: true,
  6159. configurable: true
  6160. });
  6161. /**
  6162. * @param {?} newValue
  6163. * @return {?}
  6164. */
  6165. NgModel.prototype.viewToModelUpdate = /**
  6166. * @param {?} newValue
  6167. * @return {?}
  6168. */
  6169. function (newValue) {
  6170. this.viewModel = newValue;
  6171. this.update.emit(newValue);
  6172. };
  6173. /**
  6174. * @return {?}
  6175. */
  6176. NgModel.prototype._setUpControl = /**
  6177. * @return {?}
  6178. */
  6179. function () {
  6180. this._setUpdateStrategy();
  6181. this._isStandalone() ? this._setUpStandalone() :
  6182. this.formDirective.addControl(this);
  6183. this._registered = true;
  6184. };
  6185. /**
  6186. * @return {?}
  6187. */
  6188. NgModel.prototype._setUpdateStrategy = /**
  6189. * @return {?}
  6190. */
  6191. function () {
  6192. if (this.options && this.options.updateOn != null) {
  6193. this.control._updateOn = this.options.updateOn;
  6194. }
  6195. };
  6196. /**
  6197. * @return {?}
  6198. */
  6199. NgModel.prototype._isStandalone = /**
  6200. * @return {?}
  6201. */
  6202. function () {
  6203. return !this._parent || !!(this.options && this.options.standalone);
  6204. };
  6205. /**
  6206. * @return {?}
  6207. */
  6208. NgModel.prototype._setUpStandalone = /**
  6209. * @return {?}
  6210. */
  6211. function () {
  6212. setUpControl(this.control, this);
  6213. this.control.updateValueAndValidity({ emitEvent: false });
  6214. };
  6215. /**
  6216. * @return {?}
  6217. */
  6218. NgModel.prototype._checkForErrors = /**
  6219. * @return {?}
  6220. */
  6221. function () {
  6222. if (!this._isStandalone()) {
  6223. this._checkParentType();
  6224. }
  6225. this._checkName();
  6226. };
  6227. /**
  6228. * @return {?}
  6229. */
  6230. NgModel.prototype._checkParentType = /**
  6231. * @return {?}
  6232. */
  6233. function () {
  6234. if (!(this._parent instanceof NgModelGroup) &&
  6235. this._parent instanceof AbstractFormGroupDirective) {
  6236. TemplateDrivenErrors.formGroupNameException();
  6237. }
  6238. else if (!(this._parent instanceof NgModelGroup) && !(this._parent instanceof NgForm)) {
  6239. TemplateDrivenErrors.modelParentException();
  6240. }
  6241. };
  6242. /**
  6243. * @return {?}
  6244. */
  6245. NgModel.prototype._checkName = /**
  6246. * @return {?}
  6247. */
  6248. function () {
  6249. if (this.options && this.options.name)
  6250. this.name = this.options.name;
  6251. if (!this._isStandalone() && !this.name) {
  6252. TemplateDrivenErrors.missingNameException();
  6253. }
  6254. };
  6255. /**
  6256. * @param {?} value
  6257. * @return {?}
  6258. */
  6259. NgModel.prototype._updateValue = /**
  6260. * @param {?} value
  6261. * @return {?}
  6262. */
  6263. function (value) {
  6264. var _this = this;
  6265. resolvedPromise$1.then(function () { _this.control.setValue(value, { emitViewToModelChange: false }); });
  6266. };
  6267. /**
  6268. * @param {?} changes
  6269. * @return {?}
  6270. */
  6271. NgModel.prototype._updateDisabled = /**
  6272. * @param {?} changes
  6273. * @return {?}
  6274. */
  6275. function (changes) {
  6276. var _this = this;
  6277. var /** @type {?} */ disabledValue = changes['isDisabled'].currentValue;
  6278. var /** @type {?} */ isDisabled = disabledValue === '' || (disabledValue && disabledValue !== 'false');
  6279. resolvedPromise$1.then(function () {
  6280. if (isDisabled && !_this.control.disabled) {
  6281. _this.control.disable();
  6282. }
  6283. else if (!isDisabled && _this.control.disabled) {
  6284. _this.control.enable();
  6285. }
  6286. });
  6287. };
  6288. NgModel.decorators = [
  6289. { type: _angular_core.Directive, args: [{
  6290. selector: '[ngModel]:not([formControlName]):not([formControl])',
  6291. providers: [formControlBinding],
  6292. exportAs: 'ngModel'
  6293. },] },
  6294. ];
  6295. /** @nocollapse */
  6296. NgModel.ctorParameters = function () { return [
  6297. { type: ControlContainer, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host },] },
  6298. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
  6299. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
  6300. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALUE_ACCESSOR,] },] },
  6301. ]; };
  6302. NgModel.propDecorators = {
  6303. "name": [{ type: _angular_core.Input },],
  6304. "isDisabled": [{ type: _angular_core.Input, args: ['disabled',] },],
  6305. "model": [{ type: _angular_core.Input, args: ['ngModel',] },],
  6306. "options": [{ type: _angular_core.Input, args: ['ngModelOptions',] },],
  6307. "update": [{ type: _angular_core.Output, args: ['ngModelChange',] },],
  6308. };
  6309. return NgModel;
  6310. }(NgControl));
  6311. /**
  6312. * @fileoverview added by tsickle
  6313. * @suppress {checkTypes} checked by tsc
  6314. */
  6315. /**
  6316. * @license
  6317. * Copyright Google Inc. All Rights Reserved.
  6318. *
  6319. * Use of this source code is governed by an MIT-style license that can be
  6320. * found in the LICENSE file at https://angular.io/license
  6321. */
  6322. var ReactiveErrors = /** @class */ (function () {
  6323. function ReactiveErrors() {
  6324. }
  6325. /**
  6326. * @return {?}
  6327. */
  6328. ReactiveErrors.controlParentException = /**
  6329. * @return {?}
  6330. */
  6331. function () {
  6332. throw new Error("formControlName must be used with a parent formGroup directive. You'll want to add a formGroup\n directive and pass it an existing FormGroup instance (you can create one in your class).\n\n Example:\n\n " + FormErrorExamples.formControlName);
  6333. };
  6334. /**
  6335. * @return {?}
  6336. */
  6337. ReactiveErrors.ngModelGroupException = /**
  6338. * @return {?}
  6339. */
  6340. function () {
  6341. throw new Error("formControlName cannot be used with an ngModelGroup parent. It is only compatible with parents\n that also have a \"form\" prefix: formGroupName, formArrayName, or formGroup.\n\n Option 1: Update the parent to be formGroupName (reactive form strategy)\n\n " + FormErrorExamples.formGroupName + "\n\n Option 2: Use ngModel instead of formControlName (template-driven strategy)\n\n " + FormErrorExamples.ngModelGroup);
  6342. };
  6343. /**
  6344. * @return {?}
  6345. */
  6346. ReactiveErrors.missingFormException = /**
  6347. * @return {?}
  6348. */
  6349. function () {
  6350. throw new Error("formGroup expects a FormGroup instance. Please pass one in.\n\n Example:\n\n " + FormErrorExamples.formControlName);
  6351. };
  6352. /**
  6353. * @return {?}
  6354. */
  6355. ReactiveErrors.groupParentException = /**
  6356. * @return {?}
  6357. */
  6358. function () {
  6359. throw new Error("formGroupName must be used with a parent formGroup directive. You'll want to add a formGroup\n directive and pass it an existing FormGroup instance (you can create one in your class).\n\n Example:\n\n " + FormErrorExamples.formGroupName);
  6360. };
  6361. /**
  6362. * @return {?}
  6363. */
  6364. ReactiveErrors.arrayParentException = /**
  6365. * @return {?}
  6366. */
  6367. function () {
  6368. throw new Error("formArrayName must be used with a parent formGroup directive. You'll want to add a formGroup\n directive and pass it an existing FormGroup instance (you can create one in your class).\n\n Example:\n\n " + FormErrorExamples.formArrayName);
  6369. };
  6370. /**
  6371. * @return {?}
  6372. */
  6373. ReactiveErrors.disabledAttrWarning = /**
  6374. * @return {?}
  6375. */
  6376. function () {
  6377. console.warn("\n It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true\n when you set up this control in your component class, the disabled attribute will actually be set in the DOM for\n you. We recommend using this approach to avoid 'changed after checked' errors.\n \n Example: \n form = new FormGroup({\n first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),\n last: new FormControl('Drew', Validators.required)\n });\n ");
  6378. };
  6379. return ReactiveErrors;
  6380. }());
  6381. /**
  6382. * @fileoverview added by tsickle
  6383. * @suppress {checkTypes} checked by tsc
  6384. */
  6385. /**
  6386. * @license
  6387. * Copyright Google Inc. All Rights Reserved.
  6388. *
  6389. * Use of this source code is governed by an MIT-style license that can be
  6390. * found in the LICENSE file at https://angular.io/license
  6391. */
  6392. var formControlBinding$1 = {
  6393. provide: NgControl,
  6394. useExisting: _angular_core.forwardRef(function () { return FormControlDirective; })
  6395. };
  6396. /**
  6397. * \@whatItDoes Syncs a standalone {\@link FormControl} instance to a form control element.
  6398. *
  6399. * In other words, this directive ensures that any values written to the {\@link FormControl}
  6400. * instance programmatically will be written to the DOM element (model -> view). Conversely,
  6401. * any values written to the DOM element through user input will be reflected in the
  6402. * {\@link FormControl} instance (view -> model).
  6403. *
  6404. * \@howToUse
  6405. *
  6406. * Use this directive if you'd like to create and manage a {\@link FormControl} instance directly.
  6407. * Simply create a {\@link FormControl}, save it to your component class, and pass it into the
  6408. * {\@link FormControlDirective}.
  6409. *
  6410. * This directive is designed to be used as a standalone control. Unlike {\@link FormControlName},
  6411. * it does not require that your {\@link FormControl} instance be part of any parent
  6412. * {\@link FormGroup}, and it won't be registered to any {\@link FormGroupDirective} that
  6413. * exists above it.
  6414. *
  6415. * **Get the value**: the `value` property is always synced and available on the
  6416. * {\@link FormControl} instance. See a full list of available properties in
  6417. * {\@link AbstractControl}.
  6418. *
  6419. * **Set the value**: You can pass in an initial value when instantiating the {\@link FormControl},
  6420. * or you can set it programmatically later using {\@link AbstractControl#setValue setValue} or
  6421. * {\@link AbstractControl#patchValue patchValue}.
  6422. *
  6423. * **Listen to value**: If you want to listen to changes in the value of the control, you can
  6424. * subscribe to the {\@link AbstractControl#valueChanges valueChanges} event. You can also listen to
  6425. * {\@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
  6426. * re-calculated.
  6427. *
  6428. * ### Example
  6429. *
  6430. * {\@example forms/ts/simpleFormControl/simple_form_control_example.ts region='Component'}
  6431. *
  6432. * * **npm package**: `\@angular/forms`
  6433. *
  6434. * * **NgModule**: `ReactiveFormsModule`
  6435. *
  6436. * \@stable
  6437. */
  6438. var FormControlDirective = /** @class */ (function (_super) {
  6439. __extends(FormControlDirective, _super);
  6440. function FormControlDirective(validators, asyncValidators, valueAccessors) {
  6441. var _this = _super.call(this) || this;
  6442. _this.update = new _angular_core.EventEmitter();
  6443. _this._rawValidators = validators || [];
  6444. _this._rawAsyncValidators = asyncValidators || [];
  6445. _this.valueAccessor = selectValueAccessor(_this, valueAccessors);
  6446. return _this;
  6447. }
  6448. Object.defineProperty(FormControlDirective.prototype, "isDisabled", {
  6449. set: /**
  6450. * @param {?} isDisabled
  6451. * @return {?}
  6452. */
  6453. function (isDisabled) { ReactiveErrors.disabledAttrWarning(); },
  6454. enumerable: true,
  6455. configurable: true
  6456. });
  6457. /**
  6458. * @param {?} changes
  6459. * @return {?}
  6460. */
  6461. FormControlDirective.prototype.ngOnChanges = /**
  6462. * @param {?} changes
  6463. * @return {?}
  6464. */
  6465. function (changes) {
  6466. if (this._isControlChanged(changes)) {
  6467. setUpControl(this.form, this);
  6468. if (this.control.disabled && /** @type {?} */ ((this.valueAccessor)).setDisabledState) {
  6469. /** @type {?} */ ((/** @type {?} */ ((this.valueAccessor)).setDisabledState))(true);
  6470. }
  6471. this.form.updateValueAndValidity({ emitEvent: false });
  6472. }
  6473. if (isPropertyUpdated(changes, this.viewModel)) {
  6474. this.form.setValue(this.model);
  6475. this.viewModel = this.model;
  6476. }
  6477. };
  6478. Object.defineProperty(FormControlDirective.prototype, "path", {
  6479. get: /**
  6480. * @return {?}
  6481. */
  6482. function () { return []; },
  6483. enumerable: true,
  6484. configurable: true
  6485. });
  6486. Object.defineProperty(FormControlDirective.prototype, "validator", {
  6487. get: /**
  6488. * @return {?}
  6489. */
  6490. function () { return composeValidators(this._rawValidators); },
  6491. enumerable: true,
  6492. configurable: true
  6493. });
  6494. Object.defineProperty(FormControlDirective.prototype, "asyncValidator", {
  6495. get: /**
  6496. * @return {?}
  6497. */
  6498. function () {
  6499. return composeAsyncValidators(this._rawAsyncValidators);
  6500. },
  6501. enumerable: true,
  6502. configurable: true
  6503. });
  6504. Object.defineProperty(FormControlDirective.prototype, "control", {
  6505. get: /**
  6506. * @return {?}
  6507. */
  6508. function () { return this.form; },
  6509. enumerable: true,
  6510. configurable: true
  6511. });
  6512. /**
  6513. * @param {?} newValue
  6514. * @return {?}
  6515. */
  6516. FormControlDirective.prototype.viewToModelUpdate = /**
  6517. * @param {?} newValue
  6518. * @return {?}
  6519. */
  6520. function (newValue) {
  6521. this.viewModel = newValue;
  6522. this.update.emit(newValue);
  6523. };
  6524. /**
  6525. * @param {?} changes
  6526. * @return {?}
  6527. */
  6528. FormControlDirective.prototype._isControlChanged = /**
  6529. * @param {?} changes
  6530. * @return {?}
  6531. */
  6532. function (changes) {
  6533. return changes.hasOwnProperty('form');
  6534. };
  6535. FormControlDirective.decorators = [
  6536. { type: _angular_core.Directive, args: [{ selector: '[formControl]', providers: [formControlBinding$1], exportAs: 'ngForm' },] },
  6537. ];
  6538. /** @nocollapse */
  6539. FormControlDirective.ctorParameters = function () { return [
  6540. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
  6541. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
  6542. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALUE_ACCESSOR,] },] },
  6543. ]; };
  6544. FormControlDirective.propDecorators = {
  6545. "form": [{ type: _angular_core.Input, args: ['formControl',] },],
  6546. "model": [{ type: _angular_core.Input, args: ['ngModel',] },],
  6547. "update": [{ type: _angular_core.Output, args: ['ngModelChange',] },],
  6548. "isDisabled": [{ type: _angular_core.Input, args: ['disabled',] },],
  6549. };
  6550. return FormControlDirective;
  6551. }(NgControl));
  6552. /**
  6553. * @fileoverview added by tsickle
  6554. * @suppress {checkTypes} checked by tsc
  6555. */
  6556. /**
  6557. * @license
  6558. * Copyright Google Inc. All Rights Reserved.
  6559. *
  6560. * Use of this source code is governed by an MIT-style license that can be
  6561. * found in the LICENSE file at https://angular.io/license
  6562. */
  6563. var formDirectiveProvider$1 = {
  6564. provide: ControlContainer,
  6565. useExisting: _angular_core.forwardRef(function () { return FormGroupDirective; })
  6566. };
  6567. /**
  6568. * \@whatItDoes Binds an existing {\@link FormGroup} to a DOM element.
  6569. *
  6570. * \@howToUse
  6571. *
  6572. * This directive accepts an existing {\@link FormGroup} instance. It will then use this
  6573. * {\@link FormGroup} instance to match any child {\@link FormControl}, {\@link FormGroup},
  6574. * and {\@link FormArray} instances to child {\@link FormControlName}, {\@link FormGroupName},
  6575. * and {\@link FormArrayName} directives.
  6576. *
  6577. * **Set value**: You can set the form's initial value when instantiating the
  6578. * {\@link FormGroup}, or you can set it programmatically later using the {\@link FormGroup}'s
  6579. * {\@link AbstractControl#setValue setValue} or {\@link AbstractControl#patchValue patchValue}
  6580. * methods.
  6581. *
  6582. * **Listen to value**: If you want to listen to changes in the value of the form, you can subscribe
  6583. * to the {\@link FormGroup}'s {\@link AbstractControl#valueChanges valueChanges} event. You can also
  6584. * listen to its {\@link AbstractControl#statusChanges statusChanges} event to be notified when the
  6585. * validation status is re-calculated.
  6586. *
  6587. * Furthermore, you can listen to the directive's `ngSubmit` event to be notified when the user has
  6588. * triggered a form submission. The `ngSubmit` event will be emitted with the original form
  6589. * submission event.
  6590. *
  6591. * ### Example
  6592. *
  6593. * In this example, we create form controls for first name and last name.
  6594. *
  6595. * {\@example forms/ts/simpleFormGroup/simple_form_group_example.ts region='Component'}
  6596. *
  6597. * **npm package**: `\@angular/forms`
  6598. *
  6599. * **NgModule**: {\@link ReactiveFormsModule}
  6600. *
  6601. * \@stable
  6602. */
  6603. var FormGroupDirective = /** @class */ (function (_super) {
  6604. __extends(FormGroupDirective, _super);
  6605. function FormGroupDirective(_validators, _asyncValidators) {
  6606. var _this = _super.call(this) || this;
  6607. _this._validators = _validators;
  6608. _this._asyncValidators = _asyncValidators;
  6609. _this.submitted = false;
  6610. _this.directives = [];
  6611. _this.form = /** @type {?} */ ((null));
  6612. _this.ngSubmit = new _angular_core.EventEmitter();
  6613. return _this;
  6614. }
  6615. /**
  6616. * @param {?} changes
  6617. * @return {?}
  6618. */
  6619. FormGroupDirective.prototype.ngOnChanges = /**
  6620. * @param {?} changes
  6621. * @return {?}
  6622. */
  6623. function (changes) {
  6624. this._checkFormPresent();
  6625. if (changes.hasOwnProperty('form')) {
  6626. this._updateValidators();
  6627. this._updateDomValue();
  6628. this._updateRegistrations();
  6629. }
  6630. };
  6631. Object.defineProperty(FormGroupDirective.prototype, "formDirective", {
  6632. get: /**
  6633. * @return {?}
  6634. */
  6635. function () { return this; },
  6636. enumerable: true,
  6637. configurable: true
  6638. });
  6639. Object.defineProperty(FormGroupDirective.prototype, "control", {
  6640. get: /**
  6641. * @return {?}
  6642. */
  6643. function () { return this.form; },
  6644. enumerable: true,
  6645. configurable: true
  6646. });
  6647. Object.defineProperty(FormGroupDirective.prototype, "path", {
  6648. get: /**
  6649. * @return {?}
  6650. */
  6651. function () { return []; },
  6652. enumerable: true,
  6653. configurable: true
  6654. });
  6655. /**
  6656. * @param {?} dir
  6657. * @return {?}
  6658. */
  6659. FormGroupDirective.prototype.addControl = /**
  6660. * @param {?} dir
  6661. * @return {?}
  6662. */
  6663. function (dir) {
  6664. var /** @type {?} */ ctrl = this.form.get(dir.path);
  6665. setUpControl(ctrl, dir);
  6666. ctrl.updateValueAndValidity({ emitEvent: false });
  6667. this.directives.push(dir);
  6668. return ctrl;
  6669. };
  6670. /**
  6671. * @param {?} dir
  6672. * @return {?}
  6673. */
  6674. FormGroupDirective.prototype.getControl = /**
  6675. * @param {?} dir
  6676. * @return {?}
  6677. */
  6678. function (dir) { return /** @type {?} */ (this.form.get(dir.path)); };
  6679. /**
  6680. * @param {?} dir
  6681. * @return {?}
  6682. */
  6683. FormGroupDirective.prototype.removeControl = /**
  6684. * @param {?} dir
  6685. * @return {?}
  6686. */
  6687. function (dir) { removeDir(this.directives, dir); };
  6688. /**
  6689. * @param {?} dir
  6690. * @return {?}
  6691. */
  6692. FormGroupDirective.prototype.addFormGroup = /**
  6693. * @param {?} dir
  6694. * @return {?}
  6695. */
  6696. function (dir) {
  6697. var /** @type {?} */ ctrl = this.form.get(dir.path);
  6698. setUpFormContainer(ctrl, dir);
  6699. ctrl.updateValueAndValidity({ emitEvent: false });
  6700. };
  6701. /**
  6702. * @param {?} dir
  6703. * @return {?}
  6704. */
  6705. FormGroupDirective.prototype.removeFormGroup = /**
  6706. * @param {?} dir
  6707. * @return {?}
  6708. */
  6709. function (dir) { };
  6710. /**
  6711. * @param {?} dir
  6712. * @return {?}
  6713. */
  6714. FormGroupDirective.prototype.getFormGroup = /**
  6715. * @param {?} dir
  6716. * @return {?}
  6717. */
  6718. function (dir) { return /** @type {?} */ (this.form.get(dir.path)); };
  6719. /**
  6720. * @param {?} dir
  6721. * @return {?}
  6722. */
  6723. FormGroupDirective.prototype.addFormArray = /**
  6724. * @param {?} dir
  6725. * @return {?}
  6726. */
  6727. function (dir) {
  6728. var /** @type {?} */ ctrl = this.form.get(dir.path);
  6729. setUpFormContainer(ctrl, dir);
  6730. ctrl.updateValueAndValidity({ emitEvent: false });
  6731. };
  6732. /**
  6733. * @param {?} dir
  6734. * @return {?}
  6735. */
  6736. FormGroupDirective.prototype.removeFormArray = /**
  6737. * @param {?} dir
  6738. * @return {?}
  6739. */
  6740. function (dir) { };
  6741. /**
  6742. * @param {?} dir
  6743. * @return {?}
  6744. */
  6745. FormGroupDirective.prototype.getFormArray = /**
  6746. * @param {?} dir
  6747. * @return {?}
  6748. */
  6749. function (dir) { return /** @type {?} */ (this.form.get(dir.path)); };
  6750. /**
  6751. * @param {?} dir
  6752. * @param {?} value
  6753. * @return {?}
  6754. */
  6755. FormGroupDirective.prototype.updateModel = /**
  6756. * @param {?} dir
  6757. * @param {?} value
  6758. * @return {?}
  6759. */
  6760. function (dir, value) {
  6761. var /** @type {?} */ ctrl = /** @type {?} */ (this.form.get(dir.path));
  6762. ctrl.setValue(value);
  6763. };
  6764. /**
  6765. * @param {?} $event
  6766. * @return {?}
  6767. */
  6768. FormGroupDirective.prototype.onSubmit = /**
  6769. * @param {?} $event
  6770. * @return {?}
  6771. */
  6772. function ($event) {
  6773. (/** @type {?} */ (this)).submitted = true;
  6774. syncPendingControls(this.form, this.directives);
  6775. this.ngSubmit.emit($event);
  6776. return false;
  6777. };
  6778. /**
  6779. * @return {?}
  6780. */
  6781. FormGroupDirective.prototype.onReset = /**
  6782. * @return {?}
  6783. */
  6784. function () { this.resetForm(); };
  6785. /**
  6786. * @param {?=} value
  6787. * @return {?}
  6788. */
  6789. FormGroupDirective.prototype.resetForm = /**
  6790. * @param {?=} value
  6791. * @return {?}
  6792. */
  6793. function (value) {
  6794. if (value === void 0) { value = undefined; }
  6795. this.form.reset(value);
  6796. (/** @type {?} */ (this)).submitted = false;
  6797. };
  6798. /** @internal */
  6799. /**
  6800. * \@internal
  6801. * @return {?}
  6802. */
  6803. FormGroupDirective.prototype._updateDomValue = /**
  6804. * \@internal
  6805. * @return {?}
  6806. */
  6807. function () {
  6808. var _this = this;
  6809. this.directives.forEach(function (dir) {
  6810. var /** @type {?} */ newCtrl = _this.form.get(dir.path);
  6811. if (dir.control !== newCtrl) {
  6812. cleanUpControl(dir.control, dir);
  6813. if (newCtrl)
  6814. setUpControl(newCtrl, dir);
  6815. (/** @type {?} */ (dir)).control = newCtrl;
  6816. }
  6817. });
  6818. this.form._updateTreeValidity({ emitEvent: false });
  6819. };
  6820. /**
  6821. * @return {?}
  6822. */
  6823. FormGroupDirective.prototype._updateRegistrations = /**
  6824. * @return {?}
  6825. */
  6826. function () {
  6827. var _this = this;
  6828. this.form._registerOnCollectionChange(function () { return _this._updateDomValue(); });
  6829. if (this._oldForm)
  6830. this._oldForm._registerOnCollectionChange(function () { });
  6831. this._oldForm = this.form;
  6832. };
  6833. /**
  6834. * @return {?}
  6835. */
  6836. FormGroupDirective.prototype._updateValidators = /**
  6837. * @return {?}
  6838. */
  6839. function () {
  6840. var /** @type {?} */ sync = composeValidators(this._validators);
  6841. this.form.validator = Validators.compose([/** @type {?} */ ((this.form.validator)), /** @type {?} */ ((sync))]);
  6842. var /** @type {?} */ async = composeAsyncValidators(this._asyncValidators);
  6843. this.form.asyncValidator = Validators.composeAsync([/** @type {?} */ ((this.form.asyncValidator)), /** @type {?} */ ((async))]);
  6844. };
  6845. /**
  6846. * @return {?}
  6847. */
  6848. FormGroupDirective.prototype._checkFormPresent = /**
  6849. * @return {?}
  6850. */
  6851. function () {
  6852. if (!this.form) {
  6853. ReactiveErrors.missingFormException();
  6854. }
  6855. };
  6856. FormGroupDirective.decorators = [
  6857. { type: _angular_core.Directive, args: [{
  6858. selector: '[formGroup]',
  6859. providers: [formDirectiveProvider$1],
  6860. host: { '(submit)': 'onSubmit($event)', '(reset)': 'onReset()' },
  6861. exportAs: 'ngForm'
  6862. },] },
  6863. ];
  6864. /** @nocollapse */
  6865. FormGroupDirective.ctorParameters = function () { return [
  6866. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
  6867. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
  6868. ]; };
  6869. FormGroupDirective.propDecorators = {
  6870. "form": [{ type: _angular_core.Input, args: ['formGroup',] },],
  6871. "ngSubmit": [{ type: _angular_core.Output },],
  6872. };
  6873. return FormGroupDirective;
  6874. }(ControlContainer));
  6875. /**
  6876. * @fileoverview added by tsickle
  6877. * @suppress {checkTypes} checked by tsc
  6878. */
  6879. /**
  6880. * @license
  6881. * Copyright Google Inc. All Rights Reserved.
  6882. *
  6883. * Use of this source code is governed by an MIT-style license that can be
  6884. * found in the LICENSE file at https://angular.io/license
  6885. */
  6886. var formGroupNameProvider = {
  6887. provide: ControlContainer,
  6888. useExisting: _angular_core.forwardRef(function () { return FormGroupName; })
  6889. };
  6890. /**
  6891. * \@whatItDoes Syncs a nested {\@link FormGroup} to a DOM element.
  6892. *
  6893. * \@howToUse
  6894. *
  6895. * This directive can only be used with a parent {\@link FormGroupDirective} (selector:
  6896. * `[formGroup]`).
  6897. *
  6898. * It accepts the string name of the nested {\@link FormGroup} you want to link, and
  6899. * will look for a {\@link FormGroup} registered with that name in the parent
  6900. * {\@link FormGroup} instance you passed into {\@link FormGroupDirective}.
  6901. *
  6902. * Nested form groups can come in handy when you want to validate a sub-group of a
  6903. * form separately from the rest or when you'd like to group the values of certain
  6904. * controls into their own nested object.
  6905. *
  6906. * **Access the group**: You can access the associated {\@link FormGroup} using the
  6907. * {\@link AbstractControl#get get} method. Ex: `this.form.get('name')`.
  6908. *
  6909. * You can also access individual controls within the group using dot syntax.
  6910. * Ex: `this.form.get('name.first')`
  6911. *
  6912. * **Get the value**: the `value` property is always synced and available on the
  6913. * {\@link FormGroup}. See a full list of available properties in {\@link AbstractControl}.
  6914. *
  6915. * **Set the value**: You can set an initial value for each child control when instantiating
  6916. * the {\@link FormGroup}, or you can set it programmatically later using
  6917. * {\@link AbstractControl#setValue setValue} or {\@link AbstractControl#patchValue patchValue}.
  6918. *
  6919. * **Listen to value**: If you want to listen to changes in the value of the group, you can
  6920. * subscribe to the {\@link AbstractControl#valueChanges valueChanges} event. You can also listen to
  6921. * {\@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
  6922. * re-calculated.
  6923. *
  6924. * ### Example
  6925. *
  6926. * {\@example forms/ts/nestedFormGroup/nested_form_group_example.ts region='Component'}
  6927. *
  6928. * * **npm package**: `\@angular/forms`
  6929. *
  6930. * * **NgModule**: `ReactiveFormsModule`
  6931. *
  6932. * \@stable
  6933. */
  6934. var FormGroupName = /** @class */ (function (_super) {
  6935. __extends(FormGroupName, _super);
  6936. function FormGroupName(parent, validators, asyncValidators) {
  6937. var _this = _super.call(this) || this;
  6938. _this._parent = parent;
  6939. _this._validators = validators;
  6940. _this._asyncValidators = asyncValidators;
  6941. return _this;
  6942. }
  6943. /** @internal */
  6944. /**
  6945. * \@internal
  6946. * @return {?}
  6947. */
  6948. FormGroupName.prototype._checkParentType = /**
  6949. * \@internal
  6950. * @return {?}
  6951. */
  6952. function () {
  6953. if (_hasInvalidParent(this._parent)) {
  6954. ReactiveErrors.groupParentException();
  6955. }
  6956. };
  6957. FormGroupName.decorators = [
  6958. { type: _angular_core.Directive, args: [{ selector: '[formGroupName]', providers: [formGroupNameProvider] },] },
  6959. ];
  6960. /** @nocollapse */
  6961. FormGroupName.ctorParameters = function () { return [
  6962. { type: ControlContainer, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host }, { type: _angular_core.SkipSelf },] },
  6963. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
  6964. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
  6965. ]; };
  6966. FormGroupName.propDecorators = {
  6967. "name": [{ type: _angular_core.Input, args: ['formGroupName',] },],
  6968. };
  6969. return FormGroupName;
  6970. }(AbstractFormGroupDirective));
  6971. var formArrayNameProvider = {
  6972. provide: ControlContainer,
  6973. useExisting: _angular_core.forwardRef(function () { return FormArrayName; })
  6974. };
  6975. /**
  6976. * \@whatItDoes Syncs a nested {\@link FormArray} to a DOM element.
  6977. *
  6978. * \@howToUse
  6979. *
  6980. * This directive is designed to be used with a parent {\@link FormGroupDirective} (selector:
  6981. * `[formGroup]`).
  6982. *
  6983. * It accepts the string name of the nested {\@link FormArray} you want to link, and
  6984. * will look for a {\@link FormArray} registered with that name in the parent
  6985. * {\@link FormGroup} instance you passed into {\@link FormGroupDirective}.
  6986. *
  6987. * Nested form arrays can come in handy when you have a group of form controls but
  6988. * you're not sure how many there will be. Form arrays allow you to create new
  6989. * form controls dynamically.
  6990. *
  6991. * **Access the array**: You can access the associated {\@link FormArray} using the
  6992. * {\@link AbstractControl#get get} method on the parent {\@link FormGroup}.
  6993. * Ex: `this.form.get('cities')`.
  6994. *
  6995. * **Get the value**: the `value` property is always synced and available on the
  6996. * {\@link FormArray}. See a full list of available properties in {\@link AbstractControl}.
  6997. *
  6998. * **Set the value**: You can set an initial value for each child control when instantiating
  6999. * the {\@link FormArray}, or you can set the value programmatically later using the
  7000. * {\@link FormArray}'s {\@link AbstractControl#setValue setValue} or
  7001. * {\@link AbstractControl#patchValue patchValue} methods.
  7002. *
  7003. * **Listen to value**: If you want to listen to changes in the value of the array, you can
  7004. * subscribe to the {\@link FormArray}'s {\@link AbstractControl#valueChanges valueChanges} event.
  7005. * You can also listen to its {\@link AbstractControl#statusChanges statusChanges} event to be
  7006. * notified when the validation status is re-calculated.
  7007. *
  7008. * **Add new controls**: You can add new controls to the {\@link FormArray} dynamically by calling
  7009. * its {\@link FormArray#push push} method.
  7010. * Ex: `this.form.get('cities').push(new FormControl());`
  7011. *
  7012. * ### Example
  7013. *
  7014. * {\@example forms/ts/nestedFormArray/nested_form_array_example.ts region='Component'}
  7015. *
  7016. * * **npm package**: `\@angular/forms`
  7017. *
  7018. * * **NgModule**: `ReactiveFormsModule`
  7019. *
  7020. * \@stable
  7021. */
  7022. var FormArrayName = /** @class */ (function (_super) {
  7023. __extends(FormArrayName, _super);
  7024. function FormArrayName(parent, validators, asyncValidators) {
  7025. var _this = _super.call(this) || this;
  7026. _this._parent = parent;
  7027. _this._validators = validators;
  7028. _this._asyncValidators = asyncValidators;
  7029. return _this;
  7030. }
  7031. /**
  7032. * @return {?}
  7033. */
  7034. FormArrayName.prototype.ngOnInit = /**
  7035. * @return {?}
  7036. */
  7037. function () {
  7038. this._checkParentType(); /** @type {?} */
  7039. ((this.formDirective)).addFormArray(this);
  7040. };
  7041. /**
  7042. * @return {?}
  7043. */
  7044. FormArrayName.prototype.ngOnDestroy = /**
  7045. * @return {?}
  7046. */
  7047. function () {
  7048. if (this.formDirective) {
  7049. this.formDirective.removeFormArray(this);
  7050. }
  7051. };
  7052. Object.defineProperty(FormArrayName.prototype, "control", {
  7053. get: /**
  7054. * @return {?}
  7055. */
  7056. function () { return /** @type {?} */ ((this.formDirective)).getFormArray(this); },
  7057. enumerable: true,
  7058. configurable: true
  7059. });
  7060. Object.defineProperty(FormArrayName.prototype, "formDirective", {
  7061. get: /**
  7062. * @return {?}
  7063. */
  7064. function () {
  7065. return this._parent ? /** @type {?} */ (this._parent.formDirective) : null;
  7066. },
  7067. enumerable: true,
  7068. configurable: true
  7069. });
  7070. Object.defineProperty(FormArrayName.prototype, "path", {
  7071. get: /**
  7072. * @return {?}
  7073. */
  7074. function () { return controlPath(this.name, this._parent); },
  7075. enumerable: true,
  7076. configurable: true
  7077. });
  7078. Object.defineProperty(FormArrayName.prototype, "validator", {
  7079. get: /**
  7080. * @return {?}
  7081. */
  7082. function () { return composeValidators(this._validators); },
  7083. enumerable: true,
  7084. configurable: true
  7085. });
  7086. Object.defineProperty(FormArrayName.prototype, "asyncValidator", {
  7087. get: /**
  7088. * @return {?}
  7089. */
  7090. function () {
  7091. return composeAsyncValidators(this._asyncValidators);
  7092. },
  7093. enumerable: true,
  7094. configurable: true
  7095. });
  7096. /**
  7097. * @return {?}
  7098. */
  7099. FormArrayName.prototype._checkParentType = /**
  7100. * @return {?}
  7101. */
  7102. function () {
  7103. if (_hasInvalidParent(this._parent)) {
  7104. ReactiveErrors.arrayParentException();
  7105. }
  7106. };
  7107. FormArrayName.decorators = [
  7108. { type: _angular_core.Directive, args: [{ selector: '[formArrayName]', providers: [formArrayNameProvider] },] },
  7109. ];
  7110. /** @nocollapse */
  7111. FormArrayName.ctorParameters = function () { return [
  7112. { type: ControlContainer, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host }, { type: _angular_core.SkipSelf },] },
  7113. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
  7114. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
  7115. ]; };
  7116. FormArrayName.propDecorators = {
  7117. "name": [{ type: _angular_core.Input, args: ['formArrayName',] },],
  7118. };
  7119. return FormArrayName;
  7120. }(ControlContainer));
  7121. /**
  7122. * @param {?} parent
  7123. * @return {?}
  7124. */
  7125. function _hasInvalidParent(parent) {
  7126. return !(parent instanceof FormGroupName) && !(parent instanceof FormGroupDirective) &&
  7127. !(parent instanceof FormArrayName);
  7128. }
  7129. /**
  7130. * @fileoverview added by tsickle
  7131. * @suppress {checkTypes} checked by tsc
  7132. */
  7133. /**
  7134. * @license
  7135. * Copyright Google Inc. All Rights Reserved.
  7136. *
  7137. * Use of this source code is governed by an MIT-style license that can be
  7138. * found in the LICENSE file at https://angular.io/license
  7139. */
  7140. var controlNameBinding = {
  7141. provide: NgControl,
  7142. useExisting: _angular_core.forwardRef(function () { return FormControlName; })
  7143. };
  7144. /**
  7145. * \@whatItDoes Syncs a {\@link FormControl} in an existing {\@link FormGroup} to a form control
  7146. * element by name.
  7147. *
  7148. * In other words, this directive ensures that any values written to the {\@link FormControl}
  7149. * instance programmatically will be written to the DOM element (model -> view). Conversely,
  7150. * any values written to the DOM element through user input will be reflected in the
  7151. * {\@link FormControl} instance (view -> model).
  7152. *
  7153. * \@howToUse
  7154. *
  7155. * This directive is designed to be used with a parent {\@link FormGroupDirective} (selector:
  7156. * `[formGroup]`).
  7157. *
  7158. * It accepts the string name of the {\@link FormControl} instance you want to
  7159. * link, and will look for a {\@link FormControl} registered with that name in the
  7160. * closest {\@link FormGroup} or {\@link FormArray} above it.
  7161. *
  7162. * **Access the control**: You can access the {\@link FormControl} associated with
  7163. * this directive by using the {\@link AbstractControl#get get} method.
  7164. * Ex: `this.form.get('first');`
  7165. *
  7166. * **Get value**: the `value` property is always synced and available on the {\@link FormControl}.
  7167. * See a full list of available properties in {\@link AbstractControl}.
  7168. *
  7169. * **Set value**: You can set an initial value for the control when instantiating the
  7170. * {\@link FormControl}, or you can set it programmatically later using
  7171. * {\@link AbstractControl#setValue setValue} or {\@link AbstractControl#patchValue patchValue}.
  7172. *
  7173. * **Listen to value**: If you want to listen to changes in the value of the control, you can
  7174. * subscribe to the {\@link AbstractControl#valueChanges valueChanges} event. You can also listen to
  7175. * {\@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
  7176. * re-calculated.
  7177. *
  7178. * ### Example
  7179. *
  7180. * In this example, we create form controls for first name and last name.
  7181. *
  7182. * {\@example forms/ts/simpleFormGroup/simple_form_group_example.ts region='Component'}
  7183. *
  7184. * To see `formControlName` examples with different form control types, see:
  7185. *
  7186. * * Radio buttons: {\@link RadioControlValueAccessor}
  7187. * * Selects: {\@link SelectControlValueAccessor}
  7188. *
  7189. * **npm package**: `\@angular/forms`
  7190. *
  7191. * **NgModule**: {\@link ReactiveFormsModule}
  7192. *
  7193. * \@stable
  7194. */
  7195. var FormControlName = /** @class */ (function (_super) {
  7196. __extends(FormControlName, _super);
  7197. function FormControlName(parent, validators, asyncValidators, valueAccessors) {
  7198. var _this = _super.call(this) || this;
  7199. _this._added = false;
  7200. _this.update = new _angular_core.EventEmitter();
  7201. _this._parent = parent;
  7202. _this._rawValidators = validators || [];
  7203. _this._rawAsyncValidators = asyncValidators || [];
  7204. _this.valueAccessor = selectValueAccessor(_this, valueAccessors);
  7205. return _this;
  7206. }
  7207. Object.defineProperty(FormControlName.prototype, "isDisabled", {
  7208. set: /**
  7209. * @param {?} isDisabled
  7210. * @return {?}
  7211. */
  7212. function (isDisabled) { ReactiveErrors.disabledAttrWarning(); },
  7213. enumerable: true,
  7214. configurable: true
  7215. });
  7216. /**
  7217. * @param {?} changes
  7218. * @return {?}
  7219. */
  7220. FormControlName.prototype.ngOnChanges = /**
  7221. * @param {?} changes
  7222. * @return {?}
  7223. */
  7224. function (changes) {
  7225. if (!this._added)
  7226. this._setUpControl();
  7227. if (isPropertyUpdated(changes, this.viewModel)) {
  7228. this.viewModel = this.model;
  7229. this.formDirective.updateModel(this, this.model);
  7230. }
  7231. };
  7232. /**
  7233. * @return {?}
  7234. */
  7235. FormControlName.prototype.ngOnDestroy = /**
  7236. * @return {?}
  7237. */
  7238. function () {
  7239. if (this.formDirective) {
  7240. this.formDirective.removeControl(this);
  7241. }
  7242. };
  7243. /**
  7244. * @param {?} newValue
  7245. * @return {?}
  7246. */
  7247. FormControlName.prototype.viewToModelUpdate = /**
  7248. * @param {?} newValue
  7249. * @return {?}
  7250. */
  7251. function (newValue) {
  7252. this.viewModel = newValue;
  7253. this.update.emit(newValue);
  7254. };
  7255. Object.defineProperty(FormControlName.prototype, "path", {
  7256. get: /**
  7257. * @return {?}
  7258. */
  7259. function () { return controlPath(this.name, /** @type {?} */ ((this._parent))); },
  7260. enumerable: true,
  7261. configurable: true
  7262. });
  7263. Object.defineProperty(FormControlName.prototype, "formDirective", {
  7264. get: /**
  7265. * @return {?}
  7266. */
  7267. function () { return this._parent ? this._parent.formDirective : null; },
  7268. enumerable: true,
  7269. configurable: true
  7270. });
  7271. Object.defineProperty(FormControlName.prototype, "validator", {
  7272. get: /**
  7273. * @return {?}
  7274. */
  7275. function () { return composeValidators(this._rawValidators); },
  7276. enumerable: true,
  7277. configurable: true
  7278. });
  7279. Object.defineProperty(FormControlName.prototype, "asyncValidator", {
  7280. get: /**
  7281. * @return {?}
  7282. */
  7283. function () {
  7284. return /** @type {?} */ ((composeAsyncValidators(this._rawAsyncValidators)));
  7285. },
  7286. enumerable: true,
  7287. configurable: true
  7288. });
  7289. /**
  7290. * @return {?}
  7291. */
  7292. FormControlName.prototype._checkParentType = /**
  7293. * @return {?}
  7294. */
  7295. function () {
  7296. if (!(this._parent instanceof FormGroupName) &&
  7297. this._parent instanceof AbstractFormGroupDirective) {
  7298. ReactiveErrors.ngModelGroupException();
  7299. }
  7300. else if (!(this._parent instanceof FormGroupName) && !(this._parent instanceof FormGroupDirective) &&
  7301. !(this._parent instanceof FormArrayName)) {
  7302. ReactiveErrors.controlParentException();
  7303. }
  7304. };
  7305. /**
  7306. * @return {?}
  7307. */
  7308. FormControlName.prototype._setUpControl = /**
  7309. * @return {?}
  7310. */
  7311. function () {
  7312. this._checkParentType();
  7313. (/** @type {?} */ (this)).control = this.formDirective.addControl(this);
  7314. if (this.control.disabled && /** @type {?} */ ((this.valueAccessor)).setDisabledState) {
  7315. /** @type {?} */ ((/** @type {?} */ ((this.valueAccessor)).setDisabledState))(true);
  7316. }
  7317. this._added = true;
  7318. };
  7319. FormControlName.decorators = [
  7320. { type: _angular_core.Directive, args: [{ selector: '[formControlName]', providers: [controlNameBinding] },] },
  7321. ];
  7322. /** @nocollapse */
  7323. FormControlName.ctorParameters = function () { return [
  7324. { type: ControlContainer, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Host }, { type: _angular_core.SkipSelf },] },
  7325. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALIDATORS,] },] },
  7326. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_ASYNC_VALIDATORS,] },] },
  7327. { type: Array, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Self }, { type: _angular_core.Inject, args: [NG_VALUE_ACCESSOR,] },] },
  7328. ]; };
  7329. FormControlName.propDecorators = {
  7330. "name": [{ type: _angular_core.Input, args: ['formControlName',] },],
  7331. "model": [{ type: _angular_core.Input, args: ['ngModel',] },],
  7332. "update": [{ type: _angular_core.Output, args: ['ngModelChange',] },],
  7333. "isDisabled": [{ type: _angular_core.Input, args: ['disabled',] },],
  7334. };
  7335. return FormControlName;
  7336. }(NgControl));
  7337. /**
  7338. * @fileoverview added by tsickle
  7339. * @suppress {checkTypes} checked by tsc
  7340. */
  7341. /**
  7342. * @license
  7343. * Copyright Google Inc. All Rights Reserved.
  7344. *
  7345. * Use of this source code is governed by an MIT-style license that can be
  7346. * found in the LICENSE file at https://angular.io/license
  7347. */
  7348. /**
  7349. * An interface that can be implemented by classes that can act as validators.
  7350. *
  7351. * ## Usage
  7352. *
  7353. * ```typescript
  7354. * \@Directive({
  7355. * selector: '[custom-validator]',
  7356. * providers: [{provide: NG_VALIDATORS, useExisting: CustomValidatorDirective, multi: true}]
  7357. * })
  7358. * class CustomValidatorDirective implements Validator {
  7359. * validate(c: Control): {[key: string]: any} {
  7360. * return {"custom": true};
  7361. * }
  7362. * }
  7363. * ```
  7364. *
  7365. * \@stable
  7366. * @record
  7367. */
  7368. /**
  7369. * \@experimental
  7370. * @record
  7371. */
  7372. var REQUIRED_VALIDATOR = {
  7373. provide: NG_VALIDATORS,
  7374. useExisting: _angular_core.forwardRef(function () { return RequiredValidator; }),
  7375. multi: true
  7376. };
  7377. var CHECKBOX_REQUIRED_VALIDATOR = {
  7378. provide: NG_VALIDATORS,
  7379. useExisting: _angular_core.forwardRef(function () { return CheckboxRequiredValidator; }),
  7380. multi: true
  7381. };
  7382. /**
  7383. * A Directive that adds the `required` validator to any controls marked with the
  7384. * `required` attribute, via the {\@link NG_VALIDATORS} binding.
  7385. *
  7386. * ### Example
  7387. *
  7388. * ```
  7389. * <input name="fullName" ngModel required>
  7390. * ```
  7391. *
  7392. * \@stable
  7393. */
  7394. var RequiredValidator = /** @class */ (function () {
  7395. function RequiredValidator() {
  7396. }
  7397. Object.defineProperty(RequiredValidator.prototype, "required", {
  7398. get: /**
  7399. * @return {?}
  7400. */
  7401. function () { return this._required; },
  7402. set: /**
  7403. * @param {?} value
  7404. * @return {?}
  7405. */
  7406. function (value) {
  7407. this._required = value != null && value !== false && "" + value !== 'false';
  7408. if (this._onChange)
  7409. this._onChange();
  7410. },
  7411. enumerable: true,
  7412. configurable: true
  7413. });
  7414. /**
  7415. * @param {?} c
  7416. * @return {?}
  7417. */
  7418. RequiredValidator.prototype.validate = /**
  7419. * @param {?} c
  7420. * @return {?}
  7421. */
  7422. function (c) {
  7423. return this.required ? Validators.required(c) : null;
  7424. };
  7425. /**
  7426. * @param {?} fn
  7427. * @return {?}
  7428. */
  7429. RequiredValidator.prototype.registerOnValidatorChange = /**
  7430. * @param {?} fn
  7431. * @return {?}
  7432. */
  7433. function (fn) { this._onChange = fn; };
  7434. RequiredValidator.decorators = [
  7435. { type: _angular_core.Directive, args: [{
  7436. selector: ':not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]',
  7437. providers: [REQUIRED_VALIDATOR],
  7438. host: { '[attr.required]': 'required ? "" : null' }
  7439. },] },
  7440. ];
  7441. /** @nocollapse */
  7442. RequiredValidator.ctorParameters = function () { return []; };
  7443. RequiredValidator.propDecorators = {
  7444. "required": [{ type: _angular_core.Input },],
  7445. };
  7446. return RequiredValidator;
  7447. }());
  7448. /**
  7449. * A Directive that adds the `required` validator to checkbox controls marked with the
  7450. * `required` attribute, via the {\@link NG_VALIDATORS} binding.
  7451. *
  7452. * ### Example
  7453. *
  7454. * ```
  7455. * <input type="checkbox" name="active" ngModel required>
  7456. * ```
  7457. *
  7458. * \@experimental
  7459. */
  7460. var CheckboxRequiredValidator = /** @class */ (function (_super) {
  7461. __extends(CheckboxRequiredValidator, _super);
  7462. function CheckboxRequiredValidator() {
  7463. return _super !== null && _super.apply(this, arguments) || this;
  7464. }
  7465. /**
  7466. * @param {?} c
  7467. * @return {?}
  7468. */
  7469. CheckboxRequiredValidator.prototype.validate = /**
  7470. * @param {?} c
  7471. * @return {?}
  7472. */
  7473. function (c) {
  7474. return this.required ? Validators.requiredTrue(c) : null;
  7475. };
  7476. CheckboxRequiredValidator.decorators = [
  7477. { type: _angular_core.Directive, args: [{
  7478. selector: 'input[type=checkbox][required][formControlName],input[type=checkbox][required][formControl],input[type=checkbox][required][ngModel]',
  7479. providers: [CHECKBOX_REQUIRED_VALIDATOR],
  7480. host: { '[attr.required]': 'required ? "" : null' }
  7481. },] },
  7482. ];
  7483. /** @nocollapse */
  7484. CheckboxRequiredValidator.ctorParameters = function () { return []; };
  7485. return CheckboxRequiredValidator;
  7486. }(RequiredValidator));
  7487. /**
  7488. * Provider which adds {\@link EmailValidator} to {\@link NG_VALIDATORS}.
  7489. */
  7490. var EMAIL_VALIDATOR = {
  7491. provide: NG_VALIDATORS,
  7492. useExisting: _angular_core.forwardRef(function () { return EmailValidator; }),
  7493. multi: true
  7494. };
  7495. /**
  7496. * A Directive that adds the `email` validator to controls marked with the
  7497. * `email` attribute, via the {\@link NG_VALIDATORS} binding.
  7498. *
  7499. * ### Example
  7500. *
  7501. * ```
  7502. * <input type="email" name="email" ngModel email>
  7503. * <input type="email" name="email" ngModel email="true">
  7504. * <input type="email" name="email" ngModel [email]="true">
  7505. * ```
  7506. *
  7507. * \@experimental
  7508. */
  7509. var EmailValidator = /** @class */ (function () {
  7510. function EmailValidator() {
  7511. }
  7512. Object.defineProperty(EmailValidator.prototype, "email", {
  7513. set: /**
  7514. * @param {?} value
  7515. * @return {?}
  7516. */
  7517. function (value) {
  7518. this._enabled = value === '' || value === true || value === 'true';
  7519. if (this._onChange)
  7520. this._onChange();
  7521. },
  7522. enumerable: true,
  7523. configurable: true
  7524. });
  7525. /**
  7526. * @param {?} c
  7527. * @return {?}
  7528. */
  7529. EmailValidator.prototype.validate = /**
  7530. * @param {?} c
  7531. * @return {?}
  7532. */
  7533. function (c) {
  7534. return this._enabled ? Validators.email(c) : null;
  7535. };
  7536. /**
  7537. * @param {?} fn
  7538. * @return {?}
  7539. */
  7540. EmailValidator.prototype.registerOnValidatorChange = /**
  7541. * @param {?} fn
  7542. * @return {?}
  7543. */
  7544. function (fn) { this._onChange = fn; };
  7545. EmailValidator.decorators = [
  7546. { type: _angular_core.Directive, args: [{
  7547. selector: '[email][formControlName],[email][formControl],[email][ngModel]',
  7548. providers: [EMAIL_VALIDATOR]
  7549. },] },
  7550. ];
  7551. /** @nocollapse */
  7552. EmailValidator.ctorParameters = function () { return []; };
  7553. EmailValidator.propDecorators = {
  7554. "email": [{ type: _angular_core.Input },],
  7555. };
  7556. return EmailValidator;
  7557. }());
  7558. /**
  7559. * \@stable
  7560. * @record
  7561. */
  7562. /**
  7563. * \@stable
  7564. * @record
  7565. */
  7566. /**
  7567. * Provider which adds {\@link MinLengthValidator} to {\@link NG_VALIDATORS}.
  7568. *
  7569. * ## Example:
  7570. *
  7571. * {\@example common/forms/ts/validators/validators.ts region='min'}
  7572. */
  7573. var MIN_LENGTH_VALIDATOR = {
  7574. provide: NG_VALIDATORS,
  7575. useExisting: _angular_core.forwardRef(function () { return MinLengthValidator; }),
  7576. multi: true
  7577. };
  7578. /**
  7579. * A directive which installs the {\@link MinLengthValidator} for any `formControlName`,
  7580. * `formControl`, or control with `ngModel` that also has a `minlength` attribute.
  7581. *
  7582. * \@stable
  7583. */
  7584. var MinLengthValidator = /** @class */ (function () {
  7585. function MinLengthValidator() {
  7586. }
  7587. /**
  7588. * @param {?} changes
  7589. * @return {?}
  7590. */
  7591. MinLengthValidator.prototype.ngOnChanges = /**
  7592. * @param {?} changes
  7593. * @return {?}
  7594. */
  7595. function (changes) {
  7596. if ('minlength' in changes) {
  7597. this._createValidator();
  7598. if (this._onChange)
  7599. this._onChange();
  7600. }
  7601. };
  7602. /**
  7603. * @param {?} c
  7604. * @return {?}
  7605. */
  7606. MinLengthValidator.prototype.validate = /**
  7607. * @param {?} c
  7608. * @return {?}
  7609. */
  7610. function (c) {
  7611. return this.minlength == null ? null : this._validator(c);
  7612. };
  7613. /**
  7614. * @param {?} fn
  7615. * @return {?}
  7616. */
  7617. MinLengthValidator.prototype.registerOnValidatorChange = /**
  7618. * @param {?} fn
  7619. * @return {?}
  7620. */
  7621. function (fn) { this._onChange = fn; };
  7622. /**
  7623. * @return {?}
  7624. */
  7625. MinLengthValidator.prototype._createValidator = /**
  7626. * @return {?}
  7627. */
  7628. function () {
  7629. this._validator = Validators.minLength(parseInt(this.minlength, 10));
  7630. };
  7631. MinLengthValidator.decorators = [
  7632. { type: _angular_core.Directive, args: [{
  7633. selector: '[minlength][formControlName],[minlength][formControl],[minlength][ngModel]',
  7634. providers: [MIN_LENGTH_VALIDATOR],
  7635. host: { '[attr.minlength]': 'minlength ? minlength : null' }
  7636. },] },
  7637. ];
  7638. /** @nocollapse */
  7639. MinLengthValidator.ctorParameters = function () { return []; };
  7640. MinLengthValidator.propDecorators = {
  7641. "minlength": [{ type: _angular_core.Input },],
  7642. };
  7643. return MinLengthValidator;
  7644. }());
  7645. /**
  7646. * Provider which adds {\@link MaxLengthValidator} to {\@link NG_VALIDATORS}.
  7647. *
  7648. * ## Example:
  7649. *
  7650. * {\@example common/forms/ts/validators/validators.ts region='max'}
  7651. */
  7652. var MAX_LENGTH_VALIDATOR = {
  7653. provide: NG_VALIDATORS,
  7654. useExisting: _angular_core.forwardRef(function () { return MaxLengthValidator; }),
  7655. multi: true
  7656. };
  7657. /**
  7658. * A directive which installs the {\@link MaxLengthValidator} for any `formControlName,
  7659. * `formControl`,
  7660. * or control with `ngModel` that also has a `maxlength` attribute.
  7661. *
  7662. * \@stable
  7663. */
  7664. var MaxLengthValidator = /** @class */ (function () {
  7665. function MaxLengthValidator() {
  7666. }
  7667. /**
  7668. * @param {?} changes
  7669. * @return {?}
  7670. */
  7671. MaxLengthValidator.prototype.ngOnChanges = /**
  7672. * @param {?} changes
  7673. * @return {?}
  7674. */
  7675. function (changes) {
  7676. if ('maxlength' in changes) {
  7677. this._createValidator();
  7678. if (this._onChange)
  7679. this._onChange();
  7680. }
  7681. };
  7682. /**
  7683. * @param {?} c
  7684. * @return {?}
  7685. */
  7686. MaxLengthValidator.prototype.validate = /**
  7687. * @param {?} c
  7688. * @return {?}
  7689. */
  7690. function (c) {
  7691. return this.maxlength != null ? this._validator(c) : null;
  7692. };
  7693. /**
  7694. * @param {?} fn
  7695. * @return {?}
  7696. */
  7697. MaxLengthValidator.prototype.registerOnValidatorChange = /**
  7698. * @param {?} fn
  7699. * @return {?}
  7700. */
  7701. function (fn) { this._onChange = fn; };
  7702. /**
  7703. * @return {?}
  7704. */
  7705. MaxLengthValidator.prototype._createValidator = /**
  7706. * @return {?}
  7707. */
  7708. function () {
  7709. this._validator = Validators.maxLength(parseInt(this.maxlength, 10));
  7710. };
  7711. MaxLengthValidator.decorators = [
  7712. { type: _angular_core.Directive, args: [{
  7713. selector: '[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]',
  7714. providers: [MAX_LENGTH_VALIDATOR],
  7715. host: { '[attr.maxlength]': 'maxlength ? maxlength : null' }
  7716. },] },
  7717. ];
  7718. /** @nocollapse */
  7719. MaxLengthValidator.ctorParameters = function () { return []; };
  7720. MaxLengthValidator.propDecorators = {
  7721. "maxlength": [{ type: _angular_core.Input },],
  7722. };
  7723. return MaxLengthValidator;
  7724. }());
  7725. var PATTERN_VALIDATOR = {
  7726. provide: NG_VALIDATORS,
  7727. useExisting: _angular_core.forwardRef(function () { return PatternValidator; }),
  7728. multi: true
  7729. };
  7730. /**
  7731. * A Directive that adds the `pattern` validator to any controls marked with the
  7732. * `pattern` attribute, via the {\@link NG_VALIDATORS} binding. Uses attribute value
  7733. * as the regex to validate Control value against. Follows pattern attribute
  7734. * semantics; i.e. regex must match entire Control value.
  7735. *
  7736. * ### Example
  7737. *
  7738. * ```
  7739. * <input [name]="fullName" pattern="[a-zA-Z ]*" ngModel>
  7740. * ```
  7741. * \@stable
  7742. */
  7743. var PatternValidator = /** @class */ (function () {
  7744. function PatternValidator() {
  7745. }
  7746. /**
  7747. * @param {?} changes
  7748. * @return {?}
  7749. */
  7750. PatternValidator.prototype.ngOnChanges = /**
  7751. * @param {?} changes
  7752. * @return {?}
  7753. */
  7754. function (changes) {
  7755. if ('pattern' in changes) {
  7756. this._createValidator();
  7757. if (this._onChange)
  7758. this._onChange();
  7759. }
  7760. };
  7761. /**
  7762. * @param {?} c
  7763. * @return {?}
  7764. */
  7765. PatternValidator.prototype.validate = /**
  7766. * @param {?} c
  7767. * @return {?}
  7768. */
  7769. function (c) { return this._validator(c); };
  7770. /**
  7771. * @param {?} fn
  7772. * @return {?}
  7773. */
  7774. PatternValidator.prototype.registerOnValidatorChange = /**
  7775. * @param {?} fn
  7776. * @return {?}
  7777. */
  7778. function (fn) { this._onChange = fn; };
  7779. /**
  7780. * @return {?}
  7781. */
  7782. PatternValidator.prototype._createValidator = /**
  7783. * @return {?}
  7784. */
  7785. function () { this._validator = Validators.pattern(this.pattern); };
  7786. PatternValidator.decorators = [
  7787. { type: _angular_core.Directive, args: [{
  7788. selector: '[pattern][formControlName],[pattern][formControl],[pattern][ngModel]',
  7789. providers: [PATTERN_VALIDATOR],
  7790. host: { '[attr.pattern]': 'pattern ? pattern : null' }
  7791. },] },
  7792. ];
  7793. /** @nocollapse */
  7794. PatternValidator.ctorParameters = function () { return []; };
  7795. PatternValidator.propDecorators = {
  7796. "pattern": [{ type: _angular_core.Input },],
  7797. };
  7798. return PatternValidator;
  7799. }());
  7800. /**
  7801. * @fileoverview added by tsickle
  7802. * @suppress {checkTypes} checked by tsc
  7803. */
  7804. /**
  7805. * @license
  7806. * Copyright Google Inc. All Rights Reserved.
  7807. *
  7808. * Use of this source code is governed by an MIT-style license that can be
  7809. * found in the LICENSE file at https://angular.io/license
  7810. */
  7811. /**
  7812. * \@whatItDoes Creates an {\@link AbstractControl} from a user-specified configuration.
  7813. *
  7814. * It is essentially syntactic sugar that shortens the `new FormGroup()`,
  7815. * `new FormControl()`, and `new FormArray()` boilerplate that can build up in larger
  7816. * forms.
  7817. *
  7818. * \@howToUse
  7819. *
  7820. * To use, inject `FormBuilder` into your component class. You can then call its methods
  7821. * directly.
  7822. *
  7823. * {\@example forms/ts/formBuilder/form_builder_example.ts region='Component'}
  7824. *
  7825. * * **npm package**: `\@angular/forms`
  7826. *
  7827. * * **NgModule**: {\@link ReactiveFormsModule}
  7828. *
  7829. * \@stable
  7830. */
  7831. var FormBuilder = /** @class */ (function () {
  7832. function FormBuilder() {
  7833. }
  7834. /**
  7835. * Construct a new {@link FormGroup} with the given map of configuration.
  7836. * Valid keys for the `extra` parameter map are `validator` and `asyncValidator`.
  7837. *
  7838. * See the {@link FormGroup} constructor for more details.
  7839. */
  7840. /**
  7841. * Construct a new {\@link FormGroup} with the given map of configuration.
  7842. * Valid keys for the `extra` parameter map are `validator` and `asyncValidator`.
  7843. *
  7844. * See the {\@link FormGroup} constructor for more details.
  7845. * @param {?} controlsConfig
  7846. * @param {?=} extra
  7847. * @return {?}
  7848. */
  7849. FormBuilder.prototype.group = /**
  7850. * Construct a new {\@link FormGroup} with the given map of configuration.
  7851. * Valid keys for the `extra` parameter map are `validator` and `asyncValidator`.
  7852. *
  7853. * See the {\@link FormGroup} constructor for more details.
  7854. * @param {?} controlsConfig
  7855. * @param {?=} extra
  7856. * @return {?}
  7857. */
  7858. function (controlsConfig, extra) {
  7859. if (extra === void 0) { extra = null; }
  7860. var /** @type {?} */ controls = this._reduceControls(controlsConfig);
  7861. var /** @type {?} */ validator = extra != null ? extra['validator'] : null;
  7862. var /** @type {?} */ asyncValidator = extra != null ? extra['asyncValidator'] : null;
  7863. return new FormGroup(controls, validator, asyncValidator);
  7864. };
  7865. /**
  7866. * Construct a new {@link FormControl} with the given `formState`,`validator`, and
  7867. * `asyncValidator`.
  7868. *
  7869. * `formState` can either be a standalone value for the form control or an object
  7870. * that contains both a value and a disabled status.
  7871. *
  7872. */
  7873. /**
  7874. * Construct a new {\@link FormControl} with the given `formState`,`validator`, and
  7875. * `asyncValidator`.
  7876. *
  7877. * `formState` can either be a standalone value for the form control or an object
  7878. * that contains both a value and a disabled status.
  7879. *
  7880. * @param {?} formState
  7881. * @param {?=} validator
  7882. * @param {?=} asyncValidator
  7883. * @return {?}
  7884. */
  7885. FormBuilder.prototype.control = /**
  7886. * Construct a new {\@link FormControl} with the given `formState`,`validator`, and
  7887. * `asyncValidator`.
  7888. *
  7889. * `formState` can either be a standalone value for the form control or an object
  7890. * that contains both a value and a disabled status.
  7891. *
  7892. * @param {?} formState
  7893. * @param {?=} validator
  7894. * @param {?=} asyncValidator
  7895. * @return {?}
  7896. */
  7897. function (formState, validator, asyncValidator) {
  7898. return new FormControl(formState, validator, asyncValidator);
  7899. };
  7900. /**
  7901. * Construct a {@link FormArray} from the given `controlsConfig` array of
  7902. * configuration, with the given optional `validator` and `asyncValidator`.
  7903. */
  7904. /**
  7905. * Construct a {\@link FormArray} from the given `controlsConfig` array of
  7906. * configuration, with the given optional `validator` and `asyncValidator`.
  7907. * @param {?} controlsConfig
  7908. * @param {?=} validator
  7909. * @param {?=} asyncValidator
  7910. * @return {?}
  7911. */
  7912. FormBuilder.prototype.array = /**
  7913. * Construct a {\@link FormArray} from the given `controlsConfig` array of
  7914. * configuration, with the given optional `validator` and `asyncValidator`.
  7915. * @param {?} controlsConfig
  7916. * @param {?=} validator
  7917. * @param {?=} asyncValidator
  7918. * @return {?}
  7919. */
  7920. function (controlsConfig, validator, asyncValidator) {
  7921. var _this = this;
  7922. var /** @type {?} */ controls = controlsConfig.map(function (c) { return _this._createControl(c); });
  7923. return new FormArray(controls, validator, asyncValidator);
  7924. };
  7925. /** @internal */
  7926. /**
  7927. * \@internal
  7928. * @param {?} controlsConfig
  7929. * @return {?}
  7930. */
  7931. FormBuilder.prototype._reduceControls = /**
  7932. * \@internal
  7933. * @param {?} controlsConfig
  7934. * @return {?}
  7935. */
  7936. function (controlsConfig) {
  7937. var _this = this;
  7938. var /** @type {?} */ controls = {};
  7939. Object.keys(controlsConfig).forEach(function (controlName) {
  7940. controls[controlName] = _this._createControl(controlsConfig[controlName]);
  7941. });
  7942. return controls;
  7943. };
  7944. /** @internal */
  7945. /**
  7946. * \@internal
  7947. * @param {?} controlConfig
  7948. * @return {?}
  7949. */
  7950. FormBuilder.prototype._createControl = /**
  7951. * \@internal
  7952. * @param {?} controlConfig
  7953. * @return {?}
  7954. */
  7955. function (controlConfig) {
  7956. if (controlConfig instanceof FormControl || controlConfig instanceof FormGroup ||
  7957. controlConfig instanceof FormArray) {
  7958. return controlConfig;
  7959. }
  7960. else if (Array.isArray(controlConfig)) {
  7961. var /** @type {?} */ value = controlConfig[0];
  7962. var /** @type {?} */ validator = controlConfig.length > 1 ? controlConfig[1] : null;
  7963. var /** @type {?} */ asyncValidator = controlConfig.length > 2 ? controlConfig[2] : null;
  7964. return this.control(value, validator, asyncValidator);
  7965. }
  7966. else {
  7967. return this.control(controlConfig);
  7968. }
  7969. };
  7970. FormBuilder.decorators = [
  7971. { type: _angular_core.Injectable },
  7972. ];
  7973. /** @nocollapse */
  7974. FormBuilder.ctorParameters = function () { return []; };
  7975. return FormBuilder;
  7976. }());
  7977. /**
  7978. * @fileoverview added by tsickle
  7979. * @suppress {checkTypes} checked by tsc
  7980. */
  7981. /**
  7982. * @license
  7983. * Copyright Google Inc. All Rights Reserved.
  7984. *
  7985. * Use of this source code is governed by an MIT-style license that can be
  7986. * found in the LICENSE file at https://angular.io/license
  7987. */
  7988. /**
  7989. * \@stable
  7990. */
  7991. var VERSION = new _angular_core.Version('5.2.11');
  7992. /**
  7993. * @fileoverview added by tsickle
  7994. * @suppress {checkTypes} checked by tsc
  7995. */
  7996. /**
  7997. * @license
  7998. * Copyright Google Inc. All Rights Reserved.
  7999. *
  8000. * Use of this source code is governed by an MIT-style license that can be
  8001. * found in the LICENSE file at https://angular.io/license
  8002. */
  8003. /**
  8004. * \@whatItDoes Adds `novalidate` attribute to all forms by default.
  8005. *
  8006. * `novalidate` is used to disable browser's native form validation.
  8007. *
  8008. * If you want to use native validation with Angular forms, just add `ngNativeValidate` attribute:
  8009. *
  8010. * ```
  8011. * <form ngNativeValidate></form>
  8012. * ```
  8013. *
  8014. * \@experimental
  8015. */
  8016. var NgNoValidate = /** @class */ (function () {
  8017. function NgNoValidate() {
  8018. }
  8019. NgNoValidate.decorators = [
  8020. { type: _angular_core.Directive, args: [{
  8021. selector: 'form:not([ngNoForm]):not([ngNativeValidate])',
  8022. host: { 'novalidate': '' },
  8023. },] },
  8024. ];
  8025. /** @nocollapse */
  8026. NgNoValidate.ctorParameters = function () { return []; };
  8027. return NgNoValidate;
  8028. }());
  8029. /**
  8030. * @fileoverview added by tsickle
  8031. * @suppress {checkTypes} checked by tsc
  8032. */
  8033. /**
  8034. * @license
  8035. * Copyright Google Inc. All Rights Reserved.
  8036. *
  8037. * Use of this source code is governed by an MIT-style license that can be
  8038. * found in the LICENSE file at https://angular.io/license
  8039. */
  8040. var SHARED_FORM_DIRECTIVES = [
  8041. NgNoValidate,
  8042. NgSelectOption,
  8043. NgSelectMultipleOption,
  8044. DefaultValueAccessor,
  8045. NumberValueAccessor,
  8046. RangeValueAccessor,
  8047. CheckboxControlValueAccessor,
  8048. SelectControlValueAccessor,
  8049. SelectMultipleControlValueAccessor,
  8050. RadioControlValueAccessor,
  8051. NgControlStatus,
  8052. NgControlStatusGroup,
  8053. RequiredValidator,
  8054. MinLengthValidator,
  8055. MaxLengthValidator,
  8056. PatternValidator,
  8057. CheckboxRequiredValidator,
  8058. EmailValidator,
  8059. ];
  8060. var TEMPLATE_DRIVEN_DIRECTIVES = [NgModel, NgModelGroup, NgForm];
  8061. var REACTIVE_DRIVEN_DIRECTIVES = [FormControlDirective, FormGroupDirective, FormControlName, FormGroupName, FormArrayName];
  8062. /**
  8063. * Internal module used for sharing directives between FormsModule and ReactiveFormsModule
  8064. */
  8065. var InternalFormsSharedModule = /** @class */ (function () {
  8066. function InternalFormsSharedModule() {
  8067. }
  8068. InternalFormsSharedModule.decorators = [
  8069. { type: _angular_core.NgModule, args: [{
  8070. declarations: SHARED_FORM_DIRECTIVES,
  8071. exports: SHARED_FORM_DIRECTIVES,
  8072. },] },
  8073. ];
  8074. /** @nocollapse */
  8075. InternalFormsSharedModule.ctorParameters = function () { return []; };
  8076. return InternalFormsSharedModule;
  8077. }());
  8078. /**
  8079. * @fileoverview added by tsickle
  8080. * @suppress {checkTypes} checked by tsc
  8081. */
  8082. /**
  8083. * @license
  8084. * Copyright Google Inc. All Rights Reserved.
  8085. *
  8086. * Use of this source code is governed by an MIT-style license that can be
  8087. * found in the LICENSE file at https://angular.io/license
  8088. */
  8089. /**
  8090. * The ng module for forms.
  8091. * \@stable
  8092. */
  8093. var FormsModule = /** @class */ (function () {
  8094. function FormsModule() {
  8095. }
  8096. FormsModule.decorators = [
  8097. { type: _angular_core.NgModule, args: [{
  8098. declarations: TEMPLATE_DRIVEN_DIRECTIVES,
  8099. providers: [RadioControlRegistry],
  8100. exports: [InternalFormsSharedModule, TEMPLATE_DRIVEN_DIRECTIVES]
  8101. },] },
  8102. ];
  8103. /** @nocollapse */
  8104. FormsModule.ctorParameters = function () { return []; };
  8105. return FormsModule;
  8106. }());
  8107. /**
  8108. * The ng module for reactive forms.
  8109. * \@stable
  8110. */
  8111. var ReactiveFormsModule = /** @class */ (function () {
  8112. function ReactiveFormsModule() {
  8113. }
  8114. ReactiveFormsModule.decorators = [
  8115. { type: _angular_core.NgModule, args: [{
  8116. declarations: [REACTIVE_DRIVEN_DIRECTIVES],
  8117. providers: [FormBuilder, RadioControlRegistry],
  8118. exports: [InternalFormsSharedModule, REACTIVE_DRIVEN_DIRECTIVES]
  8119. },] },
  8120. ];
  8121. /** @nocollapse */
  8122. ReactiveFormsModule.ctorParameters = function () { return []; };
  8123. return ReactiveFormsModule;
  8124. }());
  8125. exports.AbstractControlDirective = AbstractControlDirective;
  8126. exports.AbstractFormGroupDirective = AbstractFormGroupDirective;
  8127. exports.CheckboxControlValueAccessor = CheckboxControlValueAccessor;
  8128. exports.ControlContainer = ControlContainer;
  8129. exports.NG_VALUE_ACCESSOR = NG_VALUE_ACCESSOR;
  8130. exports.COMPOSITION_BUFFER_MODE = COMPOSITION_BUFFER_MODE;
  8131. exports.DefaultValueAccessor = DefaultValueAccessor;
  8132. exports.NgControl = NgControl;
  8133. exports.NgControlStatus = NgControlStatus;
  8134. exports.NgControlStatusGroup = NgControlStatusGroup;
  8135. exports.NgForm = NgForm;
  8136. exports.NgModel = NgModel;
  8137. exports.NgModelGroup = NgModelGroup;
  8138. exports.RadioControlValueAccessor = RadioControlValueAccessor;
  8139. exports.FormControlDirective = FormControlDirective;
  8140. exports.FormControlName = FormControlName;
  8141. exports.FormGroupDirective = FormGroupDirective;
  8142. exports.FormArrayName = FormArrayName;
  8143. exports.FormGroupName = FormGroupName;
  8144. exports.NgSelectOption = NgSelectOption;
  8145. exports.SelectControlValueAccessor = SelectControlValueAccessor;
  8146. exports.SelectMultipleControlValueAccessor = SelectMultipleControlValueAccessor;
  8147. exports.CheckboxRequiredValidator = CheckboxRequiredValidator;
  8148. exports.EmailValidator = EmailValidator;
  8149. exports.MaxLengthValidator = MaxLengthValidator;
  8150. exports.MinLengthValidator = MinLengthValidator;
  8151. exports.PatternValidator = PatternValidator;
  8152. exports.RequiredValidator = RequiredValidator;
  8153. exports.FormBuilder = FormBuilder;
  8154. exports.AbstractControl = AbstractControl;
  8155. exports.FormArray = FormArray;
  8156. exports.FormControl = FormControl;
  8157. exports.FormGroup = FormGroup;
  8158. exports.NG_ASYNC_VALIDATORS = NG_ASYNC_VALIDATORS;
  8159. exports.NG_VALIDATORS = NG_VALIDATORS;
  8160. exports.Validators = Validators;
  8161. exports.VERSION = VERSION;
  8162. exports.FormsModule = FormsModule;
  8163. exports.ReactiveFormsModule = ReactiveFormsModule;
  8164. exports.ɵba = InternalFormsSharedModule;
  8165. exports.ɵz = REACTIVE_DRIVEN_DIRECTIVES;
  8166. exports.ɵx = SHARED_FORM_DIRECTIVES;
  8167. exports.ɵy = TEMPLATE_DRIVEN_DIRECTIVES;
  8168. exports.ɵa = CHECKBOX_VALUE_ACCESSOR;
  8169. exports.ɵb = DEFAULT_VALUE_ACCESSOR;
  8170. exports.ɵc = AbstractControlStatus;
  8171. exports.ɵd = ngControlStatusHost;
  8172. exports.ɵe = formDirectiveProvider;
  8173. exports.ɵf = formControlBinding;
  8174. exports.ɵg = modelGroupProvider;
  8175. exports.ɵbf = NgNoValidate;
  8176. exports.ɵbb = NUMBER_VALUE_ACCESSOR;
  8177. exports.ɵbc = NumberValueAccessor;
  8178. exports.ɵh = RADIO_VALUE_ACCESSOR;
  8179. exports.ɵi = RadioControlRegistry;
  8180. exports.ɵbd = RANGE_VALUE_ACCESSOR;
  8181. exports.ɵbe = RangeValueAccessor;
  8182. exports.ɵj = formControlBinding$1;
  8183. exports.ɵk = controlNameBinding;
  8184. exports.ɵl = formDirectiveProvider$1;
  8185. exports.ɵn = formArrayNameProvider;
  8186. exports.ɵm = formGroupNameProvider;
  8187. exports.ɵo = SELECT_VALUE_ACCESSOR;
  8188. exports.ɵq = NgSelectMultipleOption;
  8189. exports.ɵp = SELECT_MULTIPLE_VALUE_ACCESSOR;
  8190. exports.ɵs = CHECKBOX_REQUIRED_VALIDATOR;
  8191. exports.ɵt = EMAIL_VALIDATOR;
  8192. exports.ɵv = MAX_LENGTH_VALIDATOR;
  8193. exports.ɵu = MIN_LENGTH_VALIDATOR;
  8194. exports.ɵw = PATTERN_VALIDATOR;
  8195. exports.ɵr = REQUIRED_VALIDATOR;
  8196. Object.defineProperty(exports, '__esModule', { value: true });
  8197. })));
  8198. //# sourceMappingURL=forms.umd.js.map