Front end of the Slack clone application.

forms.js 258KB

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