material-components-web.js 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
  7. */
  8. (function webpackUniversalModuleDefinition(root, factory) {
  9. if(typeof exports === 'object' && typeof module === 'object')
  10. module.exports = factory();
  11. else if(typeof define === 'function' && define.amd)
  12. define([], factory);
  13. else if(typeof exports === 'object')
  14. exports["mdc"] = factory();
  15. else
  16. root["mdc"] = factory();
  17. })(this, function() {
  18. return /******/ (function(modules) { // webpackBootstrap
  19. /******/ // The module cache
  20. /******/ var installedModules = {};
  21. /******/
  22. /******/ // The require function
  23. /******/ function __webpack_require__(moduleId) {
  24. /******/
  25. /******/ // Check if module is in cache
  26. /******/ if(installedModules[moduleId]) {
  27. /******/ return installedModules[moduleId].exports;
  28. /******/ }
  29. /******/ // Create a new module (and put it into the cache)
  30. /******/ var module = installedModules[moduleId] = {
  31. /******/ i: moduleId,
  32. /******/ l: false,
  33. /******/ exports: {}
  34. /******/ };
  35. /******/
  36. /******/ // Execute the module function
  37. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  38. /******/
  39. /******/ // Flag the module as loaded
  40. /******/ module.l = true;
  41. /******/
  42. /******/ // Return the exports of the module
  43. /******/ return module.exports;
  44. /******/ }
  45. /******/
  46. /******/
  47. /******/ // expose the modules object (__webpack_modules__)
  48. /******/ __webpack_require__.m = modules;
  49. /******/
  50. /******/ // expose the module cache
  51. /******/ __webpack_require__.c = installedModules;
  52. /******/
  53. /******/ // define getter function for harmony exports
  54. /******/ __webpack_require__.d = function(exports, name, getter) {
  55. /******/ if(!__webpack_require__.o(exports, name)) {
  56. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  57. /******/ }
  58. /******/ };
  59. /******/
  60. /******/ // define __esModule on exports
  61. /******/ __webpack_require__.r = function(exports) {
  62. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  63. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  64. /******/ }
  65. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  66. /******/ };
  67. /******/
  68. /******/ // create a fake namespace object
  69. /******/ // mode & 1: value is a module id, require it
  70. /******/ // mode & 2: merge all properties of value into the ns
  71. /******/ // mode & 4: return value when already ns object
  72. /******/ // mode & 8|1: behave like require
  73. /******/ __webpack_require__.t = function(value, mode) {
  74. /******/ if(mode & 1) value = __webpack_require__(value);
  75. /******/ if(mode & 8) return value;
  76. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  77. /******/ var ns = Object.create(null);
  78. /******/ __webpack_require__.r(ns);
  79. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  80. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  81. /******/ return ns;
  82. /******/ };
  83. /******/
  84. /******/ // getDefaultExport function for compatibility with non-harmony modules
  85. /******/ __webpack_require__.n = function(module) {
  86. /******/ var getter = module && module.__esModule ?
  87. /******/ function getDefault() { return module['default']; } :
  88. /******/ function getModuleExports() { return module; };
  89. /******/ __webpack_require__.d(getter, 'a', getter);
  90. /******/ return getter;
  91. /******/ };
  92. /******/
  93. /******/ // Object.prototype.hasOwnProperty.call
  94. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  95. /******/
  96. /******/ // __webpack_public_path__
  97. /******/ __webpack_require__.p = "";
  98. /******/
  99. /******/
  100. /******/ // Load entry module and return exports
  101. /******/ return __webpack_require__(__webpack_require__.s = "./packages/material-components-web/index.ts");
  102. /******/ })
  103. /************************************************************************/
  104. /******/ ({
  105. /***/ "./packages/material-components-web/index.ts":
  106. /*!***************************************************!*\
  107. !*** ./packages/material-components-web/index.ts ***!
  108. \***************************************************/
  109. /*! no static exports found */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. "use strict";
  112. /**
  113. * @license
  114. * Copyright 2016 Google Inc.
  115. *
  116. * Permission is hereby granted, free of charge, to any person obtaining a copy
  117. * of this software and associated documentation files (the "Software"), to deal
  118. * in the Software without restriction, including without limitation the rights
  119. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  120. * copies of the Software, and to permit persons to whom the Software is
  121. * furnished to do so, subject to the following conditions:
  122. *
  123. * The above copyright notice and this permission notice shall be included in
  124. * all copies or substantial portions of the Software.
  125. *
  126. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  127. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  128. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  129. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  130. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  131. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  132. * THE SOFTWARE.
  133. */
  134. var __importDefault = this && this.__importDefault || function (mod) {
  135. return mod && mod.__esModule ? mod : { "default": mod };
  136. };
  137. var __importStar = this && this.__importStar || function (mod) {
  138. if (mod && mod.__esModule) return mod;
  139. var result = {};
  140. if (mod != null) for (var k in mod) {
  141. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  142. }result["default"] = mod;
  143. return result;
  144. };
  145. Object.defineProperty(exports, "__esModule", { value: true });
  146. var index_1 = __importDefault(__webpack_require__(/*! @material/auto-init/index */ "./packages/mdc-auto-init/index.ts"));
  147. exports.autoInit = index_1.default;
  148. var banner = __importStar(__webpack_require__(/*! @material/banner/index */ "./packages/mdc-banner/index.ts"));
  149. exports.banner = banner;
  150. var base = __importStar(__webpack_require__(/*! @material/base/index */ "./packages/mdc-base/index.ts"));
  151. exports.base = base;
  152. var checkbox = __importStar(__webpack_require__(/*! @material/checkbox/index */ "./packages/mdc-checkbox/index.ts"));
  153. exports.checkbox = checkbox;
  154. var chips = __importStar(__webpack_require__(/*! @material/chips/index */ "./packages/mdc-chips/index.ts"));
  155. exports.chips = chips;
  156. var circularProgress = __importStar(__webpack_require__(/*! @material/circular-progress/index */ "./packages/mdc-circular-progress/index.ts"));
  157. exports.circularProgress = circularProgress;
  158. var dataTable = __importStar(__webpack_require__(/*! @material/data-table/index */ "./packages/mdc-data-table/index.ts"));
  159. exports.dataTable = dataTable;
  160. var dialog = __importStar(__webpack_require__(/*! @material/dialog/index */ "./packages/mdc-dialog/index.ts"));
  161. exports.dialog = dialog;
  162. var dom = __importStar(__webpack_require__(/*! @material/dom/index */ "./packages/mdc-dom/index.ts"));
  163. exports.dom = dom;
  164. var drawer = __importStar(__webpack_require__(/*! @material/drawer/index */ "./packages/mdc-drawer/index.ts"));
  165. exports.drawer = drawer;
  166. var floatingLabel = __importStar(__webpack_require__(/*! @material/floating-label/index */ "./packages/mdc-floating-label/index.ts"));
  167. exports.floatingLabel = floatingLabel;
  168. var formField = __importStar(__webpack_require__(/*! @material/form-field/index */ "./packages/mdc-form-field/index.ts"));
  169. exports.formField = formField;
  170. var iconButton = __importStar(__webpack_require__(/*! @material/icon-button/index */ "./packages/mdc-icon-button/index.ts"));
  171. exports.iconButton = iconButton;
  172. var lineRipple = __importStar(__webpack_require__(/*! @material/line-ripple/index */ "./packages/mdc-line-ripple/index.ts"));
  173. exports.lineRipple = lineRipple;
  174. var linearProgress = __importStar(__webpack_require__(/*! @material/linear-progress/index */ "./packages/mdc-linear-progress/index.ts"));
  175. exports.linearProgress = linearProgress;
  176. var list = __importStar(__webpack_require__(/*! @material/list/index */ "./packages/mdc-list/index.ts"));
  177. exports.list = list;
  178. var menuSurface = __importStar(__webpack_require__(/*! @material/menu-surface/index */ "./packages/mdc-menu-surface/index.ts"));
  179. exports.menuSurface = menuSurface;
  180. var menu = __importStar(__webpack_require__(/*! @material/menu/index */ "./packages/mdc-menu/index.ts"));
  181. exports.menu = menu;
  182. var notchedOutline = __importStar(__webpack_require__(/*! @material/notched-outline/index */ "./packages/mdc-notched-outline/index.ts"));
  183. exports.notchedOutline = notchedOutline;
  184. var radio = __importStar(__webpack_require__(/*! @material/radio/index */ "./packages/mdc-radio/index.ts"));
  185. exports.radio = radio;
  186. var ripple = __importStar(__webpack_require__(/*! @material/ripple/index */ "./packages/mdc-ripple/index.ts"));
  187. exports.ripple = ripple;
  188. var segmentedButton = __importStar(__webpack_require__(/*! @material/segmented-button/index */ "./packages/mdc-segmented-button/index.ts"));
  189. exports.segmentedButton = segmentedButton;
  190. var select = __importStar(__webpack_require__(/*! @material/select/index */ "./packages/mdc-select/index.ts"));
  191. exports.select = select;
  192. var slider = __importStar(__webpack_require__(/*! @material/slider/index */ "./packages/mdc-slider/index.ts"));
  193. exports.slider = slider;
  194. var snackbar = __importStar(__webpack_require__(/*! @material/snackbar/index */ "./packages/mdc-snackbar/index.ts"));
  195. exports.snackbar = snackbar;
  196. var switchControl = __importStar(__webpack_require__(/*! @material/switch/index */ "./packages/mdc-switch/index.ts"));
  197. exports.switchControl = switchControl;
  198. var tabBar = __importStar(__webpack_require__(/*! @material/tab-bar/index */ "./packages/mdc-tab-bar/index.ts"));
  199. exports.tabBar = tabBar;
  200. var tabIndicator = __importStar(__webpack_require__(/*! @material/tab-indicator/index */ "./packages/mdc-tab-indicator/index.ts"));
  201. exports.tabIndicator = tabIndicator;
  202. var tabScroller = __importStar(__webpack_require__(/*! @material/tab-scroller/index */ "./packages/mdc-tab-scroller/index.ts"));
  203. exports.tabScroller = tabScroller;
  204. var tab = __importStar(__webpack_require__(/*! @material/tab/index */ "./packages/mdc-tab/index.ts"));
  205. exports.tab = tab;
  206. var textField = __importStar(__webpack_require__(/*! @material/textfield/index */ "./packages/mdc-textfield/index.ts"));
  207. exports.textField = textField;
  208. var tooltip = __importStar(__webpack_require__(/*! @material/tooltip/index */ "./packages/mdc-tooltip/index.ts"));
  209. exports.tooltip = tooltip;
  210. var topAppBar = __importStar(__webpack_require__(/*! @material/top-app-bar/index */ "./packages/mdc-top-app-bar/index.ts"));
  211. exports.topAppBar = topAppBar;
  212. // Register all components
  213. index_1.default.register('MDCBanner', banner.MDCBanner);
  214. index_1.default.register('MDCCheckbox', checkbox.MDCCheckbox);
  215. index_1.default.register('MDCChip', chips.MDCChip);
  216. index_1.default.register('MDCChipSet', chips.MDCChipSet);
  217. index_1.default.register('MDCCircularProgress', circularProgress.MDCCircularProgress);
  218. index_1.default.register('MDCDataTable', dataTable.MDCDataTable);
  219. index_1.default.register('MDCDialog', dialog.MDCDialog);
  220. index_1.default.register('MDCDrawer', drawer.MDCDrawer);
  221. index_1.default.register('MDCFloatingLabel', floatingLabel.MDCFloatingLabel);
  222. index_1.default.register('MDCFormField', formField.MDCFormField);
  223. index_1.default.register('MDCIconButtonToggle', iconButton.MDCIconButtonToggle);
  224. index_1.default.register('MDCLineRipple', lineRipple.MDCLineRipple);
  225. index_1.default.register('MDCLinearProgress', linearProgress.MDCLinearProgress);
  226. index_1.default.register('MDCList', list.MDCList);
  227. index_1.default.register('MDCMenu', menu.MDCMenu);
  228. index_1.default.register('MDCMenuSurface', menuSurface.MDCMenuSurface);
  229. index_1.default.register('MDCNotchedOutline', notchedOutline.MDCNotchedOutline);
  230. index_1.default.register('MDCRadio', radio.MDCRadio);
  231. index_1.default.register('MDCRipple', ripple.MDCRipple);
  232. index_1.default.register('MDCSegmentedButton', segmentedButton.MDCSegmentedButton);
  233. index_1.default.register('MDCSelect', select.MDCSelect);
  234. index_1.default.register('MDCSlider', slider.MDCSlider);
  235. index_1.default.register('MDCSnackbar', snackbar.MDCSnackbar);
  236. index_1.default.register('MDCSwitch', switchControl.MDCSwitch);
  237. index_1.default.register('MDCTabBar', tabBar.MDCTabBar);
  238. index_1.default.register('MDCTextField', textField.MDCTextField);
  239. index_1.default.register('MDCTooltip', tooltip.MDCTooltip);
  240. index_1.default.register('MDCTopAppBar', topAppBar.MDCTopAppBar);
  241. /***/ }),
  242. /***/ "./packages/mdc-animation/animationframe.ts":
  243. /*!**************************************************!*\
  244. !*** ./packages/mdc-animation/animationframe.ts ***!
  245. \**************************************************/
  246. /*! no static exports found */
  247. /***/ (function(module, exports, __webpack_require__) {
  248. "use strict";
  249. /**
  250. * @license
  251. * Copyright 2020 Google Inc.
  252. *
  253. * Permission is hereby granted, free of charge, to any person obtaining a copy
  254. * of this software and associated documentation files (the "Software"), to deal
  255. * in the Software without restriction, including without limitation the rights
  256. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  257. * copies of the Software, and to permit persons to whom the Software is
  258. * furnished to do so, subject to the following conditions:
  259. *
  260. * The above copyright notice and this permission notice shall be included in
  261. * all copies or substantial portions of the Software.
  262. *
  263. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  264. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  265. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  266. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  267. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  268. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  269. * THE SOFTWARE.
  270. */
  271. Object.defineProperty(exports, "__esModule", { value: true });
  272. /**
  273. * AnimationFrame provides a user-friendly abstraction around requesting
  274. * and canceling animation frames.
  275. */
  276. var AnimationFrame = /** @class */function () {
  277. function AnimationFrame() {
  278. this.rafIDs = new Map();
  279. }
  280. /**
  281. * Requests an animation frame. Cancels any existing frame with the same key.
  282. * @param {string} key The key for this callback.
  283. * @param {FrameRequestCallback} callback The callback to be executed.
  284. */
  285. AnimationFrame.prototype.request = function (key, callback) {
  286. var _this = this;
  287. this.cancel(key);
  288. var frameID = requestAnimationFrame(function (frame) {
  289. _this.rafIDs.delete(key);
  290. // Callback must come *after* the key is deleted so that nested calls to
  291. // request with the same key are not deleted.
  292. callback(frame);
  293. });
  294. this.rafIDs.set(key, frameID);
  295. };
  296. /**
  297. * Cancels a queued callback with the given key.
  298. * @param {string} key The key for this callback.
  299. */
  300. AnimationFrame.prototype.cancel = function (key) {
  301. var rafID = this.rafIDs.get(key);
  302. if (rafID) {
  303. cancelAnimationFrame(rafID);
  304. this.rafIDs.delete(key);
  305. }
  306. };
  307. /**
  308. * Cancels all queued callback.
  309. */
  310. AnimationFrame.prototype.cancelAll = function () {
  311. var _this = this;
  312. // Need to use forEach because it's the only iteration method supported
  313. // by IE11. Suppress the underscore because we don't need it.
  314. // tslint:disable-next-line:enforce-name-casing
  315. this.rafIDs.forEach(function (_, key) {
  316. _this.cancel(key);
  317. });
  318. };
  319. /**
  320. * Returns the queue of unexecuted callback keys.
  321. */
  322. AnimationFrame.prototype.getQueue = function () {
  323. var queue = [];
  324. // Need to use forEach because it's the only iteration method supported
  325. // by IE11. Suppress the underscore because we don't need it.
  326. // tslint:disable-next-line:enforce-name-casing
  327. this.rafIDs.forEach(function (_, key) {
  328. queue.push(key);
  329. });
  330. return queue;
  331. };
  332. return AnimationFrame;
  333. }();
  334. exports.AnimationFrame = AnimationFrame;
  335. /***/ }),
  336. /***/ "./packages/mdc-animation/util.ts":
  337. /*!****************************************!*\
  338. !*** ./packages/mdc-animation/util.ts ***!
  339. \****************************************/
  340. /*! no static exports found */
  341. /***/ (function(module, exports, __webpack_require__) {
  342. "use strict";
  343. /**
  344. * @license
  345. * Copyright 2016 Google Inc.
  346. *
  347. * Permission is hereby granted, free of charge, to any person obtaining a copy
  348. * of this software and associated documentation files (the "Software"), to deal
  349. * in the Software without restriction, including without limitation the rights
  350. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  351. * copies of the Software, and to permit persons to whom the Software is
  352. * furnished to do so, subject to the following conditions:
  353. *
  354. * The above copyright notice and this permission notice shall be included in
  355. * all copies or substantial portions of the Software.
  356. *
  357. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  358. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  359. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  360. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  361. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  362. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  363. * THE SOFTWARE.
  364. */
  365. Object.defineProperty(exports, "__esModule", { value: true });
  366. var cssPropertyNameMap = {
  367. animation: {
  368. prefixed: '-webkit-animation',
  369. standard: 'animation'
  370. },
  371. transform: {
  372. prefixed: '-webkit-transform',
  373. standard: 'transform'
  374. },
  375. transition: {
  376. prefixed: '-webkit-transition',
  377. standard: 'transition'
  378. }
  379. };
  380. var jsEventTypeMap = {
  381. animationend: {
  382. cssProperty: 'animation',
  383. prefixed: 'webkitAnimationEnd',
  384. standard: 'animationend'
  385. },
  386. animationiteration: {
  387. cssProperty: 'animation',
  388. prefixed: 'webkitAnimationIteration',
  389. standard: 'animationiteration'
  390. },
  391. animationstart: {
  392. cssProperty: 'animation',
  393. prefixed: 'webkitAnimationStart',
  394. standard: 'animationstart'
  395. },
  396. transitionend: {
  397. cssProperty: 'transition',
  398. prefixed: 'webkitTransitionEnd',
  399. standard: 'transitionend'
  400. }
  401. };
  402. function isWindow(windowObj) {
  403. return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function';
  404. }
  405. function getCorrectPropertyName(windowObj, cssProperty) {
  406. if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) {
  407. var el = windowObj.document.createElement('div');
  408. var _a = cssPropertyNameMap[cssProperty],
  409. standard = _a.standard,
  410. prefixed = _a.prefixed;
  411. var isStandard = standard in el.style;
  412. return isStandard ? standard : prefixed;
  413. }
  414. return cssProperty;
  415. }
  416. exports.getCorrectPropertyName = getCorrectPropertyName;
  417. function getCorrectEventName(windowObj, eventType) {
  418. if (isWindow(windowObj) && eventType in jsEventTypeMap) {
  419. var el = windowObj.document.createElement('div');
  420. var _a = jsEventTypeMap[eventType],
  421. standard = _a.standard,
  422. prefixed = _a.prefixed,
  423. cssProperty = _a.cssProperty;
  424. var isStandard = cssProperty in el.style;
  425. return isStandard ? standard : prefixed;
  426. }
  427. return eventType;
  428. }
  429. exports.getCorrectEventName = getCorrectEventName;
  430. /***/ }),
  431. /***/ "./packages/mdc-auto-init/constants.ts":
  432. /*!*********************************************!*\
  433. !*** ./packages/mdc-auto-init/constants.ts ***!
  434. \*********************************************/
  435. /*! no static exports found */
  436. /***/ (function(module, exports, __webpack_require__) {
  437. "use strict";
  438. /**
  439. * @license
  440. * Copyright 2019 Google Inc.
  441. *
  442. * Permission is hereby granted, free of charge, to any person obtaining a copy
  443. * of this software and associated documentation files (the "Software"), to deal
  444. * in the Software without restriction, including without limitation the rights
  445. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  446. * copies of the Software, and to permit persons to whom the Software is
  447. * furnished to do so, subject to the following conditions:
  448. *
  449. * The above copyright notice and this permission notice shall be included in
  450. * all copies or substantial portions of the Software.
  451. *
  452. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  453. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  454. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  455. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  456. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  457. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  458. * THE SOFTWARE.
  459. */
  460. Object.defineProperty(exports, "__esModule", { value: true });
  461. exports.strings = {
  462. AUTO_INIT_ATTR: 'data-mdc-auto-init',
  463. AUTO_INIT_STATE_ATTR: 'data-mdc-auto-init-state',
  464. INITIALIZED_STATE: 'initialized'
  465. };
  466. /***/ }),
  467. /***/ "./packages/mdc-auto-init/index.ts":
  468. /*!*****************************************!*\
  469. !*** ./packages/mdc-auto-init/index.ts ***!
  470. \*****************************************/
  471. /*! no static exports found */
  472. /***/ (function(module, exports, __webpack_require__) {
  473. "use strict";
  474. /**
  475. * @license
  476. * Copyright 2016 Google Inc.
  477. *
  478. * Permission is hereby granted, free of charge, to any person obtaining a copy
  479. * of this software and associated documentation files (the "Software"), to deal
  480. * in the Software without restriction, including without limitation the rights
  481. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  482. * copies of the Software, and to permit persons to whom the Software is
  483. * furnished to do so, subject to the following conditions:
  484. *
  485. * The above copyright notice and this permission notice shall be included in
  486. * all copies or substantial portions of the Software.
  487. *
  488. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  489. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  490. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  491. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  492. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  493. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  494. * THE SOFTWARE.
  495. */
  496. var __values = this && this.__values || function (o) {
  497. var s = typeof Symbol === "function" && Symbol.iterator,
  498. m = s && o[s],
  499. i = 0;
  500. if (m) return m.call(o);
  501. if (o && typeof o.length === "number") return {
  502. next: function next() {
  503. if (o && i >= o.length) o = void 0;
  504. return { value: o && o[i++], done: !o };
  505. }
  506. };
  507. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  508. };
  509. Object.defineProperty(exports, "__esModule", { value: true });
  510. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-auto-init/constants.ts");
  511. var AUTO_INIT_ATTR = constants_1.strings.AUTO_INIT_ATTR,
  512. AUTO_INIT_STATE_ATTR = constants_1.strings.AUTO_INIT_STATE_ATTR,
  513. INITIALIZED_STATE = constants_1.strings.INITIALIZED_STATE;
  514. var registry = {};
  515. var CONSOLE_WARN = console.warn.bind(console); // tslint:disable-line:no-console
  516. function emit(evtType, evtData, shouldBubble) {
  517. if (shouldBubble === void 0) {
  518. shouldBubble = false;
  519. }
  520. var evt;
  521. if (typeof CustomEvent === 'function') {
  522. evt = new CustomEvent(evtType, {
  523. bubbles: shouldBubble,
  524. detail: evtData
  525. });
  526. } else {
  527. evt = document.createEvent('CustomEvent');
  528. evt.initCustomEvent(evtType, shouldBubble, false, evtData);
  529. }
  530. document.dispatchEvent(evt);
  531. }
  532. /* istanbul ignore next: optional argument is not a branch statement */
  533. /**
  534. * Auto-initializes all MDC components on a page.
  535. */
  536. function mdcAutoInit(root) {
  537. var e_1, _a;
  538. if (root === void 0) {
  539. root = document;
  540. }
  541. var components = [];
  542. var nodes = [].slice.call(root.querySelectorAll("[" + AUTO_INIT_ATTR + "]"));
  543. nodes = nodes.filter(function (node) {
  544. return node.getAttribute(AUTO_INIT_STATE_ATTR) !== INITIALIZED_STATE;
  545. });
  546. try {
  547. for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
  548. var node = nodes_1_1.value;
  549. var ctorName = node.getAttribute(AUTO_INIT_ATTR);
  550. if (!ctorName) {
  551. throw new Error('(mdc-auto-init) Constructor name must be given.');
  552. }
  553. var Constructor = registry[ctorName]; // tslint:disable-line:variable-name
  554. if (typeof Constructor !== 'function') {
  555. throw new Error("(mdc-auto-init) Could not find constructor in registry for " + ctorName);
  556. }
  557. // TODO: Should we make an eslint rule for an attachTo() static method?
  558. // See https://github.com/Microsoft/TypeScript/issues/14600 for discussion of static interface support in TS
  559. var component = Constructor.attachTo(node);
  560. Object.defineProperty(node, ctorName, {
  561. configurable: true,
  562. enumerable: false,
  563. value: component,
  564. writable: false
  565. });
  566. components.push(component);
  567. node.setAttribute(AUTO_INIT_STATE_ATTR, INITIALIZED_STATE);
  568. }
  569. } catch (e_1_1) {
  570. e_1 = { error: e_1_1 };
  571. } finally {
  572. try {
  573. if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
  574. } finally {
  575. if (e_1) throw e_1.error;
  576. }
  577. }
  578. emit('MDCAutoInit:End', {});
  579. return components;
  580. }
  581. exports.mdcAutoInit = mdcAutoInit;
  582. // Constructor is PascalCased because it is a direct reference to a class, rather than an instance of a class.
  583. // tslint:disable-next-line:variable-name
  584. mdcAutoInit.register = function (componentName, Constructor, warn) {
  585. if (warn === void 0) {
  586. warn = CONSOLE_WARN;
  587. }
  588. if (typeof Constructor !== 'function') {
  589. throw new Error("(mdc-auto-init) Invalid Constructor value: " + Constructor + ". Expected function.");
  590. }
  591. var registryValue = registry[componentName];
  592. if (registryValue) {
  593. warn("(mdc-auto-init) Overriding registration for " + componentName + " with " + Constructor + ". Was: " + registryValue);
  594. }
  595. registry[componentName] = Constructor;
  596. };
  597. mdcAutoInit.deregister = function (componentName) {
  598. delete registry[componentName];
  599. };
  600. /** @nocollapse */
  601. mdcAutoInit.deregisterAll = function () {
  602. var keys = Object.keys(registry);
  603. keys.forEach(this.deregister, this);
  604. };
  605. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  606. exports.default = mdcAutoInit;
  607. /***/ }),
  608. /***/ "./packages/mdc-banner/component.ts":
  609. /*!******************************************!*\
  610. !*** ./packages/mdc-banner/component.ts ***!
  611. \******************************************/
  612. /*! no static exports found */
  613. /***/ (function(module, exports, __webpack_require__) {
  614. "use strict";
  615. /**
  616. * @license
  617. * Copyright 2020 Google Inc.
  618. *
  619. * Permission is hereby granted, free of charge, to any person obtaining a copy
  620. * of this software and associated documentation files (the "Software"), to deal
  621. * in the Software without restriction, including without limitation the rights
  622. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  623. * copies of the Software, and to permit persons to whom the Software is
  624. * furnished to do so, subject to the following conditions:
  625. *
  626. * The above copyright notice and this permission notice shall be included in
  627. * all copies or substantial portions of the Software.
  628. *
  629. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  630. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  631. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  632. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  633. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  634. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  635. * THE SOFTWARE.
  636. */
  637. var __extends = this && this.__extends || function () {
  638. var _extendStatics = function extendStatics(d, b) {
  639. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  640. d.__proto__ = b;
  641. } || function (d, b) {
  642. for (var p in b) {
  643. if (b.hasOwnProperty(p)) d[p] = b[p];
  644. }
  645. };
  646. return _extendStatics(d, b);
  647. };
  648. return function (d, b) {
  649. _extendStatics(d, b);
  650. function __() {
  651. this.constructor = d;
  652. }
  653. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  654. };
  655. }();
  656. Object.defineProperty(exports, "__esModule", { value: true });
  657. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  658. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  659. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-banner/constants.ts");
  660. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-banner/foundation.ts");
  661. /** Vanilla JS implementation of banner component. */
  662. var MDCBanner = /** @class */function (_super) {
  663. __extends(MDCBanner, _super);
  664. function MDCBanner() {
  665. return _super !== null && _super.apply(this, arguments) || this;
  666. }
  667. MDCBanner.attachTo = function (root) {
  668. return new MDCBanner(root);
  669. };
  670. MDCBanner.prototype.initialize = function () {
  671. var _this = this;
  672. this.contentEl = this.root.querySelector(constants_1.selectors.CONTENT);
  673. this.textEl = this.root.querySelector(constants_1.selectors.TEXT);
  674. this.primaryActionEl = this.root.querySelector(constants_1.selectors.PRIMARY_ACTION);
  675. this.secondaryActionEl = this.root.querySelector(constants_1.selectors.SECONDARY_ACTION);
  676. this.handleContentClick = function (evt) {
  677. var target = evt.target;
  678. if (ponyfill_1.closest(target, constants_1.selectors.PRIMARY_ACTION)) {
  679. _this.foundation.handlePrimaryActionClick();
  680. } else if (ponyfill_1.closest(target, constants_1.selectors.SECONDARY_ACTION)) {
  681. _this.foundation.handleSecondaryActionClick();
  682. }
  683. };
  684. };
  685. MDCBanner.prototype.initialSyncWithDOM = function () {
  686. this.registerContentClickHandler(this.handleContentClick);
  687. };
  688. MDCBanner.prototype.destroy = function () {
  689. _super.prototype.destroy.call(this);
  690. this.deregisterContentClickHandler(this.handleContentClick);
  691. };
  692. MDCBanner.prototype.layout = function () {
  693. this.foundation.layout();
  694. };
  695. /**
  696. * Opens the banner and fires events.OPENING to indicate the beginning of its
  697. * opening animation and then events.OPENED once the animation finishes.
  698. */
  699. MDCBanner.prototype.open = function () {
  700. this.foundation.open();
  701. };
  702. /**
  703. * Closes the banner and fires events.CLOSING to indicate the beginning of its
  704. * closing animation and then events.CLOSED once the animation finishes.
  705. * @param reason Why the banner was closed. Value will be passed to
  706. * events.CLOSING and events.CLOSED via the `event.detail.reason`
  707. * property. Standard values are CloseReason.PRIMARY and
  708. * CloseReason.SECONDARY, but CloseReason.UNSPECIFIED is provided for
  709. * custom handling of programmatic closing of the banner.
  710. */
  711. MDCBanner.prototype.close = function (reason) {
  712. this.foundation.close(reason);
  713. };
  714. MDCBanner.prototype.getDefaultFoundation = function () {
  715. var _this = this;
  716. // DO NOT INLINE this variable. For backward compatibility, foundations take
  717. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  718. // methods, we need a separate, strongly typed adapter variable.
  719. var adapter = {
  720. addClass: function addClass(className) {
  721. _this.root.classList.add(className);
  722. },
  723. getContentHeight: function getContentHeight() {
  724. return _this.contentEl.offsetHeight;
  725. },
  726. notifyClosed: function notifyClosed(reason) {
  727. _this.emit(constants_1.events.CLOSED, { reason: reason });
  728. },
  729. notifyClosing: function notifyClosing(reason) {
  730. _this.emit(constants_1.events.CLOSING, { reason: reason });
  731. },
  732. notifyOpened: function notifyOpened() {
  733. _this.emit(constants_1.events.OPENED, {});
  734. },
  735. notifyOpening: function notifyOpening() {
  736. _this.emit(constants_1.events.OPENING, {});
  737. },
  738. removeClass: function removeClass(className) {
  739. _this.root.classList.remove(className);
  740. },
  741. setStyleProperty: function setStyleProperty(propertyName, value) {
  742. _this.root.style.setProperty(propertyName, value);
  743. }
  744. };
  745. return new foundation_1.MDCBannerFoundation(adapter);
  746. };
  747. Object.defineProperty(MDCBanner.prototype, "isOpen", {
  748. get: function get() {
  749. return this.foundation.isOpen();
  750. },
  751. enumerable: true,
  752. configurable: true
  753. });
  754. MDCBanner.prototype.getText = function () {
  755. return this.textEl.textContent || '';
  756. };
  757. MDCBanner.prototype.setText = function (text) {
  758. this.textEl.textContent = text;
  759. };
  760. MDCBanner.prototype.getPrimaryActionText = function () {
  761. return this.primaryActionEl.textContent || '';
  762. };
  763. MDCBanner.prototype.setPrimaryActionText = function (actionButtonText) {
  764. this.primaryActionEl.textContent = actionButtonText;
  765. };
  766. /** Returns null if the banner has no secondary action. */
  767. MDCBanner.prototype.getSecondaryActionText = function () {
  768. return this.secondaryActionEl ? this.secondaryActionEl.textContent || '' : null;
  769. };
  770. MDCBanner.prototype.setSecondaryActionText = function (actionButtonText) {
  771. if (this.secondaryActionEl) {
  772. this.secondaryActionEl.textContent = actionButtonText;
  773. }
  774. };
  775. MDCBanner.prototype.registerContentClickHandler = function (handler) {
  776. this.contentEl.addEventListener('click', handler);
  777. };
  778. MDCBanner.prototype.deregisterContentClickHandler = function (handler) {
  779. this.contentEl.removeEventListener('click', handler);
  780. };
  781. return MDCBanner;
  782. }(component_1.MDCComponent);
  783. exports.MDCBanner = MDCBanner;
  784. /***/ }),
  785. /***/ "./packages/mdc-banner/constants.ts":
  786. /*!******************************************!*\
  787. !*** ./packages/mdc-banner/constants.ts ***!
  788. \******************************************/
  789. /*! no static exports found */
  790. /***/ (function(module, exports, __webpack_require__) {
  791. "use strict";
  792. /**
  793. * @license
  794. * Copyright 2020 Google Inc.
  795. *
  796. * Permission is hereby granted, free of charge, to any person obtaining a copy
  797. * of this software and associated documentation files (the "Software"), to deal
  798. * in the Software without restriction, including without limitation the rights
  799. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  800. * copies of the Software, and to permit persons to whom the Software is
  801. * furnished to do so, subject to the following conditions:
  802. *
  803. * The above copyright notice and this permission notice shall be included in
  804. * all copies or substantial portions of the Software.
  805. *
  806. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  807. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  808. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  809. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  810. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  811. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  812. * THE SOFTWARE.
  813. */
  814. Object.defineProperty(exports, "__esModule", { value: true });
  815. /** Banner element classes. */
  816. exports.cssClasses = {
  817. CLOSING: 'mdc-banner--closing',
  818. OPEN: 'mdc-banner--open',
  819. OPENING: 'mdc-banner--opening'
  820. };
  821. /** Banner numbers. */
  822. exports.numbers = {
  823. BANNER_ANIMATION_CLOSE_TIME_MS: 250,
  824. BANNER_ANIMATION_OPEN_TIME_MS: 300
  825. };
  826. /** Banner events. */
  827. exports.events = {
  828. CLOSED: 'MDCBanner:closed',
  829. CLOSING: 'MDCBanner:closing',
  830. OPENED: 'MDCBanner:opened',
  831. OPENING: 'MDCBanner:opening'
  832. };
  833. /** Banner selectors. */
  834. exports.selectors = {
  835. CONTENT: '.mdc-banner__content',
  836. PRIMARY_ACTION: '.mdc-banner__primary-action',
  837. SECONDARY_ACTION: '.mdc-banner__secondary-action',
  838. TEXT: '.mdc-banner__text'
  839. };
  840. /** Reason as to why the banner was closed. */
  841. var CloseReason;
  842. (function (CloseReason) {
  843. // Indicates the banner was closed via primary action button.
  844. CloseReason[CloseReason["PRIMARY"] = 0] = "PRIMARY";
  845. // Indicates the banner was closed via secondary action button.
  846. CloseReason[CloseReason["SECONDARY"] = 1] = "SECONDARY";
  847. // Will never be used by the component. Provided for custom handling of
  848. // programmatic closing of the banner.
  849. CloseReason[CloseReason["UNSPECIFIED"] = 2] = "UNSPECIFIED";
  850. })(CloseReason = exports.CloseReason || (exports.CloseReason = {}));
  851. /***/ }),
  852. /***/ "./packages/mdc-banner/foundation.ts":
  853. /*!*******************************************!*\
  854. !*** ./packages/mdc-banner/foundation.ts ***!
  855. \*******************************************/
  856. /*! no static exports found */
  857. /***/ (function(module, exports, __webpack_require__) {
  858. "use strict";
  859. /**
  860. * @license
  861. * Copyright 2020 Google Inc.
  862. *
  863. * Permission is hereby granted, free of charge, to any person obtaining a copy
  864. * of this software and associated documentation files (the "Software"), to deal
  865. * in the Software without restriction, including without limitation the rights
  866. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  867. * copies of the Software, and to permit persons to whom the Software is
  868. * furnished to do so, subject to the following conditions:
  869. *
  870. * The above copyright notice and this permission notice shall be included in
  871. * all copies or substantial portions of the Software.
  872. *
  873. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  874. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  875. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  876. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  877. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  878. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  879. * THE SOFTWARE.
  880. */
  881. var __extends = this && this.__extends || function () {
  882. var _extendStatics = function extendStatics(d, b) {
  883. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  884. d.__proto__ = b;
  885. } || function (d, b) {
  886. for (var p in b) {
  887. if (b.hasOwnProperty(p)) d[p] = b[p];
  888. }
  889. };
  890. return _extendStatics(d, b);
  891. };
  892. return function (d, b) {
  893. _extendStatics(d, b);
  894. function __() {
  895. this.constructor = d;
  896. }
  897. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  898. };
  899. }();
  900. var __assign = this && this.__assign || function () {
  901. __assign = Object.assign || function (t) {
  902. for (var s, i = 1, n = arguments.length; i < n; i++) {
  903. s = arguments[i];
  904. for (var p in s) {
  905. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  906. }
  907. }
  908. return t;
  909. };
  910. return __assign.apply(this, arguments);
  911. };
  912. Object.defineProperty(exports, "__esModule", { value: true });
  913. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  914. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-banner/constants.ts");
  915. var OPENING = constants_1.cssClasses.OPENING,
  916. OPEN = constants_1.cssClasses.OPEN,
  917. CLOSING = constants_1.cssClasses.CLOSING;
  918. /**
  919. * Foundation class for banner. Responsibilities include opening and closing the
  920. * banner.
  921. */
  922. var MDCBannerFoundation = /** @class */function (_super) {
  923. __extends(MDCBannerFoundation, _super);
  924. function MDCBannerFoundation(adapter) {
  925. var _this = _super.call(this, __assign(__assign({}, MDCBannerFoundation.defaultAdapter), adapter)) || this;
  926. _this.isOpened = false;
  927. // Request id for open animation, used to cancel the refresh callback
  928. // request on close() and destroy().
  929. _this.animationFrame = 0;
  930. // Timer id for close and open animation, used to cancel the timer on
  931. // close() and destroy().
  932. _this.animationTimer = 0;
  933. return _this;
  934. }
  935. Object.defineProperty(MDCBannerFoundation, "defaultAdapter", {
  936. get: function get() {
  937. return {
  938. addClass: function addClass() {
  939. return undefined;
  940. },
  941. getContentHeight: function getContentHeight() {
  942. return 0;
  943. },
  944. notifyClosed: function notifyClosed() {
  945. return undefined;
  946. },
  947. notifyClosing: function notifyClosing() {
  948. return undefined;
  949. },
  950. notifyOpened: function notifyOpened() {
  951. return undefined;
  952. },
  953. notifyOpening: function notifyOpening() {
  954. return undefined;
  955. },
  956. removeClass: function removeClass() {
  957. return undefined;
  958. },
  959. setStyleProperty: function setStyleProperty() {
  960. return undefined;
  961. }
  962. };
  963. },
  964. enumerable: true,
  965. configurable: true
  966. });
  967. MDCBannerFoundation.prototype.destroy = function () {
  968. cancelAnimationFrame(this.animationFrame);
  969. this.animationFrame = 0;
  970. clearTimeout(this.animationTimer);
  971. this.animationTimer = 0;
  972. };
  973. MDCBannerFoundation.prototype.open = function () {
  974. var _this = this;
  975. this.isOpened = true;
  976. this.adapter.notifyOpening();
  977. this.adapter.removeClass(CLOSING);
  978. this.adapter.addClass(OPENING);
  979. var contentHeight = this.adapter.getContentHeight();
  980. this.animationFrame = requestAnimationFrame(function () {
  981. _this.adapter.addClass(OPEN);
  982. _this.adapter.setStyleProperty('height', contentHeight + "px");
  983. _this.animationTimer = setTimeout(function () {
  984. _this.handleAnimationTimerEnd();
  985. _this.adapter.notifyOpened();
  986. }, constants_1.numbers.BANNER_ANIMATION_OPEN_TIME_MS);
  987. });
  988. };
  989. /**
  990. * @param reason Why the banner was closed. Value will be passed to
  991. * events.CLOSING and events.CLOSED via the `event.detail.reason`
  992. * property. Standard values are CloseReason.PRIMARY and
  993. * CloseReason.SECONDARY, but CloseReason.UNSPECIFIED is provided for
  994. * custom handling of programmatic closing of the banner.
  995. */
  996. MDCBannerFoundation.prototype.close = function (reason) {
  997. var _this = this;
  998. if (!this.isOpened) {
  999. // Avoid redundant close calls (and events), e.g. repeated interactions as
  1000. // the banner is animating closed
  1001. return;
  1002. }
  1003. cancelAnimationFrame(this.animationFrame);
  1004. this.animationFrame = 0;
  1005. this.isOpened = false;
  1006. this.adapter.notifyClosing(reason);
  1007. this.adapter.addClass(CLOSING);
  1008. this.adapter.setStyleProperty('height', '0');
  1009. this.adapter.removeClass(OPEN);
  1010. this.adapter.removeClass(OPENING);
  1011. clearTimeout(this.animationTimer);
  1012. this.animationTimer = setTimeout(function () {
  1013. _this.handleAnimationTimerEnd();
  1014. _this.adapter.notifyClosed(reason);
  1015. }, constants_1.numbers.BANNER_ANIMATION_CLOSE_TIME_MS);
  1016. };
  1017. MDCBannerFoundation.prototype.isOpen = function () {
  1018. return this.isOpened;
  1019. };
  1020. MDCBannerFoundation.prototype.handlePrimaryActionClick = function () {
  1021. this.close(constants_1.CloseReason.PRIMARY);
  1022. };
  1023. MDCBannerFoundation.prototype.handleSecondaryActionClick = function () {
  1024. this.close(constants_1.CloseReason.SECONDARY);
  1025. };
  1026. MDCBannerFoundation.prototype.layout = function () {
  1027. var contentHeight = this.adapter.getContentHeight();
  1028. this.adapter.setStyleProperty('height', contentHeight + "px");
  1029. };
  1030. MDCBannerFoundation.prototype.handleAnimationTimerEnd = function () {
  1031. this.animationTimer = 0;
  1032. this.adapter.removeClass(OPENING);
  1033. this.adapter.removeClass(CLOSING);
  1034. };
  1035. return MDCBannerFoundation;
  1036. }(foundation_1.MDCFoundation);
  1037. exports.MDCBannerFoundation = MDCBannerFoundation;
  1038. /***/ }),
  1039. /***/ "./packages/mdc-banner/index.ts":
  1040. /*!**************************************!*\
  1041. !*** ./packages/mdc-banner/index.ts ***!
  1042. \**************************************/
  1043. /*! no static exports found */
  1044. /***/ (function(module, exports, __webpack_require__) {
  1045. "use strict";
  1046. /**
  1047. * @license
  1048. * Copyright 2020 Google Inc.
  1049. *
  1050. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1051. * of this software and associated documentation files (the "Software"), to deal
  1052. * in the Software without restriction, including without limitation the rights
  1053. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1054. * copies of the Software, and to permit persons to whom the Software is
  1055. * furnished to do so, subject to the following conditions:
  1056. *
  1057. * The above copyright notice and this permission notice shall be included in
  1058. * all copies or substantial portions of the Software.
  1059. *
  1060. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1061. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1062. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1063. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1064. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1065. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1066. * THE SOFTWARE.
  1067. */
  1068. function __export(m) {
  1069. for (var p in m) {
  1070. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1071. }
  1072. }
  1073. Object.defineProperty(exports, "__esModule", { value: true });
  1074. __export(__webpack_require__(/*! ./component */ "./packages/mdc-banner/component.ts"));
  1075. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-banner/constants.ts"));
  1076. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-banner/foundation.ts"));
  1077. /***/ }),
  1078. /***/ "./packages/mdc-base/component.ts":
  1079. /*!****************************************!*\
  1080. !*** ./packages/mdc-base/component.ts ***!
  1081. \****************************************/
  1082. /*! no static exports found */
  1083. /***/ (function(module, exports, __webpack_require__) {
  1084. "use strict";
  1085. /**
  1086. * @license
  1087. * Copyright 2016 Google Inc.
  1088. *
  1089. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1090. * of this software and associated documentation files (the "Software"), to deal
  1091. * in the Software without restriction, including without limitation the rights
  1092. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1093. * copies of the Software, and to permit persons to whom the Software is
  1094. * furnished to do so, subject to the following conditions:
  1095. *
  1096. * The above copyright notice and this permission notice shall be included in
  1097. * all copies or substantial portions of the Software.
  1098. *
  1099. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1100. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1101. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1102. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1103. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1104. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1105. * THE SOFTWARE.
  1106. */
  1107. var __read = this && this.__read || function (o, n) {
  1108. var m = typeof Symbol === "function" && o[Symbol.iterator];
  1109. if (!m) return o;
  1110. var i = m.call(o),
  1111. r,
  1112. ar = [],
  1113. e;
  1114. try {
  1115. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  1116. ar.push(r.value);
  1117. }
  1118. } catch (error) {
  1119. e = { error: error };
  1120. } finally {
  1121. try {
  1122. if (r && !r.done && (m = i["return"])) m.call(i);
  1123. } finally {
  1124. if (e) throw e.error;
  1125. }
  1126. }
  1127. return ar;
  1128. };
  1129. var __spread = this && this.__spread || function () {
  1130. for (var ar = [], i = 0; i < arguments.length; i++) {
  1131. ar = ar.concat(__read(arguments[i]));
  1132. }return ar;
  1133. };
  1134. Object.defineProperty(exports, "__esModule", { value: true });
  1135. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
  1136. var MDCComponent = /** @class */function () {
  1137. function MDCComponent(root, foundation) {
  1138. var args = [];
  1139. for (var _i = 2; _i < arguments.length; _i++) {
  1140. args[_i - 2] = arguments[_i];
  1141. }
  1142. this.root = root;
  1143. this.initialize.apply(this, __spread(args));
  1144. // Note that we initialize foundation here and not within the constructor's default param so that
  1145. // this.root_ is defined and can be used within the foundation class.
  1146. this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
  1147. this.foundation.init();
  1148. this.initialSyncWithDOM();
  1149. }
  1150. MDCComponent.attachTo = function (root) {
  1151. // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
  1152. // returns an instantiated component with its root set to that element. Also note that in the cases of
  1153. // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
  1154. // from getDefaultFoundation().
  1155. return new MDCComponent(root, new foundation_1.MDCFoundation({}));
  1156. };
  1157. /* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
  1158. MDCComponent.prototype.initialize = function () {
  1159. var _args = [];
  1160. for (var _i = 0; _i < arguments.length; _i++) {
  1161. _args[_i] = arguments[_i];
  1162. }
  1163. // Subclasses can override this to do any additional setup work that would be considered part of a
  1164. // "constructor". Essentially, it is a hook into the parent constructor before the foundation is
  1165. // initialized. Any additional arguments besides root and foundation will be passed in here.
  1166. };
  1167. MDCComponent.prototype.getDefaultFoundation = function () {
  1168. // Subclasses must override this method to return a properly configured foundation class for the
  1169. // component.
  1170. throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
  1171. };
  1172. MDCComponent.prototype.initialSyncWithDOM = function () {
  1173. // Subclasses should override this method if they need to perform work to synchronize with a host DOM
  1174. // object. An example of this would be a form control wrapper that needs to synchronize its internal state
  1175. // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
  1176. // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
  1177. };
  1178. MDCComponent.prototype.destroy = function () {
  1179. // Subclasses may implement this method to release any resources / deregister any listeners they have
  1180. // attached. An example of this might be deregistering a resize event from the window object.
  1181. this.foundation.destroy();
  1182. };
  1183. MDCComponent.prototype.listen = function (evtType, handler, options) {
  1184. this.root.addEventListener(evtType, handler, options);
  1185. };
  1186. MDCComponent.prototype.unlisten = function (evtType, handler, options) {
  1187. this.root.removeEventListener(evtType, handler, options);
  1188. };
  1189. /**
  1190. * Fires a cross-browser-compatible custom event from the component root of the given type, with the given data.
  1191. */
  1192. MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
  1193. if (shouldBubble === void 0) {
  1194. shouldBubble = false;
  1195. }
  1196. var evt;
  1197. if (typeof CustomEvent === 'function') {
  1198. evt = new CustomEvent(evtType, {
  1199. bubbles: shouldBubble,
  1200. detail: evtData
  1201. });
  1202. } else {
  1203. evt = document.createEvent('CustomEvent');
  1204. evt.initCustomEvent(evtType, shouldBubble, false, evtData);
  1205. }
  1206. this.root.dispatchEvent(evt);
  1207. };
  1208. return MDCComponent;
  1209. }();
  1210. exports.MDCComponent = MDCComponent;
  1211. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  1212. exports.default = MDCComponent;
  1213. /***/ }),
  1214. /***/ "./packages/mdc-base/foundation.ts":
  1215. /*!*****************************************!*\
  1216. !*** ./packages/mdc-base/foundation.ts ***!
  1217. \*****************************************/
  1218. /*! no static exports found */
  1219. /***/ (function(module, exports, __webpack_require__) {
  1220. "use strict";
  1221. /**
  1222. * @license
  1223. * Copyright 2016 Google Inc.
  1224. *
  1225. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1226. * of this software and associated documentation files (the "Software"), to deal
  1227. * in the Software without restriction, including without limitation the rights
  1228. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1229. * copies of the Software, and to permit persons to whom the Software is
  1230. * furnished to do so, subject to the following conditions:
  1231. *
  1232. * The above copyright notice and this permission notice shall be included in
  1233. * all copies or substantial portions of the Software.
  1234. *
  1235. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1236. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1237. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1238. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1239. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1240. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1241. * THE SOFTWARE.
  1242. */
  1243. Object.defineProperty(exports, "__esModule", { value: true });
  1244. var MDCFoundation = /** @class */function () {
  1245. function MDCFoundation(adapter) {
  1246. if (adapter === void 0) {
  1247. adapter = {};
  1248. }
  1249. this.adapter = adapter;
  1250. }
  1251. Object.defineProperty(MDCFoundation, "cssClasses", {
  1252. get: function get() {
  1253. // Classes extending MDCFoundation should implement this method to return an object which exports every
  1254. // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
  1255. return {};
  1256. },
  1257. enumerable: true,
  1258. configurable: true
  1259. });
  1260. Object.defineProperty(MDCFoundation, "strings", {
  1261. get: function get() {
  1262. // Classes extending MDCFoundation should implement this method to return an object which exports all
  1263. // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
  1264. return {};
  1265. },
  1266. enumerable: true,
  1267. configurable: true
  1268. });
  1269. Object.defineProperty(MDCFoundation, "numbers", {
  1270. get: function get() {
  1271. // Classes extending MDCFoundation should implement this method to return an object which exports all
  1272. // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
  1273. return {};
  1274. },
  1275. enumerable: true,
  1276. configurable: true
  1277. });
  1278. Object.defineProperty(MDCFoundation, "defaultAdapter", {
  1279. get: function get() {
  1280. // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
  1281. // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
  1282. // validation.
  1283. return {};
  1284. },
  1285. enumerable: true,
  1286. configurable: true
  1287. });
  1288. MDCFoundation.prototype.init = function () {
  1289. // Subclasses should override this method to perform initialization routines (registering events, etc.)
  1290. };
  1291. MDCFoundation.prototype.destroy = function () {
  1292. // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
  1293. };
  1294. return MDCFoundation;
  1295. }();
  1296. exports.MDCFoundation = MDCFoundation;
  1297. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  1298. exports.default = MDCFoundation;
  1299. /***/ }),
  1300. /***/ "./packages/mdc-base/index.ts":
  1301. /*!************************************!*\
  1302. !*** ./packages/mdc-base/index.ts ***!
  1303. \************************************/
  1304. /*! no static exports found */
  1305. /***/ (function(module, exports, __webpack_require__) {
  1306. "use strict";
  1307. /**
  1308. * @license
  1309. * Copyright 2019 Google Inc.
  1310. *
  1311. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1312. * of this software and associated documentation files (the "Software"), to deal
  1313. * in the Software without restriction, including without limitation the rights
  1314. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1315. * copies of the Software, and to permit persons to whom the Software is
  1316. * furnished to do so, subject to the following conditions:
  1317. *
  1318. * The above copyright notice and this permission notice shall be included in
  1319. * all copies or substantial portions of the Software.
  1320. *
  1321. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1322. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1323. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1324. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1325. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1326. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1327. * THE SOFTWARE.
  1328. */
  1329. function __export(m) {
  1330. for (var p in m) {
  1331. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1332. }
  1333. }
  1334. Object.defineProperty(exports, "__esModule", { value: true });
  1335. __export(__webpack_require__(/*! ./component */ "./packages/mdc-base/component.ts"));
  1336. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts"));
  1337. /***/ }),
  1338. /***/ "./packages/mdc-checkbox/component.ts":
  1339. /*!********************************************!*\
  1340. !*** ./packages/mdc-checkbox/component.ts ***!
  1341. \********************************************/
  1342. /*! no static exports found */
  1343. /***/ (function(module, exports, __webpack_require__) {
  1344. "use strict";
  1345. /**
  1346. * @license
  1347. * Copyright 2016 Google Inc.
  1348. *
  1349. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1350. * of this software and associated documentation files (the "Software"), to deal
  1351. * in the Software without restriction, including without limitation the rights
  1352. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1353. * copies of the Software, and to permit persons to whom the Software is
  1354. * furnished to do so, subject to the following conditions:
  1355. *
  1356. * The above copyright notice and this permission notice shall be included in
  1357. * all copies or substantial portions of the Software.
  1358. *
  1359. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1360. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1361. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1362. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1363. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1364. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1365. * THE SOFTWARE.
  1366. */
  1367. var __extends = this && this.__extends || function () {
  1368. var _extendStatics = function extendStatics(d, b) {
  1369. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  1370. d.__proto__ = b;
  1371. } || function (d, b) {
  1372. for (var p in b) {
  1373. if (b.hasOwnProperty(p)) d[p] = b[p];
  1374. }
  1375. };
  1376. return _extendStatics(d, b);
  1377. };
  1378. return function (d, b) {
  1379. _extendStatics(d, b);
  1380. function __() {
  1381. this.constructor = d;
  1382. }
  1383. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1384. };
  1385. }();
  1386. var __assign = this && this.__assign || function () {
  1387. __assign = Object.assign || function (t) {
  1388. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1389. s = arguments[i];
  1390. for (var p in s) {
  1391. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  1392. }
  1393. }
  1394. return t;
  1395. };
  1396. return __assign.apply(this, arguments);
  1397. };
  1398. Object.defineProperty(exports, "__esModule", { value: true });
  1399. var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
  1400. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  1401. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  1402. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  1403. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  1404. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  1405. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts");
  1406. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-checkbox/foundation.ts");
  1407. var CB_PROTO_PROPS = ['checked', 'indeterminate'];
  1408. var MDCCheckbox = /** @class */function (_super) {
  1409. __extends(MDCCheckbox, _super);
  1410. function MDCCheckbox() {
  1411. var _this = _super !== null && _super.apply(this, arguments) || this;
  1412. _this.ripple_ = _this.createRipple_();
  1413. return _this;
  1414. }
  1415. MDCCheckbox.attachTo = function (root) {
  1416. return new MDCCheckbox(root);
  1417. };
  1418. Object.defineProperty(MDCCheckbox.prototype, "ripple", {
  1419. get: function get() {
  1420. return this.ripple_;
  1421. },
  1422. enumerable: true,
  1423. configurable: true
  1424. });
  1425. Object.defineProperty(MDCCheckbox.prototype, "checked", {
  1426. get: function get() {
  1427. return this.nativeControl_.checked;
  1428. },
  1429. set: function set(checked) {
  1430. this.nativeControl_.checked = checked;
  1431. },
  1432. enumerable: true,
  1433. configurable: true
  1434. });
  1435. Object.defineProperty(MDCCheckbox.prototype, "indeterminate", {
  1436. get: function get() {
  1437. return this.nativeControl_.indeterminate;
  1438. },
  1439. set: function set(indeterminate) {
  1440. this.nativeControl_.indeterminate = indeterminate;
  1441. },
  1442. enumerable: true,
  1443. configurable: true
  1444. });
  1445. Object.defineProperty(MDCCheckbox.prototype, "disabled", {
  1446. get: function get() {
  1447. return this.nativeControl_.disabled;
  1448. },
  1449. set: function set(disabled) {
  1450. this.foundation.setDisabled(disabled);
  1451. },
  1452. enumerable: true,
  1453. configurable: true
  1454. });
  1455. Object.defineProperty(MDCCheckbox.prototype, "value", {
  1456. get: function get() {
  1457. return this.nativeControl_.value;
  1458. },
  1459. set: function set(value) {
  1460. this.nativeControl_.value = value;
  1461. },
  1462. enumerable: true,
  1463. configurable: true
  1464. });
  1465. MDCCheckbox.prototype.initialize = function () {
  1466. var DATA_INDETERMINATE_ATTR = constants_1.strings.DATA_INDETERMINATE_ATTR;
  1467. this.nativeControl_.indeterminate = this.nativeControl_.getAttribute(DATA_INDETERMINATE_ATTR) === 'true';
  1468. this.nativeControl_.removeAttribute(DATA_INDETERMINATE_ATTR);
  1469. };
  1470. MDCCheckbox.prototype.initialSyncWithDOM = function () {
  1471. var _this = this;
  1472. this.handleChange_ = function () {
  1473. return _this.foundation.handleChange();
  1474. };
  1475. this.handleAnimationEnd_ = function () {
  1476. return _this.foundation.handleAnimationEnd();
  1477. };
  1478. this.nativeControl_.addEventListener('change', this.handleChange_);
  1479. this.listen(util_1.getCorrectEventName(window, 'animationend'), this.handleAnimationEnd_);
  1480. this.installPropertyChangeHooks_();
  1481. };
  1482. MDCCheckbox.prototype.destroy = function () {
  1483. this.ripple_.destroy();
  1484. this.nativeControl_.removeEventListener('change', this.handleChange_);
  1485. this.unlisten(util_1.getCorrectEventName(window, 'animationend'), this.handleAnimationEnd_);
  1486. this.uninstallPropertyChangeHooks_();
  1487. _super.prototype.destroy.call(this);
  1488. };
  1489. MDCCheckbox.prototype.getDefaultFoundation = function () {
  1490. var _this = this;
  1491. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  1492. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  1493. var adapter = {
  1494. addClass: function addClass(className) {
  1495. return _this.root.classList.add(className);
  1496. },
  1497. forceLayout: function forceLayout() {
  1498. return _this.root.offsetWidth;
  1499. },
  1500. hasNativeControl: function hasNativeControl() {
  1501. return !!_this.nativeControl_;
  1502. },
  1503. isAttachedToDOM: function isAttachedToDOM() {
  1504. return Boolean(_this.root.parentNode);
  1505. },
  1506. isChecked: function isChecked() {
  1507. return _this.checked;
  1508. },
  1509. isIndeterminate: function isIndeterminate() {
  1510. return _this.indeterminate;
  1511. },
  1512. removeClass: function removeClass(className) {
  1513. _this.root.classList.remove(className);
  1514. },
  1515. removeNativeControlAttr: function removeNativeControlAttr(attr) {
  1516. _this.nativeControl_.removeAttribute(attr);
  1517. },
  1518. setNativeControlAttr: function setNativeControlAttr(attr, value) {
  1519. _this.nativeControl_.setAttribute(attr, value);
  1520. },
  1521. setNativeControlDisabled: function setNativeControlDisabled(disabled) {
  1522. _this.nativeControl_.disabled = disabled;
  1523. }
  1524. };
  1525. return new foundation_2.MDCCheckboxFoundation(adapter);
  1526. };
  1527. MDCCheckbox.prototype.createRipple_ = function () {
  1528. var _this = this;
  1529. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  1530. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  1531. var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  1532. return _this.nativeControl_.removeEventListener(evtType, handler, events_1.applyPassive());
  1533. }, isSurfaceActive: function isSurfaceActive() {
  1534. return ponyfill_1.matches(_this.nativeControl_, ':active');
  1535. }, isUnbounded: function isUnbounded() {
  1536. return true;
  1537. }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  1538. return _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
  1539. } });
  1540. return new component_2.MDCRipple(this.root, new foundation_1.MDCRippleFoundation(adapter));
  1541. };
  1542. MDCCheckbox.prototype.installPropertyChangeHooks_ = function () {
  1543. var _this = this;
  1544. var nativeCb = this.nativeControl_;
  1545. var cbProto = Object.getPrototypeOf(nativeCb);
  1546. CB_PROTO_PROPS.forEach(function (controlState) {
  1547. var desc = Object.getOwnPropertyDescriptor(cbProto, controlState);
  1548. // We have to check for this descriptor, since some browsers (Safari) don't support its return.
  1549. // See: https://bugs.webkit.org/show_bug.cgi?id=49739
  1550. if (!validDescriptor(desc)) {
  1551. return;
  1552. }
  1553. // Type cast is needed for compatibility with Closure Compiler.
  1554. var nativeGetter = desc.get;
  1555. var nativeCbDesc = {
  1556. configurable: desc.configurable,
  1557. enumerable: desc.enumerable,
  1558. get: nativeGetter,
  1559. set: function set(state) {
  1560. desc.set.call(nativeCb, state);
  1561. _this.foundation.handleChange();
  1562. }
  1563. };
  1564. Object.defineProperty(nativeCb, controlState, nativeCbDesc);
  1565. });
  1566. };
  1567. MDCCheckbox.prototype.uninstallPropertyChangeHooks_ = function () {
  1568. var nativeCb = this.nativeControl_;
  1569. var cbProto = Object.getPrototypeOf(nativeCb);
  1570. CB_PROTO_PROPS.forEach(function (controlState) {
  1571. var desc = Object.getOwnPropertyDescriptor(cbProto, controlState);
  1572. if (!validDescriptor(desc)) {
  1573. return;
  1574. }
  1575. Object.defineProperty(nativeCb, controlState, desc);
  1576. });
  1577. };
  1578. Object.defineProperty(MDCCheckbox.prototype, "nativeControl_", {
  1579. get: function get() {
  1580. var NATIVE_CONTROL_SELECTOR = constants_1.strings.NATIVE_CONTROL_SELECTOR;
  1581. var el = this.root.querySelector(NATIVE_CONTROL_SELECTOR);
  1582. if (!el) {
  1583. throw new Error("Checkbox component requires a " + NATIVE_CONTROL_SELECTOR + " element");
  1584. }
  1585. return el;
  1586. },
  1587. enumerable: true,
  1588. configurable: true
  1589. });
  1590. return MDCCheckbox;
  1591. }(component_1.MDCComponent);
  1592. exports.MDCCheckbox = MDCCheckbox;
  1593. function validDescriptor(inputPropDesc) {
  1594. return !!inputPropDesc && typeof inputPropDesc.set === 'function';
  1595. }
  1596. /***/ }),
  1597. /***/ "./packages/mdc-checkbox/constants.ts":
  1598. /*!********************************************!*\
  1599. !*** ./packages/mdc-checkbox/constants.ts ***!
  1600. \********************************************/
  1601. /*! no static exports found */
  1602. /***/ (function(module, exports, __webpack_require__) {
  1603. "use strict";
  1604. /**
  1605. * @license
  1606. * Copyright 2016 Google Inc.
  1607. *
  1608. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1609. * of this software and associated documentation files (the "Software"), to deal
  1610. * in the Software without restriction, including without limitation the rights
  1611. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1612. * copies of the Software, and to permit persons to whom the Software is
  1613. * furnished to do so, subject to the following conditions:
  1614. *
  1615. * The above copyright notice and this permission notice shall be included in
  1616. * all copies or substantial portions of the Software.
  1617. *
  1618. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1619. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1620. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1621. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1622. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1623. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1624. * THE SOFTWARE.
  1625. */
  1626. Object.defineProperty(exports, "__esModule", { value: true });
  1627. exports.cssClasses = {
  1628. ANIM_CHECKED_INDETERMINATE: 'mdc-checkbox--anim-checked-indeterminate',
  1629. ANIM_CHECKED_UNCHECKED: 'mdc-checkbox--anim-checked-unchecked',
  1630. ANIM_INDETERMINATE_CHECKED: 'mdc-checkbox--anim-indeterminate-checked',
  1631. ANIM_INDETERMINATE_UNCHECKED: 'mdc-checkbox--anim-indeterminate-unchecked',
  1632. ANIM_UNCHECKED_CHECKED: 'mdc-checkbox--anim-unchecked-checked',
  1633. ANIM_UNCHECKED_INDETERMINATE: 'mdc-checkbox--anim-unchecked-indeterminate',
  1634. BACKGROUND: 'mdc-checkbox__background',
  1635. CHECKED: 'mdc-checkbox--checked',
  1636. CHECKMARK: 'mdc-checkbox__checkmark',
  1637. CHECKMARK_PATH: 'mdc-checkbox__checkmark-path',
  1638. DISABLED: 'mdc-checkbox--disabled',
  1639. INDETERMINATE: 'mdc-checkbox--indeterminate',
  1640. MIXEDMARK: 'mdc-checkbox__mixedmark',
  1641. NATIVE_CONTROL: 'mdc-checkbox__native-control',
  1642. ROOT: 'mdc-checkbox',
  1643. SELECTED: 'mdc-checkbox--selected',
  1644. UPGRADED: 'mdc-checkbox--upgraded'
  1645. };
  1646. exports.strings = {
  1647. ARIA_CHECKED_ATTR: 'aria-checked',
  1648. ARIA_CHECKED_INDETERMINATE_VALUE: 'mixed',
  1649. DATA_INDETERMINATE_ATTR: 'data-indeterminate',
  1650. NATIVE_CONTROL_SELECTOR: '.mdc-checkbox__native-control',
  1651. TRANSITION_STATE_CHECKED: 'checked',
  1652. TRANSITION_STATE_INDETERMINATE: 'indeterminate',
  1653. TRANSITION_STATE_INIT: 'init',
  1654. TRANSITION_STATE_UNCHECKED: 'unchecked'
  1655. };
  1656. exports.numbers = {
  1657. ANIM_END_LATCH_MS: 250
  1658. };
  1659. /***/ }),
  1660. /***/ "./packages/mdc-checkbox/foundation.ts":
  1661. /*!*********************************************!*\
  1662. !*** ./packages/mdc-checkbox/foundation.ts ***!
  1663. \*********************************************/
  1664. /*! no static exports found */
  1665. /***/ (function(module, exports, __webpack_require__) {
  1666. "use strict";
  1667. /**
  1668. * @license
  1669. * Copyright 2016 Google Inc.
  1670. *
  1671. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1672. * of this software and associated documentation files (the "Software"), to deal
  1673. * in the Software without restriction, including without limitation the rights
  1674. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1675. * copies of the Software, and to permit persons to whom the Software is
  1676. * furnished to do so, subject to the following conditions:
  1677. *
  1678. * The above copyright notice and this permission notice shall be included in
  1679. * all copies or substantial portions of the Software.
  1680. *
  1681. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1682. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1683. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1684. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1685. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1686. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1687. * THE SOFTWARE.
  1688. */
  1689. var __extends = this && this.__extends || function () {
  1690. var _extendStatics = function extendStatics(d, b) {
  1691. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  1692. d.__proto__ = b;
  1693. } || function (d, b) {
  1694. for (var p in b) {
  1695. if (b.hasOwnProperty(p)) d[p] = b[p];
  1696. }
  1697. };
  1698. return _extendStatics(d, b);
  1699. };
  1700. return function (d, b) {
  1701. _extendStatics(d, b);
  1702. function __() {
  1703. this.constructor = d;
  1704. }
  1705. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1706. };
  1707. }();
  1708. var __assign = this && this.__assign || function () {
  1709. __assign = Object.assign || function (t) {
  1710. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1711. s = arguments[i];
  1712. for (var p in s) {
  1713. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  1714. }
  1715. }
  1716. return t;
  1717. };
  1718. return __assign.apply(this, arguments);
  1719. };
  1720. Object.defineProperty(exports, "__esModule", { value: true });
  1721. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  1722. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts");
  1723. var MDCCheckboxFoundation = /** @class */function (_super) {
  1724. __extends(MDCCheckboxFoundation, _super);
  1725. function MDCCheckboxFoundation(adapter) {
  1726. var _this = _super.call(this, __assign(__assign({}, MDCCheckboxFoundation.defaultAdapter), adapter)) || this;
  1727. _this.currentCheckState_ = constants_1.strings.TRANSITION_STATE_INIT;
  1728. _this.currentAnimationClass_ = '';
  1729. _this.animEndLatchTimer_ = 0;
  1730. _this.enableAnimationEndHandler_ = false;
  1731. return _this;
  1732. }
  1733. Object.defineProperty(MDCCheckboxFoundation, "cssClasses", {
  1734. get: function get() {
  1735. return constants_1.cssClasses;
  1736. },
  1737. enumerable: true,
  1738. configurable: true
  1739. });
  1740. Object.defineProperty(MDCCheckboxFoundation, "strings", {
  1741. get: function get() {
  1742. return constants_1.strings;
  1743. },
  1744. enumerable: true,
  1745. configurable: true
  1746. });
  1747. Object.defineProperty(MDCCheckboxFoundation, "numbers", {
  1748. get: function get() {
  1749. return constants_1.numbers;
  1750. },
  1751. enumerable: true,
  1752. configurable: true
  1753. });
  1754. Object.defineProperty(MDCCheckboxFoundation, "defaultAdapter", {
  1755. get: function get() {
  1756. return {
  1757. addClass: function addClass() {
  1758. return undefined;
  1759. },
  1760. forceLayout: function forceLayout() {
  1761. return undefined;
  1762. },
  1763. hasNativeControl: function hasNativeControl() {
  1764. return false;
  1765. },
  1766. isAttachedToDOM: function isAttachedToDOM() {
  1767. return false;
  1768. },
  1769. isChecked: function isChecked() {
  1770. return false;
  1771. },
  1772. isIndeterminate: function isIndeterminate() {
  1773. return false;
  1774. },
  1775. removeClass: function removeClass() {
  1776. return undefined;
  1777. },
  1778. removeNativeControlAttr: function removeNativeControlAttr() {
  1779. return undefined;
  1780. },
  1781. setNativeControlAttr: function setNativeControlAttr() {
  1782. return undefined;
  1783. },
  1784. setNativeControlDisabled: function setNativeControlDisabled() {
  1785. return undefined;
  1786. }
  1787. };
  1788. },
  1789. enumerable: true,
  1790. configurable: true
  1791. });
  1792. MDCCheckboxFoundation.prototype.init = function () {
  1793. this.currentCheckState_ = this.determineCheckState_();
  1794. this.updateAriaChecked_();
  1795. this.adapter.addClass(constants_1.cssClasses.UPGRADED);
  1796. };
  1797. MDCCheckboxFoundation.prototype.destroy = function () {
  1798. clearTimeout(this.animEndLatchTimer_);
  1799. };
  1800. MDCCheckboxFoundation.prototype.setDisabled = function (disabled) {
  1801. this.adapter.setNativeControlDisabled(disabled);
  1802. if (disabled) {
  1803. this.adapter.addClass(constants_1.cssClasses.DISABLED);
  1804. } else {
  1805. this.adapter.removeClass(constants_1.cssClasses.DISABLED);
  1806. }
  1807. };
  1808. /**
  1809. * Handles the animationend event for the checkbox
  1810. */
  1811. MDCCheckboxFoundation.prototype.handleAnimationEnd = function () {
  1812. var _this = this;
  1813. if (!this.enableAnimationEndHandler_) {
  1814. return;
  1815. }
  1816. clearTimeout(this.animEndLatchTimer_);
  1817. this.animEndLatchTimer_ = setTimeout(function () {
  1818. _this.adapter.removeClass(_this.currentAnimationClass_);
  1819. _this.enableAnimationEndHandler_ = false;
  1820. }, constants_1.numbers.ANIM_END_LATCH_MS);
  1821. };
  1822. /**
  1823. * Handles the change event for the checkbox
  1824. */
  1825. MDCCheckboxFoundation.prototype.handleChange = function () {
  1826. this.transitionCheckState_();
  1827. };
  1828. MDCCheckboxFoundation.prototype.transitionCheckState_ = function () {
  1829. if (!this.adapter.hasNativeControl()) {
  1830. return;
  1831. }
  1832. var oldState = this.currentCheckState_;
  1833. var newState = this.determineCheckState_();
  1834. if (oldState === newState) {
  1835. return;
  1836. }
  1837. this.updateAriaChecked_();
  1838. var TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
  1839. var SELECTED = constants_1.cssClasses.SELECTED;
  1840. if (newState === TRANSITION_STATE_UNCHECKED) {
  1841. this.adapter.removeClass(SELECTED);
  1842. } else {
  1843. this.adapter.addClass(SELECTED);
  1844. }
  1845. // Check to ensure that there isn't a previously existing animation class, in case for example
  1846. // the user interacted with the checkbox before the animation was finished.
  1847. if (this.currentAnimationClass_.length > 0) {
  1848. clearTimeout(this.animEndLatchTimer_);
  1849. this.adapter.forceLayout();
  1850. this.adapter.removeClass(this.currentAnimationClass_);
  1851. }
  1852. this.currentAnimationClass_ = this.getTransitionAnimationClass_(oldState, newState);
  1853. this.currentCheckState_ = newState;
  1854. // Check for parentNode so that animations are only run when the element is attached
  1855. // to the DOM.
  1856. if (this.adapter.isAttachedToDOM() && this.currentAnimationClass_.length > 0) {
  1857. this.adapter.addClass(this.currentAnimationClass_);
  1858. this.enableAnimationEndHandler_ = true;
  1859. }
  1860. };
  1861. MDCCheckboxFoundation.prototype.determineCheckState_ = function () {
  1862. var TRANSITION_STATE_INDETERMINATE = constants_1.strings.TRANSITION_STATE_INDETERMINATE,
  1863. TRANSITION_STATE_CHECKED = constants_1.strings.TRANSITION_STATE_CHECKED,
  1864. TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
  1865. if (this.adapter.isIndeterminate()) {
  1866. return TRANSITION_STATE_INDETERMINATE;
  1867. }
  1868. return this.adapter.isChecked() ? TRANSITION_STATE_CHECKED : TRANSITION_STATE_UNCHECKED;
  1869. };
  1870. MDCCheckboxFoundation.prototype.getTransitionAnimationClass_ = function (oldState, newState) {
  1871. var TRANSITION_STATE_INIT = constants_1.strings.TRANSITION_STATE_INIT,
  1872. TRANSITION_STATE_CHECKED = constants_1.strings.TRANSITION_STATE_CHECKED,
  1873. TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
  1874. var _a = MDCCheckboxFoundation.cssClasses,
  1875. ANIM_UNCHECKED_CHECKED = _a.ANIM_UNCHECKED_CHECKED,
  1876. ANIM_UNCHECKED_INDETERMINATE = _a.ANIM_UNCHECKED_INDETERMINATE,
  1877. ANIM_CHECKED_UNCHECKED = _a.ANIM_CHECKED_UNCHECKED,
  1878. ANIM_CHECKED_INDETERMINATE = _a.ANIM_CHECKED_INDETERMINATE,
  1879. ANIM_INDETERMINATE_CHECKED = _a.ANIM_INDETERMINATE_CHECKED,
  1880. ANIM_INDETERMINATE_UNCHECKED = _a.ANIM_INDETERMINATE_UNCHECKED;
  1881. switch (oldState) {
  1882. case TRANSITION_STATE_INIT:
  1883. if (newState === TRANSITION_STATE_UNCHECKED) {
  1884. return '';
  1885. }
  1886. return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED;
  1887. case TRANSITION_STATE_UNCHECKED:
  1888. return newState === TRANSITION_STATE_CHECKED ? ANIM_UNCHECKED_CHECKED : ANIM_UNCHECKED_INDETERMINATE;
  1889. case TRANSITION_STATE_CHECKED:
  1890. return newState === TRANSITION_STATE_UNCHECKED ? ANIM_CHECKED_UNCHECKED : ANIM_CHECKED_INDETERMINATE;
  1891. default:
  1892. // TRANSITION_STATE_INDETERMINATE
  1893. return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED;
  1894. }
  1895. };
  1896. MDCCheckboxFoundation.prototype.updateAriaChecked_ = function () {
  1897. // Ensure aria-checked is set to mixed if checkbox is in indeterminate state.
  1898. if (this.adapter.isIndeterminate()) {
  1899. this.adapter.setNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR, constants_1.strings.ARIA_CHECKED_INDETERMINATE_VALUE);
  1900. } else {
  1901. // The on/off state does not need to keep track of aria-checked, since
  1902. // the screenreader uses the checked property on the checkbox element.
  1903. this.adapter.removeNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR);
  1904. }
  1905. };
  1906. return MDCCheckboxFoundation;
  1907. }(foundation_1.MDCFoundation);
  1908. exports.MDCCheckboxFoundation = MDCCheckboxFoundation;
  1909. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  1910. exports.default = MDCCheckboxFoundation;
  1911. /***/ }),
  1912. /***/ "./packages/mdc-checkbox/index.ts":
  1913. /*!****************************************!*\
  1914. !*** ./packages/mdc-checkbox/index.ts ***!
  1915. \****************************************/
  1916. /*! no static exports found */
  1917. /***/ (function(module, exports, __webpack_require__) {
  1918. "use strict";
  1919. /**
  1920. * @license
  1921. * Copyright 2019 Google Inc.
  1922. *
  1923. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1924. * of this software and associated documentation files (the "Software"), to deal
  1925. * in the Software without restriction, including without limitation the rights
  1926. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1927. * copies of the Software, and to permit persons to whom the Software is
  1928. * furnished to do so, subject to the following conditions:
  1929. *
  1930. * The above copyright notice and this permission notice shall be included in
  1931. * all copies or substantial portions of the Software.
  1932. *
  1933. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1934. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1935. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1936. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1937. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1938. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1939. * THE SOFTWARE.
  1940. */
  1941. function __export(m) {
  1942. for (var p in m) {
  1943. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  1944. }
  1945. }
  1946. Object.defineProperty(exports, "__esModule", { value: true });
  1947. __export(__webpack_require__(/*! ./component */ "./packages/mdc-checkbox/component.ts"));
  1948. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts"));
  1949. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-checkbox/foundation.ts"));
  1950. /***/ }),
  1951. /***/ "./packages/mdc-chips/chip-set/component.ts":
  1952. /*!**************************************************!*\
  1953. !*** ./packages/mdc-chips/chip-set/component.ts ***!
  1954. \**************************************************/
  1955. /*! no static exports found */
  1956. /***/ (function(module, exports, __webpack_require__) {
  1957. "use strict";
  1958. /**
  1959. * @license
  1960. * Copyright 2016 Google Inc.
  1961. *
  1962. * Permission is hereby granted, free of charge, to any person obtaining a copy
  1963. * of this software and associated documentation files (the "Software"), to deal
  1964. * in the Software without restriction, including without limitation the rights
  1965. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  1966. * copies of the Software, and to permit persons to whom the Software is
  1967. * furnished to do so, subject to the following conditions:
  1968. *
  1969. * The above copyright notice and this permission notice shall be included in
  1970. * all copies or substantial portions of the Software.
  1971. *
  1972. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1973. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1974. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1975. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1976. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1977. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1978. * THE SOFTWARE.
  1979. */
  1980. var __extends = this && this.__extends || function () {
  1981. var _extendStatics = function extendStatics(d, b) {
  1982. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  1983. d.__proto__ = b;
  1984. } || function (d, b) {
  1985. for (var p in b) {
  1986. if (b.hasOwnProperty(p)) d[p] = b[p];
  1987. }
  1988. };
  1989. return _extendStatics(d, b);
  1990. };
  1991. return function (d, b) {
  1992. _extendStatics(d, b);
  1993. function __() {
  1994. this.constructor = d;
  1995. }
  1996. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1997. };
  1998. }();
  1999. Object.defineProperty(exports, "__esModule", { value: true });
  2000. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  2001. var announce_1 = __webpack_require__(/*! @material/dom/announce */ "./packages/mdc-dom/announce.ts");
  2002. var component_2 = __webpack_require__(/*! ../chip/component */ "./packages/mdc-chips/chip/component.ts");
  2003. var foundation_1 = __webpack_require__(/*! ../chip/foundation */ "./packages/mdc-chips/chip/foundation.ts");
  2004. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip-set/foundation.ts");
  2005. var _a = foundation_1.MDCChipFoundation.strings,
  2006. INTERACTION_EVENT = _a.INTERACTION_EVENT,
  2007. SELECTION_EVENT = _a.SELECTION_EVENT,
  2008. REMOVAL_EVENT = _a.REMOVAL_EVENT,
  2009. NAVIGATION_EVENT = _a.NAVIGATION_EVENT;
  2010. var CHIP_SELECTOR = foundation_2.MDCChipSetFoundation.strings.CHIP_SELECTOR;
  2011. var idCounter = 0;
  2012. var MDCChipSet = /** @class */function (_super) {
  2013. __extends(MDCChipSet, _super);
  2014. function MDCChipSet() {
  2015. return _super !== null && _super.apply(this, arguments) || this;
  2016. }
  2017. MDCChipSet.attachTo = function (root) {
  2018. return new MDCChipSet(root);
  2019. };
  2020. Object.defineProperty(MDCChipSet.prototype, "chips", {
  2021. get: function get() {
  2022. return this.chips_.slice();
  2023. },
  2024. enumerable: true,
  2025. configurable: true
  2026. });
  2027. Object.defineProperty(MDCChipSet.prototype, "selectedChipIds", {
  2028. /**
  2029. * @return An array of the IDs of all selected chips.
  2030. */
  2031. get: function get() {
  2032. return this.foundation.getSelectedChipIds();
  2033. },
  2034. enumerable: true,
  2035. configurable: true
  2036. });
  2037. /**
  2038. * @param chipFactory A function which creates a new MDCChip.
  2039. */
  2040. MDCChipSet.prototype.initialize = function (chipFactory) {
  2041. if (chipFactory === void 0) {
  2042. chipFactory = function chipFactory(el) {
  2043. return new component_2.MDCChip(el);
  2044. };
  2045. }
  2046. this.chipFactory_ = chipFactory;
  2047. this.chips_ = this.instantiateChips_(this.chipFactory_);
  2048. };
  2049. MDCChipSet.prototype.initialSyncWithDOM = function () {
  2050. var _this = this;
  2051. this.chips_.forEach(function (chip) {
  2052. if (chip.id && chip.selected) {
  2053. _this.foundation.select(chip.id);
  2054. }
  2055. });
  2056. this.handleChipInteraction_ = function (evt) {
  2057. return _this.foundation.handleChipInteraction(evt.detail);
  2058. };
  2059. this.handleChipSelection_ = function (evt) {
  2060. return _this.foundation.handleChipSelection(evt.detail);
  2061. };
  2062. this.handleChipRemoval_ = function (evt) {
  2063. return _this.foundation.handleChipRemoval(evt.detail);
  2064. };
  2065. this.handleChipNavigation_ = function (evt) {
  2066. return _this.foundation.handleChipNavigation(evt.detail);
  2067. };
  2068. this.listen(INTERACTION_EVENT, this.handleChipInteraction_);
  2069. this.listen(SELECTION_EVENT, this.handleChipSelection_);
  2070. this.listen(REMOVAL_EVENT, this.handleChipRemoval_);
  2071. this.listen(NAVIGATION_EVENT, this.handleChipNavigation_);
  2072. };
  2073. MDCChipSet.prototype.destroy = function () {
  2074. this.chips_.forEach(function (chip) {
  2075. chip.destroy();
  2076. });
  2077. this.unlisten(INTERACTION_EVENT, this.handleChipInteraction_);
  2078. this.unlisten(SELECTION_EVENT, this.handleChipSelection_);
  2079. this.unlisten(REMOVAL_EVENT, this.handleChipRemoval_);
  2080. this.unlisten(NAVIGATION_EVENT, this.handleChipNavigation_);
  2081. _super.prototype.destroy.call(this);
  2082. };
  2083. /**
  2084. * Adds a new chip object to the chip set from the given chip element.
  2085. */
  2086. MDCChipSet.prototype.addChip = function (chipEl) {
  2087. chipEl.id = chipEl.id || "mdc-chip-" + ++idCounter;
  2088. this.chips_.push(this.chipFactory_(chipEl));
  2089. };
  2090. MDCChipSet.prototype.getDefaultFoundation = function () {
  2091. var _this = this;
  2092. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  2093. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  2094. var adapter = {
  2095. announceMessage: function announceMessage(message) {
  2096. announce_1.announce(message);
  2097. },
  2098. focusChipPrimaryActionAtIndex: function focusChipPrimaryActionAtIndex(index) {
  2099. _this.chips_[index].focusPrimaryAction();
  2100. },
  2101. focusChipTrailingActionAtIndex: function focusChipTrailingActionAtIndex(index) {
  2102. _this.chips_[index].focusTrailingAction();
  2103. },
  2104. getChipListCount: function getChipListCount() {
  2105. return _this.chips_.length;
  2106. },
  2107. getIndexOfChipById: function getIndexOfChipById(chipId) {
  2108. return _this.findChipIndex_(chipId);
  2109. },
  2110. hasClass: function hasClass(className) {
  2111. return _this.root.classList.contains(className);
  2112. },
  2113. isRTL: function isRTL() {
  2114. return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
  2115. },
  2116. removeChipAtIndex: function removeChipAtIndex(index) {
  2117. if (index >= 0 && index < _this.chips_.length) {
  2118. _this.chips_[index].destroy();
  2119. _this.chips_[index].remove();
  2120. _this.chips_.splice(index, 1);
  2121. }
  2122. },
  2123. removeFocusFromChipAtIndex: function removeFocusFromChipAtIndex(index) {
  2124. _this.chips_[index].removeFocus();
  2125. },
  2126. selectChipAtIndex: function selectChipAtIndex(index, selected, shouldNotifyClients) {
  2127. if (index >= 0 && index < _this.chips_.length) {
  2128. _this.chips_[index].setSelectedFromChipSet(selected, shouldNotifyClients);
  2129. }
  2130. }
  2131. };
  2132. return new foundation_2.MDCChipSetFoundation(adapter);
  2133. };
  2134. /**
  2135. * Instantiates chip components on all of the chip set's child chip elements.
  2136. */
  2137. MDCChipSet.prototype.instantiateChips_ = function (chipFactory) {
  2138. var chipElements = [].slice.call(this.root.querySelectorAll(CHIP_SELECTOR));
  2139. return chipElements.map(function (el) {
  2140. el.id = el.id || "mdc-chip-" + ++idCounter;
  2141. return chipFactory(el);
  2142. });
  2143. };
  2144. /**
  2145. * Returns the index of the chip with the given id, or -1 if the chip does not exist.
  2146. */
  2147. MDCChipSet.prototype.findChipIndex_ = function (chipId) {
  2148. for (var i = 0; i < this.chips_.length; i++) {
  2149. if (this.chips_[i].id === chipId) {
  2150. return i;
  2151. }
  2152. }
  2153. return -1;
  2154. };
  2155. return MDCChipSet;
  2156. }(component_1.MDCComponent);
  2157. exports.MDCChipSet = MDCChipSet;
  2158. /***/ }),
  2159. /***/ "./packages/mdc-chips/chip-set/constants.ts":
  2160. /*!**************************************************!*\
  2161. !*** ./packages/mdc-chips/chip-set/constants.ts ***!
  2162. \**************************************************/
  2163. /*! no static exports found */
  2164. /***/ (function(module, exports, __webpack_require__) {
  2165. "use strict";
  2166. /**
  2167. * @license
  2168. * Copyright 2016 Google Inc.
  2169. *
  2170. * Permission is hereby granted, free of charge, to any person obtaining a copy
  2171. * of this software and associated documentation files (the "Software"), to deal
  2172. * in the Software without restriction, including without limitation the rights
  2173. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2174. * copies of the Software, and to permit persons to whom the Software is
  2175. * furnished to do so, subject to the following conditions:
  2176. *
  2177. * The above copyright notice and this permission notice shall be included in
  2178. * all copies or substantial portions of the Software.
  2179. *
  2180. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2181. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2182. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2183. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2184. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2185. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2186. * THE SOFTWARE.
  2187. */
  2188. Object.defineProperty(exports, "__esModule", { value: true });
  2189. exports.strings = {
  2190. CHIP_SELECTOR: '.mdc-chip'
  2191. };
  2192. exports.cssClasses = {
  2193. CHOICE: 'mdc-chip-set--choice',
  2194. FILTER: 'mdc-chip-set--filter'
  2195. };
  2196. /***/ }),
  2197. /***/ "./packages/mdc-chips/chip-set/foundation.ts":
  2198. /*!***************************************************!*\
  2199. !*** ./packages/mdc-chips/chip-set/foundation.ts ***!
  2200. \***************************************************/
  2201. /*! no static exports found */
  2202. /***/ (function(module, exports, __webpack_require__) {
  2203. "use strict";
  2204. /**
  2205. * @license
  2206. * Copyright 2017 Google Inc.
  2207. *
  2208. * Permission is hereby granted, free of charge, to any person obtaining a copy
  2209. * of this software and associated documentation files (the "Software"), to deal
  2210. * in the Software without restriction, including without limitation the rights
  2211. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2212. * copies of the Software, and to permit persons to whom the Software is
  2213. * furnished to do so, subject to the following conditions:
  2214. *
  2215. * The above copyright notice and this permission notice shall be included in
  2216. * all copies or substantial portions of the Software.
  2217. *
  2218. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2219. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2220. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2221. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2222. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2223. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2224. * THE SOFTWARE.
  2225. */
  2226. var __extends = this && this.__extends || function () {
  2227. var _extendStatics = function extendStatics(d, b) {
  2228. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  2229. d.__proto__ = b;
  2230. } || function (d, b) {
  2231. for (var p in b) {
  2232. if (b.hasOwnProperty(p)) d[p] = b[p];
  2233. }
  2234. };
  2235. return _extendStatics(d, b);
  2236. };
  2237. return function (d, b) {
  2238. _extendStatics(d, b);
  2239. function __() {
  2240. this.constructor = d;
  2241. }
  2242. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2243. };
  2244. }();
  2245. var __assign = this && this.__assign || function () {
  2246. __assign = Object.assign || function (t) {
  2247. for (var s, i = 1, n = arguments.length; i < n; i++) {
  2248. s = arguments[i];
  2249. for (var p in s) {
  2250. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  2251. }
  2252. }
  2253. return t;
  2254. };
  2255. return __assign.apply(this, arguments);
  2256. };
  2257. Object.defineProperty(exports, "__esModule", { value: true });
  2258. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  2259. var constants_1 = __webpack_require__(/*! ../chip/constants */ "./packages/mdc-chips/chip/constants.ts");
  2260. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip-set/constants.ts");
  2261. var MDCChipSetFoundation = /** @class */function (_super) {
  2262. __extends(MDCChipSetFoundation, _super);
  2263. function MDCChipSetFoundation(adapter) {
  2264. var _this = _super.call(this, __assign(__assign({}, MDCChipSetFoundation.defaultAdapter), adapter)) || this;
  2265. /**
  2266. * The ids of the selected chips in the set. Only used for choice chip set or filter chip set.
  2267. */
  2268. _this.selectedChipIds_ = [];
  2269. return _this;
  2270. }
  2271. Object.defineProperty(MDCChipSetFoundation, "strings", {
  2272. get: function get() {
  2273. return constants_2.strings;
  2274. },
  2275. enumerable: true,
  2276. configurable: true
  2277. });
  2278. Object.defineProperty(MDCChipSetFoundation, "cssClasses", {
  2279. get: function get() {
  2280. return constants_2.cssClasses;
  2281. },
  2282. enumerable: true,
  2283. configurable: true
  2284. });
  2285. Object.defineProperty(MDCChipSetFoundation, "defaultAdapter", {
  2286. get: function get() {
  2287. return {
  2288. announceMessage: function announceMessage() {
  2289. return undefined;
  2290. },
  2291. focusChipPrimaryActionAtIndex: function focusChipPrimaryActionAtIndex() {
  2292. return undefined;
  2293. },
  2294. focusChipTrailingActionAtIndex: function focusChipTrailingActionAtIndex() {
  2295. return undefined;
  2296. },
  2297. getChipListCount: function getChipListCount() {
  2298. return -1;
  2299. },
  2300. getIndexOfChipById: function getIndexOfChipById() {
  2301. return -1;
  2302. },
  2303. hasClass: function hasClass() {
  2304. return false;
  2305. },
  2306. isRTL: function isRTL() {
  2307. return false;
  2308. },
  2309. removeChipAtIndex: function removeChipAtIndex() {
  2310. return undefined;
  2311. },
  2312. removeFocusFromChipAtIndex: function removeFocusFromChipAtIndex() {
  2313. return undefined;
  2314. },
  2315. selectChipAtIndex: function selectChipAtIndex() {
  2316. return undefined;
  2317. }
  2318. };
  2319. },
  2320. enumerable: true,
  2321. configurable: true
  2322. });
  2323. /**
  2324. * Returns an array of the IDs of all selected chips.
  2325. */
  2326. MDCChipSetFoundation.prototype.getSelectedChipIds = function () {
  2327. return this.selectedChipIds_.slice();
  2328. };
  2329. /**
  2330. * Selects the chip with the given id. Deselects all other chips if the chip set is of the choice variant.
  2331. * Does not notify clients of the updated selection state.
  2332. */
  2333. MDCChipSetFoundation.prototype.select = function (chipId) {
  2334. this.select_(chipId, false);
  2335. };
  2336. /**
  2337. * Handles a chip interaction event
  2338. */
  2339. MDCChipSetFoundation.prototype.handleChipInteraction = function (_a) {
  2340. var chipId = _a.chipId;
  2341. var index = this.adapter.getIndexOfChipById(chipId);
  2342. this.removeFocusFromChipsExcept_(index);
  2343. if (this.adapter.hasClass(constants_2.cssClasses.CHOICE) || this.adapter.hasClass(constants_2.cssClasses.FILTER)) {
  2344. this.toggleSelect_(chipId);
  2345. }
  2346. };
  2347. /**
  2348. * Handles a chip selection event, used to handle discrepancy when selection state is set directly on the Chip.
  2349. */
  2350. MDCChipSetFoundation.prototype.handleChipSelection = function (_a) {
  2351. var chipId = _a.chipId,
  2352. selected = _a.selected,
  2353. shouldIgnore = _a.shouldIgnore;
  2354. // Early exit if we should ignore the event
  2355. if (shouldIgnore) {
  2356. return;
  2357. }
  2358. var chipIsSelected = this.selectedChipIds_.indexOf(chipId) >= 0;
  2359. if (selected && !chipIsSelected) {
  2360. this.select(chipId);
  2361. } else if (!selected && chipIsSelected) {
  2362. this.deselect_(chipId);
  2363. }
  2364. };
  2365. /**
  2366. * Handles the event when a chip is removed.
  2367. */
  2368. MDCChipSetFoundation.prototype.handleChipRemoval = function (_a) {
  2369. var chipId = _a.chipId,
  2370. removedAnnouncement = _a.removedAnnouncement;
  2371. if (removedAnnouncement) {
  2372. this.adapter.announceMessage(removedAnnouncement);
  2373. }
  2374. var index = this.adapter.getIndexOfChipById(chipId);
  2375. this.deselectAndNotifyClients_(chipId);
  2376. this.adapter.removeChipAtIndex(index);
  2377. var maxIndex = this.adapter.getChipListCount() - 1;
  2378. if (maxIndex < 0) {
  2379. return;
  2380. }
  2381. var nextIndex = Math.min(index, maxIndex);
  2382. this.removeFocusFromChipsExcept_(nextIndex);
  2383. // After removing a chip, we should focus the trailing action for the next chip.
  2384. this.adapter.focusChipTrailingActionAtIndex(nextIndex);
  2385. };
  2386. /**
  2387. * Handles a chip navigation event.
  2388. */
  2389. MDCChipSetFoundation.prototype.handleChipNavigation = function (_a) {
  2390. var chipId = _a.chipId,
  2391. key = _a.key,
  2392. source = _a.source;
  2393. var maxIndex = this.adapter.getChipListCount() - 1;
  2394. var index = this.adapter.getIndexOfChipById(chipId);
  2395. // Early exit if the index is out of range or the key is unusable
  2396. if (index === -1 || !constants_1.navigationKeys.has(key)) {
  2397. return;
  2398. }
  2399. var isRTL = this.adapter.isRTL();
  2400. var isLeftKey = key === constants_1.strings.ARROW_LEFT_KEY || key === constants_1.strings.IE_ARROW_LEFT_KEY;
  2401. var isRightKey = key === constants_1.strings.ARROW_RIGHT_KEY || key === constants_1.strings.IE_ARROW_RIGHT_KEY;
  2402. var isDownKey = key === constants_1.strings.ARROW_DOWN_KEY || key === constants_1.strings.IE_ARROW_DOWN_KEY;
  2403. var shouldIncrement = !isRTL && isRightKey || isRTL && isLeftKey || isDownKey;
  2404. var isHome = key === constants_1.strings.HOME_KEY;
  2405. var isEnd = key === constants_1.strings.END_KEY;
  2406. if (shouldIncrement) {
  2407. index++;
  2408. } else if (isHome) {
  2409. index = 0;
  2410. } else if (isEnd) {
  2411. index = maxIndex;
  2412. } else {
  2413. index--;
  2414. }
  2415. // Early exit if the index is out of bounds
  2416. if (index < 0 || index > maxIndex) {
  2417. return;
  2418. }
  2419. this.removeFocusFromChipsExcept_(index);
  2420. this.focusChipAction_(index, key, source);
  2421. };
  2422. MDCChipSetFoundation.prototype.focusChipAction_ = function (index, key, source) {
  2423. var shouldJumpChips = constants_1.jumpChipKeys.has(key);
  2424. if (shouldJumpChips && source === constants_1.EventSource.PRIMARY) {
  2425. return this.adapter.focusChipPrimaryActionAtIndex(index);
  2426. }
  2427. if (shouldJumpChips && source === constants_1.EventSource.TRAILING) {
  2428. return this.adapter.focusChipTrailingActionAtIndex(index);
  2429. }
  2430. var dir = this.getDirection_(key);
  2431. if (dir === constants_1.Direction.LEFT) {
  2432. return this.adapter.focusChipTrailingActionAtIndex(index);
  2433. }
  2434. if (dir === constants_1.Direction.RIGHT) {
  2435. return this.adapter.focusChipPrimaryActionAtIndex(index);
  2436. }
  2437. };
  2438. MDCChipSetFoundation.prototype.getDirection_ = function (key) {
  2439. var isRTL = this.adapter.isRTL();
  2440. var isLeftKey = key === constants_1.strings.ARROW_LEFT_KEY || key === constants_1.strings.IE_ARROW_LEFT_KEY;
  2441. var isRightKey = key === constants_1.strings.ARROW_RIGHT_KEY || key === constants_1.strings.IE_ARROW_RIGHT_KEY;
  2442. if (!isRTL && isLeftKey || isRTL && isRightKey) {
  2443. return constants_1.Direction.LEFT;
  2444. }
  2445. return constants_1.Direction.RIGHT;
  2446. };
  2447. /**
  2448. * Deselects the chip with the given id and optionally notifies clients.
  2449. */
  2450. MDCChipSetFoundation.prototype.deselect_ = function (chipId, shouldNotifyClients) {
  2451. if (shouldNotifyClients === void 0) {
  2452. shouldNotifyClients = false;
  2453. }
  2454. var index = this.selectedChipIds_.indexOf(chipId);
  2455. if (index >= 0) {
  2456. this.selectedChipIds_.splice(index, 1);
  2457. var chipIndex = this.adapter.getIndexOfChipById(chipId);
  2458. this.adapter.selectChipAtIndex(chipIndex, /** isSelected */false, shouldNotifyClients);
  2459. }
  2460. };
  2461. /**
  2462. * Deselects the chip with the given id and notifies clients.
  2463. */
  2464. MDCChipSetFoundation.prototype.deselectAndNotifyClients_ = function (chipId) {
  2465. this.deselect_(chipId, true);
  2466. };
  2467. /**
  2468. * Toggles selection of the chip with the given id.
  2469. */
  2470. MDCChipSetFoundation.prototype.toggleSelect_ = function (chipId) {
  2471. if (this.selectedChipIds_.indexOf(chipId) >= 0) {
  2472. this.deselectAndNotifyClients_(chipId);
  2473. } else {
  2474. this.selectAndNotifyClients_(chipId);
  2475. }
  2476. };
  2477. MDCChipSetFoundation.prototype.removeFocusFromChipsExcept_ = function (index) {
  2478. var chipCount = this.adapter.getChipListCount();
  2479. for (var i = 0; i < chipCount; i++) {
  2480. if (i !== index) {
  2481. this.adapter.removeFocusFromChipAtIndex(i);
  2482. }
  2483. }
  2484. };
  2485. MDCChipSetFoundation.prototype.selectAndNotifyClients_ = function (chipId) {
  2486. this.select_(chipId, true);
  2487. };
  2488. MDCChipSetFoundation.prototype.select_ = function (chipId, shouldNotifyClients) {
  2489. if (this.selectedChipIds_.indexOf(chipId) >= 0) {
  2490. return;
  2491. }
  2492. if (this.adapter.hasClass(constants_2.cssClasses.CHOICE) && this.selectedChipIds_.length > 0) {
  2493. var previouslySelectedChip = this.selectedChipIds_[0];
  2494. var previouslySelectedIndex = this.adapter.getIndexOfChipById(previouslySelectedChip);
  2495. this.selectedChipIds_ = [];
  2496. this.adapter.selectChipAtIndex(previouslySelectedIndex, /** isSelected */false, shouldNotifyClients);
  2497. }
  2498. this.selectedChipIds_.push(chipId);
  2499. var index = this.adapter.getIndexOfChipById(chipId);
  2500. this.adapter.selectChipAtIndex(index, /** isSelected */true, shouldNotifyClients);
  2501. };
  2502. return MDCChipSetFoundation;
  2503. }(foundation_1.MDCFoundation);
  2504. exports.MDCChipSetFoundation = MDCChipSetFoundation;
  2505. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  2506. exports.default = MDCChipSetFoundation;
  2507. /***/ }),
  2508. /***/ "./packages/mdc-chips/chip-set/index.ts":
  2509. /*!**********************************************!*\
  2510. !*** ./packages/mdc-chips/chip-set/index.ts ***!
  2511. \**********************************************/
  2512. /*! no static exports found */
  2513. /***/ (function(module, exports, __webpack_require__) {
  2514. "use strict";
  2515. /**
  2516. * @license
  2517. * Copyright 2019 Google Inc.
  2518. *
  2519. * Permission is hereby granted, free of charge, to any person obtaining a copy
  2520. * of this software and associated documentation files (the "Software"), to deal
  2521. * in the Software without restriction, including without limitation the rights
  2522. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2523. * copies of the Software, and to permit persons to whom the Software is
  2524. * furnished to do so, subject to the following conditions:
  2525. *
  2526. * The above copyright notice and this permission notice shall be included in
  2527. * all copies or substantial portions of the Software.
  2528. *
  2529. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2530. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2531. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2532. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2533. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2534. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2535. * THE SOFTWARE.
  2536. */
  2537. function __export(m) {
  2538. for (var p in m) {
  2539. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  2540. }
  2541. }
  2542. Object.defineProperty(exports, "__esModule", { value: true });
  2543. __export(__webpack_require__(/*! ./component */ "./packages/mdc-chips/chip-set/component.ts"));
  2544. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip-set/foundation.ts"));
  2545. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip-set/constants.ts");
  2546. exports.chipSetCssClasses = constants_1.cssClasses;
  2547. exports.chipSetStrings = constants_1.strings;
  2548. /***/ }),
  2549. /***/ "./packages/mdc-chips/chip/component.ts":
  2550. /*!**********************************************!*\
  2551. !*** ./packages/mdc-chips/chip/component.ts ***!
  2552. \**********************************************/
  2553. /*! no static exports found */
  2554. /***/ (function(module, exports, __webpack_require__) {
  2555. "use strict";
  2556. /**
  2557. * @license
  2558. * Copyright 2016 Google Inc.
  2559. *
  2560. * Permission is hereby granted, free of charge, to any person obtaining a copy
  2561. * of this software and associated documentation files (the "Software"), to deal
  2562. * in the Software without restriction, including without limitation the rights
  2563. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2564. * copies of the Software, and to permit persons to whom the Software is
  2565. * furnished to do so, subject to the following conditions:
  2566. *
  2567. * The above copyright notice and this permission notice shall be included in
  2568. * all copies or substantial portions of the Software.
  2569. *
  2570. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2571. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2572. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2573. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2574. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2575. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2576. * THE SOFTWARE.
  2577. */
  2578. var __extends = this && this.__extends || function () {
  2579. var _extendStatics = function extendStatics(d, b) {
  2580. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  2581. d.__proto__ = b;
  2582. } || function (d, b) {
  2583. for (var p in b) {
  2584. if (b.hasOwnProperty(p)) d[p] = b[p];
  2585. }
  2586. };
  2587. return _extendStatics(d, b);
  2588. };
  2589. return function (d, b) {
  2590. _extendStatics(d, b);
  2591. function __() {
  2592. this.constructor = d;
  2593. }
  2594. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2595. };
  2596. }();
  2597. var __assign = this && this.__assign || function () {
  2598. __assign = Object.assign || function (t) {
  2599. for (var s, i = 1, n = arguments.length; i < n; i++) {
  2600. s = arguments[i];
  2601. for (var p in s) {
  2602. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  2603. }
  2604. }
  2605. return t;
  2606. };
  2607. return __assign.apply(this, arguments);
  2608. };
  2609. Object.defineProperty(exports, "__esModule", { value: true });
  2610. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  2611. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  2612. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  2613. var component_3 = __webpack_require__(/*! ../trailingaction/component */ "./packages/mdc-chips/trailingaction/component.ts");
  2614. var constants_1 = __webpack_require__(/*! ../trailingaction/constants */ "./packages/mdc-chips/trailingaction/constants.ts");
  2615. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip/constants.ts");
  2616. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip/foundation.ts");
  2617. var MDCChip = /** @class */function (_super) {
  2618. __extends(MDCChip, _super);
  2619. function MDCChip() {
  2620. return _super !== null && _super.apply(this, arguments) || this;
  2621. }
  2622. Object.defineProperty(MDCChip.prototype, "selected", {
  2623. /**
  2624. * @return Whether the chip is selected.
  2625. */
  2626. get: function get() {
  2627. return this.foundation.isSelected();
  2628. },
  2629. /**
  2630. * Sets selected state on the chip.
  2631. */
  2632. set: function set(selected) {
  2633. this.foundation.setSelected(selected);
  2634. },
  2635. enumerable: true,
  2636. configurable: true
  2637. });
  2638. Object.defineProperty(MDCChip.prototype, "shouldRemoveOnTrailingIconClick", {
  2639. /**
  2640. * @return Whether a trailing icon click should trigger exit/removal of the chip.
  2641. */
  2642. get: function get() {
  2643. return this.foundation.getShouldRemoveOnTrailingIconClick();
  2644. },
  2645. /**
  2646. * Sets whether a trailing icon click should trigger exit/removal of the chip.
  2647. */
  2648. set: function set(shouldRemove) {
  2649. this.foundation.setShouldRemoveOnTrailingIconClick(shouldRemove);
  2650. },
  2651. enumerable: true,
  2652. configurable: true
  2653. });
  2654. Object.defineProperty(MDCChip.prototype, "setShouldFocusPrimaryActionOnClick", {
  2655. /**
  2656. * Sets whether a clicking on the chip should focus the primary action.
  2657. */
  2658. set: function set(shouldFocus) {
  2659. this.foundation.setShouldFocusPrimaryActionOnClick(shouldFocus);
  2660. },
  2661. enumerable: true,
  2662. configurable: true
  2663. });
  2664. Object.defineProperty(MDCChip.prototype, "ripple", {
  2665. get: function get() {
  2666. return this.ripple_;
  2667. },
  2668. enumerable: true,
  2669. configurable: true
  2670. });
  2671. Object.defineProperty(MDCChip.prototype, "id", {
  2672. get: function get() {
  2673. return this.root.id;
  2674. },
  2675. enumerable: true,
  2676. configurable: true
  2677. });
  2678. MDCChip.attachTo = function (root) {
  2679. return new MDCChip(root);
  2680. };
  2681. MDCChip.prototype.initialize = function (rippleFactory, trailingActionFactory) {
  2682. var _this = this;
  2683. if (rippleFactory === void 0) {
  2684. rippleFactory = function rippleFactory(el, foundation) {
  2685. return new component_2.MDCRipple(el, foundation);
  2686. };
  2687. }
  2688. if (trailingActionFactory === void 0) {
  2689. trailingActionFactory = function trailingActionFactory(el) {
  2690. return new component_3.MDCChipTrailingAction(el);
  2691. };
  2692. }
  2693. this.leadingIcon_ = this.root.querySelector(constants_2.strings.LEADING_ICON_SELECTOR);
  2694. this.checkmark_ = this.root.querySelector(constants_2.strings.CHECKMARK_SELECTOR);
  2695. this.primaryAction_ = this.root.querySelector(constants_2.strings.PRIMARY_ACTION_SELECTOR);
  2696. var trailingActionEl = this.root.querySelector(constants_2.strings.TRAILING_ACTION_SELECTOR);
  2697. if (trailingActionEl) {
  2698. this.trailingAction_ = trailingActionFactory(trailingActionEl);
  2699. }
  2700. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  2701. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  2702. var rippleAdapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { computeBoundingRect: function computeBoundingRect() {
  2703. return _this.foundation.getDimensions();
  2704. } });
  2705. this.ripple_ = rippleFactory(this.root, new foundation_1.MDCRippleFoundation(rippleAdapter));
  2706. };
  2707. MDCChip.prototype.initialSyncWithDOM = function () {
  2708. var _this = this;
  2709. // Custom events
  2710. this.handleTrailingActionInteraction_ = function () {
  2711. _this.foundation.handleTrailingActionInteraction();
  2712. };
  2713. this.handleTrailingActionNavigation_ = function (evt) {
  2714. _this.foundation.handleTrailingActionNavigation(evt);
  2715. };
  2716. // Native events
  2717. this.handleClick_ = function () {
  2718. _this.foundation.handleClick();
  2719. };
  2720. this.handleKeydown_ = function (evt) {
  2721. _this.foundation.handleKeydown(evt);
  2722. };
  2723. this.handleTransitionEnd_ = function (evt) {
  2724. _this.foundation.handleTransitionEnd(evt);
  2725. };
  2726. this.handleFocusIn_ = function (evt) {
  2727. _this.foundation.handleFocusIn(evt);
  2728. };
  2729. this.handleFocusOut_ = function (evt) {
  2730. _this.foundation.handleFocusOut(evt);
  2731. };
  2732. this.listen('transitionend', this.handleTransitionEnd_);
  2733. this.listen('click', this.handleClick_);
  2734. this.listen('keydown', this.handleKeydown_);
  2735. this.listen('focusin', this.handleFocusIn_);
  2736. this.listen('focusout', this.handleFocusOut_);
  2737. if (this.trailingAction_) {
  2738. this.listen(constants_1.strings.INTERACTION_EVENT, this.handleTrailingActionInteraction_);
  2739. this.listen(constants_1.strings.NAVIGATION_EVENT, this.handleTrailingActionNavigation_);
  2740. }
  2741. };
  2742. MDCChip.prototype.destroy = function () {
  2743. this.ripple_.destroy();
  2744. this.unlisten('transitionend', this.handleTransitionEnd_);
  2745. this.unlisten('keydown', this.handleKeydown_);
  2746. this.unlisten('click', this.handleClick_);
  2747. this.unlisten('focusin', this.handleFocusIn_);
  2748. this.unlisten('focusout', this.handleFocusOut_);
  2749. if (this.trailingAction_) {
  2750. this.unlisten(constants_1.strings.INTERACTION_EVENT, this.handleTrailingActionInteraction_);
  2751. this.unlisten(constants_1.strings.NAVIGATION_EVENT, this.handleTrailingActionNavigation_);
  2752. }
  2753. _super.prototype.destroy.call(this);
  2754. };
  2755. /**
  2756. * Begins the exit animation which leads to removal of the chip.
  2757. */
  2758. MDCChip.prototype.beginExit = function () {
  2759. this.foundation.beginExit();
  2760. };
  2761. MDCChip.prototype.getDefaultFoundation = function () {
  2762. var _this = this;
  2763. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  2764. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  2765. var adapter = {
  2766. addClass: function addClass(className) {
  2767. return _this.root.classList.add(className);
  2768. },
  2769. addClassToLeadingIcon: function addClassToLeadingIcon(className) {
  2770. if (_this.leadingIcon_) {
  2771. _this.leadingIcon_.classList.add(className);
  2772. }
  2773. },
  2774. eventTargetHasClass: function eventTargetHasClass(target, className) {
  2775. return target ? target.classList.contains(className) : false;
  2776. },
  2777. focusPrimaryAction: function focusPrimaryAction() {
  2778. if (_this.primaryAction_) {
  2779. _this.primaryAction_.focus();
  2780. }
  2781. },
  2782. focusTrailingAction: function focusTrailingAction() {
  2783. if (_this.trailingAction_) {
  2784. _this.trailingAction_.focus();
  2785. }
  2786. },
  2787. getAttribute: function getAttribute(attr) {
  2788. return _this.root.getAttribute(attr);
  2789. },
  2790. getCheckmarkBoundingClientRect: function getCheckmarkBoundingClientRect() {
  2791. return _this.checkmark_ ? _this.checkmark_.getBoundingClientRect() : null;
  2792. },
  2793. getComputedStyleValue: function getComputedStyleValue(propertyName) {
  2794. return window.getComputedStyle(_this.root).getPropertyValue(propertyName);
  2795. },
  2796. getRootBoundingClientRect: function getRootBoundingClientRect() {
  2797. return _this.root.getBoundingClientRect();
  2798. },
  2799. hasClass: function hasClass(className) {
  2800. return _this.root.classList.contains(className);
  2801. },
  2802. hasLeadingIcon: function hasLeadingIcon() {
  2803. return !!_this.leadingIcon_;
  2804. },
  2805. isRTL: function isRTL() {
  2806. return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
  2807. },
  2808. isTrailingActionNavigable: function isTrailingActionNavigable() {
  2809. if (_this.trailingAction_) {
  2810. return _this.trailingAction_.isNavigable();
  2811. }
  2812. return false;
  2813. },
  2814. notifyInteraction: function notifyInteraction() {
  2815. return _this.emit(constants_2.strings.INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */);
  2816. },
  2817. notifyNavigation: function notifyNavigation(key, source) {
  2818. return _this.emit(constants_2.strings.NAVIGATION_EVENT, { chipId: _this.id, key: key, source: source }, true /* shouldBubble */);
  2819. },
  2820. notifyRemoval: function notifyRemoval(removedAnnouncement) {
  2821. _this.emit(constants_2.strings.REMOVAL_EVENT, { chipId: _this.id, removedAnnouncement: removedAnnouncement }, true /* shouldBubble */);
  2822. },
  2823. notifySelection: function notifySelection(selected, shouldIgnore) {
  2824. return _this.emit(constants_2.strings.SELECTION_EVENT, { chipId: _this.id, selected: selected, shouldIgnore: shouldIgnore }, true /* shouldBubble */);
  2825. },
  2826. notifyTrailingIconInteraction: function notifyTrailingIconInteraction() {
  2827. return _this.emit(constants_2.strings.TRAILING_ICON_INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */);
  2828. },
  2829. notifyEditStart: function notifyEditStart() {},
  2830. notifyEditFinish: function notifyEditFinish() {},
  2831. removeClass: function removeClass(className) {
  2832. return _this.root.classList.remove(className);
  2833. },
  2834. removeClassFromLeadingIcon: function removeClassFromLeadingIcon(className) {
  2835. if (_this.leadingIcon_) {
  2836. _this.leadingIcon_.classList.remove(className);
  2837. }
  2838. },
  2839. removeTrailingActionFocus: function removeTrailingActionFocus() {
  2840. if (_this.trailingAction_) {
  2841. _this.trailingAction_.removeFocus();
  2842. }
  2843. },
  2844. setPrimaryActionAttr: function setPrimaryActionAttr(attr, value) {
  2845. if (_this.primaryAction_) {
  2846. _this.primaryAction_.setAttribute(attr, value);
  2847. }
  2848. },
  2849. setStyleProperty: function setStyleProperty(propertyName, value) {
  2850. return _this.root.style.setProperty(propertyName, value);
  2851. }
  2852. };
  2853. return new foundation_2.MDCChipFoundation(adapter);
  2854. };
  2855. MDCChip.prototype.setSelectedFromChipSet = function (selected, shouldNotifyClients) {
  2856. this.foundation.setSelectedFromChipSet(selected, shouldNotifyClients);
  2857. };
  2858. MDCChip.prototype.focusPrimaryAction = function () {
  2859. this.foundation.focusPrimaryAction();
  2860. };
  2861. MDCChip.prototype.focusTrailingAction = function () {
  2862. this.foundation.focusTrailingAction();
  2863. };
  2864. MDCChip.prototype.removeFocus = function () {
  2865. this.foundation.removeFocus();
  2866. };
  2867. MDCChip.prototype.remove = function () {
  2868. var parent = this.root.parentNode;
  2869. if (parent !== null) {
  2870. parent.removeChild(this.root);
  2871. }
  2872. };
  2873. return MDCChip;
  2874. }(component_1.MDCComponent);
  2875. exports.MDCChip = MDCChip;
  2876. /***/ }),
  2877. /***/ "./packages/mdc-chips/chip/constants.ts":
  2878. /*!**********************************************!*\
  2879. !*** ./packages/mdc-chips/chip/constants.ts ***!
  2880. \**********************************************/
  2881. /*! no static exports found */
  2882. /***/ (function(module, exports, __webpack_require__) {
  2883. "use strict";
  2884. /**
  2885. * @license
  2886. * Copyright 2016 Google Inc.
  2887. *
  2888. * Permission is hereby granted, free of charge, to any person obtaining a copy
  2889. * of this software and associated documentation files (the "Software"), to deal
  2890. * in the Software without restriction, including without limitation the rights
  2891. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  2892. * copies of the Software, and to permit persons to whom the Software is
  2893. * furnished to do so, subject to the following conditions:
  2894. *
  2895. * The above copyright notice and this permission notice shall be included in
  2896. * all copies or substantial portions of the Software.
  2897. *
  2898. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2899. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  2900. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  2901. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  2902. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  2903. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  2904. * THE SOFTWARE.
  2905. */
  2906. Object.defineProperty(exports, "__esModule", { value: true });
  2907. var Direction;
  2908. (function (Direction) {
  2909. Direction["LEFT"] = "left";
  2910. Direction["RIGHT"] = "right";
  2911. })(Direction = exports.Direction || (exports.Direction = {}));
  2912. var EventSource;
  2913. (function (EventSource) {
  2914. EventSource["PRIMARY"] = "primary";
  2915. EventSource["TRAILING"] = "trailing";
  2916. EventSource["NONE"] = "none";
  2917. })(EventSource = exports.EventSource || (exports.EventSource = {}));
  2918. exports.strings = {
  2919. ADDED_ANNOUNCEMENT_ATTRIBUTE: 'data-mdc-chip-added-announcement',
  2920. ARIA_CHECKED: 'aria-checked',
  2921. ARROW_DOWN_KEY: 'ArrowDown',
  2922. ARROW_LEFT_KEY: 'ArrowLeft',
  2923. ARROW_RIGHT_KEY: 'ArrowRight',
  2924. ARROW_UP_KEY: 'ArrowUp',
  2925. BACKSPACE_KEY: 'Backspace',
  2926. CHECKMARK_SELECTOR: '.mdc-chip__checkmark',
  2927. DELETE_KEY: 'Delete',
  2928. END_KEY: 'End',
  2929. ENTER_KEY: 'Enter',
  2930. ENTRY_ANIMATION_NAME: 'mdc-chip-entry',
  2931. HOME_KEY: 'Home',
  2932. IE_ARROW_DOWN_KEY: 'Down',
  2933. IE_ARROW_LEFT_KEY: 'Left',
  2934. IE_ARROW_RIGHT_KEY: 'Right',
  2935. IE_ARROW_UP_KEY: 'Up',
  2936. IE_DELETE_KEY: 'Del',
  2937. INTERACTION_EVENT: 'MDCChip:interaction',
  2938. LEADING_ICON_SELECTOR: '.mdc-chip__icon--leading',
  2939. NAVIGATION_EVENT: 'MDCChip:navigation',
  2940. PRIMARY_ACTION_SELECTOR: '.mdc-chip__primary-action',
  2941. REMOVED_ANNOUNCEMENT_ATTRIBUTE: 'data-mdc-chip-removed-announcement',
  2942. REMOVAL_EVENT: 'MDCChip:removal',
  2943. SELECTION_EVENT: 'MDCChip:selection',
  2944. SPACEBAR_KEY: ' ',
  2945. TAB_INDEX: 'tabindex',
  2946. TRAILING_ACTION_SELECTOR: '.mdc-chip-trailing-action',
  2947. TRAILING_ICON_INTERACTION_EVENT: 'MDCChip:trailingIconInteraction',
  2948. TRAILING_ICON_SELECTOR: '.mdc-chip__icon--trailing'
  2949. };
  2950. exports.cssClasses = {
  2951. CHECKMARK: 'mdc-chip__checkmark',
  2952. CHIP_EXIT: 'mdc-chip--exit',
  2953. DELETABLE: 'mdc-chip--deletable',
  2954. EDITABLE: 'mdc-chip--editable',
  2955. EDITING: 'mdc-chip--editing',
  2956. HIDDEN_LEADING_ICON: 'mdc-chip__icon--leading-hidden',
  2957. LEADING_ICON: 'mdc-chip__icon--leading',
  2958. PRIMARY_ACTION: 'mdc-chip__primary-action',
  2959. PRIMARY_ACTION_FOCUSED: 'mdc-chip--primary-action-focused',
  2960. SELECTED: 'mdc-chip--selected',
  2961. TEXT: 'mdc-chip__text',
  2962. TRAILING_ACTION: 'mdc-chip__trailing-action',
  2963. TRAILING_ICON: 'mdc-chip__icon--trailing'
  2964. };
  2965. exports.navigationKeys = new Set();
  2966. // IE11 has no support for new Set with iterable so we need to initialize this by hand
  2967. exports.navigationKeys.add(exports.strings.ARROW_LEFT_KEY);
  2968. exports.navigationKeys.add(exports.strings.ARROW_RIGHT_KEY);
  2969. exports.navigationKeys.add(exports.strings.ARROW_DOWN_KEY);
  2970. exports.navigationKeys.add(exports.strings.ARROW_UP_KEY);
  2971. exports.navigationKeys.add(exports.strings.END_KEY);
  2972. exports.navigationKeys.add(exports.strings.HOME_KEY);
  2973. exports.navigationKeys.add(exports.strings.IE_ARROW_LEFT_KEY);
  2974. exports.navigationKeys.add(exports.strings.IE_ARROW_RIGHT_KEY);
  2975. exports.navigationKeys.add(exports.strings.IE_ARROW_DOWN_KEY);
  2976. exports.navigationKeys.add(exports.strings.IE_ARROW_UP_KEY);
  2977. exports.jumpChipKeys = new Set();
  2978. // IE11 has no support for new Set with iterable so we need to initialize this by hand
  2979. exports.jumpChipKeys.add(exports.strings.ARROW_UP_KEY);
  2980. exports.jumpChipKeys.add(exports.strings.ARROW_DOWN_KEY);
  2981. exports.jumpChipKeys.add(exports.strings.HOME_KEY);
  2982. exports.jumpChipKeys.add(exports.strings.END_KEY);
  2983. exports.jumpChipKeys.add(exports.strings.IE_ARROW_UP_KEY);
  2984. exports.jumpChipKeys.add(exports.strings.IE_ARROW_DOWN_KEY);
  2985. /***/ }),
  2986. /***/ "./packages/mdc-chips/chip/foundation.ts":
  2987. /*!***********************************************!*\
  2988. !*** ./packages/mdc-chips/chip/foundation.ts ***!
  2989. \***********************************************/
  2990. /*! no static exports found */
  2991. /***/ (function(module, exports, __webpack_require__) {
  2992. "use strict";
  2993. /**
  2994. * @license
  2995. * Copyright 2016 Google Inc.
  2996. *
  2997. * Permission is hereby granted, free of charge, to any person obtaining a copy
  2998. * of this software and associated documentation files (the "Software"), to deal
  2999. * in the Software without restriction, including without limitation the rights
  3000. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3001. * copies of the Software, and to permit persons to whom the Software is
  3002. * furnished to do so, subject to the following conditions:
  3003. *
  3004. * The above copyright notice and this permission notice shall be included in
  3005. * all copies or substantial portions of the Software.
  3006. *
  3007. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3008. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3009. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3010. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3011. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3012. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3013. * THE SOFTWARE.
  3014. */
  3015. var __extends = this && this.__extends || function () {
  3016. var _extendStatics = function extendStatics(d, b) {
  3017. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  3018. d.__proto__ = b;
  3019. } || function (d, b) {
  3020. for (var p in b) {
  3021. if (b.hasOwnProperty(p)) d[p] = b[p];
  3022. }
  3023. };
  3024. return _extendStatics(d, b);
  3025. };
  3026. return function (d, b) {
  3027. _extendStatics(d, b);
  3028. function __() {
  3029. this.constructor = d;
  3030. }
  3031. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3032. };
  3033. }();
  3034. var __assign = this && this.__assign || function () {
  3035. __assign = Object.assign || function (t) {
  3036. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3037. s = arguments[i];
  3038. for (var p in s) {
  3039. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  3040. }
  3041. }
  3042. return t;
  3043. };
  3044. return __assign.apply(this, arguments);
  3045. };
  3046. Object.defineProperty(exports, "__esModule", { value: true });
  3047. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  3048. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip/constants.ts");
  3049. var emptyClientRect = {
  3050. bottom: 0,
  3051. height: 0,
  3052. left: 0,
  3053. right: 0,
  3054. top: 0,
  3055. width: 0
  3056. };
  3057. var FocusBehavior;
  3058. (function (FocusBehavior) {
  3059. FocusBehavior[FocusBehavior["SHOULD_FOCUS"] = 0] = "SHOULD_FOCUS";
  3060. FocusBehavior[FocusBehavior["SHOULD_NOT_FOCUS"] = 1] = "SHOULD_NOT_FOCUS";
  3061. })(FocusBehavior || (FocusBehavior = {}));
  3062. var MDCChipFoundation = /** @class */function (_super) {
  3063. __extends(MDCChipFoundation, _super);
  3064. function MDCChipFoundation(adapter) {
  3065. var _this = _super.call(this, __assign(__assign({}, MDCChipFoundation.defaultAdapter), adapter)) || this;
  3066. /** Whether a trailing icon click should immediately trigger exit/removal of the chip. */
  3067. _this.shouldRemoveOnTrailingIconClick_ = true;
  3068. /**
  3069. * Whether the primary action should receive focus on click. Should only be
  3070. * set to true for clients who programmatically give focus to a different
  3071. * element on the page when a chip is clicked (like a menu).
  3072. */
  3073. _this.shouldFocusPrimaryActionOnClick_ = true;
  3074. return _this;
  3075. }
  3076. Object.defineProperty(MDCChipFoundation, "strings", {
  3077. get: function get() {
  3078. return constants_1.strings;
  3079. },
  3080. enumerable: true,
  3081. configurable: true
  3082. });
  3083. Object.defineProperty(MDCChipFoundation, "cssClasses", {
  3084. get: function get() {
  3085. return constants_1.cssClasses;
  3086. },
  3087. enumerable: true,
  3088. configurable: true
  3089. });
  3090. Object.defineProperty(MDCChipFoundation, "defaultAdapter", {
  3091. get: function get() {
  3092. return {
  3093. addClass: function addClass() {
  3094. return undefined;
  3095. },
  3096. addClassToLeadingIcon: function addClassToLeadingIcon() {
  3097. return undefined;
  3098. },
  3099. eventTargetHasClass: function eventTargetHasClass() {
  3100. return false;
  3101. },
  3102. focusPrimaryAction: function focusPrimaryAction() {
  3103. return undefined;
  3104. },
  3105. focusTrailingAction: function focusTrailingAction() {
  3106. return undefined;
  3107. },
  3108. getAttribute: function getAttribute() {
  3109. return null;
  3110. },
  3111. getCheckmarkBoundingClientRect: function getCheckmarkBoundingClientRect() {
  3112. return emptyClientRect;
  3113. },
  3114. getComputedStyleValue: function getComputedStyleValue() {
  3115. return '';
  3116. },
  3117. getRootBoundingClientRect: function getRootBoundingClientRect() {
  3118. return emptyClientRect;
  3119. },
  3120. hasClass: function hasClass() {
  3121. return false;
  3122. },
  3123. hasLeadingIcon: function hasLeadingIcon() {
  3124. return false;
  3125. },
  3126. isRTL: function isRTL() {
  3127. return false;
  3128. },
  3129. isTrailingActionNavigable: function isTrailingActionNavigable() {
  3130. return false;
  3131. },
  3132. notifyEditFinish: function notifyEditFinish() {
  3133. return undefined;
  3134. },
  3135. notifyEditStart: function notifyEditStart() {
  3136. return undefined;
  3137. },
  3138. notifyInteraction: function notifyInteraction() {
  3139. return undefined;
  3140. },
  3141. notifyNavigation: function notifyNavigation() {
  3142. return undefined;
  3143. },
  3144. notifyRemoval: function notifyRemoval() {
  3145. return undefined;
  3146. },
  3147. notifySelection: function notifySelection() {
  3148. return undefined;
  3149. },
  3150. notifyTrailingIconInteraction: function notifyTrailingIconInteraction() {
  3151. return undefined;
  3152. },
  3153. removeClass: function removeClass() {
  3154. return undefined;
  3155. },
  3156. removeClassFromLeadingIcon: function removeClassFromLeadingIcon() {
  3157. return undefined;
  3158. },
  3159. removeTrailingActionFocus: function removeTrailingActionFocus() {
  3160. return undefined;
  3161. },
  3162. setPrimaryActionAttr: function setPrimaryActionAttr() {
  3163. return undefined;
  3164. },
  3165. setStyleProperty: function setStyleProperty() {
  3166. return undefined;
  3167. }
  3168. };
  3169. },
  3170. enumerable: true,
  3171. configurable: true
  3172. });
  3173. MDCChipFoundation.prototype.isSelected = function () {
  3174. return this.adapter.hasClass(constants_1.cssClasses.SELECTED);
  3175. };
  3176. MDCChipFoundation.prototype.isEditable = function () {
  3177. return this.adapter.hasClass(constants_1.cssClasses.EDITABLE);
  3178. };
  3179. MDCChipFoundation.prototype.isEditing = function () {
  3180. return this.adapter.hasClass(constants_1.cssClasses.EDITING);
  3181. };
  3182. MDCChipFoundation.prototype.setSelected = function (selected) {
  3183. this.setSelected_(selected);
  3184. this.notifySelection_(selected);
  3185. };
  3186. MDCChipFoundation.prototype.setSelectedFromChipSet = function (selected, shouldNotifyClients) {
  3187. this.setSelected_(selected);
  3188. if (shouldNotifyClients) {
  3189. this.notifyIgnoredSelection_(selected);
  3190. }
  3191. };
  3192. MDCChipFoundation.prototype.getShouldRemoveOnTrailingIconClick = function () {
  3193. return this.shouldRemoveOnTrailingIconClick_;
  3194. };
  3195. MDCChipFoundation.prototype.setShouldRemoveOnTrailingIconClick = function (shouldRemove) {
  3196. this.shouldRemoveOnTrailingIconClick_ = shouldRemove;
  3197. };
  3198. MDCChipFoundation.prototype.setShouldFocusPrimaryActionOnClick = function (shouldFocus) {
  3199. this.shouldFocusPrimaryActionOnClick_ = shouldFocus;
  3200. };
  3201. MDCChipFoundation.prototype.getDimensions = function () {
  3202. var _this = this;
  3203. var getRootRect = function getRootRect() {
  3204. return _this.adapter.getRootBoundingClientRect();
  3205. };
  3206. var getCheckmarkRect = function getCheckmarkRect() {
  3207. return _this.adapter.getCheckmarkBoundingClientRect();
  3208. };
  3209. // When a chip has a checkmark and not a leading icon, the bounding rect changes in size depending on the current
  3210. // size of the checkmark.
  3211. if (!this.adapter.hasLeadingIcon()) {
  3212. var checkmarkRect = getCheckmarkRect();
  3213. if (checkmarkRect) {
  3214. var rootRect = getRootRect();
  3215. // Checkmark is a square, meaning the client rect's width and height are identical once the animation completes.
  3216. // However, the checkbox is initially hidden by setting the width to 0.
  3217. // To account for an initial width of 0, we use the checkbox's height instead (which equals the end-state width)
  3218. // when adding it to the root client rect's width.
  3219. return {
  3220. bottom: rootRect.bottom,
  3221. height: rootRect.height,
  3222. left: rootRect.left,
  3223. right: rootRect.right,
  3224. top: rootRect.top,
  3225. width: rootRect.width + checkmarkRect.height
  3226. };
  3227. }
  3228. }
  3229. return getRootRect();
  3230. };
  3231. /**
  3232. * Begins the exit animation which leads to removal of the chip.
  3233. */
  3234. MDCChipFoundation.prototype.beginExit = function () {
  3235. this.adapter.addClass(constants_1.cssClasses.CHIP_EXIT);
  3236. };
  3237. MDCChipFoundation.prototype.handleClick = function () {
  3238. this.adapter.notifyInteraction();
  3239. this.setPrimaryActionFocusable_(this.getFocusBehavior_());
  3240. };
  3241. MDCChipFoundation.prototype.handleDoubleClick = function () {
  3242. if (this.isEditable()) {
  3243. this.startEditing();
  3244. }
  3245. };
  3246. /**
  3247. * Handles a transition end event on the root element.
  3248. */
  3249. MDCChipFoundation.prototype.handleTransitionEnd = function (evt) {
  3250. var _this = this;
  3251. // Handle transition end event on the chip when it is about to be removed.
  3252. var shouldHandle = this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.CHIP_EXIT);
  3253. var widthIsAnimating = evt.propertyName === 'width';
  3254. var opacityIsAnimating = evt.propertyName === 'opacity';
  3255. if (shouldHandle && opacityIsAnimating) {
  3256. // See: https://css-tricks.com/using-css-transitions-auto-dimensions/#article-header-id-5
  3257. var chipWidth_1 = this.adapter.getComputedStyleValue('width');
  3258. // On the next frame (once we get the computed width), explicitly set the chip's width
  3259. // to its current pixel width, so we aren't transitioning out of 'auto'.
  3260. requestAnimationFrame(function () {
  3261. _this.adapter.setStyleProperty('width', chipWidth_1);
  3262. // To mitigate jitter, start transitioning padding and margin before width.
  3263. _this.adapter.setStyleProperty('padding', '0');
  3264. _this.adapter.setStyleProperty('margin', '0');
  3265. // On the next frame (once width is explicitly set), transition width to 0.
  3266. requestAnimationFrame(function () {
  3267. _this.adapter.setStyleProperty('width', '0');
  3268. });
  3269. });
  3270. return;
  3271. }
  3272. if (shouldHandle && widthIsAnimating) {
  3273. this.removeFocus();
  3274. var removedAnnouncement = this.adapter.getAttribute(constants_1.strings.REMOVED_ANNOUNCEMENT_ATTRIBUTE);
  3275. this.adapter.notifyRemoval(removedAnnouncement);
  3276. }
  3277. // Handle a transition end event on the leading icon or checkmark, since the transition end event bubbles.
  3278. if (!opacityIsAnimating) {
  3279. return;
  3280. }
  3281. var shouldHideLeadingIcon = this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.LEADING_ICON) && this.adapter.hasClass(constants_1.cssClasses.SELECTED);
  3282. var shouldShowLeadingIcon = this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.CHECKMARK) && !this.adapter.hasClass(constants_1.cssClasses.SELECTED);
  3283. if (shouldHideLeadingIcon) {
  3284. this.adapter.addClassToLeadingIcon(constants_1.cssClasses.HIDDEN_LEADING_ICON);
  3285. return;
  3286. }
  3287. if (shouldShowLeadingIcon) {
  3288. this.adapter.removeClassFromLeadingIcon(constants_1.cssClasses.HIDDEN_LEADING_ICON);
  3289. return;
  3290. }
  3291. };
  3292. MDCChipFoundation.prototype.handleFocusIn = function (evt) {
  3293. // Early exit if the event doesn't come from the primary action
  3294. if (!this.eventFromPrimaryAction_(evt)) {
  3295. return;
  3296. }
  3297. this.adapter.addClass(constants_1.cssClasses.PRIMARY_ACTION_FOCUSED);
  3298. };
  3299. MDCChipFoundation.prototype.handleFocusOut = function (evt) {
  3300. // Early exit if the event doesn't come from the primary action
  3301. if (!this.eventFromPrimaryAction_(evt)) {
  3302. return;
  3303. }
  3304. if (this.isEditing()) {
  3305. this.finishEditing();
  3306. }
  3307. this.adapter.removeClass(constants_1.cssClasses.PRIMARY_ACTION_FOCUSED);
  3308. };
  3309. /**
  3310. * Handles an interaction event on the trailing icon element. This is used to
  3311. * prevent the ripple from activating on interaction with the trailing icon.
  3312. */
  3313. MDCChipFoundation.prototype.handleTrailingActionInteraction = function () {
  3314. this.adapter.notifyTrailingIconInteraction();
  3315. this.removeChip_();
  3316. };
  3317. /**
  3318. * Handles a keydown event from the root element.
  3319. */
  3320. MDCChipFoundation.prototype.handleKeydown = function (evt) {
  3321. if (this.isEditing()) {
  3322. if (this.shouldFinishEditing(evt)) {
  3323. evt.preventDefault();
  3324. this.finishEditing();
  3325. }
  3326. // When editing, the foundation should only handle key events that finish
  3327. // the editing process.
  3328. return;
  3329. }
  3330. if (this.isEditable()) {
  3331. if (this.shouldStartEditing(evt)) {
  3332. evt.preventDefault();
  3333. this.startEditing();
  3334. }
  3335. }
  3336. if (this.shouldNotifyInteraction_(evt)) {
  3337. this.adapter.notifyInteraction();
  3338. this.setPrimaryActionFocusable_(this.getFocusBehavior_());
  3339. return;
  3340. }
  3341. if (this.isDeleteAction_(evt)) {
  3342. evt.preventDefault();
  3343. this.removeChip_();
  3344. return;
  3345. }
  3346. // Early exit if the key is not usable
  3347. if (!constants_1.navigationKeys.has(evt.key)) {
  3348. return;
  3349. }
  3350. // Prevent default behavior for movement keys which could include scrolling
  3351. evt.preventDefault();
  3352. this.focusNextAction_(evt.key, constants_1.EventSource.PRIMARY);
  3353. };
  3354. MDCChipFoundation.prototype.handleTrailingActionNavigation = function (evt) {
  3355. return this.focusNextAction_(evt.detail.key, constants_1.EventSource.TRAILING);
  3356. };
  3357. /**
  3358. * Called by the chip set to remove focus from the chip actions.
  3359. */
  3360. MDCChipFoundation.prototype.removeFocus = function () {
  3361. this.adapter.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '-1');
  3362. this.adapter.removeTrailingActionFocus();
  3363. };
  3364. /**
  3365. * Called by the chip set to focus the primary action.
  3366. *
  3367. */
  3368. MDCChipFoundation.prototype.focusPrimaryAction = function () {
  3369. this.setPrimaryActionFocusable_(FocusBehavior.SHOULD_FOCUS);
  3370. };
  3371. /**
  3372. * Called by the chip set to focus the trailing action (if present), otherwise
  3373. * gives focus to the trailing action.
  3374. */
  3375. MDCChipFoundation.prototype.focusTrailingAction = function () {
  3376. var trailingActionIsNavigable = this.adapter.isTrailingActionNavigable();
  3377. if (trailingActionIsNavigable) {
  3378. this.adapter.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '-1');
  3379. this.adapter.focusTrailingAction();
  3380. return;
  3381. }
  3382. this.focusPrimaryAction();
  3383. };
  3384. MDCChipFoundation.prototype.setPrimaryActionFocusable_ = function (focusBehavior) {
  3385. this.adapter.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '0');
  3386. if (focusBehavior === FocusBehavior.SHOULD_FOCUS) {
  3387. this.adapter.focusPrimaryAction();
  3388. }
  3389. this.adapter.removeTrailingActionFocus();
  3390. };
  3391. MDCChipFoundation.prototype.getFocusBehavior_ = function () {
  3392. if (this.shouldFocusPrimaryActionOnClick_) {
  3393. return FocusBehavior.SHOULD_FOCUS;
  3394. }
  3395. return FocusBehavior.SHOULD_NOT_FOCUS;
  3396. };
  3397. MDCChipFoundation.prototype.focusNextAction_ = function (key, source) {
  3398. var isTrailingActionNavigable = this.adapter.isTrailingActionNavigable();
  3399. var dir = this.getDirection_(key);
  3400. // Early exit if the key should jump chips
  3401. if (constants_1.jumpChipKeys.has(key) || !isTrailingActionNavigable) {
  3402. return this.adapter.notifyNavigation(key, source);
  3403. }
  3404. if (source === constants_1.EventSource.PRIMARY && dir === constants_1.Direction.RIGHT) {
  3405. return this.focusTrailingAction();
  3406. }
  3407. if (source === constants_1.EventSource.TRAILING && dir === constants_1.Direction.LEFT) {
  3408. return this.focusPrimaryAction();
  3409. }
  3410. this.adapter.notifyNavigation(key, constants_1.EventSource.NONE);
  3411. };
  3412. MDCChipFoundation.prototype.getDirection_ = function (key) {
  3413. var isRTL = this.adapter.isRTL();
  3414. var isLeftKey = key === constants_1.strings.ARROW_LEFT_KEY || key === constants_1.strings.IE_ARROW_LEFT_KEY;
  3415. var isRightKey = key === constants_1.strings.ARROW_RIGHT_KEY || key === constants_1.strings.IE_ARROW_RIGHT_KEY;
  3416. if (!isRTL && isLeftKey || isRTL && isRightKey) {
  3417. return constants_1.Direction.LEFT;
  3418. }
  3419. return constants_1.Direction.RIGHT;
  3420. };
  3421. MDCChipFoundation.prototype.removeChip_ = function () {
  3422. if (this.shouldRemoveOnTrailingIconClick_) {
  3423. this.beginExit();
  3424. }
  3425. };
  3426. MDCChipFoundation.prototype.shouldStartEditing = function (evt) {
  3427. return this.eventFromPrimaryAction_(evt) && evt.key === constants_1.strings.ENTER_KEY;
  3428. };
  3429. MDCChipFoundation.prototype.shouldFinishEditing = function (evt) {
  3430. return evt.key === constants_1.strings.ENTER_KEY;
  3431. };
  3432. MDCChipFoundation.prototype.shouldNotifyInteraction_ = function (evt) {
  3433. return evt.key === constants_1.strings.ENTER_KEY || evt.key === constants_1.strings.SPACEBAR_KEY;
  3434. };
  3435. MDCChipFoundation.prototype.isDeleteAction_ = function (evt) {
  3436. var isDeletable = this.adapter.hasClass(constants_1.cssClasses.DELETABLE);
  3437. return isDeletable && (evt.key === constants_1.strings.BACKSPACE_KEY || evt.key === constants_1.strings.DELETE_KEY || evt.key === constants_1.strings.IE_DELETE_KEY);
  3438. };
  3439. MDCChipFoundation.prototype.setSelected_ = function (selected) {
  3440. if (selected) {
  3441. this.adapter.addClass(constants_1.cssClasses.SELECTED);
  3442. this.adapter.setPrimaryActionAttr(constants_1.strings.ARIA_CHECKED, 'true');
  3443. } else {
  3444. this.adapter.removeClass(constants_1.cssClasses.SELECTED);
  3445. this.adapter.setPrimaryActionAttr(constants_1.strings.ARIA_CHECKED, 'false');
  3446. }
  3447. };
  3448. MDCChipFoundation.prototype.notifySelection_ = function (selected) {
  3449. this.adapter.notifySelection(selected, false);
  3450. };
  3451. MDCChipFoundation.prototype.notifyIgnoredSelection_ = function (selected) {
  3452. this.adapter.notifySelection(selected, true);
  3453. };
  3454. MDCChipFoundation.prototype.eventFromPrimaryAction_ = function (evt) {
  3455. return this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.PRIMARY_ACTION);
  3456. };
  3457. MDCChipFoundation.prototype.startEditing = function () {
  3458. this.adapter.addClass(constants_1.cssClasses.EDITING);
  3459. this.adapter.notifyEditStart();
  3460. };
  3461. MDCChipFoundation.prototype.finishEditing = function () {
  3462. this.adapter.removeClass(constants_1.cssClasses.EDITING);
  3463. this.adapter.notifyEditFinish();
  3464. };
  3465. return MDCChipFoundation;
  3466. }(foundation_1.MDCFoundation);
  3467. exports.MDCChipFoundation = MDCChipFoundation;
  3468. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  3469. exports.default = MDCChipFoundation;
  3470. /***/ }),
  3471. /***/ "./packages/mdc-chips/chip/index.ts":
  3472. /*!******************************************!*\
  3473. !*** ./packages/mdc-chips/chip/index.ts ***!
  3474. \******************************************/
  3475. /*! no static exports found */
  3476. /***/ (function(module, exports, __webpack_require__) {
  3477. "use strict";
  3478. /**
  3479. * @license
  3480. * Copyright 2019 Google Inc.
  3481. *
  3482. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3483. * of this software and associated documentation files (the "Software"), to deal
  3484. * in the Software without restriction, including without limitation the rights
  3485. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3486. * copies of the Software, and to permit persons to whom the Software is
  3487. * furnished to do so, subject to the following conditions:
  3488. *
  3489. * The above copyright notice and this permission notice shall be included in
  3490. * all copies or substantial portions of the Software.
  3491. *
  3492. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3493. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3494. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3495. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3496. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3497. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3498. * THE SOFTWARE.
  3499. */
  3500. function __export(m) {
  3501. for (var p in m) {
  3502. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  3503. }
  3504. }
  3505. Object.defineProperty(exports, "__esModule", { value: true });
  3506. __export(__webpack_require__(/*! ./component */ "./packages/mdc-chips/chip/component.ts"));
  3507. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip/foundation.ts"));
  3508. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip/constants.ts");
  3509. exports.chipCssClasses = constants_1.cssClasses;
  3510. exports.chipStrings = constants_1.strings;
  3511. /***/ }),
  3512. /***/ "./packages/mdc-chips/index.ts":
  3513. /*!*************************************!*\
  3514. !*** ./packages/mdc-chips/index.ts ***!
  3515. \*************************************/
  3516. /*! no static exports found */
  3517. /***/ (function(module, exports, __webpack_require__) {
  3518. "use strict";
  3519. /**
  3520. * @license
  3521. * Copyright 2019 Google Inc.
  3522. *
  3523. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3524. * of this software and associated documentation files (the "Software"), to deal
  3525. * in the Software without restriction, including without limitation the rights
  3526. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3527. * copies of the Software, and to permit persons to whom the Software is
  3528. * furnished to do so, subject to the following conditions:
  3529. *
  3530. * The above copyright notice and this permission notice shall be included in
  3531. * all copies or substantial portions of the Software.
  3532. *
  3533. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3534. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3535. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3536. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3537. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3538. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3539. * THE SOFTWARE.
  3540. */
  3541. function __export(m) {
  3542. for (var p in m) {
  3543. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  3544. }
  3545. }
  3546. Object.defineProperty(exports, "__esModule", { value: true });
  3547. __export(__webpack_require__(/*! ./trailingaction/index */ "./packages/mdc-chips/trailingaction/index.ts"));
  3548. __export(__webpack_require__(/*! ./chip/index */ "./packages/mdc-chips/chip/index.ts"));
  3549. __export(__webpack_require__(/*! ./chip-set/index */ "./packages/mdc-chips/chip-set/index.ts"));
  3550. /***/ }),
  3551. /***/ "./packages/mdc-chips/trailingaction/component.ts":
  3552. /*!********************************************************!*\
  3553. !*** ./packages/mdc-chips/trailingaction/component.ts ***!
  3554. \********************************************************/
  3555. /*! no static exports found */
  3556. /***/ (function(module, exports, __webpack_require__) {
  3557. "use strict";
  3558. /**
  3559. * @license
  3560. * Copyright 2020 Google Inc.
  3561. *
  3562. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3563. * of this software and associated documentation files (the "Software"), to deal
  3564. * in the Software without restriction, including without limitation the rights
  3565. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3566. * copies of the Software, and to permit persons to whom the Software is
  3567. * furnished to do so, subject to the following conditions:
  3568. *
  3569. * The above copyright notice and this permission notice shall be included in
  3570. * all copies or substantial portions of the Software.
  3571. *
  3572. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3573. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3574. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3575. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3576. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3577. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3578. * THE SOFTWARE.
  3579. */
  3580. var __extends = this && this.__extends || function () {
  3581. var _extendStatics = function extendStatics(d, b) {
  3582. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  3583. d.__proto__ = b;
  3584. } || function (d, b) {
  3585. for (var p in b) {
  3586. if (b.hasOwnProperty(p)) d[p] = b[p];
  3587. }
  3588. };
  3589. return _extendStatics(d, b);
  3590. };
  3591. return function (d, b) {
  3592. _extendStatics(d, b);
  3593. function __() {
  3594. this.constructor = d;
  3595. }
  3596. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3597. };
  3598. }();
  3599. Object.defineProperty(exports, "__esModule", { value: true });
  3600. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  3601. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  3602. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  3603. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/trailingaction/constants.ts");
  3604. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/trailingaction/foundation.ts");
  3605. var MDCChipTrailingAction = /** @class */function (_super) {
  3606. __extends(MDCChipTrailingAction, _super);
  3607. function MDCChipTrailingAction() {
  3608. return _super !== null && _super.apply(this, arguments) || this;
  3609. }
  3610. Object.defineProperty(MDCChipTrailingAction.prototype, "ripple", {
  3611. get: function get() {
  3612. return this.ripple_;
  3613. },
  3614. enumerable: true,
  3615. configurable: true
  3616. });
  3617. MDCChipTrailingAction.attachTo = function (root) {
  3618. return new MDCChipTrailingAction(root);
  3619. };
  3620. MDCChipTrailingAction.prototype.initialize = function (rippleFactory) {
  3621. if (rippleFactory === void 0) {
  3622. rippleFactory = function rippleFactory(el, foundation) {
  3623. return new component_2.MDCRipple(el, foundation);
  3624. };
  3625. }
  3626. // DO NOT INLINE this variable. For backward compatibility, foundations take
  3627. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  3628. // methods, we need a separate, strongly typed adapter variable.
  3629. var rippleAdapter = component_2.MDCRipple.createAdapter(this);
  3630. this.ripple_ = rippleFactory(this.root, new foundation_1.MDCRippleFoundation(rippleAdapter));
  3631. };
  3632. MDCChipTrailingAction.prototype.initialSyncWithDOM = function () {
  3633. var _this = this;
  3634. this.handleClick_ = function (evt) {
  3635. _this.foundation.handleClick(evt);
  3636. };
  3637. this.handleKeydown_ = function (evt) {
  3638. _this.foundation.handleKeydown(evt);
  3639. };
  3640. this.listen('click', this.handleClick_);
  3641. this.listen('keydown', this.handleKeydown_);
  3642. };
  3643. MDCChipTrailingAction.prototype.destroy = function () {
  3644. this.ripple_.destroy();
  3645. this.unlisten('click', this.handleClick_);
  3646. this.unlisten('keydown', this.handleKeydown_);
  3647. _super.prototype.destroy.call(this);
  3648. };
  3649. MDCChipTrailingAction.prototype.getDefaultFoundation = function () {
  3650. var _this = this;
  3651. // DO NOT INLINE this variable. For backward compatibility, foundations take
  3652. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  3653. // methods, we need a separate, strongly typed adapter variable.
  3654. var adapter = {
  3655. focus: function focus() {
  3656. // TODO(b/157231863): Migate MDCComponent#root to HTMLElement
  3657. _this.root.focus();
  3658. },
  3659. getAttribute: function getAttribute(attr) {
  3660. return _this.root.getAttribute(attr);
  3661. },
  3662. notifyInteraction: function notifyInteraction(trigger) {
  3663. return _this.emit(constants_1.strings.INTERACTION_EVENT, { trigger: trigger }, true /* shouldBubble */);
  3664. },
  3665. notifyNavigation: function notifyNavigation(key) {
  3666. _this.emit(constants_1.strings.NAVIGATION_EVENT, { key: key }, true /* shouldBubble */);
  3667. },
  3668. setAttribute: function setAttribute(attr, value) {
  3669. _this.root.setAttribute(attr, value);
  3670. }
  3671. };
  3672. return new foundation_2.MDCChipTrailingActionFoundation(adapter);
  3673. };
  3674. MDCChipTrailingAction.prototype.isNavigable = function () {
  3675. return this.foundation.isNavigable();
  3676. };
  3677. MDCChipTrailingAction.prototype.focus = function () {
  3678. this.foundation.focus();
  3679. };
  3680. MDCChipTrailingAction.prototype.removeFocus = function () {
  3681. this.foundation.removeFocus();
  3682. };
  3683. return MDCChipTrailingAction;
  3684. }(component_1.MDCComponent);
  3685. exports.MDCChipTrailingAction = MDCChipTrailingAction;
  3686. /***/ }),
  3687. /***/ "./packages/mdc-chips/trailingaction/constants.ts":
  3688. /*!********************************************************!*\
  3689. !*** ./packages/mdc-chips/trailingaction/constants.ts ***!
  3690. \********************************************************/
  3691. /*! no static exports found */
  3692. /***/ (function(module, exports, __webpack_require__) {
  3693. "use strict";
  3694. /**
  3695. * @license
  3696. * Copyright 2020 Google Inc.
  3697. *
  3698. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3699. * of this software and associated documentation files (the "Software"), to deal
  3700. * in the Software without restriction, including without limitation the rights
  3701. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3702. * copies of the Software, and to permit persons to whom the Software is
  3703. * furnished to do so, subject to the following conditions:
  3704. *
  3705. * The above copyright notice and this permission notice shall be included in
  3706. * all copies or substantial portions of the Software.
  3707. *
  3708. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3709. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3710. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3711. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3712. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3713. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3714. * THE SOFTWARE.
  3715. */
  3716. Object.defineProperty(exports, "__esModule", { value: true });
  3717. var InteractionTrigger;
  3718. (function (InteractionTrigger) {
  3719. InteractionTrigger[InteractionTrigger["UNSPECIFIED"] = 0] = "UNSPECIFIED";
  3720. InteractionTrigger[InteractionTrigger["CLICK"] = 1] = "CLICK";
  3721. InteractionTrigger[InteractionTrigger["BACKSPACE_KEY"] = 2] = "BACKSPACE_KEY";
  3722. InteractionTrigger[InteractionTrigger["DELETE_KEY"] = 3] = "DELETE_KEY";
  3723. InteractionTrigger[InteractionTrigger["SPACEBAR_KEY"] = 4] = "SPACEBAR_KEY";
  3724. InteractionTrigger[InteractionTrigger["ENTER_KEY"] = 5] = "ENTER_KEY";
  3725. })(InteractionTrigger = exports.InteractionTrigger || (exports.InteractionTrigger = {}));
  3726. exports.strings = {
  3727. ARIA_HIDDEN: 'aria-hidden',
  3728. INTERACTION_EVENT: 'MDCChipTrailingAction:interaction',
  3729. NAVIGATION_EVENT: 'MDCChipTrailingAction:navigation',
  3730. TAB_INDEX: 'tabindex'
  3731. };
  3732. /***/ }),
  3733. /***/ "./packages/mdc-chips/trailingaction/foundation.ts":
  3734. /*!*********************************************************!*\
  3735. !*** ./packages/mdc-chips/trailingaction/foundation.ts ***!
  3736. \*********************************************************/
  3737. /*! no static exports found */
  3738. /***/ (function(module, exports, __webpack_require__) {
  3739. "use strict";
  3740. /**
  3741. * @license
  3742. * Copyright 2020 Google Inc.
  3743. *
  3744. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3745. * of this software and associated documentation files (the "Software"), to deal
  3746. * in the Software without restriction, including without limitation the rights
  3747. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3748. * copies of the Software, and to permit persons to whom the Software is
  3749. * furnished to do so, subject to the following conditions:
  3750. *
  3751. * The above copyright notice and this permission notice shall be included in
  3752. * all copies or substantial portions of the Software.
  3753. *
  3754. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3755. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3756. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3757. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3758. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3759. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3760. * THE SOFTWARE.
  3761. */
  3762. var __extends = this && this.__extends || function () {
  3763. var _extendStatics = function extendStatics(d, b) {
  3764. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  3765. d.__proto__ = b;
  3766. } || function (d, b) {
  3767. for (var p in b) {
  3768. if (b.hasOwnProperty(p)) d[p] = b[p];
  3769. }
  3770. };
  3771. return _extendStatics(d, b);
  3772. };
  3773. return function (d, b) {
  3774. _extendStatics(d, b);
  3775. function __() {
  3776. this.constructor = d;
  3777. }
  3778. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3779. };
  3780. }();
  3781. var __assign = this && this.__assign || function () {
  3782. __assign = Object.assign || function (t) {
  3783. for (var s, i = 1, n = arguments.length; i < n; i++) {
  3784. s = arguments[i];
  3785. for (var p in s) {
  3786. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  3787. }
  3788. }
  3789. return t;
  3790. };
  3791. return __assign.apply(this, arguments);
  3792. };
  3793. Object.defineProperty(exports, "__esModule", { value: true });
  3794. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  3795. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  3796. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/trailingaction/constants.ts");
  3797. var MDCChipTrailingActionFoundation = /** @class */function (_super) {
  3798. __extends(MDCChipTrailingActionFoundation, _super);
  3799. function MDCChipTrailingActionFoundation(adapter) {
  3800. return _super.call(this, __assign(__assign({}, MDCChipTrailingActionFoundation.defaultAdapter), adapter)) || this;
  3801. }
  3802. Object.defineProperty(MDCChipTrailingActionFoundation, "strings", {
  3803. get: function get() {
  3804. return constants_1.strings;
  3805. },
  3806. enumerable: true,
  3807. configurable: true
  3808. });
  3809. Object.defineProperty(MDCChipTrailingActionFoundation, "defaultAdapter", {
  3810. get: function get() {
  3811. return {
  3812. focus: function focus() {
  3813. return undefined;
  3814. },
  3815. getAttribute: function getAttribute() {
  3816. return null;
  3817. },
  3818. setAttribute: function setAttribute() {
  3819. return undefined;
  3820. },
  3821. notifyInteraction: function notifyInteraction() {
  3822. return undefined;
  3823. },
  3824. notifyNavigation: function notifyNavigation() {
  3825. return undefined;
  3826. }
  3827. };
  3828. },
  3829. enumerable: true,
  3830. configurable: true
  3831. });
  3832. MDCChipTrailingActionFoundation.prototype.handleClick = function (evt) {
  3833. evt.stopPropagation();
  3834. this.adapter.notifyInteraction(constants_1.InteractionTrigger.CLICK);
  3835. };
  3836. MDCChipTrailingActionFoundation.prototype.handleKeydown = function (evt) {
  3837. evt.stopPropagation();
  3838. var key = keyboard_1.normalizeKey(evt);
  3839. if (this.shouldNotifyInteractionFromKey_(key)) {
  3840. var trigger = this.getTriggerFromKey_(key);
  3841. this.adapter.notifyInteraction(trigger);
  3842. return;
  3843. }
  3844. if (keyboard_1.isNavigationEvent(evt)) {
  3845. this.adapter.notifyNavigation(key);
  3846. return;
  3847. }
  3848. };
  3849. MDCChipTrailingActionFoundation.prototype.removeFocus = function () {
  3850. this.adapter.setAttribute(constants_1.strings.TAB_INDEX, '-1');
  3851. };
  3852. MDCChipTrailingActionFoundation.prototype.focus = function () {
  3853. this.adapter.setAttribute(constants_1.strings.TAB_INDEX, '0');
  3854. this.adapter.focus();
  3855. };
  3856. MDCChipTrailingActionFoundation.prototype.isNavigable = function () {
  3857. return this.adapter.getAttribute(constants_1.strings.ARIA_HIDDEN) !== 'true';
  3858. };
  3859. MDCChipTrailingActionFoundation.prototype.shouldNotifyInteractionFromKey_ = function (key) {
  3860. var isFromActionKey = key === keyboard_1.KEY.ENTER || key === keyboard_1.KEY.SPACEBAR;
  3861. var isFromDeleteKey = key === keyboard_1.KEY.BACKSPACE || key === keyboard_1.KEY.DELETE;
  3862. return isFromActionKey || isFromDeleteKey;
  3863. };
  3864. MDCChipTrailingActionFoundation.prototype.getTriggerFromKey_ = function (key) {
  3865. if (key === keyboard_1.KEY.SPACEBAR) {
  3866. return constants_1.InteractionTrigger.SPACEBAR_KEY;
  3867. }
  3868. if (key === keyboard_1.KEY.ENTER) {
  3869. return constants_1.InteractionTrigger.ENTER_KEY;
  3870. }
  3871. if (key === keyboard_1.KEY.DELETE) {
  3872. return constants_1.InteractionTrigger.DELETE_KEY;
  3873. }
  3874. if (key === keyboard_1.KEY.BACKSPACE) {
  3875. return constants_1.InteractionTrigger.BACKSPACE_KEY;
  3876. }
  3877. // Default case, should never be returned
  3878. return constants_1.InteractionTrigger.UNSPECIFIED;
  3879. };
  3880. return MDCChipTrailingActionFoundation;
  3881. }(foundation_1.MDCFoundation);
  3882. exports.MDCChipTrailingActionFoundation = MDCChipTrailingActionFoundation;
  3883. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  3884. exports.default = MDCChipTrailingActionFoundation;
  3885. /***/ }),
  3886. /***/ "./packages/mdc-chips/trailingaction/index.ts":
  3887. /*!****************************************************!*\
  3888. !*** ./packages/mdc-chips/trailingaction/index.ts ***!
  3889. \****************************************************/
  3890. /*! no static exports found */
  3891. /***/ (function(module, exports, __webpack_require__) {
  3892. "use strict";
  3893. /**
  3894. * @license
  3895. * Copyright 2020 Google Inc.
  3896. *
  3897. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3898. * of this software and associated documentation files (the "Software"), to deal
  3899. * in the Software without restriction, including without limitation the rights
  3900. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3901. * copies of the Software, and to permit persons to whom the Software is
  3902. * furnished to do so, subject to the following conditions:
  3903. *
  3904. * The above copyright notice and this permission notice shall be included in
  3905. * all copies or substantial portions of the Software.
  3906. *
  3907. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3908. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3909. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3910. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3911. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3912. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3913. * THE SOFTWARE.
  3914. */
  3915. function __export(m) {
  3916. for (var p in m) {
  3917. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  3918. }
  3919. }
  3920. Object.defineProperty(exports, "__esModule", { value: true });
  3921. __export(__webpack_require__(/*! ./component */ "./packages/mdc-chips/trailingaction/component.ts"));
  3922. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-chips/trailingaction/foundation.ts"));
  3923. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/trailingaction/constants.ts");
  3924. exports.trailingActionStrings = constants_1.strings;
  3925. /***/ }),
  3926. /***/ "./packages/mdc-circular-progress/component.ts":
  3927. /*!*****************************************************!*\
  3928. !*** ./packages/mdc-circular-progress/component.ts ***!
  3929. \*****************************************************/
  3930. /*! no static exports found */
  3931. /***/ (function(module, exports, __webpack_require__) {
  3932. "use strict";
  3933. /**
  3934. * @license
  3935. * Copyright 2020 Google Inc.
  3936. *
  3937. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3938. * of this software and associated documentation files (the "Software"), to deal
  3939. * in the Software without restriction, including without limitation the rights
  3940. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3941. * copies of the Software, and to permit persons to whom the Software is
  3942. * furnished to do so, subject to the following conditions:
  3943. *
  3944. * The above copyright notice and this permission notice shall be included in
  3945. * all copies or substantial portions of the Software.
  3946. *
  3947. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3948. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3949. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3950. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3951. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3952. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3953. * THE SOFTWARE.
  3954. */
  3955. var __extends = this && this.__extends || function () {
  3956. var _extendStatics = function extendStatics(d, b) {
  3957. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  3958. d.__proto__ = b;
  3959. } || function (d, b) {
  3960. for (var p in b) {
  3961. if (b.hasOwnProperty(p)) d[p] = b[p];
  3962. }
  3963. };
  3964. return _extendStatics(d, b);
  3965. };
  3966. return function (d, b) {
  3967. _extendStatics(d, b);
  3968. function __() {
  3969. this.constructor = d;
  3970. }
  3971. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3972. };
  3973. }();
  3974. Object.defineProperty(exports, "__esModule", { value: true });
  3975. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  3976. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-circular-progress/foundation.ts");
  3977. var MDCCircularProgress = /** @class */function (_super) {
  3978. __extends(MDCCircularProgress, _super);
  3979. function MDCCircularProgress() {
  3980. return _super !== null && _super.apply(this, arguments) || this;
  3981. }
  3982. MDCCircularProgress.prototype.initialize = function () {
  3983. this.determinateCircle_ = this.root.querySelector(foundation_1.MDCCircularProgressFoundation.strings.DETERMINATE_CIRCLE_SELECTOR);
  3984. };
  3985. MDCCircularProgress.attachTo = function (root) {
  3986. return new MDCCircularProgress(root);
  3987. };
  3988. Object.defineProperty(MDCCircularProgress.prototype, "determinate", {
  3989. /**
  3990. * Sets whether the progress indicator is in determinate mode.
  3991. * @param isDeterminate Whether the indicator should be determinate.
  3992. */
  3993. set: function set(value) {
  3994. this.foundation.setDeterminate(value);
  3995. },
  3996. enumerable: true,
  3997. configurable: true
  3998. });
  3999. Object.defineProperty(MDCCircularProgress.prototype, "progress", {
  4000. /**
  4001. * Sets the current progress value. In indeterminate mode, this has no
  4002. * visual effect but will be reflected if the indicator is switched to
  4003. * determinate mode.
  4004. * @param value The current progress value, which must be between 0 and 1.
  4005. */
  4006. set: function set(value) {
  4007. this.foundation.setProgress(value);
  4008. },
  4009. enumerable: true,
  4010. configurable: true
  4011. });
  4012. Object.defineProperty(MDCCircularProgress.prototype, "isClosed", {
  4013. /**
  4014. * Whether the progress indicator is hidden.
  4015. */
  4016. get: function get() {
  4017. return this.foundation.isClosed();
  4018. },
  4019. enumerable: true,
  4020. configurable: true
  4021. });
  4022. /**
  4023. * Shows the progress indicator.
  4024. */
  4025. MDCCircularProgress.prototype.open = function () {
  4026. this.foundation.open();
  4027. };
  4028. /**
  4029. * Hides the progress indicator.
  4030. */
  4031. MDCCircularProgress.prototype.close = function () {
  4032. this.foundation.close();
  4033. };
  4034. MDCCircularProgress.prototype.getDefaultFoundation = function () {
  4035. var _this = this;
  4036. // DO NOT INLINE this variable. For backward compatibility, foundations take
  4037. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  4038. // methods, we need a separate, strongly typed adapter variable.
  4039. var adapter = {
  4040. addClass: function addClass(className) {
  4041. return _this.root.classList.add(className);
  4042. },
  4043. getDeterminateCircleAttribute: function getDeterminateCircleAttribute(attributeName) {
  4044. return _this.determinateCircle_.getAttribute(attributeName);
  4045. },
  4046. hasClass: function hasClass(className) {
  4047. return _this.root.classList.contains(className);
  4048. },
  4049. removeClass: function removeClass(className) {
  4050. return _this.root.classList.remove(className);
  4051. },
  4052. removeAttribute: function removeAttribute(attributeName) {
  4053. return _this.root.removeAttribute(attributeName);
  4054. },
  4055. setAttribute: function setAttribute(attributeName, value) {
  4056. return _this.root.setAttribute(attributeName, value);
  4057. },
  4058. setDeterminateCircleAttribute: function setDeterminateCircleAttribute(attributeName, value) {
  4059. return _this.determinateCircle_.setAttribute(attributeName, value);
  4060. }
  4061. };
  4062. return new foundation_1.MDCCircularProgressFoundation(adapter);
  4063. };
  4064. return MDCCircularProgress;
  4065. }(component_1.MDCComponent);
  4066. exports.MDCCircularProgress = MDCCircularProgress;
  4067. /***/ }),
  4068. /***/ "./packages/mdc-circular-progress/constants.ts":
  4069. /*!*****************************************************!*\
  4070. !*** ./packages/mdc-circular-progress/constants.ts ***!
  4071. \*****************************************************/
  4072. /*! no static exports found */
  4073. /***/ (function(module, exports, __webpack_require__) {
  4074. "use strict";
  4075. /**
  4076. * @license
  4077. * Copyright 2020 Google Inc.
  4078. *
  4079. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4080. * of this software and associated documentation files (the "Software"), to deal
  4081. * in the Software without restriction, including without limitation the rights
  4082. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4083. * copies of the Software, and to permit persons to whom the Software is
  4084. * furnished to do so, subject to the following conditions:
  4085. *
  4086. * The above copyright notice and this permission notice shall be included in
  4087. * all copies or substantial portions of the Software.
  4088. *
  4089. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4090. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4091. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4092. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4093. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4094. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4095. * THE SOFTWARE.
  4096. */
  4097. Object.defineProperty(exports, "__esModule", { value: true });
  4098. /**
  4099. * CSS class names used in component.
  4100. */
  4101. exports.cssClasses = {
  4102. INDETERMINATE_CLASS: 'mdc-circular-progress--indeterminate',
  4103. CLOSED_CLASS: 'mdc-circular-progress--closed'
  4104. };
  4105. /**
  4106. * Attributes and selectors used in component.
  4107. */
  4108. exports.strings = {
  4109. DETERMINATE_CIRCLE_SELECTOR: '.mdc-circular-progress__determinate-circle',
  4110. ARIA_VALUENOW: 'aria-valuenow',
  4111. RADIUS: 'r',
  4112. STROKE_DASHOFFSET: 'stroke-dashoffset'
  4113. };
  4114. /***/ }),
  4115. /***/ "./packages/mdc-circular-progress/foundation.ts":
  4116. /*!******************************************************!*\
  4117. !*** ./packages/mdc-circular-progress/foundation.ts ***!
  4118. \******************************************************/
  4119. /*! no static exports found */
  4120. /***/ (function(module, exports, __webpack_require__) {
  4121. "use strict";
  4122. /**
  4123. * @license
  4124. * Copyright 2020 Google Inc.
  4125. *
  4126. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4127. * of this software and associated documentation files (the "Software"), to deal
  4128. * in the Software without restriction, including without limitation the rights
  4129. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4130. * copies of the Software, and to permit persons to whom the Software is
  4131. * furnished to do so, subject to the following conditions:
  4132. *
  4133. * The above copyright notice and this permission notice shall be included in
  4134. * all copies or substantial portions of the Software.
  4135. *
  4136. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4137. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4138. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4139. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4140. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4141. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4142. * THE SOFTWARE.
  4143. */
  4144. var __extends = this && this.__extends || function () {
  4145. var _extendStatics = function extendStatics(d, b) {
  4146. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4147. d.__proto__ = b;
  4148. } || function (d, b) {
  4149. for (var p in b) {
  4150. if (b.hasOwnProperty(p)) d[p] = b[p];
  4151. }
  4152. };
  4153. return _extendStatics(d, b);
  4154. };
  4155. return function (d, b) {
  4156. _extendStatics(d, b);
  4157. function __() {
  4158. this.constructor = d;
  4159. }
  4160. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4161. };
  4162. }();
  4163. var __assign = this && this.__assign || function () {
  4164. __assign = Object.assign || function (t) {
  4165. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4166. s = arguments[i];
  4167. for (var p in s) {
  4168. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  4169. }
  4170. }
  4171. return t;
  4172. };
  4173. return __assign.apply(this, arguments);
  4174. };
  4175. Object.defineProperty(exports, "__esModule", { value: true });
  4176. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  4177. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-circular-progress/constants.ts");
  4178. var MDCCircularProgressFoundation = /** @class */function (_super) {
  4179. __extends(MDCCircularProgressFoundation, _super);
  4180. function MDCCircularProgressFoundation(adapter) {
  4181. return _super.call(this, __assign(__assign({}, MDCCircularProgressFoundation.defaultAdapter), adapter)) || this;
  4182. }
  4183. Object.defineProperty(MDCCircularProgressFoundation, "cssClasses", {
  4184. get: function get() {
  4185. return constants_1.cssClasses;
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. Object.defineProperty(MDCCircularProgressFoundation, "strings", {
  4191. get: function get() {
  4192. return constants_1.strings;
  4193. },
  4194. enumerable: true,
  4195. configurable: true
  4196. });
  4197. Object.defineProperty(MDCCircularProgressFoundation, "defaultAdapter", {
  4198. get: function get() {
  4199. return {
  4200. addClass: function addClass() {
  4201. return undefined;
  4202. },
  4203. getDeterminateCircleAttribute: function getDeterminateCircleAttribute() {
  4204. return null;
  4205. },
  4206. hasClass: function hasClass() {
  4207. return false;
  4208. },
  4209. removeClass: function removeClass() {
  4210. return undefined;
  4211. },
  4212. removeAttribute: function removeAttribute() {
  4213. return undefined;
  4214. },
  4215. setAttribute: function setAttribute() {
  4216. return undefined;
  4217. },
  4218. setDeterminateCircleAttribute: function setDeterminateCircleAttribute() {
  4219. return undefined;
  4220. }
  4221. };
  4222. },
  4223. enumerable: true,
  4224. configurable: true
  4225. });
  4226. MDCCircularProgressFoundation.prototype.init = function () {
  4227. this.isClosed_ = this.adapter.hasClass(constants_1.cssClasses.CLOSED_CLASS);
  4228. this.isDeterminate_ = !this.adapter.hasClass(constants_1.cssClasses.INDETERMINATE_CLASS);
  4229. this.progress_ = 0;
  4230. if (this.isDeterminate_) {
  4231. this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress_.toString());
  4232. }
  4233. this.radius_ = Number(this.adapter.getDeterminateCircleAttribute(constants_1.strings.RADIUS));
  4234. };
  4235. MDCCircularProgressFoundation.prototype.isDeterminate = function () {
  4236. return this.isDeterminate_;
  4237. };
  4238. MDCCircularProgressFoundation.prototype.getProgress = function () {
  4239. return this.progress_;
  4240. };
  4241. /**
  4242. * @return Returns whether the progress indicator is hidden.
  4243. */
  4244. MDCCircularProgressFoundation.prototype.isClosed = function () {
  4245. return this.isClosed_;
  4246. };
  4247. /**
  4248. * Sets whether the progress indicator is in determinate mode.
  4249. * @param isDeterminate Whether the indicator should be determinate.
  4250. */
  4251. MDCCircularProgressFoundation.prototype.setDeterminate = function (isDeterminate) {
  4252. this.isDeterminate_ = isDeterminate;
  4253. if (this.isDeterminate_) {
  4254. this.adapter.removeClass(constants_1.cssClasses.INDETERMINATE_CLASS);
  4255. this.setProgress(this.progress_);
  4256. } else {
  4257. this.adapter.addClass(constants_1.cssClasses.INDETERMINATE_CLASS);
  4258. this.adapter.removeAttribute(constants_1.strings.ARIA_VALUENOW);
  4259. }
  4260. };
  4261. /**
  4262. * Sets the current progress value. In indeterminate mode, this has no
  4263. * visual effect but will be reflected if the indicator is switched to
  4264. * determinate mode.
  4265. * @param value The current progress value, which must be between 0 and 1.
  4266. */
  4267. MDCCircularProgressFoundation.prototype.setProgress = function (value) {
  4268. this.progress_ = value;
  4269. if (this.isDeterminate_) {
  4270. var unfilledArcLength = (1 - this.progress_) * (2 * Math.PI * this.radius_);
  4271. this.adapter.setDeterminateCircleAttribute(constants_1.strings.STROKE_DASHOFFSET, "" + unfilledArcLength);
  4272. this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress_.toString());
  4273. }
  4274. };
  4275. /**
  4276. * Shows the progress indicator.
  4277. */
  4278. MDCCircularProgressFoundation.prototype.open = function () {
  4279. this.isClosed_ = false;
  4280. this.adapter.removeClass(constants_1.cssClasses.CLOSED_CLASS);
  4281. };
  4282. /**
  4283. * Hides the progress indicator
  4284. */
  4285. MDCCircularProgressFoundation.prototype.close = function () {
  4286. this.isClosed_ = true;
  4287. this.adapter.addClass(constants_1.cssClasses.CLOSED_CLASS);
  4288. };
  4289. return MDCCircularProgressFoundation;
  4290. }(foundation_1.MDCFoundation);
  4291. exports.MDCCircularProgressFoundation = MDCCircularProgressFoundation;
  4292. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  4293. exports.default = MDCCircularProgressFoundation;
  4294. /***/ }),
  4295. /***/ "./packages/mdc-circular-progress/index.ts":
  4296. /*!*************************************************!*\
  4297. !*** ./packages/mdc-circular-progress/index.ts ***!
  4298. \*************************************************/
  4299. /*! no static exports found */
  4300. /***/ (function(module, exports, __webpack_require__) {
  4301. "use strict";
  4302. /**
  4303. * @license
  4304. * Copyright 2020 Google Inc.
  4305. *
  4306. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4307. * of this software and associated documentation files (the "Software"), to deal
  4308. * in the Software without restriction, including without limitation the rights
  4309. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4310. * copies of the Software, and to permit persons to whom the Software is
  4311. * furnished to do so, subject to the following conditions:
  4312. *
  4313. * The above copyright notice and this permission notice shall be included in
  4314. * all copies or substantial portions of the Software.
  4315. *
  4316. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4317. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4318. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4319. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4320. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4321. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4322. * THE SOFTWARE.
  4323. */
  4324. function __export(m) {
  4325. for (var p in m) {
  4326. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  4327. }
  4328. }
  4329. Object.defineProperty(exports, "__esModule", { value: true });
  4330. __export(__webpack_require__(/*! ./component */ "./packages/mdc-circular-progress/component.ts"));
  4331. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-circular-progress/constants.ts"));
  4332. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-circular-progress/foundation.ts"));
  4333. /***/ }),
  4334. /***/ "./packages/mdc-data-table/component.ts":
  4335. /*!**********************************************!*\
  4336. !*** ./packages/mdc-data-table/component.ts ***!
  4337. \**********************************************/
  4338. /*! no static exports found */
  4339. /***/ (function(module, exports, __webpack_require__) {
  4340. "use strict";
  4341. /**
  4342. * @license
  4343. * Copyright 2019 Google Inc.
  4344. *
  4345. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4346. * of this software and associated documentation files (the "Software"), to deal
  4347. * in the Software without restriction, including without limitation the rights
  4348. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4349. * copies of the Software, and to permit persons to whom the Software is
  4350. * furnished to do so, subject to the following conditions:
  4351. *
  4352. * The above copyright notice and this permission notice shall be included in
  4353. * all copies or substantial portions of the Software.
  4354. *
  4355. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4356. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4357. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4358. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4359. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4360. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4361. * THE SOFTWARE.
  4362. */
  4363. var __extends = this && this.__extends || function () {
  4364. var _extendStatics = function extendStatics(d, b) {
  4365. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4366. d.__proto__ = b;
  4367. } || function (d, b) {
  4368. for (var p in b) {
  4369. if (b.hasOwnProperty(p)) d[p] = b[p];
  4370. }
  4371. };
  4372. return _extendStatics(d, b);
  4373. };
  4374. return function (d, b) {
  4375. _extendStatics(d, b);
  4376. function __() {
  4377. this.constructor = d;
  4378. }
  4379. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4380. };
  4381. }();
  4382. var __values = this && this.__values || function (o) {
  4383. var s = typeof Symbol === "function" && Symbol.iterator,
  4384. m = s && o[s],
  4385. i = 0;
  4386. if (m) return m.call(o);
  4387. if (o && typeof o.length === "number") return {
  4388. next: function next() {
  4389. if (o && i >= o.length) o = void 0;
  4390. return { value: o && o[i++], done: !o };
  4391. }
  4392. };
  4393. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  4394. };
  4395. Object.defineProperty(exports, "__esModule", { value: true });
  4396. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  4397. var component_2 = __webpack_require__(/*! @material/checkbox/component */ "./packages/mdc-checkbox/component.ts");
  4398. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  4399. var component_3 = __webpack_require__(/*! @material/linear-progress/component */ "./packages/mdc-linear-progress/component.ts");
  4400. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-data-table/constants.ts");
  4401. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-data-table/foundation.ts");
  4402. /**
  4403. * Implementation of `MDCDataTableFoundation`
  4404. */
  4405. var MDCDataTable = /** @class */function (_super) {
  4406. __extends(MDCDataTable, _super);
  4407. function MDCDataTable() {
  4408. return _super !== null && _super.apply(this, arguments) || this;
  4409. }
  4410. MDCDataTable.attachTo = function (root) {
  4411. return new MDCDataTable(root);
  4412. };
  4413. MDCDataTable.prototype.initialize = function (checkboxFactory) {
  4414. if (checkboxFactory === void 0) {
  4415. checkboxFactory = function checkboxFactory(el) {
  4416. return new component_2.MDCCheckbox(el);
  4417. };
  4418. }
  4419. this.checkboxFactory = checkboxFactory;
  4420. };
  4421. MDCDataTable.prototype.initialSyncWithDOM = function () {
  4422. var _this = this;
  4423. this.headerRow = this.root.querySelector("." + constants_1.cssClasses.HEADER_ROW);
  4424. this.handleHeaderRowCheckboxChange = function () {
  4425. _this.foundation.handleHeaderRowCheckboxChange();
  4426. };
  4427. this.headerRow.addEventListener('change', this.handleHeaderRowCheckboxChange);
  4428. this.headerRowClickListener = function (event) {
  4429. _this.handleHeaderRowClick(event);
  4430. };
  4431. this.headerRow.addEventListener('click', this.headerRowClickListener);
  4432. this.content = this.root.querySelector("." + constants_1.cssClasses.CONTENT);
  4433. this.handleRowCheckboxChange = function (event) {
  4434. _this.foundation.handleRowCheckboxChange(event);
  4435. };
  4436. this.content.addEventListener('change', this.handleRowCheckboxChange);
  4437. this.layout();
  4438. };
  4439. /**
  4440. * Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
  4441. */
  4442. MDCDataTable.prototype.layout = function () {
  4443. this.foundation.layout();
  4444. };
  4445. /**
  4446. * @return Returns array of header row cell elements.
  4447. */
  4448. MDCDataTable.prototype.getHeaderCells = function () {
  4449. return [].slice.call(this.root.querySelectorAll(constants_1.selectors.HEADER_CELL));
  4450. };
  4451. /**
  4452. * @return Returns array of row elements.
  4453. */
  4454. MDCDataTable.prototype.getRows = function () {
  4455. return this.foundation.getRows();
  4456. };
  4457. /**
  4458. * @return Returns array of selected row ids.
  4459. */
  4460. MDCDataTable.prototype.getSelectedRowIds = function () {
  4461. return this.foundation.getSelectedRowIds();
  4462. };
  4463. /**
  4464. * Sets selected row ids. Overwrites previously selected rows.
  4465. * @param rowIds Array of row ids that needs to be selected.
  4466. */
  4467. MDCDataTable.prototype.setSelectedRowIds = function (rowIds) {
  4468. this.foundation.setSelectedRowIds(rowIds);
  4469. };
  4470. /**
  4471. * Shows progress indicator when data table is in loading state.
  4472. */
  4473. MDCDataTable.prototype.showProgress = function () {
  4474. this.getLinearProgress().open();
  4475. this.foundation.showProgress();
  4476. };
  4477. /**
  4478. * Hides progress indicator after data table is finished loading.
  4479. */
  4480. MDCDataTable.prototype.hideProgress = function () {
  4481. this.foundation.hideProgress();
  4482. this.getLinearProgress().close();
  4483. };
  4484. MDCDataTable.prototype.destroy = function () {
  4485. var e_1, _a;
  4486. if (this.handleHeaderRowCheckboxChange) {
  4487. this.headerRow.removeEventListener('change', this.handleHeaderRowCheckboxChange);
  4488. }
  4489. if (this.headerRowClickListener) {
  4490. this.headerRow.removeEventListener('click', this.headerRowClickListener);
  4491. }
  4492. if (this.handleRowCheckboxChange) {
  4493. this.content.removeEventListener('change', this.handleRowCheckboxChange);
  4494. }
  4495. if (this.headerRowCheckbox) {
  4496. this.headerRowCheckbox.destroy();
  4497. }
  4498. if (this.rowCheckboxList) {
  4499. try {
  4500. for (var _b = __values(this.rowCheckboxList), _c = _b.next(); !_c.done; _c = _b.next()) {
  4501. var checkbox = _c.value;
  4502. checkbox.destroy();
  4503. }
  4504. } catch (e_1_1) {
  4505. e_1 = { error: e_1_1 };
  4506. } finally {
  4507. try {
  4508. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  4509. } finally {
  4510. if (e_1) throw e_1.error;
  4511. }
  4512. }
  4513. }
  4514. };
  4515. MDCDataTable.prototype.getDefaultFoundation = function () {
  4516. var _this = this;
  4517. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  4518. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  4519. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  4520. var adapter = {
  4521. addClass: function addClass(className) {
  4522. _this.root.classList.add(className);
  4523. },
  4524. removeClass: function removeClass(className) {
  4525. _this.root.classList.remove(className);
  4526. },
  4527. getHeaderCellElements: function getHeaderCellElements() {
  4528. return _this.getHeaderCells();
  4529. },
  4530. getHeaderCellCount: function getHeaderCellCount() {
  4531. return _this.getHeaderCells().length;
  4532. },
  4533. getAttributeByHeaderCellIndex: function getAttributeByHeaderCellIndex(index, attribute) {
  4534. return _this.getHeaderCells()[index].getAttribute(attribute);
  4535. },
  4536. setAttributeByHeaderCellIndex: function setAttributeByHeaderCellIndex(index, attribute, value) {
  4537. _this.getHeaderCells()[index].setAttribute(attribute, value);
  4538. },
  4539. setClassNameByHeaderCellIndex: function setClassNameByHeaderCellIndex(index, className) {
  4540. _this.getHeaderCells()[index].classList.add(className);
  4541. },
  4542. removeClassNameByHeaderCellIndex: function removeClassNameByHeaderCellIndex(index, className) {
  4543. _this.getHeaderCells()[index].classList.remove(className);
  4544. },
  4545. notifySortAction: function notifySortAction(data) {
  4546. _this.emit(constants_1.events.SORTED, data, /** shouldBubble */true);
  4547. },
  4548. getTableContainerHeight: function getTableContainerHeight() {
  4549. var tableContainer = _this.root.querySelector("." + constants_1.cssClasses.TABLE_CONTAINER);
  4550. if (!tableContainer) {
  4551. throw new Error('MDCDataTable: Table container element not found.');
  4552. }
  4553. return tableContainer.getBoundingClientRect().height;
  4554. },
  4555. getTableHeaderHeight: function getTableHeaderHeight() {
  4556. var tableHeader = _this.root.querySelector(constants_1.selectors.HEADER_ROW);
  4557. if (!tableHeader) {
  4558. throw new Error('MDCDataTable: Table header element not found.');
  4559. }
  4560. return tableHeader.getBoundingClientRect().height;
  4561. },
  4562. setProgressIndicatorStyles: function setProgressIndicatorStyles(styles) {
  4563. var progressIndicator = _this.root.querySelector(constants_1.selectors.PROGRESS_INDICATOR);
  4564. if (!progressIndicator) {
  4565. throw new Error('MDCDataTable: Progress indicator element not found.');
  4566. }
  4567. progressIndicator.style.setProperty('height', styles.height);
  4568. progressIndicator.style.setProperty('top', styles.top);
  4569. },
  4570. addClassAtRowIndex: function addClassAtRowIndex(rowIndex, className) {
  4571. _this.getRows()[rowIndex].classList.add(className);
  4572. },
  4573. getRowCount: function getRowCount() {
  4574. return _this.getRows().length;
  4575. },
  4576. getRowElements: function getRowElements() {
  4577. return [].slice.call(_this.root.querySelectorAll(constants_1.selectors.ROW));
  4578. },
  4579. getRowIdAtIndex: function getRowIdAtIndex(rowIndex) {
  4580. return _this.getRows()[rowIndex].getAttribute(constants_1.dataAttributes.ROW_ID);
  4581. },
  4582. getRowIndexByChildElement: function getRowIndexByChildElement(el) {
  4583. return _this.getRows().indexOf(ponyfill_1.closest(el, constants_1.selectors.ROW));
  4584. },
  4585. getSelectedRowCount: function getSelectedRowCount() {
  4586. return _this.root.querySelectorAll(constants_1.selectors.ROW_SELECTED).length;
  4587. },
  4588. isCheckboxAtRowIndexChecked: function isCheckboxAtRowIndexChecked(rowIndex) {
  4589. return _this.rowCheckboxList[rowIndex].checked;
  4590. },
  4591. isHeaderRowCheckboxChecked: function isHeaderRowCheckboxChecked() {
  4592. return _this.headerRowCheckbox.checked;
  4593. },
  4594. isRowsSelectable: function isRowsSelectable() {
  4595. return !!_this.root.querySelector(constants_1.selectors.ROW_CHECKBOX) || !!_this.root.querySelector(constants_1.selectors.HEADER_ROW_CHECKBOX);
  4596. },
  4597. notifyRowSelectionChanged: function notifyRowSelectionChanged(data) {
  4598. _this.emit(constants_1.events.ROW_SELECTION_CHANGED, {
  4599. row: _this.getRowByIndex(data.rowIndex),
  4600. rowId: _this.getRowIdByIndex(data.rowIndex),
  4601. rowIndex: data.rowIndex,
  4602. selected: data.selected
  4603. },
  4604. /** shouldBubble */true);
  4605. },
  4606. notifySelectedAll: function notifySelectedAll() {
  4607. _this.emit(constants_1.events.SELECTED_ALL, {}, /** shouldBubble */true);
  4608. },
  4609. notifyUnselectedAll: function notifyUnselectedAll() {
  4610. _this.emit(constants_1.events.UNSELECTED_ALL, {}, /** shouldBubble */true);
  4611. },
  4612. registerHeaderRowCheckbox: function registerHeaderRowCheckbox() {
  4613. if (_this.headerRowCheckbox) {
  4614. _this.headerRowCheckbox.destroy();
  4615. }
  4616. var checkboxEl = _this.root.querySelector(constants_1.selectors.HEADER_ROW_CHECKBOX);
  4617. _this.headerRowCheckbox = _this.checkboxFactory(checkboxEl);
  4618. },
  4619. registerRowCheckboxes: function registerRowCheckboxes() {
  4620. if (_this.rowCheckboxList) {
  4621. _this.rowCheckboxList.forEach(function (checkbox) {
  4622. checkbox.destroy();
  4623. });
  4624. }
  4625. _this.rowCheckboxList = [];
  4626. _this.getRows().forEach(function (rowEl) {
  4627. var checkbox = _this.checkboxFactory(rowEl.querySelector(constants_1.selectors.ROW_CHECKBOX));
  4628. _this.rowCheckboxList.push(checkbox);
  4629. });
  4630. },
  4631. removeClassAtRowIndex: function removeClassAtRowIndex(rowIndex, className) {
  4632. _this.getRows()[rowIndex].classList.remove(className);
  4633. },
  4634. setAttributeAtRowIndex: function setAttributeAtRowIndex(rowIndex, attr, value) {
  4635. _this.getRows()[rowIndex].setAttribute(attr, value);
  4636. },
  4637. setHeaderRowCheckboxChecked: function setHeaderRowCheckboxChecked(checked) {
  4638. _this.headerRowCheckbox.checked = checked;
  4639. },
  4640. setHeaderRowCheckboxIndeterminate: function setHeaderRowCheckboxIndeterminate(indeterminate) {
  4641. _this.headerRowCheckbox.indeterminate = indeterminate;
  4642. },
  4643. setRowCheckboxCheckedAtIndex: function setRowCheckboxCheckedAtIndex(rowIndex, checked) {
  4644. _this.rowCheckboxList[rowIndex].checked = checked;
  4645. },
  4646. setSortStatusLabelByHeaderCellIndex: function setSortStatusLabelByHeaderCellIndex(columnIndex, sortValue) {
  4647. var headerCell = _this.getHeaderCells()[columnIndex];
  4648. var sortStatusLabel = headerCell.querySelector(constants_1.selectors.SORT_STATUS_LABEL);
  4649. if (!sortStatusLabel) return;
  4650. sortStatusLabel.textContent = _this.getSortStatusMessageBySortValue(sortValue);
  4651. }
  4652. };
  4653. return new foundation_1.MDCDataTableFoundation(adapter);
  4654. };
  4655. MDCDataTable.prototype.getRowByIndex = function (index) {
  4656. return this.getRows()[index];
  4657. };
  4658. MDCDataTable.prototype.getRowIdByIndex = function (index) {
  4659. return this.getRowByIndex(index).getAttribute(constants_1.dataAttributes.ROW_ID);
  4660. };
  4661. MDCDataTable.prototype.handleHeaderRowClick = function (event) {
  4662. var headerCell = ponyfill_1.closest(event.target, constants_1.selectors.HEADER_CELL_WITH_SORT);
  4663. if (!headerCell) {
  4664. return;
  4665. }
  4666. var columnId = headerCell.getAttribute(constants_1.dataAttributes.COLUMN_ID);
  4667. var columnIndex = this.getHeaderCells().indexOf(headerCell);
  4668. if (columnIndex === -1) {
  4669. return;
  4670. }
  4671. this.foundation.handleSortAction({ columnId: columnId, columnIndex: columnIndex, headerCell: headerCell });
  4672. };
  4673. MDCDataTable.prototype.getSortStatusMessageBySortValue = function (sortValue) {
  4674. switch (sortValue) {
  4675. case constants_1.SortValue.ASCENDING:
  4676. return constants_1.messages.SORTED_IN_ASCENDING;
  4677. case constants_1.SortValue.DESCENDING:
  4678. return constants_1.messages.SORTED_IN_DESCENDING;
  4679. default:
  4680. return '';
  4681. }
  4682. };
  4683. MDCDataTable.prototype.getLinearProgressElement = function () {
  4684. var el = this.root.querySelector("." + constants_1.cssClasses.LINEAR_PROGRESS);
  4685. if (!el) {
  4686. throw new Error('MDCDataTable: linear progress element is not found.');
  4687. }
  4688. return el;
  4689. };
  4690. MDCDataTable.prototype.getLinearProgress = function () {
  4691. if (!this.linearProgress) {
  4692. var el = this.getLinearProgressElement();
  4693. this.linearProgress = new component_3.MDCLinearProgress(el);
  4694. }
  4695. return this.linearProgress;
  4696. };
  4697. return MDCDataTable;
  4698. }(component_1.MDCComponent);
  4699. exports.MDCDataTable = MDCDataTable;
  4700. /***/ }),
  4701. /***/ "./packages/mdc-data-table/constants.ts":
  4702. /*!**********************************************!*\
  4703. !*** ./packages/mdc-data-table/constants.ts ***!
  4704. \**********************************************/
  4705. /*! no static exports found */
  4706. /***/ (function(module, exports, __webpack_require__) {
  4707. "use strict";
  4708. /**
  4709. * @license
  4710. * Copyright 2019 Google Inc.
  4711. *
  4712. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4713. * of this software and associated documentation files (the "Software"), to deal
  4714. * in the Software without restriction, including without limitation the rights
  4715. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4716. * copies of the Software, and to permit persons to whom the Software is
  4717. * furnished to do so, subject to the following conditions:
  4718. *
  4719. * The above copyright notice and this permission notice shall be included in
  4720. * all copies or substantial portions of the Software.
  4721. *
  4722. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4723. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4724. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4725. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4726. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4727. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4728. * THE SOFTWARE.
  4729. */
  4730. Object.defineProperty(exports, "__esModule", { value: true });
  4731. /**
  4732. * CSS class names used in component.
  4733. */
  4734. exports.cssClasses = {
  4735. CELL: 'mdc-data-table__cell',
  4736. CELL_NUMERIC: 'mdc-data-table__cell--numeric',
  4737. CONTENT: 'mdc-data-table__content',
  4738. HEADER_CELL: 'mdc-data-table__header-cell',
  4739. HEADER_CELL_LABEL: 'mdc-data-table__header-cell-label',
  4740. HEADER_CELL_SORTED: 'mdc-data-table__header-cell--sorted',
  4741. HEADER_CELL_SORTED_DESCENDING: 'mdc-data-table__header-cell--sorted-descending',
  4742. HEADER_CELL_WITH_SORT: 'mdc-data-table__header-cell--with-sort',
  4743. HEADER_CELL_WRAPPER: 'mdc-data-table__header-cell-wrapper',
  4744. HEADER_ROW: 'mdc-data-table__header-row',
  4745. HEADER_ROW_CHECKBOX: 'mdc-data-table__header-row-checkbox',
  4746. IN_PROGRESS: 'mdc-data-table--in-progress',
  4747. LINEAR_PROGRESS: 'mdc-data-table__linear-progress',
  4748. PAGINATION_ROWS_PER_PAGE_LABEL: 'mdc-data-table__pagination-rows-per-page-label',
  4749. PAGINATION_ROWS_PER_PAGE_SELECT: 'mdc-data-table__pagination-rows-per-page-select',
  4750. PROGRESS_INDICATOR: 'mdc-data-table__progress-indicator',
  4751. ROOT: 'mdc-data-table',
  4752. ROW: 'mdc-data-table__row',
  4753. ROW_CHECKBOX: 'mdc-data-table__row-checkbox',
  4754. ROW_SELECTED: 'mdc-data-table__row--selected',
  4755. SORT_ICON_BUTTON: 'mdc-data-table__sort-icon-button',
  4756. SORT_STATUS_LABEL: 'mdc-data-table__sort-status-label',
  4757. TABLE_CONTAINER: 'mdc-data-table__table-container'
  4758. };
  4759. /**
  4760. * DOM attributes used in component.
  4761. */
  4762. exports.attributes = {
  4763. ARIA_SELECTED: 'aria-selected',
  4764. ARIA_SORT: 'aria-sort'
  4765. };
  4766. /**
  4767. * List of data attributes used in component.
  4768. */
  4769. exports.dataAttributes = {
  4770. COLUMN_ID: 'data-column-id',
  4771. ROW_ID: 'data-row-id'
  4772. };
  4773. /**
  4774. * CSS selectors used in component.
  4775. */
  4776. exports.selectors = {
  4777. CONTENT: "." + exports.cssClasses.CONTENT,
  4778. HEADER_CELL: "." + exports.cssClasses.HEADER_CELL,
  4779. HEADER_CELL_WITH_SORT: "." + exports.cssClasses.HEADER_CELL_WITH_SORT,
  4780. HEADER_ROW: "." + exports.cssClasses.HEADER_ROW,
  4781. HEADER_ROW_CHECKBOX: "." + exports.cssClasses.HEADER_ROW_CHECKBOX,
  4782. PROGRESS_INDICATOR: "." + exports.cssClasses.PROGRESS_INDICATOR,
  4783. ROW: "." + exports.cssClasses.ROW,
  4784. ROW_CHECKBOX: "." + exports.cssClasses.ROW_CHECKBOX,
  4785. ROW_SELECTED: "." + exports.cssClasses.ROW_SELECTED,
  4786. SORT_ICON_BUTTON: "." + exports.cssClasses.SORT_ICON_BUTTON,
  4787. SORT_STATUS_LABEL: "." + exports.cssClasses.SORT_STATUS_LABEL
  4788. };
  4789. /**
  4790. * Messages used in component.
  4791. */
  4792. exports.messages = {
  4793. SORTED_IN_DESCENDING: 'Sorted in descending order',
  4794. SORTED_IN_ASCENDING: 'Sorted in ascending order'
  4795. };
  4796. /**
  4797. * Attributes and selectors used in component.
  4798. * @deprecated Use `attributes`, `dataAttributes` and `selectors` instead.
  4799. */
  4800. exports.strings = {
  4801. ARIA_SELECTED: exports.attributes.ARIA_SELECTED,
  4802. ARIA_SORT: exports.attributes.ARIA_SORT,
  4803. DATA_ROW_ID_ATTR: exports.dataAttributes.ROW_ID,
  4804. HEADER_ROW_CHECKBOX_SELECTOR: exports.selectors.HEADER_ROW_CHECKBOX,
  4805. ROW_CHECKBOX_SELECTOR: exports.selectors.ROW_CHECKBOX,
  4806. ROW_SELECTED_SELECTOR: exports.selectors.ROW_SELECTED,
  4807. ROW_SELECTOR: exports.selectors.ROW
  4808. };
  4809. /**
  4810. * Sort values defined by ARIA.
  4811. * See https://www.w3.org/WAI/PF/aria/states_and_properties#aria-sort
  4812. */
  4813. var SortValue;
  4814. (function (SortValue) {
  4815. // Items are sorted in ascending order by this column.
  4816. SortValue["ASCENDING"] = "ascending";
  4817. // Items are sorted in descending order by this column.
  4818. SortValue["DESCENDING"] = "descending";
  4819. // There is no defined sort applied to the column.
  4820. SortValue["NONE"] = "none";
  4821. // A sort algorithm other than ascending or descending has been applied.
  4822. SortValue["OTHER"] = "other";
  4823. })(SortValue = exports.SortValue || (exports.SortValue = {}));
  4824. /**
  4825. * Event names used in component.
  4826. */
  4827. exports.events = {
  4828. ROW_SELECTION_CHANGED: 'MDCDataTable:rowSelectionChanged',
  4829. SELECTED_ALL: 'MDCDataTable:selectedAll',
  4830. UNSELECTED_ALL: 'MDCDataTable:unselectedAll',
  4831. SORTED: 'MDCDataTable:sorted'
  4832. };
  4833. /***/ }),
  4834. /***/ "./packages/mdc-data-table/foundation.ts":
  4835. /*!***********************************************!*\
  4836. !*** ./packages/mdc-data-table/foundation.ts ***!
  4837. \***********************************************/
  4838. /*! no static exports found */
  4839. /***/ (function(module, exports, __webpack_require__) {
  4840. "use strict";
  4841. /**
  4842. * @license
  4843. * Copyright 2019 Google Inc.
  4844. *
  4845. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4846. * of this software and associated documentation files (the "Software"), to deal
  4847. * in the Software without restriction, including without limitation the rights
  4848. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4849. * copies of the Software, and to permit persons to whom the Software is
  4850. * furnished to do so, subject to the following conditions:
  4851. *
  4852. * The above copyright notice and this permission notice shall be included in
  4853. * all copies or substantial portions of the Software.
  4854. *
  4855. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4856. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4857. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4858. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4859. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4860. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4861. * THE SOFTWARE.
  4862. */
  4863. var __extends = this && this.__extends || function () {
  4864. var _extendStatics = function extendStatics(d, b) {
  4865. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4866. d.__proto__ = b;
  4867. } || function (d, b) {
  4868. for (var p in b) {
  4869. if (b.hasOwnProperty(p)) d[p] = b[p];
  4870. }
  4871. };
  4872. return _extendStatics(d, b);
  4873. };
  4874. return function (d, b) {
  4875. _extendStatics(d, b);
  4876. function __() {
  4877. this.constructor = d;
  4878. }
  4879. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4880. };
  4881. }();
  4882. var __assign = this && this.__assign || function () {
  4883. __assign = Object.assign || function (t) {
  4884. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4885. s = arguments[i];
  4886. for (var p in s) {
  4887. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  4888. }
  4889. }
  4890. return t;
  4891. };
  4892. return __assign.apply(this, arguments);
  4893. };
  4894. var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
  4895. function adopt(value) {
  4896. return value instanceof P ? value : new P(function (resolve) {
  4897. resolve(value);
  4898. });
  4899. }
  4900. return new (P || (P = Promise))(function (resolve, reject) {
  4901. function fulfilled(value) {
  4902. try {
  4903. step(generator.next(value));
  4904. } catch (e) {
  4905. reject(e);
  4906. }
  4907. }
  4908. function rejected(value) {
  4909. try {
  4910. step(generator["throw"](value));
  4911. } catch (e) {
  4912. reject(e);
  4913. }
  4914. }
  4915. function step(result) {
  4916. result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
  4917. }
  4918. step((generator = generator.apply(thisArg, _arguments || [])).next());
  4919. });
  4920. };
  4921. var __generator = this && this.__generator || function (thisArg, body) {
  4922. var _ = { label: 0, sent: function sent() {
  4923. if (t[0] & 1) throw t[1];return t[1];
  4924. }, trys: [], ops: [] },
  4925. f,
  4926. y,
  4927. t,
  4928. g;
  4929. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
  4930. return this;
  4931. }), g;
  4932. function verb(n) {
  4933. return function (v) {
  4934. return step([n, v]);
  4935. };
  4936. }
  4937. function step(op) {
  4938. if (f) throw new TypeError("Generator is already executing.");
  4939. while (_) {
  4940. try {
  4941. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  4942. if (y = 0, t) op = [op[0] & 2, t.value];
  4943. switch (op[0]) {
  4944. case 0:case 1:
  4945. t = op;break;
  4946. case 4:
  4947. _.label++;return { value: op[1], done: false };
  4948. case 5:
  4949. _.label++;y = op[1];op = [0];continue;
  4950. case 7:
  4951. op = _.ops.pop();_.trys.pop();continue;
  4952. default:
  4953. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
  4954. _ = 0;continue;
  4955. }
  4956. if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
  4957. _.label = op[1];break;
  4958. }
  4959. if (op[0] === 6 && _.label < t[1]) {
  4960. _.label = t[1];t = op;break;
  4961. }
  4962. if (t && _.label < t[2]) {
  4963. _.label = t[2];_.ops.push(op);break;
  4964. }
  4965. if (t[2]) _.ops.pop();
  4966. _.trys.pop();continue;
  4967. }
  4968. op = body.call(thisArg, _);
  4969. } catch (e) {
  4970. op = [6, e];y = 0;
  4971. } finally {
  4972. f = t = 0;
  4973. }
  4974. }if (op[0] & 5) throw op[1];return { value: op[0] ? op[1] : void 0, done: true };
  4975. }
  4976. };
  4977. Object.defineProperty(exports, "__esModule", { value: true });
  4978. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  4979. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-data-table/constants.ts");
  4980. /**
  4981. * The Foundation of data table component containing pure business logic, any
  4982. * logic requiring DOM manipulation are delegated to adapter methods.
  4983. */
  4984. var MDCDataTableFoundation = /** @class */function (_super) {
  4985. __extends(MDCDataTableFoundation, _super);
  4986. function MDCDataTableFoundation(adapter) {
  4987. return _super.call(this, __assign(__assign({}, MDCDataTableFoundation.defaultAdapter), adapter)) || this;
  4988. }
  4989. Object.defineProperty(MDCDataTableFoundation, "defaultAdapter", {
  4990. get: function get() {
  4991. return {
  4992. addClass: function addClass() {
  4993. return undefined;
  4994. },
  4995. addClassAtRowIndex: function addClassAtRowIndex() {
  4996. return undefined;
  4997. },
  4998. getAttributeByHeaderCellIndex: function getAttributeByHeaderCellIndex() {
  4999. return '';
  5000. },
  5001. getHeaderCellCount: function getHeaderCellCount() {
  5002. return 0;
  5003. },
  5004. getHeaderCellElements: function getHeaderCellElements() {
  5005. return [];
  5006. },
  5007. getRowCount: function getRowCount() {
  5008. return 0;
  5009. },
  5010. getRowElements: function getRowElements() {
  5011. return [];
  5012. },
  5013. getRowIdAtIndex: function getRowIdAtIndex() {
  5014. return '';
  5015. },
  5016. getRowIndexByChildElement: function getRowIndexByChildElement() {
  5017. return 0;
  5018. },
  5019. getSelectedRowCount: function getSelectedRowCount() {
  5020. return 0;
  5021. },
  5022. getTableContainerHeight: function getTableContainerHeight() {
  5023. return 0;
  5024. },
  5025. getTableHeaderHeight: function getTableHeaderHeight() {
  5026. return 0;
  5027. },
  5028. isCheckboxAtRowIndexChecked: function isCheckboxAtRowIndexChecked() {
  5029. return false;
  5030. },
  5031. isHeaderRowCheckboxChecked: function isHeaderRowCheckboxChecked() {
  5032. return false;
  5033. },
  5034. isRowsSelectable: function isRowsSelectable() {
  5035. return false;
  5036. },
  5037. notifyRowSelectionChanged: function notifyRowSelectionChanged() {
  5038. return undefined;
  5039. },
  5040. notifySelectedAll: function notifySelectedAll() {
  5041. return undefined;
  5042. },
  5043. notifySortAction: function notifySortAction() {
  5044. return undefined;
  5045. },
  5046. notifyUnselectedAll: function notifyUnselectedAll() {
  5047. return undefined;
  5048. },
  5049. registerHeaderRowCheckbox: function registerHeaderRowCheckbox() {
  5050. return undefined;
  5051. },
  5052. registerRowCheckboxes: function registerRowCheckboxes() {
  5053. return undefined;
  5054. },
  5055. removeClass: function removeClass() {
  5056. return undefined;
  5057. },
  5058. removeClassAtRowIndex: function removeClassAtRowIndex() {
  5059. return undefined;
  5060. },
  5061. removeClassNameByHeaderCellIndex: function removeClassNameByHeaderCellIndex() {
  5062. return undefined;
  5063. },
  5064. setAttributeAtRowIndex: function setAttributeAtRowIndex() {
  5065. return undefined;
  5066. },
  5067. setAttributeByHeaderCellIndex: function setAttributeByHeaderCellIndex() {
  5068. return undefined;
  5069. },
  5070. setClassNameByHeaderCellIndex: function setClassNameByHeaderCellIndex() {
  5071. return undefined;
  5072. },
  5073. setHeaderRowCheckboxChecked: function setHeaderRowCheckboxChecked() {
  5074. return undefined;
  5075. },
  5076. setHeaderRowCheckboxIndeterminate: function setHeaderRowCheckboxIndeterminate() {
  5077. return undefined;
  5078. },
  5079. setProgressIndicatorStyles: function setProgressIndicatorStyles() {
  5080. return undefined;
  5081. },
  5082. setRowCheckboxCheckedAtIndex: function setRowCheckboxCheckedAtIndex() {
  5083. return undefined;
  5084. },
  5085. setSortStatusLabelByHeaderCellIndex: function setSortStatusLabelByHeaderCellIndex() {
  5086. return undefined;
  5087. }
  5088. };
  5089. },
  5090. enumerable: true,
  5091. configurable: true
  5092. });
  5093. /**
  5094. * Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
  5095. * Use this if registering checkbox is synchronous.
  5096. */
  5097. MDCDataTableFoundation.prototype.layout = function () {
  5098. if (this.adapter.isRowsSelectable()) {
  5099. this.adapter.registerHeaderRowCheckbox();
  5100. this.adapter.registerRowCheckboxes();
  5101. this.setHeaderRowCheckboxState();
  5102. }
  5103. };
  5104. /**
  5105. * Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
  5106. * Use this if registering checkbox is asynchronous.
  5107. */
  5108. MDCDataTableFoundation.prototype.layoutAsync = function () {
  5109. return __awaiter(this, void 0, void 0, function () {
  5110. return __generator(this, function (_a) {
  5111. switch (_a.label) {
  5112. case 0:
  5113. if (!this.adapter.isRowsSelectable()) return [3 /*break*/, 3];
  5114. return [4 /*yield*/, this.adapter.registerHeaderRowCheckbox()];
  5115. case 1:
  5116. _a.sent();
  5117. return [4 /*yield*/, this.adapter.registerRowCheckboxes()];
  5118. case 2:
  5119. _a.sent();
  5120. this.setHeaderRowCheckboxState();
  5121. _a.label = 3;
  5122. case 3:
  5123. return [2 /*return*/];
  5124. }
  5125. });
  5126. });
  5127. };
  5128. /**
  5129. * @return Returns array of row elements.
  5130. */
  5131. MDCDataTableFoundation.prototype.getRows = function () {
  5132. return this.adapter.getRowElements();
  5133. };
  5134. /**
  5135. * @return Array of header cell elements.
  5136. */
  5137. MDCDataTableFoundation.prototype.getHeaderCells = function () {
  5138. return this.adapter.getHeaderCellElements();
  5139. };
  5140. /**
  5141. * Sets selected row ids. Overwrites previously selected rows.
  5142. * @param rowIds Array of row ids that needs to be selected.
  5143. */
  5144. MDCDataTableFoundation.prototype.setSelectedRowIds = function (rowIds) {
  5145. for (var rowIndex = 0; rowIndex < this.adapter.getRowCount(); rowIndex++) {
  5146. var rowId = this.adapter.getRowIdAtIndex(rowIndex);
  5147. var isSelected = false;
  5148. if (rowId && rowIds.indexOf(rowId) >= 0) {
  5149. isSelected = true;
  5150. }
  5151. this.adapter.setRowCheckboxCheckedAtIndex(rowIndex, isSelected);
  5152. this.selectRowAtIndex(rowIndex, isSelected);
  5153. }
  5154. this.setHeaderRowCheckboxState();
  5155. };
  5156. /**
  5157. * @return Returns array of all row ids.
  5158. */
  5159. MDCDataTableFoundation.prototype.getRowIds = function () {
  5160. var rowIds = [];
  5161. for (var rowIndex = 0; rowIndex < this.adapter.getRowCount(); rowIndex++) {
  5162. rowIds.push(this.adapter.getRowIdAtIndex(rowIndex));
  5163. }
  5164. return rowIds;
  5165. };
  5166. /**
  5167. * @return Returns array of selected row ids.
  5168. */
  5169. MDCDataTableFoundation.prototype.getSelectedRowIds = function () {
  5170. var selectedRowIds = [];
  5171. for (var rowIndex = 0; rowIndex < this.adapter.getRowCount(); rowIndex++) {
  5172. if (this.adapter.isCheckboxAtRowIndexChecked(rowIndex)) {
  5173. selectedRowIds.push(this.adapter.getRowIdAtIndex(rowIndex));
  5174. }
  5175. }
  5176. return selectedRowIds;
  5177. };
  5178. /**
  5179. * Handles header row checkbox change event.
  5180. */
  5181. MDCDataTableFoundation.prototype.handleHeaderRowCheckboxChange = function () {
  5182. var isHeaderChecked = this.adapter.isHeaderRowCheckboxChecked();
  5183. for (var rowIndex = 0; rowIndex < this.adapter.getRowCount(); rowIndex++) {
  5184. this.adapter.setRowCheckboxCheckedAtIndex(rowIndex, isHeaderChecked);
  5185. this.selectRowAtIndex(rowIndex, isHeaderChecked);
  5186. }
  5187. if (isHeaderChecked) {
  5188. this.adapter.notifySelectedAll();
  5189. } else {
  5190. this.adapter.notifyUnselectedAll();
  5191. }
  5192. };
  5193. /**
  5194. * Handles change event originated from row checkboxes.
  5195. */
  5196. MDCDataTableFoundation.prototype.handleRowCheckboxChange = function (event) {
  5197. var rowIndex = this.adapter.getRowIndexByChildElement(event.target);
  5198. if (rowIndex === -1) {
  5199. return;
  5200. }
  5201. var selected = this.adapter.isCheckboxAtRowIndexChecked(rowIndex);
  5202. this.selectRowAtIndex(rowIndex, selected);
  5203. this.setHeaderRowCheckboxState();
  5204. var rowId = this.adapter.getRowIdAtIndex(rowIndex);
  5205. this.adapter.notifyRowSelectionChanged({ rowId: rowId, rowIndex: rowIndex, selected: selected });
  5206. };
  5207. /**
  5208. * Handles sort action on sortable header cell.
  5209. */
  5210. MDCDataTableFoundation.prototype.handleSortAction = function (eventData) {
  5211. var columnId = eventData.columnId,
  5212. columnIndex = eventData.columnIndex,
  5213. headerCell = eventData.headerCell;
  5214. // Reset sort attributes / classes on other header cells.
  5215. for (var index = 0; index < this.adapter.getHeaderCellCount(); index++) {
  5216. if (index === columnIndex) {
  5217. continue;
  5218. }
  5219. this.adapter.removeClassNameByHeaderCellIndex(index, constants_1.cssClasses.HEADER_CELL_SORTED);
  5220. this.adapter.removeClassNameByHeaderCellIndex(index, constants_1.cssClasses.HEADER_CELL_SORTED_DESCENDING);
  5221. this.adapter.setAttributeByHeaderCellIndex(index, constants_1.strings.ARIA_SORT, constants_1.SortValue.NONE);
  5222. this.adapter.setSortStatusLabelByHeaderCellIndex(index, constants_1.SortValue.NONE);
  5223. }
  5224. // Set appropriate sort attributes / classes on target header cell.
  5225. this.adapter.setClassNameByHeaderCellIndex(columnIndex, constants_1.cssClasses.HEADER_CELL_SORTED);
  5226. var currentSortValue = this.adapter.getAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT);
  5227. var sortValue = constants_1.SortValue.NONE;
  5228. // Set to descending if sorted on ascending order.
  5229. if (currentSortValue === constants_1.SortValue.ASCENDING) {
  5230. this.adapter.setClassNameByHeaderCellIndex(columnIndex, constants_1.cssClasses.HEADER_CELL_SORTED_DESCENDING);
  5231. this.adapter.setAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT, constants_1.SortValue.DESCENDING);
  5232. sortValue = constants_1.SortValue.DESCENDING;
  5233. // Set to ascending if sorted on descending order.
  5234. } else if (currentSortValue === constants_1.SortValue.DESCENDING) {
  5235. this.adapter.removeClassNameByHeaderCellIndex(columnIndex, constants_1.cssClasses.HEADER_CELL_SORTED_DESCENDING);
  5236. this.adapter.setAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT, constants_1.SortValue.ASCENDING);
  5237. sortValue = constants_1.SortValue.ASCENDING;
  5238. } else {
  5239. // Set to ascending by default when not sorted.
  5240. this.adapter.setAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT, constants_1.SortValue.ASCENDING);
  5241. sortValue = constants_1.SortValue.ASCENDING;
  5242. }
  5243. this.adapter.setSortStatusLabelByHeaderCellIndex(columnIndex, sortValue);
  5244. this.adapter.notifySortAction({
  5245. columnId: columnId,
  5246. columnIndex: columnIndex,
  5247. headerCell: headerCell,
  5248. sortValue: sortValue
  5249. });
  5250. };
  5251. /**
  5252. * Shows progress indicator blocking only the table body content when in
  5253. * loading state.
  5254. */
  5255. MDCDataTableFoundation.prototype.showProgress = function () {
  5256. var tableHeaderHeight = this.adapter.getTableHeaderHeight();
  5257. // Calculate the height of table content (Not scroll content) excluding
  5258. // header row height.
  5259. var height = this.adapter.getTableContainerHeight() - tableHeaderHeight;
  5260. var top = tableHeaderHeight;
  5261. this.adapter.setProgressIndicatorStyles({
  5262. height: height + "px",
  5263. top: top + "px"
  5264. });
  5265. this.adapter.addClass(constants_1.cssClasses.IN_PROGRESS);
  5266. };
  5267. /**
  5268. * Hides progress indicator when data table is finished loading.
  5269. */
  5270. MDCDataTableFoundation.prototype.hideProgress = function () {
  5271. this.adapter.removeClass(constants_1.cssClasses.IN_PROGRESS);
  5272. };
  5273. /**
  5274. * Updates header row checkbox state based on number of rows selected.
  5275. */
  5276. MDCDataTableFoundation.prototype.setHeaderRowCheckboxState = function () {
  5277. if (this.adapter.getSelectedRowCount() === 0) {
  5278. this.adapter.setHeaderRowCheckboxChecked(false);
  5279. this.adapter.setHeaderRowCheckboxIndeterminate(false);
  5280. } else if (this.adapter.getSelectedRowCount() === this.adapter.getRowCount()) {
  5281. this.adapter.setHeaderRowCheckboxChecked(true);
  5282. this.adapter.setHeaderRowCheckboxIndeterminate(false);
  5283. } else {
  5284. this.adapter.setHeaderRowCheckboxIndeterminate(true);
  5285. this.adapter.setHeaderRowCheckboxChecked(false);
  5286. }
  5287. };
  5288. /**
  5289. * Sets the attributes of row element based on selection state.
  5290. */
  5291. MDCDataTableFoundation.prototype.selectRowAtIndex = function (rowIndex, selected) {
  5292. if (selected) {
  5293. this.adapter.addClassAtRowIndex(rowIndex, constants_1.cssClasses.ROW_SELECTED);
  5294. this.adapter.setAttributeAtRowIndex(rowIndex, constants_1.strings.ARIA_SELECTED, 'true');
  5295. } else {
  5296. this.adapter.removeClassAtRowIndex(rowIndex, constants_1.cssClasses.ROW_SELECTED);
  5297. this.adapter.setAttributeAtRowIndex(rowIndex, constants_1.strings.ARIA_SELECTED, 'false');
  5298. }
  5299. };
  5300. return MDCDataTableFoundation;
  5301. }(foundation_1.MDCFoundation);
  5302. exports.MDCDataTableFoundation = MDCDataTableFoundation;
  5303. /***/ }),
  5304. /***/ "./packages/mdc-data-table/index.ts":
  5305. /*!******************************************!*\
  5306. !*** ./packages/mdc-data-table/index.ts ***!
  5307. \******************************************/
  5308. /*! no static exports found */
  5309. /***/ (function(module, exports, __webpack_require__) {
  5310. "use strict";
  5311. /**
  5312. * @license
  5313. * Copyright 2019 Google Inc.
  5314. *
  5315. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5316. * of this software and associated documentation files (the "Software"), to deal
  5317. * in the Software without restriction, including without limitation the rights
  5318. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5319. * copies of the Software, and to permit persons to whom the Software is
  5320. * furnished to do so, subject to the following conditions:
  5321. *
  5322. * The above copyright notice and this permission notice shall be included in
  5323. * all copies or substantial portions of the Software.
  5324. *
  5325. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5326. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5327. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5328. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5329. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5330. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5331. * THE SOFTWARE.
  5332. */
  5333. function __export(m) {
  5334. for (var p in m) {
  5335. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  5336. }
  5337. }
  5338. Object.defineProperty(exports, "__esModule", { value: true });
  5339. __export(__webpack_require__(/*! ./component */ "./packages/mdc-data-table/component.ts"));
  5340. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-data-table/foundation.ts"));
  5341. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-data-table/constants.ts"));
  5342. /***/ }),
  5343. /***/ "./packages/mdc-dialog/component.ts":
  5344. /*!******************************************!*\
  5345. !*** ./packages/mdc-dialog/component.ts ***!
  5346. \******************************************/
  5347. /*! no static exports found */
  5348. /***/ (function(module, exports, __webpack_require__) {
  5349. "use strict";
  5350. /**
  5351. * @license
  5352. * Copyright 2017 Google Inc.
  5353. *
  5354. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5355. * of this software and associated documentation files (the "Software"), to deal
  5356. * in the Software without restriction, including without limitation the rights
  5357. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5358. * copies of the Software, and to permit persons to whom the Software is
  5359. * furnished to do so, subject to the following conditions:
  5360. *
  5361. * The above copyright notice and this permission notice shall be included in
  5362. * all copies or substantial portions of the Software.
  5363. *
  5364. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5365. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5366. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5367. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5368. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5369. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5370. * THE SOFTWARE.
  5371. */
  5372. var __extends = this && this.__extends || function () {
  5373. var _extendStatics = function extendStatics(d, b) {
  5374. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  5375. d.__proto__ = b;
  5376. } || function (d, b) {
  5377. for (var p in b) {
  5378. if (b.hasOwnProperty(p)) d[p] = b[p];
  5379. }
  5380. };
  5381. return _extendStatics(d, b);
  5382. };
  5383. return function (d, b) {
  5384. _extendStatics(d, b);
  5385. function __() {
  5386. this.constructor = d;
  5387. }
  5388. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5389. };
  5390. }();
  5391. var __values = this && this.__values || function (o) {
  5392. var s = typeof Symbol === "function" && Symbol.iterator,
  5393. m = s && o[s],
  5394. i = 0;
  5395. if (m) return m.call(o);
  5396. if (o && typeof o.length === "number") return {
  5397. next: function next() {
  5398. if (o && i >= o.length) o = void 0;
  5399. return { value: o && o[i++], done: !o };
  5400. }
  5401. };
  5402. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  5403. };
  5404. var __importStar = this && this.__importStar || function (mod) {
  5405. if (mod && mod.__esModule) return mod;
  5406. var result = {};
  5407. if (mod != null) for (var k in mod) {
  5408. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  5409. }result["default"] = mod;
  5410. return result;
  5411. };
  5412. Object.defineProperty(exports, "__esModule", { value: true });
  5413. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  5414. var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
  5415. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  5416. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  5417. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts");
  5418. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
  5419. var strings = foundation_1.MDCDialogFoundation.strings;
  5420. var MDCDialog = /** @class */function (_super) {
  5421. __extends(MDCDialog, _super);
  5422. function MDCDialog() {
  5423. return _super !== null && _super.apply(this, arguments) || this;
  5424. }
  5425. Object.defineProperty(MDCDialog.prototype, "isOpen", {
  5426. get: function get() {
  5427. return this.foundation.isOpen();
  5428. },
  5429. enumerable: true,
  5430. configurable: true
  5431. });
  5432. Object.defineProperty(MDCDialog.prototype, "escapeKeyAction", {
  5433. get: function get() {
  5434. return this.foundation.getEscapeKeyAction();
  5435. },
  5436. set: function set(action) {
  5437. this.foundation.setEscapeKeyAction(action);
  5438. },
  5439. enumerable: true,
  5440. configurable: true
  5441. });
  5442. Object.defineProperty(MDCDialog.prototype, "scrimClickAction", {
  5443. get: function get() {
  5444. return this.foundation.getScrimClickAction();
  5445. },
  5446. set: function set(action) {
  5447. this.foundation.setScrimClickAction(action);
  5448. },
  5449. enumerable: true,
  5450. configurable: true
  5451. });
  5452. Object.defineProperty(MDCDialog.prototype, "autoStackButtons", {
  5453. get: function get() {
  5454. return this.foundation.getAutoStackButtons();
  5455. },
  5456. set: function set(autoStack) {
  5457. this.foundation.setAutoStackButtons(autoStack);
  5458. },
  5459. enumerable: true,
  5460. configurable: true
  5461. });
  5462. MDCDialog.attachTo = function (root) {
  5463. return new MDCDialog(root);
  5464. };
  5465. MDCDialog.prototype.initialize = function (focusTrapFactory) {
  5466. var e_1, _a;
  5467. if (focusTrapFactory === void 0) {
  5468. focusTrapFactory = function focusTrapFactory(el, focusOptions) {
  5469. return new focus_trap_1.FocusTrap(el, focusOptions);
  5470. };
  5471. }
  5472. var container = this.root.querySelector(strings.CONTAINER_SELECTOR);
  5473. if (!container) {
  5474. throw new Error("Dialog component requires a " + strings.CONTAINER_SELECTOR + " container element");
  5475. }
  5476. this.container = container;
  5477. this.content = this.root.querySelector(strings.CONTENT_SELECTOR);
  5478. this.buttons = [].slice.call(this.root.querySelectorAll(strings.BUTTON_SELECTOR));
  5479. this.defaultButton = this.root.querySelector("[" + strings.BUTTON_DEFAULT_ATTRIBUTE + "]");
  5480. this.focusTrapFactory = focusTrapFactory;
  5481. this.buttonRipples = [];
  5482. try {
  5483. for (var _b = __values(this.buttons), _c = _b.next(); !_c.done; _c = _b.next()) {
  5484. var buttonEl = _c.value;
  5485. this.buttonRipples.push(new component_2.MDCRipple(buttonEl));
  5486. }
  5487. } catch (e_1_1) {
  5488. e_1 = { error: e_1_1 };
  5489. } finally {
  5490. try {
  5491. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  5492. } finally {
  5493. if (e_1) throw e_1.error;
  5494. }
  5495. }
  5496. };
  5497. MDCDialog.prototype.initialSyncWithDOM = function () {
  5498. var _this = this;
  5499. this.focusTrap = util.createFocusTrapInstance(this.container, this.focusTrapFactory, this.getInitialFocusEl() || undefined);
  5500. this.handleClick = this.foundation.handleClick.bind(this.foundation);
  5501. this.handleKeydown = this.foundation.handleKeydown.bind(this.foundation);
  5502. this.handleDocumentKeydown = this.foundation.handleDocumentKeydown.bind(this.foundation);
  5503. this.handleLayout = this.layout.bind(this);
  5504. var LAYOUT_EVENTS = ['resize', 'orientationchange'];
  5505. this.handleOpening = function () {
  5506. LAYOUT_EVENTS.forEach(function (evtType) {
  5507. window.addEventListener(evtType, _this.handleLayout);
  5508. });
  5509. document.addEventListener('keydown', _this.handleDocumentKeydown);
  5510. };
  5511. this.handleClosing = function () {
  5512. LAYOUT_EVENTS.forEach(function (evtType) {
  5513. window.removeEventListener(evtType, _this.handleLayout);
  5514. });
  5515. document.removeEventListener('keydown', _this.handleDocumentKeydown);
  5516. };
  5517. this.listen('click', this.handleClick);
  5518. this.listen('keydown', this.handleKeydown);
  5519. this.listen(strings.OPENING_EVENT, this.handleOpening);
  5520. this.listen(strings.CLOSING_EVENT, this.handleClosing);
  5521. };
  5522. MDCDialog.prototype.destroy = function () {
  5523. this.unlisten('click', this.handleClick);
  5524. this.unlisten('keydown', this.handleKeydown);
  5525. this.unlisten(strings.OPENING_EVENT, this.handleOpening);
  5526. this.unlisten(strings.CLOSING_EVENT, this.handleClosing);
  5527. this.handleClosing();
  5528. this.buttonRipples.forEach(function (ripple) {
  5529. ripple.destroy();
  5530. });
  5531. _super.prototype.destroy.call(this);
  5532. };
  5533. MDCDialog.prototype.layout = function () {
  5534. this.foundation.layout();
  5535. };
  5536. MDCDialog.prototype.open = function () {
  5537. this.foundation.open();
  5538. };
  5539. MDCDialog.prototype.close = function (action) {
  5540. if (action === void 0) {
  5541. action = '';
  5542. }
  5543. this.foundation.close(action);
  5544. };
  5545. MDCDialog.prototype.getDefaultFoundation = function () {
  5546. var _this = this;
  5547. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  5548. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  5549. var adapter = {
  5550. addBodyClass: function addBodyClass(className) {
  5551. return document.body.classList.add(className);
  5552. },
  5553. addClass: function addClass(className) {
  5554. return _this.root.classList.add(className);
  5555. },
  5556. areButtonsStacked: function areButtonsStacked() {
  5557. return util.areTopsMisaligned(_this.buttons);
  5558. },
  5559. clickDefaultButton: function clickDefaultButton() {
  5560. if (_this.defaultButton) {
  5561. _this.defaultButton.click();
  5562. }
  5563. },
  5564. eventTargetMatches: function eventTargetMatches(target, selector) {
  5565. return target ? ponyfill_1.matches(target, selector) : false;
  5566. },
  5567. getActionFromEvent: function getActionFromEvent(evt) {
  5568. if (!evt.target) {
  5569. return '';
  5570. }
  5571. var element = ponyfill_1.closest(evt.target, "[" + strings.ACTION_ATTRIBUTE + "]");
  5572. return element && element.getAttribute(strings.ACTION_ATTRIBUTE);
  5573. },
  5574. getInitialFocusEl: function getInitialFocusEl() {
  5575. return _this.getInitialFocusEl();
  5576. },
  5577. hasClass: function hasClass(className) {
  5578. return _this.root.classList.contains(className);
  5579. },
  5580. isContentScrollable: function isContentScrollable() {
  5581. return util.isScrollable(_this.content);
  5582. },
  5583. notifyClosed: function notifyClosed(action) {
  5584. return _this.emit(strings.CLOSED_EVENT, action ? { action: action } : {});
  5585. },
  5586. notifyClosing: function notifyClosing(action) {
  5587. return _this.emit(strings.CLOSING_EVENT, action ? { action: action } : {});
  5588. },
  5589. notifyOpened: function notifyOpened() {
  5590. return _this.emit(strings.OPENED_EVENT, {});
  5591. },
  5592. notifyOpening: function notifyOpening() {
  5593. return _this.emit(strings.OPENING_EVENT, {});
  5594. },
  5595. releaseFocus: function releaseFocus() {
  5596. _this.focusTrap.releaseFocus();
  5597. },
  5598. removeBodyClass: function removeBodyClass(className) {
  5599. return document.body.classList.remove(className);
  5600. },
  5601. removeClass: function removeClass(className) {
  5602. return _this.root.classList.remove(className);
  5603. },
  5604. reverseButtons: function reverseButtons() {
  5605. _this.buttons.reverse();
  5606. _this.buttons.forEach(function (button) {
  5607. button.parentElement.appendChild(button);
  5608. });
  5609. },
  5610. trapFocus: function trapFocus() {
  5611. _this.focusTrap.trapFocus();
  5612. },
  5613. registerContentEventHandler: function registerContentEventHandler(evt, handler) {
  5614. if (_this.content instanceof HTMLElement) {
  5615. _this.content.addEventListener(evt, handler);
  5616. }
  5617. },
  5618. deregisterContentEventHandler: function deregisterContentEventHandler(evt, handler) {
  5619. if (_this.content instanceof HTMLElement) {
  5620. _this.content.removeEventListener(evt, handler);
  5621. }
  5622. },
  5623. isScrollableContentAtTop: function isScrollableContentAtTop() {
  5624. return util.isScrollAtTop(_this.content);
  5625. },
  5626. isScrollableContentAtBottom: function isScrollableContentAtBottom() {
  5627. return util.isScrollAtBottom(_this.content);
  5628. }
  5629. };
  5630. return new foundation_1.MDCDialogFoundation(adapter);
  5631. };
  5632. MDCDialog.prototype.getInitialFocusEl = function () {
  5633. return this.root.querySelector("[" + strings.INITIAL_FOCUS_ATTRIBUTE + "]");
  5634. };
  5635. return MDCDialog;
  5636. }(component_1.MDCComponent);
  5637. exports.MDCDialog = MDCDialog;
  5638. /***/ }),
  5639. /***/ "./packages/mdc-dialog/constants.ts":
  5640. /*!******************************************!*\
  5641. !*** ./packages/mdc-dialog/constants.ts ***!
  5642. \******************************************/
  5643. /*! no static exports found */
  5644. /***/ (function(module, exports, __webpack_require__) {
  5645. "use strict";
  5646. /**
  5647. * @license
  5648. * Copyright 2016 Google Inc.
  5649. *
  5650. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5651. * of this software and associated documentation files (the "Software"), to deal
  5652. * in the Software without restriction, including without limitation the rights
  5653. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5654. * copies of the Software, and to permit persons to whom the Software is
  5655. * furnished to do so, subject to the following conditions:
  5656. *
  5657. * The above copyright notice and this permission notice shall be included in
  5658. * all copies or substantial portions of the Software.
  5659. *
  5660. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5661. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5662. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5663. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5664. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5665. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5666. * THE SOFTWARE.
  5667. */
  5668. Object.defineProperty(exports, "__esModule", { value: true });
  5669. exports.cssClasses = {
  5670. CLOSING: 'mdc-dialog--closing',
  5671. OPEN: 'mdc-dialog--open',
  5672. OPENING: 'mdc-dialog--opening',
  5673. SCROLLABLE: 'mdc-dialog--scrollable',
  5674. SCROLL_LOCK: 'mdc-dialog-scroll-lock',
  5675. STACKED: 'mdc-dialog--stacked',
  5676. FULLSCREEN: 'mdc-dialog--fullscreen',
  5677. // Class for showing a scroll divider on full-screen dialog header element.
  5678. // Should only be displayed on scrollable content, when the dialog content is
  5679. // scrolled "underneath" the header.
  5680. SCROLL_DIVIDER_HEADER: 'mdc-dialog-scroll-divider-header',
  5681. // Class for showing a scroll divider on a full-screen dialog footer element.
  5682. // Should only be displayed on scrolalble content, when the dialog content is
  5683. // obscured "underneath" the footer.
  5684. SCROLL_DIVIDER_FOOTER: 'mdc-dialog-scroll-divider-footer'
  5685. };
  5686. exports.strings = {
  5687. ACTION_ATTRIBUTE: 'data-mdc-dialog-action',
  5688. BUTTON_DEFAULT_ATTRIBUTE: 'data-mdc-dialog-button-default',
  5689. BUTTON_SELECTOR: '.mdc-dialog__button',
  5690. CLOSED_EVENT: 'MDCDialog:closed',
  5691. CLOSE_ACTION: 'close',
  5692. CLOSING_EVENT: 'MDCDialog:closing',
  5693. CONTAINER_SELECTOR: '.mdc-dialog__container',
  5694. CONTENT_SELECTOR: '.mdc-dialog__content',
  5695. DESTROY_ACTION: 'destroy',
  5696. INITIAL_FOCUS_ATTRIBUTE: 'data-mdc-dialog-initial-focus',
  5697. OPENED_EVENT: 'MDCDialog:opened',
  5698. OPENING_EVENT: 'MDCDialog:opening',
  5699. SCRIM_SELECTOR: '.mdc-dialog__scrim',
  5700. SUPPRESS_DEFAULT_PRESS_SELECTOR: ['textarea', '.mdc-menu .mdc-list-item'].join(', '),
  5701. SURFACE_SELECTOR: '.mdc-dialog__surface'
  5702. };
  5703. exports.numbers = {
  5704. DIALOG_ANIMATION_CLOSE_TIME_MS: 75,
  5705. DIALOG_ANIMATION_OPEN_TIME_MS: 150
  5706. };
  5707. /***/ }),
  5708. /***/ "./packages/mdc-dialog/foundation.ts":
  5709. /*!*******************************************!*\
  5710. !*** ./packages/mdc-dialog/foundation.ts ***!
  5711. \*******************************************/
  5712. /*! no static exports found */
  5713. /***/ (function(module, exports, __webpack_require__) {
  5714. "use strict";
  5715. /**
  5716. * @license
  5717. * Copyright 2017 Google Inc.
  5718. *
  5719. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5720. * of this software and associated documentation files (the "Software"), to deal
  5721. * in the Software without restriction, including without limitation the rights
  5722. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5723. * copies of the Software, and to permit persons to whom the Software is
  5724. * furnished to do so, subject to the following conditions:
  5725. *
  5726. * The above copyright notice and this permission notice shall be included in
  5727. * all copies or substantial portions of the Software.
  5728. *
  5729. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5730. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5731. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5732. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5733. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5734. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5735. * THE SOFTWARE.
  5736. */
  5737. var __extends = this && this.__extends || function () {
  5738. var _extendStatics = function extendStatics(d, b) {
  5739. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  5740. d.__proto__ = b;
  5741. } || function (d, b) {
  5742. for (var p in b) {
  5743. if (b.hasOwnProperty(p)) d[p] = b[p];
  5744. }
  5745. };
  5746. return _extendStatics(d, b);
  5747. };
  5748. return function (d, b) {
  5749. _extendStatics(d, b);
  5750. function __() {
  5751. this.constructor = d;
  5752. }
  5753. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5754. };
  5755. }();
  5756. var __assign = this && this.__assign || function () {
  5757. __assign = Object.assign || function (t) {
  5758. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5759. s = arguments[i];
  5760. for (var p in s) {
  5761. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  5762. }
  5763. }
  5764. return t;
  5765. };
  5766. return __assign.apply(this, arguments);
  5767. };
  5768. Object.defineProperty(exports, "__esModule", { value: true });
  5769. var animationframe_1 = __webpack_require__(/*! @material/animation/animationframe */ "./packages/mdc-animation/animationframe.ts");
  5770. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  5771. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts");
  5772. var AnimationKeys;
  5773. (function (AnimationKeys) {
  5774. AnimationKeys["POLL_SCROLL_POS"] = "poll_scroll_position";
  5775. })(AnimationKeys || (AnimationKeys = {}));
  5776. var MDCDialogFoundation = /** @class */function (_super) {
  5777. __extends(MDCDialogFoundation, _super);
  5778. function MDCDialogFoundation(adapter) {
  5779. var _this = _super.call(this, __assign(__assign({}, MDCDialogFoundation.defaultAdapter), adapter)) || this;
  5780. _this.dialogOpen = false;
  5781. _this.isFullscreen = false;
  5782. _this.animationFrame = 0;
  5783. _this.animationTimer = 0;
  5784. _this.layoutFrame = 0;
  5785. _this.escapeKeyAction = constants_1.strings.CLOSE_ACTION;
  5786. _this.scrimClickAction = constants_1.strings.CLOSE_ACTION;
  5787. _this.autoStackButtons = true;
  5788. _this.areButtonsStacked = false;
  5789. _this.suppressDefaultPressSelector = constants_1.strings.SUPPRESS_DEFAULT_PRESS_SELECTOR;
  5790. _this.animFrame = new animationframe_1.AnimationFrame();
  5791. _this.contentScrollHandler = function () {
  5792. _this.handleScrollEvent();
  5793. };
  5794. return _this;
  5795. }
  5796. Object.defineProperty(MDCDialogFoundation, "cssClasses", {
  5797. get: function get() {
  5798. return constants_1.cssClasses;
  5799. },
  5800. enumerable: true,
  5801. configurable: true
  5802. });
  5803. Object.defineProperty(MDCDialogFoundation, "strings", {
  5804. get: function get() {
  5805. return constants_1.strings;
  5806. },
  5807. enumerable: true,
  5808. configurable: true
  5809. });
  5810. Object.defineProperty(MDCDialogFoundation, "numbers", {
  5811. get: function get() {
  5812. return constants_1.numbers;
  5813. },
  5814. enumerable: true,
  5815. configurable: true
  5816. });
  5817. Object.defineProperty(MDCDialogFoundation, "defaultAdapter", {
  5818. get: function get() {
  5819. return {
  5820. addBodyClass: function addBodyClass() {
  5821. return undefined;
  5822. },
  5823. addClass: function addClass() {
  5824. return undefined;
  5825. },
  5826. areButtonsStacked: function areButtonsStacked() {
  5827. return false;
  5828. },
  5829. clickDefaultButton: function clickDefaultButton() {
  5830. return undefined;
  5831. },
  5832. eventTargetMatches: function eventTargetMatches() {
  5833. return false;
  5834. },
  5835. getActionFromEvent: function getActionFromEvent() {
  5836. return '';
  5837. },
  5838. getInitialFocusEl: function getInitialFocusEl() {
  5839. return null;
  5840. },
  5841. hasClass: function hasClass() {
  5842. return false;
  5843. },
  5844. isContentScrollable: function isContentScrollable() {
  5845. return false;
  5846. },
  5847. notifyClosed: function notifyClosed() {
  5848. return undefined;
  5849. },
  5850. notifyClosing: function notifyClosing() {
  5851. return undefined;
  5852. },
  5853. notifyOpened: function notifyOpened() {
  5854. return undefined;
  5855. },
  5856. notifyOpening: function notifyOpening() {
  5857. return undefined;
  5858. },
  5859. releaseFocus: function releaseFocus() {
  5860. return undefined;
  5861. },
  5862. removeBodyClass: function removeBodyClass() {
  5863. return undefined;
  5864. },
  5865. removeClass: function removeClass() {
  5866. return undefined;
  5867. },
  5868. reverseButtons: function reverseButtons() {
  5869. return undefined;
  5870. },
  5871. trapFocus: function trapFocus() {
  5872. return undefined;
  5873. },
  5874. registerContentEventHandler: function registerContentEventHandler() {
  5875. return undefined;
  5876. },
  5877. deregisterContentEventHandler: function deregisterContentEventHandler() {
  5878. return undefined;
  5879. },
  5880. isScrollableContentAtTop: function isScrollableContentAtTop() {
  5881. return false;
  5882. },
  5883. isScrollableContentAtBottom: function isScrollableContentAtBottom() {
  5884. return false;
  5885. }
  5886. };
  5887. },
  5888. enumerable: true,
  5889. configurable: true
  5890. });
  5891. MDCDialogFoundation.prototype.init = function () {
  5892. if (this.adapter.hasClass(constants_1.cssClasses.STACKED)) {
  5893. this.setAutoStackButtons(false);
  5894. }
  5895. this.isFullscreen = this.adapter.hasClass(constants_1.cssClasses.FULLSCREEN);
  5896. };
  5897. MDCDialogFoundation.prototype.destroy = function () {
  5898. if (this.dialogOpen) {
  5899. this.close(constants_1.strings.DESTROY_ACTION);
  5900. }
  5901. if (this.animationTimer) {
  5902. clearTimeout(this.animationTimer);
  5903. this.handleAnimationTimerEnd();
  5904. }
  5905. if (this.layoutFrame) {
  5906. cancelAnimationFrame(this.layoutFrame);
  5907. this.layoutFrame = 0;
  5908. }
  5909. if (this.isFullscreen && this.adapter.isContentScrollable()) {
  5910. this.adapter.deregisterContentEventHandler('scroll', this.contentScrollHandler);
  5911. }
  5912. };
  5913. MDCDialogFoundation.prototype.open = function () {
  5914. var _this = this;
  5915. this.dialogOpen = true;
  5916. this.adapter.notifyOpening();
  5917. this.adapter.addClass(constants_1.cssClasses.OPENING);
  5918. if (this.isFullscreen && this.adapter.isContentScrollable()) {
  5919. this.adapter.registerContentEventHandler('scroll', this.contentScrollHandler);
  5920. }
  5921. // Wait a frame once display is no longer "none", to establish basis for
  5922. // animation
  5923. this.runNextAnimationFrame(function () {
  5924. _this.adapter.addClass(constants_1.cssClasses.OPEN);
  5925. _this.adapter.addBodyClass(constants_1.cssClasses.SCROLL_LOCK);
  5926. _this.layout();
  5927. _this.animationTimer = setTimeout(function () {
  5928. _this.handleAnimationTimerEnd();
  5929. _this.adapter.trapFocus(_this.adapter.getInitialFocusEl());
  5930. _this.adapter.notifyOpened();
  5931. }, constants_1.numbers.DIALOG_ANIMATION_OPEN_TIME_MS);
  5932. });
  5933. };
  5934. MDCDialogFoundation.prototype.close = function (action) {
  5935. var _this = this;
  5936. if (action === void 0) {
  5937. action = '';
  5938. }
  5939. if (!this.dialogOpen) {
  5940. // Avoid redundant close calls (and events), e.g. from keydown on elements
  5941. // that inherently emit click
  5942. return;
  5943. }
  5944. this.dialogOpen = false;
  5945. this.adapter.notifyClosing(action);
  5946. this.adapter.addClass(constants_1.cssClasses.CLOSING);
  5947. this.adapter.removeClass(constants_1.cssClasses.OPEN);
  5948. this.adapter.removeBodyClass(constants_1.cssClasses.SCROLL_LOCK);
  5949. if (this.isFullscreen && this.adapter.isContentScrollable()) {
  5950. this.adapter.deregisterContentEventHandler('scroll', this.contentScrollHandler);
  5951. }
  5952. cancelAnimationFrame(this.animationFrame);
  5953. this.animationFrame = 0;
  5954. clearTimeout(this.animationTimer);
  5955. this.animationTimer = setTimeout(function () {
  5956. _this.adapter.releaseFocus();
  5957. _this.handleAnimationTimerEnd();
  5958. _this.adapter.notifyClosed(action);
  5959. }, constants_1.numbers.DIALOG_ANIMATION_CLOSE_TIME_MS);
  5960. };
  5961. MDCDialogFoundation.prototype.isOpen = function () {
  5962. return this.dialogOpen;
  5963. };
  5964. MDCDialogFoundation.prototype.getEscapeKeyAction = function () {
  5965. return this.escapeKeyAction;
  5966. };
  5967. MDCDialogFoundation.prototype.setEscapeKeyAction = function (action) {
  5968. this.escapeKeyAction = action;
  5969. };
  5970. MDCDialogFoundation.prototype.getScrimClickAction = function () {
  5971. return this.scrimClickAction;
  5972. };
  5973. MDCDialogFoundation.prototype.setScrimClickAction = function (action) {
  5974. this.scrimClickAction = action;
  5975. };
  5976. MDCDialogFoundation.prototype.getAutoStackButtons = function () {
  5977. return this.autoStackButtons;
  5978. };
  5979. MDCDialogFoundation.prototype.setAutoStackButtons = function (autoStack) {
  5980. this.autoStackButtons = autoStack;
  5981. };
  5982. MDCDialogFoundation.prototype.getSuppressDefaultPressSelector = function () {
  5983. return this.suppressDefaultPressSelector;
  5984. };
  5985. MDCDialogFoundation.prototype.setSuppressDefaultPressSelector = function (selector) {
  5986. this.suppressDefaultPressSelector = selector;
  5987. };
  5988. MDCDialogFoundation.prototype.layout = function () {
  5989. var _this = this;
  5990. if (this.layoutFrame) {
  5991. cancelAnimationFrame(this.layoutFrame);
  5992. }
  5993. this.layoutFrame = requestAnimationFrame(function () {
  5994. _this.layoutInternal();
  5995. _this.layoutFrame = 0;
  5996. });
  5997. };
  5998. /** Handles click on the dialog root element. */
  5999. MDCDialogFoundation.prototype.handleClick = function (evt) {
  6000. var isScrim = this.adapter.eventTargetMatches(evt.target, constants_1.strings.SCRIM_SELECTOR);
  6001. // Check for scrim click first since it doesn't require querying ancestors.
  6002. if (isScrim && this.scrimClickAction !== '') {
  6003. this.close(this.scrimClickAction);
  6004. } else {
  6005. var action = this.adapter.getActionFromEvent(evt);
  6006. if (action) {
  6007. this.close(action);
  6008. }
  6009. }
  6010. };
  6011. /** Handles keydown on the dialog root element. */
  6012. MDCDialogFoundation.prototype.handleKeydown = function (evt) {
  6013. var isEnter = evt.key === 'Enter' || evt.keyCode === 13;
  6014. if (!isEnter) {
  6015. return;
  6016. }
  6017. var action = this.adapter.getActionFromEvent(evt);
  6018. if (action) {
  6019. // Action button callback is handled in `handleClick`,
  6020. // since space/enter keydowns on buttons trigger click events.
  6021. return;
  6022. }
  6023. // `composedPath` is used here, when available, to account for use cases
  6024. // where a target meant to suppress the default press behaviour
  6025. // may exist in a shadow root.
  6026. // For example, a textarea inside a web component:
  6027. // <mwc-dialog>
  6028. // <horizontal-layout>
  6029. // #shadow-root (open)
  6030. // <mwc-textarea>
  6031. // #shadow-root (open)
  6032. // <textarea></textarea>
  6033. // </mwc-textarea>
  6034. // </horizontal-layout>
  6035. // </mwc-dialog>
  6036. var target = evt.composedPath ? evt.composedPath()[0] : evt.target;
  6037. var isDefault = this.suppressDefaultPressSelector ? !this.adapter.eventTargetMatches(target, this.suppressDefaultPressSelector) : true;
  6038. if (isEnter && isDefault) {
  6039. this.adapter.clickDefaultButton();
  6040. }
  6041. };
  6042. /** Handles keydown on the document. */
  6043. MDCDialogFoundation.prototype.handleDocumentKeydown = function (evt) {
  6044. var isEscape = evt.key === 'Escape' || evt.keyCode === 27;
  6045. if (isEscape && this.escapeKeyAction !== '') {
  6046. this.close(this.escapeKeyAction);
  6047. }
  6048. };
  6049. /**
  6050. * Handles scroll event on the dialog's content element -- showing a scroll
  6051. * divider on the header or footer based on the scroll position. This handler
  6052. * should only be registered on full-screen dialogs with scrollable content.
  6053. */
  6054. MDCDialogFoundation.prototype.handleScrollEvent = function () {
  6055. var _this = this;
  6056. // Since scroll events can fire at a high rate, we throttle these events by
  6057. // using requestAnimationFrame.
  6058. this.animFrame.request(AnimationKeys.POLL_SCROLL_POS, function () {
  6059. _this.toggleScrollDividerHeader();
  6060. _this.toggleScrollDividerFooter();
  6061. });
  6062. };
  6063. MDCDialogFoundation.prototype.layoutInternal = function () {
  6064. if (this.autoStackButtons) {
  6065. this.detectStackedButtons();
  6066. }
  6067. this.toggleScrollableClasses();
  6068. };
  6069. MDCDialogFoundation.prototype.handleAnimationTimerEnd = function () {
  6070. this.animationTimer = 0;
  6071. this.adapter.removeClass(constants_1.cssClasses.OPENING);
  6072. this.adapter.removeClass(constants_1.cssClasses.CLOSING);
  6073. };
  6074. /**
  6075. * Runs the given logic on the next animation frame, using setTimeout to
  6076. * factor in Firefox reflow behavior.
  6077. */
  6078. MDCDialogFoundation.prototype.runNextAnimationFrame = function (callback) {
  6079. var _this = this;
  6080. cancelAnimationFrame(this.animationFrame);
  6081. this.animationFrame = requestAnimationFrame(function () {
  6082. _this.animationFrame = 0;
  6083. clearTimeout(_this.animationTimer);
  6084. _this.animationTimer = setTimeout(callback, 0);
  6085. });
  6086. };
  6087. MDCDialogFoundation.prototype.detectStackedButtons = function () {
  6088. // Remove the class first to let us measure the buttons' natural positions.
  6089. this.adapter.removeClass(constants_1.cssClasses.STACKED);
  6090. var areButtonsStacked = this.adapter.areButtonsStacked();
  6091. if (areButtonsStacked) {
  6092. this.adapter.addClass(constants_1.cssClasses.STACKED);
  6093. }
  6094. if (areButtonsStacked !== this.areButtonsStacked) {
  6095. this.adapter.reverseButtons();
  6096. this.areButtonsStacked = areButtonsStacked;
  6097. }
  6098. };
  6099. MDCDialogFoundation.prototype.toggleScrollableClasses = function () {
  6100. // Remove the class first to let us measure the natural height of the
  6101. // content.
  6102. this.adapter.removeClass(constants_1.cssClasses.SCROLLABLE);
  6103. if (this.adapter.isContentScrollable()) {
  6104. this.adapter.addClass(constants_1.cssClasses.SCROLLABLE);
  6105. if (this.isFullscreen) {
  6106. // If dialog is full-screen and scrollable, check if a scroll divider
  6107. // should be shown.
  6108. this.toggleScrollDividerHeader();
  6109. this.toggleScrollDividerFooter();
  6110. }
  6111. }
  6112. };
  6113. MDCDialogFoundation.prototype.toggleScrollDividerHeader = function () {
  6114. if (!this.adapter.isScrollableContentAtTop()) {
  6115. this.adapter.addClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER);
  6116. } else if (this.adapter.hasClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER)) {
  6117. this.adapter.removeClass(constants_1.cssClasses.SCROLL_DIVIDER_HEADER);
  6118. }
  6119. };
  6120. MDCDialogFoundation.prototype.toggleScrollDividerFooter = function () {
  6121. if (!this.adapter.isScrollableContentAtBottom()) {
  6122. this.adapter.addClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER);
  6123. } else if (this.adapter.hasClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER)) {
  6124. this.adapter.removeClass(constants_1.cssClasses.SCROLL_DIVIDER_FOOTER);
  6125. }
  6126. };
  6127. return MDCDialogFoundation;
  6128. }(foundation_1.MDCFoundation);
  6129. exports.MDCDialogFoundation = MDCDialogFoundation;
  6130. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  6131. exports.default = MDCDialogFoundation;
  6132. /***/ }),
  6133. /***/ "./packages/mdc-dialog/index.ts":
  6134. /*!**************************************!*\
  6135. !*** ./packages/mdc-dialog/index.ts ***!
  6136. \**************************************/
  6137. /*! no static exports found */
  6138. /***/ (function(module, exports, __webpack_require__) {
  6139. "use strict";
  6140. /**
  6141. * @license
  6142. * Copyright 2019 Google Inc.
  6143. *
  6144. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6145. * of this software and associated documentation files (the "Software"), to deal
  6146. * in the Software without restriction, including without limitation the rights
  6147. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6148. * copies of the Software, and to permit persons to whom the Software is
  6149. * furnished to do so, subject to the following conditions:
  6150. *
  6151. * The above copyright notice and this permission notice shall be included in
  6152. * all copies or substantial portions of the Software.
  6153. *
  6154. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6155. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6156. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6157. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6158. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6159. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6160. * THE SOFTWARE.
  6161. */
  6162. function __export(m) {
  6163. for (var p in m) {
  6164. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6165. }
  6166. }
  6167. var __importStar = this && this.__importStar || function (mod) {
  6168. if (mod && mod.__esModule) return mod;
  6169. var result = {};
  6170. if (mod != null) for (var k in mod) {
  6171. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  6172. }result["default"] = mod;
  6173. return result;
  6174. };
  6175. Object.defineProperty(exports, "__esModule", { value: true });
  6176. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
  6177. exports.util = util;
  6178. __export(__webpack_require__(/*! ./component */ "./packages/mdc-dialog/component.ts"));
  6179. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts"));
  6180. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts"));
  6181. /***/ }),
  6182. /***/ "./packages/mdc-dialog/util.ts":
  6183. /*!*************************************!*\
  6184. !*** ./packages/mdc-dialog/util.ts ***!
  6185. \*************************************/
  6186. /*! no static exports found */
  6187. /***/ (function(module, exports, __webpack_require__) {
  6188. "use strict";
  6189. /**
  6190. * @license
  6191. * Copyright 2016 Google Inc.
  6192. *
  6193. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6194. * of this software and associated documentation files (the "Software"), to deal
  6195. * in the Software without restriction, including without limitation the rights
  6196. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6197. * copies of the Software, and to permit persons to whom the Software is
  6198. * furnished to do so, subject to the following conditions:
  6199. *
  6200. * The above copyright notice and this permission notice shall be included in
  6201. * all copies or substantial portions of the Software.
  6202. *
  6203. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6204. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6205. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6206. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6207. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6208. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6209. * THE SOFTWARE.
  6210. */
  6211. Object.defineProperty(exports, "__esModule", { value: true });
  6212. function createFocusTrapInstance(surfaceEl, focusTrapFactory, initialFocusEl) {
  6213. return focusTrapFactory(surfaceEl, { initialFocusEl: initialFocusEl });
  6214. }
  6215. exports.createFocusTrapInstance = createFocusTrapInstance;
  6216. function isScrollable(el) {
  6217. return el ? el.scrollHeight > el.offsetHeight : false;
  6218. }
  6219. exports.isScrollable = isScrollable;
  6220. /**
  6221. * For scrollable content, returns true if the content has not been scrolled
  6222. * (that is, the scroll content is as the "top"). This is used in full-screen
  6223. * dialogs, where the scroll divider is expected only to appear once the
  6224. * content has been scrolled "underneath" the header bar.
  6225. */
  6226. function isScrollAtTop(el) {
  6227. return el ? el.scrollTop === 0 : false;
  6228. }
  6229. exports.isScrollAtTop = isScrollAtTop;
  6230. /**
  6231. * For scrollable content, returns true if the content has been scrolled all the
  6232. * way to the bottom. This is used in full-screen dialogs, where the footer
  6233. * scroll divider is expected only to appear when the content is "cut-off" by
  6234. * the footer bar.
  6235. */
  6236. function isScrollAtBottom(el) {
  6237. return el ? Math.ceil(el.scrollHeight - el.scrollTop) === el.clientHeight : false;
  6238. }
  6239. exports.isScrollAtBottom = isScrollAtBottom;
  6240. function areTopsMisaligned(els) {
  6241. var tops = new Set();
  6242. [].forEach.call(els, function (el) {
  6243. return tops.add(el.offsetTop);
  6244. });
  6245. return tops.size > 1;
  6246. }
  6247. exports.areTopsMisaligned = areTopsMisaligned;
  6248. /***/ }),
  6249. /***/ "./packages/mdc-dom/announce.ts":
  6250. /*!**************************************!*\
  6251. !*** ./packages/mdc-dom/announce.ts ***!
  6252. \**************************************/
  6253. /*! no static exports found */
  6254. /***/ (function(module, exports, __webpack_require__) {
  6255. "use strict";
  6256. /**
  6257. * @license
  6258. * Copyright 2020 Google Inc.
  6259. *
  6260. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6261. * of this software and associated documentation files (the "Software"), to deal
  6262. * in the Software without restriction, including without limitation the rights
  6263. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6264. * copies of the Software, and to permit persons to whom the Software is
  6265. * furnished to do so, subject to the following conditions:
  6266. *
  6267. * The above copyright notice and this permission notice shall be included in
  6268. * all copies or substantial portions of the Software.
  6269. *
  6270. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6271. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6272. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6273. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6274. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6275. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6276. * THE SOFTWARE.
  6277. */
  6278. Object.defineProperty(exports, "__esModule", { value: true });
  6279. /**
  6280. * Priorities for the announce function
  6281. */
  6282. var AnnouncerPriority;
  6283. (function (AnnouncerPriority) {
  6284. AnnouncerPriority["POLITE"] = "polite";
  6285. AnnouncerPriority["ASSERTIVE"] = "assertive";
  6286. })(AnnouncerPriority = exports.AnnouncerPriority || (exports.AnnouncerPriority = {}));
  6287. /**
  6288. * Data attribute added to live region element.
  6289. */
  6290. exports.DATA_MDC_DOM_ANNOUNCE = 'data-mdc-dom-announce';
  6291. /**
  6292. * Announces the given message with optional priority, defaulting to "polite"
  6293. */
  6294. function announce(message, priority) {
  6295. Announcer.getInstance().say(message, priority);
  6296. }
  6297. exports.announce = announce;
  6298. var Announcer = /** @class */function () {
  6299. // Constructor made private to ensure only the singleton is used
  6300. function Announcer() {
  6301. this.liveRegions = new Map();
  6302. }
  6303. Announcer.getInstance = function () {
  6304. if (!Announcer.instance) {
  6305. Announcer.instance = new Announcer();
  6306. }
  6307. return Announcer.instance;
  6308. };
  6309. Announcer.prototype.say = function (message, priority) {
  6310. if (priority === void 0) {
  6311. priority = AnnouncerPriority.POLITE;
  6312. }
  6313. var liveRegion = this.getLiveRegion(priority);
  6314. // Reset the region to pick up the message, even if the message is the
  6315. // exact same as before.
  6316. liveRegion.textContent = '';
  6317. // Timeout is necessary for screen readers like NVDA and VoiceOver.
  6318. setTimeout(function () {
  6319. liveRegion.textContent = message;
  6320. document.addEventListener('click', clearLiveRegion);
  6321. }, 1);
  6322. function clearLiveRegion() {
  6323. liveRegion.textContent = '';
  6324. document.removeEventListener('click', clearLiveRegion);
  6325. }
  6326. };
  6327. Announcer.prototype.getLiveRegion = function (priority) {
  6328. var existingLiveRegion = this.liveRegions.get(priority);
  6329. if (existingLiveRegion && document.body.contains(existingLiveRegion)) {
  6330. return existingLiveRegion;
  6331. }
  6332. var liveRegion = this.createLiveRegion(priority);
  6333. this.liveRegions.set(priority, liveRegion);
  6334. return liveRegion;
  6335. };
  6336. Announcer.prototype.createLiveRegion = function (priority) {
  6337. var el = document.createElement('div');
  6338. el.style.position = 'absolute';
  6339. el.style.top = '-9999px';
  6340. el.style.left = '-9999px';
  6341. el.style.height = '1px';
  6342. el.style.overflow = 'hidden';
  6343. el.setAttribute('aria-atomic', 'true');
  6344. el.setAttribute('aria-live', priority);
  6345. el.setAttribute(exports.DATA_MDC_DOM_ANNOUNCE, 'true');
  6346. document.body.appendChild(el);
  6347. return el;
  6348. };
  6349. return Announcer;
  6350. }();
  6351. /***/ }),
  6352. /***/ "./packages/mdc-dom/events.ts":
  6353. /*!************************************!*\
  6354. !*** ./packages/mdc-dom/events.ts ***!
  6355. \************************************/
  6356. /*! no static exports found */
  6357. /***/ (function(module, exports, __webpack_require__) {
  6358. "use strict";
  6359. /**
  6360. * @license
  6361. * Copyright 2019 Google Inc.
  6362. *
  6363. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6364. * of this software and associated documentation files (the "Software"), to deal
  6365. * in the Software without restriction, including without limitation the rights
  6366. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6367. * copies of the Software, and to permit persons to whom the Software is
  6368. * furnished to do so, subject to the following conditions:
  6369. *
  6370. * The above copyright notice and this permission notice shall be included in
  6371. * all copies or substantial portions of the Software.
  6372. *
  6373. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6374. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6375. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6376. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6377. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6378. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6379. * THE SOFTWARE.
  6380. */
  6381. Object.defineProperty(exports, "__esModule", { value: true });
  6382. /**
  6383. * Determine whether the current browser supports passive event listeners, and
  6384. * if so, use them.
  6385. */
  6386. function applyPassive(globalObj) {
  6387. if (globalObj === void 0) {
  6388. globalObj = window;
  6389. }
  6390. return supportsPassiveOption(globalObj) ? { passive: true } : false;
  6391. }
  6392. exports.applyPassive = applyPassive;
  6393. function supportsPassiveOption(globalObj) {
  6394. if (globalObj === void 0) {
  6395. globalObj = window;
  6396. }
  6397. // See
  6398. // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
  6399. var passiveSupported = false;
  6400. try {
  6401. var options = {
  6402. // This function will be called when the browser
  6403. // attempts to access the passive property.
  6404. get passive() {
  6405. passiveSupported = true;
  6406. return false;
  6407. }
  6408. };
  6409. var handler = function handler() {};
  6410. globalObj.document.addEventListener('test', handler, options);
  6411. globalObj.document.removeEventListener('test', handler, options);
  6412. } catch (err) {
  6413. passiveSupported = false;
  6414. }
  6415. return passiveSupported;
  6416. }
  6417. /***/ }),
  6418. /***/ "./packages/mdc-dom/focus-trap.ts":
  6419. /*!****************************************!*\
  6420. !*** ./packages/mdc-dom/focus-trap.ts ***!
  6421. \****************************************/
  6422. /*! no static exports found */
  6423. /***/ (function(module, exports, __webpack_require__) {
  6424. "use strict";
  6425. /**
  6426. * @license
  6427. * Copyright 2020 Google Inc.
  6428. *
  6429. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6430. * of this software and associated documentation files (the "Software"), to deal
  6431. * in the Software without restriction, including without limitation the rights
  6432. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6433. * copies of the Software, and to permit persons to whom the Software is
  6434. * furnished to do so, subject to the following conditions:
  6435. *
  6436. * The above copyright notice and this permission notice shall be included in
  6437. * all copies or substantial portions of the Software.
  6438. *
  6439. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6440. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6441. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6442. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6443. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6444. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6445. * THE SOFTWARE.
  6446. */
  6447. Object.defineProperty(exports, "__esModule", { value: true });
  6448. var FOCUS_SENTINEL_CLASS = 'mdc-dom-focus-sentinel';
  6449. /**
  6450. * Utility to trap focus in a given root element, e.g. for modal components such
  6451. * as dialogs. The root should have at least one focusable child element,
  6452. * for setting initial focus when trapping focus.
  6453. * Also tracks the previously focused element, and restores focus to that
  6454. * element when releasing focus.
  6455. */
  6456. var FocusTrap = /** @class */function () {
  6457. function FocusTrap(root, options) {
  6458. if (options === void 0) {
  6459. options = {};
  6460. }
  6461. this.root = root;
  6462. this.options = options;
  6463. // Previously focused element before trapping focus.
  6464. this.elFocusedBeforeTrapFocus = null;
  6465. }
  6466. /**
  6467. * Traps focus in `root`. Also focuses on either `initialFocusEl` if set;
  6468. * otherwises sets initial focus to the first focusable child element.
  6469. */
  6470. FocusTrap.prototype.trapFocus = function () {
  6471. var focusableEls = this.getFocusableElements(this.root);
  6472. if (focusableEls.length === 0) {
  6473. throw new Error('FocusTrap: Element must have at least one focusable child.');
  6474. }
  6475. this.elFocusedBeforeTrapFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
  6476. this.wrapTabFocus(this.root, focusableEls);
  6477. if (!this.options.skipInitialFocus) {
  6478. this.focusInitialElement(focusableEls, this.options.initialFocusEl);
  6479. }
  6480. };
  6481. /**
  6482. * Releases focus from `root`. Also restores focus to the previously focused
  6483. * element.
  6484. */
  6485. FocusTrap.prototype.releaseFocus = function () {
  6486. [].slice.call(this.root.querySelectorAll("." + FOCUS_SENTINEL_CLASS)).forEach(function (sentinelEl) {
  6487. sentinelEl.parentElement.removeChild(sentinelEl);
  6488. });
  6489. if (this.elFocusedBeforeTrapFocus) {
  6490. this.elFocusedBeforeTrapFocus.focus();
  6491. }
  6492. };
  6493. /**
  6494. * Wraps tab focus within `el` by adding two hidden sentinel divs which are
  6495. * used to mark the beginning and the end of the tabbable region. When
  6496. * focused, these sentinel elements redirect focus to the first/last
  6497. * children elements of the tabbable region, ensuring that focus is trapped
  6498. * within that region.
  6499. */
  6500. FocusTrap.prototype.wrapTabFocus = function (el, focusableEls) {
  6501. var sentinelStart = this.createSentinel();
  6502. var sentinelEnd = this.createSentinel();
  6503. sentinelStart.addEventListener('focus', function () {
  6504. if (focusableEls.length > 0) {
  6505. focusableEls[focusableEls.length - 1].focus();
  6506. }
  6507. });
  6508. sentinelEnd.addEventListener('focus', function () {
  6509. if (focusableEls.length > 0) {
  6510. focusableEls[0].focus();
  6511. }
  6512. });
  6513. el.insertBefore(sentinelStart, el.children[0]);
  6514. el.appendChild(sentinelEnd);
  6515. };
  6516. /**
  6517. * Focuses on `initialFocusEl` if defined and a child of the root element.
  6518. * Otherwise, focuses on the first focusable child element of the root.
  6519. */
  6520. FocusTrap.prototype.focusInitialElement = function (focusableEls, initialFocusEl) {
  6521. var focusIndex = 0;
  6522. if (initialFocusEl) {
  6523. focusIndex = Math.max(focusableEls.indexOf(initialFocusEl), 0);
  6524. }
  6525. focusableEls[focusIndex].focus();
  6526. };
  6527. FocusTrap.prototype.getFocusableElements = function (root) {
  6528. var focusableEls = [].slice.call(root.querySelectorAll('[autofocus], [tabindex], a, input, textarea, select, button'));
  6529. return focusableEls.filter(function (el) {
  6530. var isDisabledOrHidden = el.getAttribute('aria-disabled') === 'true' || el.getAttribute('disabled') != null || el.getAttribute('hidden') != null || el.getAttribute('aria-hidden') === 'true';
  6531. var isTabbableAndVisible = el.tabIndex >= 0 && el.getBoundingClientRect().width > 0 && !el.classList.contains(FOCUS_SENTINEL_CLASS) && !isDisabledOrHidden;
  6532. var isProgrammaticallyHidden = false;
  6533. if (isTabbableAndVisible) {
  6534. var style = getComputedStyle(el);
  6535. isProgrammaticallyHidden = style.display === 'none' || style.visibility === 'hidden';
  6536. }
  6537. return isTabbableAndVisible && !isProgrammaticallyHidden;
  6538. });
  6539. };
  6540. FocusTrap.prototype.createSentinel = function () {
  6541. var sentinel = document.createElement('div');
  6542. sentinel.setAttribute('tabindex', '0');
  6543. // Don't announce in screen readers.
  6544. sentinel.setAttribute('aria-hidden', 'true');
  6545. sentinel.classList.add(FOCUS_SENTINEL_CLASS);
  6546. return sentinel;
  6547. };
  6548. return FocusTrap;
  6549. }();
  6550. exports.FocusTrap = FocusTrap;
  6551. /***/ }),
  6552. /***/ "./packages/mdc-dom/index.ts":
  6553. /*!***********************************!*\
  6554. !*** ./packages/mdc-dom/index.ts ***!
  6555. \***********************************/
  6556. /*! no static exports found */
  6557. /***/ (function(module, exports, __webpack_require__) {
  6558. "use strict";
  6559. /**
  6560. * @license
  6561. * Copyright 2018 Google Inc.
  6562. *
  6563. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6564. * of this software and associated documentation files (the "Software"), to deal
  6565. * in the Software without restriction, including without limitation the rights
  6566. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6567. * copies of the Software, and to permit persons to whom the Software is
  6568. * furnished to do so, subject to the following conditions:
  6569. *
  6570. * The above copyright notice and this permission notice shall be included in
  6571. * all copies or substantial portions of the Software.
  6572. *
  6573. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6574. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6575. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6576. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6577. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6578. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6579. * THE SOFTWARE.
  6580. */
  6581. var __importStar = this && this.__importStar || function (mod) {
  6582. if (mod && mod.__esModule) return mod;
  6583. var result = {};
  6584. if (mod != null) for (var k in mod) {
  6585. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  6586. }result["default"] = mod;
  6587. return result;
  6588. };
  6589. Object.defineProperty(exports, "__esModule", { value: true });
  6590. var events = __importStar(__webpack_require__(/*! ./events */ "./packages/mdc-dom/events.ts"));
  6591. exports.events = events;
  6592. var focusTrap = __importStar(__webpack_require__(/*! ./focus-trap */ "./packages/mdc-dom/focus-trap.ts"));
  6593. exports.focusTrap = focusTrap;
  6594. var keyboard = __importStar(__webpack_require__(/*! ./keyboard */ "./packages/mdc-dom/keyboard.ts"));
  6595. exports.keyboard = keyboard;
  6596. var ponyfill = __importStar(__webpack_require__(/*! ./ponyfill */ "./packages/mdc-dom/ponyfill.ts"));
  6597. exports.ponyfill = ponyfill;
  6598. /***/ }),
  6599. /***/ "./packages/mdc-dom/keyboard.ts":
  6600. /*!**************************************!*\
  6601. !*** ./packages/mdc-dom/keyboard.ts ***!
  6602. \**************************************/
  6603. /*! no static exports found */
  6604. /***/ (function(module, exports, __webpack_require__) {
  6605. "use strict";
  6606. /**
  6607. * @license
  6608. * Copyright 2020 Google Inc.
  6609. *
  6610. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6611. * of this software and associated documentation files (the "Software"), to deal
  6612. * in the Software without restriction, including without limitation the rights
  6613. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6614. * copies of the Software, and to permit persons to whom the Software is
  6615. * furnished to do so, subject to the following conditions:
  6616. *
  6617. * The above copyright notice and this permission notice shall be included in
  6618. * all copies or substantial portions of the Software.
  6619. *
  6620. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6621. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6622. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6623. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6624. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6625. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6626. * THE SOFTWARE.
  6627. */
  6628. Object.defineProperty(exports, "__esModule", { value: true });
  6629. /**
  6630. * KEY provides normalized string values for keys.
  6631. */
  6632. exports.KEY = {
  6633. UNKNOWN: 'Unknown',
  6634. BACKSPACE: 'Backspace',
  6635. ENTER: 'Enter',
  6636. SPACEBAR: 'Spacebar',
  6637. PAGE_UP: 'PageUp',
  6638. PAGE_DOWN: 'PageDown',
  6639. END: 'End',
  6640. HOME: 'Home',
  6641. ARROW_LEFT: 'ArrowLeft',
  6642. ARROW_UP: 'ArrowUp',
  6643. ARROW_RIGHT: 'ArrowRight',
  6644. ARROW_DOWN: 'ArrowDown',
  6645. DELETE: 'Delete',
  6646. ESCAPE: 'Escape'
  6647. };
  6648. var normalizedKeys = new Set();
  6649. // IE11 has no support for new Map with iterable so we need to initialize this
  6650. // by hand.
  6651. normalizedKeys.add(exports.KEY.BACKSPACE);
  6652. normalizedKeys.add(exports.KEY.ENTER);
  6653. normalizedKeys.add(exports.KEY.SPACEBAR);
  6654. normalizedKeys.add(exports.KEY.PAGE_UP);
  6655. normalizedKeys.add(exports.KEY.PAGE_DOWN);
  6656. normalizedKeys.add(exports.KEY.END);
  6657. normalizedKeys.add(exports.KEY.HOME);
  6658. normalizedKeys.add(exports.KEY.ARROW_LEFT);
  6659. normalizedKeys.add(exports.KEY.ARROW_UP);
  6660. normalizedKeys.add(exports.KEY.ARROW_RIGHT);
  6661. normalizedKeys.add(exports.KEY.ARROW_DOWN);
  6662. normalizedKeys.add(exports.KEY.DELETE);
  6663. normalizedKeys.add(exports.KEY.ESCAPE);
  6664. var KEY_CODE = {
  6665. BACKSPACE: 8,
  6666. ENTER: 13,
  6667. SPACEBAR: 32,
  6668. PAGE_UP: 33,
  6669. PAGE_DOWN: 34,
  6670. END: 35,
  6671. HOME: 36,
  6672. ARROW_LEFT: 37,
  6673. ARROW_UP: 38,
  6674. ARROW_RIGHT: 39,
  6675. ARROW_DOWN: 40,
  6676. DELETE: 46,
  6677. ESCAPE: 27
  6678. };
  6679. var mappedKeyCodes = new Map();
  6680. // IE11 has no support for new Map with iterable so we need to initialize this
  6681. // by hand.
  6682. mappedKeyCodes.set(KEY_CODE.BACKSPACE, exports.KEY.BACKSPACE);
  6683. mappedKeyCodes.set(KEY_CODE.ENTER, exports.KEY.ENTER);
  6684. mappedKeyCodes.set(KEY_CODE.SPACEBAR, exports.KEY.SPACEBAR);
  6685. mappedKeyCodes.set(KEY_CODE.PAGE_UP, exports.KEY.PAGE_UP);
  6686. mappedKeyCodes.set(KEY_CODE.PAGE_DOWN, exports.KEY.PAGE_DOWN);
  6687. mappedKeyCodes.set(KEY_CODE.END, exports.KEY.END);
  6688. mappedKeyCodes.set(KEY_CODE.HOME, exports.KEY.HOME);
  6689. mappedKeyCodes.set(KEY_CODE.ARROW_LEFT, exports.KEY.ARROW_LEFT);
  6690. mappedKeyCodes.set(KEY_CODE.ARROW_UP, exports.KEY.ARROW_UP);
  6691. mappedKeyCodes.set(KEY_CODE.ARROW_RIGHT, exports.KEY.ARROW_RIGHT);
  6692. mappedKeyCodes.set(KEY_CODE.ARROW_DOWN, exports.KEY.ARROW_DOWN);
  6693. mappedKeyCodes.set(KEY_CODE.DELETE, exports.KEY.DELETE);
  6694. mappedKeyCodes.set(KEY_CODE.ESCAPE, exports.KEY.ESCAPE);
  6695. var navigationKeys = new Set();
  6696. // IE11 has no support for new Set with iterable so we need to initialize this
  6697. // by hand.
  6698. navigationKeys.add(exports.KEY.PAGE_UP);
  6699. navigationKeys.add(exports.KEY.PAGE_DOWN);
  6700. navigationKeys.add(exports.KEY.END);
  6701. navigationKeys.add(exports.KEY.HOME);
  6702. navigationKeys.add(exports.KEY.ARROW_LEFT);
  6703. navigationKeys.add(exports.KEY.ARROW_UP);
  6704. navigationKeys.add(exports.KEY.ARROW_RIGHT);
  6705. navigationKeys.add(exports.KEY.ARROW_DOWN);
  6706. /**
  6707. * normalizeKey returns the normalized string for a navigational action.
  6708. */
  6709. function normalizeKey(evt) {
  6710. var key = evt.key;
  6711. // If the event already has a normalized key, return it
  6712. if (normalizedKeys.has(key)) {
  6713. return key;
  6714. }
  6715. // tslint:disable-next-line:deprecation
  6716. var mappedKey = mappedKeyCodes.get(evt.keyCode);
  6717. if (mappedKey) {
  6718. return mappedKey;
  6719. }
  6720. return exports.KEY.UNKNOWN;
  6721. }
  6722. exports.normalizeKey = normalizeKey;
  6723. /**
  6724. * isNavigationEvent returns whether the event is a navigation event
  6725. */
  6726. function isNavigationEvent(evt) {
  6727. return navigationKeys.has(normalizeKey(evt));
  6728. }
  6729. exports.isNavigationEvent = isNavigationEvent;
  6730. /***/ }),
  6731. /***/ "./packages/mdc-dom/ponyfill.ts":
  6732. /*!**************************************!*\
  6733. !*** ./packages/mdc-dom/ponyfill.ts ***!
  6734. \**************************************/
  6735. /*! no static exports found */
  6736. /***/ (function(module, exports, __webpack_require__) {
  6737. "use strict";
  6738. /**
  6739. * @license
  6740. * Copyright 2018 Google Inc.
  6741. *
  6742. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6743. * of this software and associated documentation files (the "Software"), to deal
  6744. * in the Software without restriction, including without limitation the rights
  6745. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6746. * copies of the Software, and to permit persons to whom the Software is
  6747. * furnished to do so, subject to the following conditions:
  6748. *
  6749. * The above copyright notice and this permission notice shall be included in
  6750. * all copies or substantial portions of the Software.
  6751. *
  6752. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6753. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6754. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6755. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6756. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6757. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6758. * THE SOFTWARE.
  6759. */
  6760. Object.defineProperty(exports, "__esModule", { value: true });
  6761. /**
  6762. * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
  6763. * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
  6764. */
  6765. function closest(element, selector) {
  6766. if (element.closest) {
  6767. return element.closest(selector);
  6768. }
  6769. var el = element;
  6770. while (el) {
  6771. if (matches(el, selector)) {
  6772. return el;
  6773. }
  6774. el = el.parentElement;
  6775. }
  6776. return null;
  6777. }
  6778. exports.closest = closest;
  6779. function matches(element, selector) {
  6780. var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
  6781. return nativeMatches.call(element, selector);
  6782. }
  6783. exports.matches = matches;
  6784. /**
  6785. * Used to compute the estimated scroll width of elements. When an element is
  6786. * hidden due to display: none; being applied to a parent element, the width is
  6787. * returned as 0. However, the element will have a true width once no longer
  6788. * inside a display: none context. This method computes an estimated width when
  6789. * the element is hidden or returns the true width when the element is visble.
  6790. * @param {Element} element the element whose width to estimate
  6791. */
  6792. function estimateScrollWidth(element) {
  6793. // Check the offsetParent. If the element inherits display: none from any
  6794. // parent, the offsetParent property will be null (see
  6795. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
  6796. // This check ensures we only clone the node when necessary.
  6797. var htmlEl = element;
  6798. if (htmlEl.offsetParent !== null) {
  6799. return htmlEl.scrollWidth;
  6800. }
  6801. var clone = htmlEl.cloneNode(true);
  6802. clone.style.setProperty('position', 'absolute');
  6803. clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
  6804. document.documentElement.appendChild(clone);
  6805. var scrollWidth = clone.scrollWidth;
  6806. document.documentElement.removeChild(clone);
  6807. return scrollWidth;
  6808. }
  6809. exports.estimateScrollWidth = estimateScrollWidth;
  6810. /***/ }),
  6811. /***/ "./packages/mdc-drawer/component.ts":
  6812. /*!******************************************!*\
  6813. !*** ./packages/mdc-drawer/component.ts ***!
  6814. \******************************************/
  6815. /*! no static exports found */
  6816. /***/ (function(module, exports, __webpack_require__) {
  6817. "use strict";
  6818. /**
  6819. * @license
  6820. * Copyright 2016 Google Inc.
  6821. *
  6822. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6823. * of this software and associated documentation files (the "Software"), to deal
  6824. * in the Software without restriction, including without limitation the rights
  6825. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6826. * copies of the Software, and to permit persons to whom the Software is
  6827. * furnished to do so, subject to the following conditions:
  6828. *
  6829. * The above copyright notice and this permission notice shall be included in
  6830. * all copies or substantial portions of the Software.
  6831. *
  6832. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6833. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6834. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6835. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6836. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6837. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6838. * THE SOFTWARE.
  6839. */
  6840. var __extends = this && this.__extends || function () {
  6841. var _extendStatics = function extendStatics(d, b) {
  6842. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  6843. d.__proto__ = b;
  6844. } || function (d, b) {
  6845. for (var p in b) {
  6846. if (b.hasOwnProperty(p)) d[p] = b[p];
  6847. }
  6848. };
  6849. return _extendStatics(d, b);
  6850. };
  6851. return function (d, b) {
  6852. _extendStatics(d, b);
  6853. function __() {
  6854. this.constructor = d;
  6855. }
  6856. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6857. };
  6858. }();
  6859. var __importStar = this && this.__importStar || function (mod) {
  6860. if (mod && mod.__esModule) return mod;
  6861. var result = {};
  6862. if (mod != null) for (var k in mod) {
  6863. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  6864. }result["default"] = mod;
  6865. return result;
  6866. };
  6867. Object.defineProperty(exports, "__esModule", { value: true });
  6868. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  6869. var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
  6870. var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
  6871. var foundation_1 = __webpack_require__(/*! @material/list/foundation */ "./packages/mdc-list/foundation.ts");
  6872. var foundation_2 = __webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
  6873. var foundation_3 = __webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts");
  6874. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
  6875. var cssClasses = foundation_2.MDCDismissibleDrawerFoundation.cssClasses,
  6876. strings = foundation_2.MDCDismissibleDrawerFoundation.strings;
  6877. /**
  6878. * @events `MDCDrawer:closed {}` Emits when the navigation drawer has closed.
  6879. * @events `MDCDrawer:opened {}` Emits when the navigation drawer has opened.
  6880. */
  6881. var MDCDrawer = /** @class */function (_super) {
  6882. __extends(MDCDrawer, _super);
  6883. function MDCDrawer() {
  6884. return _super !== null && _super.apply(this, arguments) || this;
  6885. }
  6886. MDCDrawer.attachTo = function (root) {
  6887. return new MDCDrawer(root);
  6888. };
  6889. Object.defineProperty(MDCDrawer.prototype, "open", {
  6890. /**
  6891. * @return boolean Proxies to the foundation's `open`/`close` methods.
  6892. * Also returns true if drawer is in the open position.
  6893. */
  6894. get: function get() {
  6895. return this.foundation.isOpen();
  6896. },
  6897. /**
  6898. * Toggles the drawer open and closed.
  6899. */
  6900. set: function set(isOpen) {
  6901. if (isOpen) {
  6902. this.foundation.open();
  6903. } else {
  6904. this.foundation.close();
  6905. }
  6906. },
  6907. enumerable: true,
  6908. configurable: true
  6909. });
  6910. Object.defineProperty(MDCDrawer.prototype, "list", {
  6911. get: function get() {
  6912. return this.list_;
  6913. },
  6914. enumerable: true,
  6915. configurable: true
  6916. });
  6917. MDCDrawer.prototype.initialize = function (focusTrapFactory, listFactory) {
  6918. if (focusTrapFactory === void 0) {
  6919. focusTrapFactory = function focusTrapFactory(el) {
  6920. return new focus_trap_1.FocusTrap(el);
  6921. };
  6922. }
  6923. if (listFactory === void 0) {
  6924. listFactory = function listFactory(el) {
  6925. return new component_2.MDCList(el);
  6926. };
  6927. }
  6928. var listEl = this.root.querySelector("." + foundation_1.MDCListFoundation.cssClasses.ROOT);
  6929. if (listEl) {
  6930. this.list_ = listFactory(listEl);
  6931. this.list_.wrapFocus = true;
  6932. }
  6933. this.focusTrapFactory_ = focusTrapFactory;
  6934. };
  6935. MDCDrawer.prototype.initialSyncWithDOM = function () {
  6936. var _this = this;
  6937. var MODAL = cssClasses.MODAL;
  6938. var SCRIM_SELECTOR = strings.SCRIM_SELECTOR;
  6939. this.scrim_ = this.root.parentNode.querySelector(SCRIM_SELECTOR);
  6940. if (this.scrim_ && this.root.classList.contains(MODAL)) {
  6941. this.handleScrimClick_ = function () {
  6942. return _this.foundation.handleScrimClick();
  6943. };
  6944. this.scrim_.addEventListener('click', this.handleScrimClick_);
  6945. this.focusTrap_ = util.createFocusTrapInstance(this.root, this.focusTrapFactory_);
  6946. }
  6947. this.handleKeydown_ = function (evt) {
  6948. return _this.foundation.handleKeydown(evt);
  6949. };
  6950. this.handleTransitionEnd_ = function (evt) {
  6951. return _this.foundation.handleTransitionEnd(evt);
  6952. };
  6953. this.listen('keydown', this.handleKeydown_);
  6954. this.listen('transitionend', this.handleTransitionEnd_);
  6955. };
  6956. MDCDrawer.prototype.destroy = function () {
  6957. this.unlisten('keydown', this.handleKeydown_);
  6958. this.unlisten('transitionend', this.handleTransitionEnd_);
  6959. if (this.list_) {
  6960. this.list_.destroy();
  6961. }
  6962. var MODAL = cssClasses.MODAL;
  6963. if (this.scrim_ && this.handleScrimClick_ && this.root.classList.contains(MODAL)) {
  6964. this.scrim_.removeEventListener('click', this.handleScrimClick_);
  6965. // Ensure drawer is closed to hide scrim and release focus
  6966. this.open = false;
  6967. }
  6968. };
  6969. MDCDrawer.prototype.getDefaultFoundation = function () {
  6970. var _this = this;
  6971. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  6972. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  6973. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  6974. var adapter = {
  6975. addClass: function addClass(className) {
  6976. return _this.root.classList.add(className);
  6977. },
  6978. removeClass: function removeClass(className) {
  6979. return _this.root.classList.remove(className);
  6980. },
  6981. hasClass: function hasClass(className) {
  6982. return _this.root.classList.contains(className);
  6983. },
  6984. elementHasClass: function elementHasClass(element, className) {
  6985. return element.classList.contains(className);
  6986. },
  6987. saveFocus: function saveFocus() {
  6988. return _this.previousFocus_ = document.activeElement;
  6989. },
  6990. restoreFocus: function restoreFocus() {
  6991. var previousFocus = _this.previousFocus_;
  6992. if (previousFocus && previousFocus.focus && _this.root.contains(document.activeElement)) {
  6993. previousFocus.focus();
  6994. }
  6995. },
  6996. focusActiveNavigationItem: function focusActiveNavigationItem() {
  6997. var activeNavItemEl = _this.root.querySelector("." + foundation_1.MDCListFoundation.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
  6998. if (activeNavItemEl) {
  6999. activeNavItemEl.focus();
  7000. }
  7001. },
  7002. notifyClose: function notifyClose() {
  7003. return _this.emit(strings.CLOSE_EVENT, {}, true /* shouldBubble */);
  7004. },
  7005. notifyOpen: function notifyOpen() {
  7006. return _this.emit(strings.OPEN_EVENT, {}, true /* shouldBubble */);
  7007. },
  7008. trapFocus: function trapFocus() {
  7009. return _this.focusTrap_.trapFocus();
  7010. },
  7011. releaseFocus: function releaseFocus() {
  7012. return _this.focusTrap_.releaseFocus();
  7013. }
  7014. };
  7015. // tslint:enable:object-literal-sort-keys
  7016. var DISMISSIBLE = cssClasses.DISMISSIBLE,
  7017. MODAL = cssClasses.MODAL;
  7018. if (this.root.classList.contains(DISMISSIBLE)) {
  7019. return new foundation_2.MDCDismissibleDrawerFoundation(adapter);
  7020. } else if (this.root.classList.contains(MODAL)) {
  7021. return new foundation_3.MDCModalDrawerFoundation(adapter);
  7022. } else {
  7023. throw new Error("MDCDrawer: Failed to instantiate component. Supported variants are " + DISMISSIBLE + " and " + MODAL + ".");
  7024. }
  7025. };
  7026. return MDCDrawer;
  7027. }(component_1.MDCComponent);
  7028. exports.MDCDrawer = MDCDrawer;
  7029. /***/ }),
  7030. /***/ "./packages/mdc-drawer/constants.ts":
  7031. /*!******************************************!*\
  7032. !*** ./packages/mdc-drawer/constants.ts ***!
  7033. \******************************************/
  7034. /*! no static exports found */
  7035. /***/ (function(module, exports, __webpack_require__) {
  7036. "use strict";
  7037. /**
  7038. * @license
  7039. * Copyright 2016 Google Inc.
  7040. *
  7041. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7042. * of this software and associated documentation files (the "Software"), to deal
  7043. * in the Software without restriction, including without limitation the rights
  7044. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7045. * copies of the Software, and to permit persons to whom the Software is
  7046. * furnished to do so, subject to the following conditions:
  7047. *
  7048. * The above copyright notice and this permission notice shall be included in
  7049. * all copies or substantial portions of the Software.
  7050. *
  7051. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7052. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7053. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7054. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7055. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7056. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7057. * THE SOFTWARE.
  7058. */
  7059. Object.defineProperty(exports, "__esModule", { value: true });
  7060. var cssClasses = {
  7061. ANIMATE: 'mdc-drawer--animate',
  7062. CLOSING: 'mdc-drawer--closing',
  7063. DISMISSIBLE: 'mdc-drawer--dismissible',
  7064. MODAL: 'mdc-drawer--modal',
  7065. OPEN: 'mdc-drawer--open',
  7066. OPENING: 'mdc-drawer--opening',
  7067. ROOT: 'mdc-drawer'
  7068. };
  7069. exports.cssClasses = cssClasses;
  7070. var strings = {
  7071. APP_CONTENT_SELECTOR: '.mdc-drawer-app-content',
  7072. CLOSE_EVENT: 'MDCDrawer:closed',
  7073. OPEN_EVENT: 'MDCDrawer:opened',
  7074. SCRIM_SELECTOR: '.mdc-drawer-scrim'
  7075. };
  7076. exports.strings = strings;
  7077. /***/ }),
  7078. /***/ "./packages/mdc-drawer/dismissible/foundation.ts":
  7079. /*!*******************************************************!*\
  7080. !*** ./packages/mdc-drawer/dismissible/foundation.ts ***!
  7081. \*******************************************************/
  7082. /*! no static exports found */
  7083. /***/ (function(module, exports, __webpack_require__) {
  7084. "use strict";
  7085. /**
  7086. * @license
  7087. * Copyright 2018 Google Inc.
  7088. *
  7089. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7090. * of this software and associated documentation files (the "Software"), to deal
  7091. * in the Software without restriction, including without limitation the rights
  7092. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7093. * copies of the Software, and to permit persons to whom the Software is
  7094. * furnished to do so, subject to the following conditions:
  7095. *
  7096. * The above copyright notice and this permission notice shall be included in
  7097. * all copies or substantial portions of the Software.
  7098. *
  7099. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7100. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7101. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7102. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7103. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7104. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7105. * THE SOFTWARE.
  7106. */
  7107. var __extends = this && this.__extends || function () {
  7108. var _extendStatics = function extendStatics(d, b) {
  7109. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7110. d.__proto__ = b;
  7111. } || function (d, b) {
  7112. for (var p in b) {
  7113. if (b.hasOwnProperty(p)) d[p] = b[p];
  7114. }
  7115. };
  7116. return _extendStatics(d, b);
  7117. };
  7118. return function (d, b) {
  7119. _extendStatics(d, b);
  7120. function __() {
  7121. this.constructor = d;
  7122. }
  7123. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7124. };
  7125. }();
  7126. var __assign = this && this.__assign || function () {
  7127. __assign = Object.assign || function (t) {
  7128. for (var s, i = 1, n = arguments.length; i < n; i++) {
  7129. s = arguments[i];
  7130. for (var p in s) {
  7131. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  7132. }
  7133. }
  7134. return t;
  7135. };
  7136. return __assign.apply(this, arguments);
  7137. };
  7138. Object.defineProperty(exports, "__esModule", { value: true });
  7139. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  7140. var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-drawer/constants.ts");
  7141. var MDCDismissibleDrawerFoundation = /** @class */function (_super) {
  7142. __extends(MDCDismissibleDrawerFoundation, _super);
  7143. function MDCDismissibleDrawerFoundation(adapter) {
  7144. var _this = _super.call(this, __assign(__assign({}, MDCDismissibleDrawerFoundation.defaultAdapter), adapter)) || this;
  7145. _this.animationFrame_ = 0;
  7146. _this.animationTimer_ = 0;
  7147. return _this;
  7148. }
  7149. Object.defineProperty(MDCDismissibleDrawerFoundation, "strings", {
  7150. get: function get() {
  7151. return constants_1.strings;
  7152. },
  7153. enumerable: true,
  7154. configurable: true
  7155. });
  7156. Object.defineProperty(MDCDismissibleDrawerFoundation, "cssClasses", {
  7157. get: function get() {
  7158. return constants_1.cssClasses;
  7159. },
  7160. enumerable: true,
  7161. configurable: true
  7162. });
  7163. Object.defineProperty(MDCDismissibleDrawerFoundation, "defaultAdapter", {
  7164. get: function get() {
  7165. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  7166. return {
  7167. addClass: function addClass() {
  7168. return undefined;
  7169. },
  7170. removeClass: function removeClass() {
  7171. return undefined;
  7172. },
  7173. hasClass: function hasClass() {
  7174. return false;
  7175. },
  7176. elementHasClass: function elementHasClass() {
  7177. return false;
  7178. },
  7179. notifyClose: function notifyClose() {
  7180. return undefined;
  7181. },
  7182. notifyOpen: function notifyOpen() {
  7183. return undefined;
  7184. },
  7185. saveFocus: function saveFocus() {
  7186. return undefined;
  7187. },
  7188. restoreFocus: function restoreFocus() {
  7189. return undefined;
  7190. },
  7191. focusActiveNavigationItem: function focusActiveNavigationItem() {
  7192. return undefined;
  7193. },
  7194. trapFocus: function trapFocus() {
  7195. return undefined;
  7196. },
  7197. releaseFocus: function releaseFocus() {
  7198. return undefined;
  7199. }
  7200. };
  7201. // tslint:enable:object-literal-sort-keys
  7202. },
  7203. enumerable: true,
  7204. configurable: true
  7205. });
  7206. MDCDismissibleDrawerFoundation.prototype.destroy = function () {
  7207. if (this.animationFrame_) {
  7208. cancelAnimationFrame(this.animationFrame_);
  7209. }
  7210. if (this.animationTimer_) {
  7211. clearTimeout(this.animationTimer_);
  7212. }
  7213. };
  7214. /**
  7215. * Opens the drawer from the closed state.
  7216. */
  7217. MDCDismissibleDrawerFoundation.prototype.open = function () {
  7218. var _this = this;
  7219. if (this.isOpen() || this.isOpening() || this.isClosing()) {
  7220. return;
  7221. }
  7222. this.adapter.addClass(constants_1.cssClasses.OPEN);
  7223. this.adapter.addClass(constants_1.cssClasses.ANIMATE);
  7224. // Wait a frame once display is no longer "none", to establish basis for animation
  7225. this.runNextAnimationFrame_(function () {
  7226. _this.adapter.addClass(constants_1.cssClasses.OPENING);
  7227. });
  7228. this.adapter.saveFocus();
  7229. };
  7230. /**
  7231. * Closes the drawer from the open state.
  7232. */
  7233. MDCDismissibleDrawerFoundation.prototype.close = function () {
  7234. if (!this.isOpen() || this.isOpening() || this.isClosing()) {
  7235. return;
  7236. }
  7237. this.adapter.addClass(constants_1.cssClasses.CLOSING);
  7238. };
  7239. /**
  7240. * Returns true if the drawer is in the open position.
  7241. * @return true if drawer is in open state.
  7242. */
  7243. MDCDismissibleDrawerFoundation.prototype.isOpen = function () {
  7244. return this.adapter.hasClass(constants_1.cssClasses.OPEN);
  7245. };
  7246. /**
  7247. * Returns true if the drawer is animating open.
  7248. * @return true if drawer is animating open.
  7249. */
  7250. MDCDismissibleDrawerFoundation.prototype.isOpening = function () {
  7251. return this.adapter.hasClass(constants_1.cssClasses.OPENING) || this.adapter.hasClass(constants_1.cssClasses.ANIMATE);
  7252. };
  7253. /**
  7254. * Returns true if the drawer is animating closed.
  7255. * @return true if drawer is animating closed.
  7256. */
  7257. MDCDismissibleDrawerFoundation.prototype.isClosing = function () {
  7258. return this.adapter.hasClass(constants_1.cssClasses.CLOSING);
  7259. };
  7260. /**
  7261. * Keydown handler to close drawer when key is escape.
  7262. */
  7263. MDCDismissibleDrawerFoundation.prototype.handleKeydown = function (evt) {
  7264. var keyCode = evt.keyCode,
  7265. key = evt.key;
  7266. var isEscape = key === 'Escape' || keyCode === 27;
  7267. if (isEscape) {
  7268. this.close();
  7269. }
  7270. };
  7271. /**
  7272. * Handles the `transitionend` event when the drawer finishes opening/closing.
  7273. */
  7274. MDCDismissibleDrawerFoundation.prototype.handleTransitionEnd = function (evt) {
  7275. var OPENING = constants_1.cssClasses.OPENING,
  7276. CLOSING = constants_1.cssClasses.CLOSING,
  7277. OPEN = constants_1.cssClasses.OPEN,
  7278. ANIMATE = constants_1.cssClasses.ANIMATE,
  7279. ROOT = constants_1.cssClasses.ROOT;
  7280. // In Edge, transitionend on ripple pseudo-elements yields a target without classList, so check for Element first.
  7281. var isRootElement = this.isElement_(evt.target) && this.adapter.elementHasClass(evt.target, ROOT);
  7282. if (!isRootElement) {
  7283. return;
  7284. }
  7285. if (this.isClosing()) {
  7286. this.adapter.removeClass(OPEN);
  7287. this.closed_();
  7288. this.adapter.restoreFocus();
  7289. this.adapter.notifyClose();
  7290. } else {
  7291. this.adapter.focusActiveNavigationItem();
  7292. this.opened_();
  7293. this.adapter.notifyOpen();
  7294. }
  7295. this.adapter.removeClass(ANIMATE);
  7296. this.adapter.removeClass(OPENING);
  7297. this.adapter.removeClass(CLOSING);
  7298. };
  7299. /**
  7300. * Extension point for when drawer finishes open animation.
  7301. */
  7302. MDCDismissibleDrawerFoundation.prototype.opened_ = function () {}; // tslint:disable-line:no-empty
  7303. /**
  7304. * Extension point for when drawer finishes close animation.
  7305. */
  7306. MDCDismissibleDrawerFoundation.prototype.closed_ = function () {}; // tslint:disable-line:no-empty
  7307. /**
  7308. * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
  7309. */
  7310. MDCDismissibleDrawerFoundation.prototype.runNextAnimationFrame_ = function (callback) {
  7311. var _this = this;
  7312. cancelAnimationFrame(this.animationFrame_);
  7313. this.animationFrame_ = requestAnimationFrame(function () {
  7314. _this.animationFrame_ = 0;
  7315. clearTimeout(_this.animationTimer_);
  7316. _this.animationTimer_ = setTimeout(callback, 0);
  7317. });
  7318. };
  7319. MDCDismissibleDrawerFoundation.prototype.isElement_ = function (element) {
  7320. // In Edge, transitionend on ripple pseudo-elements yields a target without classList.
  7321. return Boolean(element.classList);
  7322. };
  7323. return MDCDismissibleDrawerFoundation;
  7324. }(foundation_1.MDCFoundation);
  7325. exports.MDCDismissibleDrawerFoundation = MDCDismissibleDrawerFoundation;
  7326. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  7327. exports.default = MDCDismissibleDrawerFoundation;
  7328. /***/ }),
  7329. /***/ "./packages/mdc-drawer/index.ts":
  7330. /*!**************************************!*\
  7331. !*** ./packages/mdc-drawer/index.ts ***!
  7332. \**************************************/
  7333. /*! no static exports found */
  7334. /***/ (function(module, exports, __webpack_require__) {
  7335. "use strict";
  7336. /**
  7337. * @license
  7338. * Copyright 2019 Google Inc.
  7339. *
  7340. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7341. * of this software and associated documentation files (the "Software"), to deal
  7342. * in the Software without restriction, including without limitation the rights
  7343. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7344. * copies of the Software, and to permit persons to whom the Software is
  7345. * furnished to do so, subject to the following conditions:
  7346. *
  7347. * The above copyright notice and this permission notice shall be included in
  7348. * all copies or substantial portions of the Software.
  7349. *
  7350. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7351. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7352. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7353. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7354. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7355. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7356. * THE SOFTWARE.
  7357. */
  7358. function __export(m) {
  7359. for (var p in m) {
  7360. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  7361. }
  7362. }
  7363. var __importStar = this && this.__importStar || function (mod) {
  7364. if (mod && mod.__esModule) return mod;
  7365. var result = {};
  7366. if (mod != null) for (var k in mod) {
  7367. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  7368. }result["default"] = mod;
  7369. return result;
  7370. };
  7371. Object.defineProperty(exports, "__esModule", { value: true });
  7372. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
  7373. exports.util = util;
  7374. __export(__webpack_require__(/*! ./component */ "./packages/mdc-drawer/component.ts"));
  7375. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-drawer/constants.ts"));
  7376. __export(__webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts"));
  7377. __export(__webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts"));
  7378. /***/ }),
  7379. /***/ "./packages/mdc-drawer/modal/foundation.ts":
  7380. /*!*************************************************!*\
  7381. !*** ./packages/mdc-drawer/modal/foundation.ts ***!
  7382. \*************************************************/
  7383. /*! no static exports found */
  7384. /***/ (function(module, exports, __webpack_require__) {
  7385. "use strict";
  7386. /**
  7387. * @license
  7388. * Copyright 2018 Google Inc.
  7389. *
  7390. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7391. * of this software and associated documentation files (the "Software"), to deal
  7392. * in the Software without restriction, including without limitation the rights
  7393. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7394. * copies of the Software, and to permit persons to whom the Software is
  7395. * furnished to do so, subject to the following conditions:
  7396. *
  7397. * The above copyright notice and this permission notice shall be included in
  7398. * all copies or substantial portions of the Software.
  7399. *
  7400. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7401. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7402. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7403. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7404. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7405. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7406. * THE SOFTWARE.
  7407. */
  7408. var __extends = this && this.__extends || function () {
  7409. var _extendStatics = function extendStatics(d, b) {
  7410. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7411. d.__proto__ = b;
  7412. } || function (d, b) {
  7413. for (var p in b) {
  7414. if (b.hasOwnProperty(p)) d[p] = b[p];
  7415. }
  7416. };
  7417. return _extendStatics(d, b);
  7418. };
  7419. return function (d, b) {
  7420. _extendStatics(d, b);
  7421. function __() {
  7422. this.constructor = d;
  7423. }
  7424. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7425. };
  7426. }();
  7427. Object.defineProperty(exports, "__esModule", { value: true });
  7428. var foundation_1 = __webpack_require__(/*! ../dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
  7429. /* istanbul ignore next: subclass is not a branch statement */
  7430. var MDCModalDrawerFoundation = /** @class */function (_super) {
  7431. __extends(MDCModalDrawerFoundation, _super);
  7432. function MDCModalDrawerFoundation() {
  7433. return _super !== null && _super.apply(this, arguments) || this;
  7434. }
  7435. /**
  7436. * Handles click event on scrim.
  7437. */
  7438. MDCModalDrawerFoundation.prototype.handleScrimClick = function () {
  7439. this.close();
  7440. };
  7441. /**
  7442. * Called when drawer finishes open animation.
  7443. */
  7444. MDCModalDrawerFoundation.prototype.opened_ = function () {
  7445. this.adapter.trapFocus();
  7446. };
  7447. /**
  7448. * Called when drawer finishes close animation.
  7449. */
  7450. MDCModalDrawerFoundation.prototype.closed_ = function () {
  7451. this.adapter.releaseFocus();
  7452. };
  7453. return MDCModalDrawerFoundation;
  7454. }(foundation_1.MDCDismissibleDrawerFoundation);
  7455. exports.MDCModalDrawerFoundation = MDCModalDrawerFoundation;
  7456. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  7457. exports.default = MDCModalDrawerFoundation;
  7458. /***/ }),
  7459. /***/ "./packages/mdc-drawer/util.ts":
  7460. /*!*************************************!*\
  7461. !*** ./packages/mdc-drawer/util.ts ***!
  7462. \*************************************/
  7463. /*! no static exports found */
  7464. /***/ (function(module, exports, __webpack_require__) {
  7465. "use strict";
  7466. /**
  7467. * @license
  7468. * Copyright 2016 Google Inc.
  7469. *
  7470. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7471. * of this software and associated documentation files (the "Software"), to deal
  7472. * in the Software without restriction, including without limitation the rights
  7473. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7474. * copies of the Software, and to permit persons to whom the Software is
  7475. * furnished to do so, subject to the following conditions:
  7476. *
  7477. * The above copyright notice and this permission notice shall be included in
  7478. * all copies or substantial portions of the Software.
  7479. *
  7480. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7481. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7482. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7483. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7484. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7485. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7486. * THE SOFTWARE.
  7487. */
  7488. Object.defineProperty(exports, "__esModule", { value: true });
  7489. function createFocusTrapInstance(surfaceEl, focusTrapFactory) {
  7490. return focusTrapFactory(surfaceEl, {
  7491. // Component handles focusing on active nav item.
  7492. skipInitialFocus: true
  7493. });
  7494. }
  7495. exports.createFocusTrapInstance = createFocusTrapInstance;
  7496. /***/ }),
  7497. /***/ "./packages/mdc-floating-label/component.ts":
  7498. /*!**************************************************!*\
  7499. !*** ./packages/mdc-floating-label/component.ts ***!
  7500. \**************************************************/
  7501. /*! no static exports found */
  7502. /***/ (function(module, exports, __webpack_require__) {
  7503. "use strict";
  7504. /**
  7505. * @license
  7506. * Copyright 2016 Google Inc.
  7507. *
  7508. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7509. * of this software and associated documentation files (the "Software"), to deal
  7510. * in the Software without restriction, including without limitation the rights
  7511. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7512. * copies of the Software, and to permit persons to whom the Software is
  7513. * furnished to do so, subject to the following conditions:
  7514. *
  7515. * The above copyright notice and this permission notice shall be included in
  7516. * all copies or substantial portions of the Software.
  7517. *
  7518. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7519. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7520. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7521. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7522. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7523. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7524. * THE SOFTWARE.
  7525. */
  7526. var __extends = this && this.__extends || function () {
  7527. var _extendStatics = function extendStatics(d, b) {
  7528. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7529. d.__proto__ = b;
  7530. } || function (d, b) {
  7531. for (var p in b) {
  7532. if (b.hasOwnProperty(p)) d[p] = b[p];
  7533. }
  7534. };
  7535. return _extendStatics(d, b);
  7536. };
  7537. return function (d, b) {
  7538. _extendStatics(d, b);
  7539. function __() {
  7540. this.constructor = d;
  7541. }
  7542. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7543. };
  7544. }();
  7545. Object.defineProperty(exports, "__esModule", { value: true });
  7546. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  7547. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  7548. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts");
  7549. var MDCFloatingLabel = /** @class */function (_super) {
  7550. __extends(MDCFloatingLabel, _super);
  7551. function MDCFloatingLabel() {
  7552. return _super !== null && _super.apply(this, arguments) || this;
  7553. }
  7554. MDCFloatingLabel.attachTo = function (root) {
  7555. return new MDCFloatingLabel(root);
  7556. };
  7557. /**
  7558. * Styles the label to produce the label shake for errors.
  7559. * @param shouldShake If true, shakes the label by adding a CSS class; otherwise, stops shaking by removing the class.
  7560. */
  7561. MDCFloatingLabel.prototype.shake = function (shouldShake) {
  7562. this.foundation.shake(shouldShake);
  7563. };
  7564. /**
  7565. * Styles the label to float/dock.
  7566. * @param shouldFloat If true, floats the label by adding a CSS class; otherwise, docks it by removing the class.
  7567. */
  7568. MDCFloatingLabel.prototype.float = function (shouldFloat) {
  7569. this.foundation.float(shouldFloat);
  7570. };
  7571. /**
  7572. * Styles the label as required.
  7573. * @param isRequired If true, adds an asterisk to the label, indicating that it is required.
  7574. */
  7575. MDCFloatingLabel.prototype.setRequired = function (isRequired) {
  7576. this.foundation.setRequired(isRequired);
  7577. };
  7578. MDCFloatingLabel.prototype.getWidth = function () {
  7579. return this.foundation.getWidth();
  7580. };
  7581. MDCFloatingLabel.prototype.getDefaultFoundation = function () {
  7582. var _this = this;
  7583. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  7584. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  7585. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  7586. var adapter = {
  7587. addClass: function addClass(className) {
  7588. return _this.root.classList.add(className);
  7589. },
  7590. removeClass: function removeClass(className) {
  7591. return _this.root.classList.remove(className);
  7592. },
  7593. getWidth: function getWidth() {
  7594. return ponyfill_1.estimateScrollWidth(_this.root);
  7595. },
  7596. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  7597. return _this.listen(evtType, handler);
  7598. },
  7599. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  7600. return _this.unlisten(evtType, handler);
  7601. }
  7602. };
  7603. // tslint:enable:object-literal-sort-keys
  7604. return new foundation_1.MDCFloatingLabelFoundation(adapter);
  7605. };
  7606. return MDCFloatingLabel;
  7607. }(component_1.MDCComponent);
  7608. exports.MDCFloatingLabel = MDCFloatingLabel;
  7609. /***/ }),
  7610. /***/ "./packages/mdc-floating-label/constants.ts":
  7611. /*!**************************************************!*\
  7612. !*** ./packages/mdc-floating-label/constants.ts ***!
  7613. \**************************************************/
  7614. /*! no static exports found */
  7615. /***/ (function(module, exports, __webpack_require__) {
  7616. "use strict";
  7617. /**
  7618. * @license
  7619. * Copyright 2016 Google Inc.
  7620. *
  7621. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7622. * of this software and associated documentation files (the "Software"), to deal
  7623. * in the Software without restriction, including without limitation the rights
  7624. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7625. * copies of the Software, and to permit persons to whom the Software is
  7626. * furnished to do so, subject to the following conditions:
  7627. *
  7628. * The above copyright notice and this permission notice shall be included in
  7629. * all copies or substantial portions of the Software.
  7630. *
  7631. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7632. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7633. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7634. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7635. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7636. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7637. * THE SOFTWARE.
  7638. */
  7639. Object.defineProperty(exports, "__esModule", { value: true });
  7640. exports.cssClasses = {
  7641. LABEL_FLOAT_ABOVE: 'mdc-floating-label--float-above',
  7642. LABEL_REQUIRED: 'mdc-floating-label--required',
  7643. LABEL_SHAKE: 'mdc-floating-label--shake',
  7644. ROOT: 'mdc-floating-label'
  7645. };
  7646. /***/ }),
  7647. /***/ "./packages/mdc-floating-label/foundation.ts":
  7648. /*!***************************************************!*\
  7649. !*** ./packages/mdc-floating-label/foundation.ts ***!
  7650. \***************************************************/
  7651. /*! no static exports found */
  7652. /***/ (function(module, exports, __webpack_require__) {
  7653. "use strict";
  7654. /**
  7655. * @license
  7656. * Copyright 2016 Google Inc.
  7657. *
  7658. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7659. * of this software and associated documentation files (the "Software"), to deal
  7660. * in the Software without restriction, including without limitation the rights
  7661. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7662. * copies of the Software, and to permit persons to whom the Software is
  7663. * furnished to do so, subject to the following conditions:
  7664. *
  7665. * The above copyright notice and this permission notice shall be included in
  7666. * all copies or substantial portions of the Software.
  7667. *
  7668. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7669. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7670. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7671. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7672. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7673. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7674. * THE SOFTWARE.
  7675. */
  7676. var __extends = this && this.__extends || function () {
  7677. var _extendStatics = function extendStatics(d, b) {
  7678. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7679. d.__proto__ = b;
  7680. } || function (d, b) {
  7681. for (var p in b) {
  7682. if (b.hasOwnProperty(p)) d[p] = b[p];
  7683. }
  7684. };
  7685. return _extendStatics(d, b);
  7686. };
  7687. return function (d, b) {
  7688. _extendStatics(d, b);
  7689. function __() {
  7690. this.constructor = d;
  7691. }
  7692. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7693. };
  7694. }();
  7695. var __assign = this && this.__assign || function () {
  7696. __assign = Object.assign || function (t) {
  7697. for (var s, i = 1, n = arguments.length; i < n; i++) {
  7698. s = arguments[i];
  7699. for (var p in s) {
  7700. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  7701. }
  7702. }
  7703. return t;
  7704. };
  7705. return __assign.apply(this, arguments);
  7706. };
  7707. Object.defineProperty(exports, "__esModule", { value: true });
  7708. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  7709. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts");
  7710. var MDCFloatingLabelFoundation = /** @class */function (_super) {
  7711. __extends(MDCFloatingLabelFoundation, _super);
  7712. function MDCFloatingLabelFoundation(adapter) {
  7713. var _this = _super.call(this, __assign(__assign({}, MDCFloatingLabelFoundation.defaultAdapter), adapter)) || this;
  7714. _this.shakeAnimationEndHandler_ = function () {
  7715. return _this.handleShakeAnimationEnd_();
  7716. };
  7717. return _this;
  7718. }
  7719. Object.defineProperty(MDCFloatingLabelFoundation, "cssClasses", {
  7720. get: function get() {
  7721. return constants_1.cssClasses;
  7722. },
  7723. enumerable: true,
  7724. configurable: true
  7725. });
  7726. Object.defineProperty(MDCFloatingLabelFoundation, "defaultAdapter", {
  7727. /**
  7728. * See {@link MDCFloatingLabelAdapter} for typing information on parameters and return types.
  7729. */
  7730. get: function get() {
  7731. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  7732. return {
  7733. addClass: function addClass() {
  7734. return undefined;
  7735. },
  7736. removeClass: function removeClass() {
  7737. return undefined;
  7738. },
  7739. getWidth: function getWidth() {
  7740. return 0;
  7741. },
  7742. registerInteractionHandler: function registerInteractionHandler() {
  7743. return undefined;
  7744. },
  7745. deregisterInteractionHandler: function deregisterInteractionHandler() {
  7746. return undefined;
  7747. }
  7748. };
  7749. // tslint:enable:object-literal-sort-keys
  7750. },
  7751. enumerable: true,
  7752. configurable: true
  7753. });
  7754. MDCFloatingLabelFoundation.prototype.init = function () {
  7755. this.adapter.registerInteractionHandler('animationend', this.shakeAnimationEndHandler_);
  7756. };
  7757. MDCFloatingLabelFoundation.prototype.destroy = function () {
  7758. this.adapter.deregisterInteractionHandler('animationend', this.shakeAnimationEndHandler_);
  7759. };
  7760. /**
  7761. * Returns the width of the label element.
  7762. */
  7763. MDCFloatingLabelFoundation.prototype.getWidth = function () {
  7764. return this.adapter.getWidth();
  7765. };
  7766. /**
  7767. * Styles the label to produce a shake animation to indicate an error.
  7768. * @param shouldShake If true, adds the shake CSS class; otherwise, removes shake class.
  7769. */
  7770. MDCFloatingLabelFoundation.prototype.shake = function (shouldShake) {
  7771. var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
  7772. if (shouldShake) {
  7773. this.adapter.addClass(LABEL_SHAKE);
  7774. } else {
  7775. this.adapter.removeClass(LABEL_SHAKE);
  7776. }
  7777. };
  7778. /**
  7779. * Styles the label to float or dock.
  7780. * @param shouldFloat If true, adds the float CSS class; otherwise, removes float and shake classes to dock the label.
  7781. */
  7782. MDCFloatingLabelFoundation.prototype.float = function (shouldFloat) {
  7783. var _a = MDCFloatingLabelFoundation.cssClasses,
  7784. LABEL_FLOAT_ABOVE = _a.LABEL_FLOAT_ABOVE,
  7785. LABEL_SHAKE = _a.LABEL_SHAKE;
  7786. if (shouldFloat) {
  7787. this.adapter.addClass(LABEL_FLOAT_ABOVE);
  7788. } else {
  7789. this.adapter.removeClass(LABEL_FLOAT_ABOVE);
  7790. this.adapter.removeClass(LABEL_SHAKE);
  7791. }
  7792. };
  7793. /**
  7794. * Styles the label as required.
  7795. * @param isRequired If true, adds an asterisk to the label, indicating that it is required.
  7796. */
  7797. MDCFloatingLabelFoundation.prototype.setRequired = function (isRequired) {
  7798. var LABEL_REQUIRED = MDCFloatingLabelFoundation.cssClasses.LABEL_REQUIRED;
  7799. if (isRequired) {
  7800. this.adapter.addClass(LABEL_REQUIRED);
  7801. } else {
  7802. this.adapter.removeClass(LABEL_REQUIRED);
  7803. }
  7804. };
  7805. MDCFloatingLabelFoundation.prototype.handleShakeAnimationEnd_ = function () {
  7806. var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
  7807. this.adapter.removeClass(LABEL_SHAKE);
  7808. };
  7809. return MDCFloatingLabelFoundation;
  7810. }(foundation_1.MDCFoundation);
  7811. exports.MDCFloatingLabelFoundation = MDCFloatingLabelFoundation;
  7812. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  7813. exports.default = MDCFloatingLabelFoundation;
  7814. /***/ }),
  7815. /***/ "./packages/mdc-floating-label/index.ts":
  7816. /*!**********************************************!*\
  7817. !*** ./packages/mdc-floating-label/index.ts ***!
  7818. \**********************************************/
  7819. /*! no static exports found */
  7820. /***/ (function(module, exports, __webpack_require__) {
  7821. "use strict";
  7822. /**
  7823. * @license
  7824. * Copyright 2019 Google Inc.
  7825. *
  7826. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7827. * of this software and associated documentation files (the "Software"), to deal
  7828. * in the Software without restriction, including without limitation the rights
  7829. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7830. * copies of the Software, and to permit persons to whom the Software is
  7831. * furnished to do so, subject to the following conditions:
  7832. *
  7833. * The above copyright notice and this permission notice shall be included in
  7834. * all copies or substantial portions of the Software.
  7835. *
  7836. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7837. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7838. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7839. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7840. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7841. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7842. * THE SOFTWARE.
  7843. */
  7844. function __export(m) {
  7845. for (var p in m) {
  7846. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  7847. }
  7848. }
  7849. Object.defineProperty(exports, "__esModule", { value: true });
  7850. __export(__webpack_require__(/*! ./component */ "./packages/mdc-floating-label/component.ts"));
  7851. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts"));
  7852. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts"));
  7853. /***/ }),
  7854. /***/ "./packages/mdc-form-field/component.ts":
  7855. /*!**********************************************!*\
  7856. !*** ./packages/mdc-form-field/component.ts ***!
  7857. \**********************************************/
  7858. /*! no static exports found */
  7859. /***/ (function(module, exports, __webpack_require__) {
  7860. "use strict";
  7861. /**
  7862. * @license
  7863. * Copyright 2017 Google Inc.
  7864. *
  7865. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7866. * of this software and associated documentation files (the "Software"), to deal
  7867. * in the Software without restriction, including without limitation the rights
  7868. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7869. * copies of the Software, and to permit persons to whom the Software is
  7870. * furnished to do so, subject to the following conditions:
  7871. *
  7872. * The above copyright notice and this permission notice shall be included in
  7873. * all copies or substantial portions of the Software.
  7874. *
  7875. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7876. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7877. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7878. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7879. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7880. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7881. * THE SOFTWARE.
  7882. */
  7883. var __extends = this && this.__extends || function () {
  7884. var _extendStatics = function extendStatics(d, b) {
  7885. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7886. d.__proto__ = b;
  7887. } || function (d, b) {
  7888. for (var p in b) {
  7889. if (b.hasOwnProperty(p)) d[p] = b[p];
  7890. }
  7891. };
  7892. return _extendStatics(d, b);
  7893. };
  7894. return function (d, b) {
  7895. _extendStatics(d, b);
  7896. function __() {
  7897. this.constructor = d;
  7898. }
  7899. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7900. };
  7901. }();
  7902. Object.defineProperty(exports, "__esModule", { value: true });
  7903. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  7904. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-form-field/foundation.ts");
  7905. var MDCFormField = /** @class */function (_super) {
  7906. __extends(MDCFormField, _super);
  7907. function MDCFormField() {
  7908. return _super !== null && _super.apply(this, arguments) || this;
  7909. }
  7910. MDCFormField.attachTo = function (root) {
  7911. return new MDCFormField(root);
  7912. };
  7913. MDCFormField.prototype.labelEl = function () {
  7914. var LABEL_SELECTOR = foundation_1.MDCFormFieldFoundation.strings.LABEL_SELECTOR;
  7915. return this.root.querySelector(LABEL_SELECTOR);
  7916. };
  7917. MDCFormField.prototype.getDefaultFoundation = function () {
  7918. var _this = this;
  7919. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  7920. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  7921. var adapter = {
  7922. activateInputRipple: function activateInputRipple() {
  7923. if (_this.input && _this.input.ripple) {
  7924. _this.input.ripple.activate();
  7925. }
  7926. },
  7927. deactivateInputRipple: function deactivateInputRipple() {
  7928. if (_this.input && _this.input.ripple) {
  7929. _this.input.ripple.deactivate();
  7930. }
  7931. },
  7932. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  7933. var labelEl = _this.labelEl();
  7934. if (labelEl) {
  7935. labelEl.removeEventListener(evtType, handler);
  7936. }
  7937. },
  7938. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  7939. var labelEl = _this.labelEl();
  7940. if (labelEl) {
  7941. labelEl.addEventListener(evtType, handler);
  7942. }
  7943. }
  7944. };
  7945. return new foundation_1.MDCFormFieldFoundation(adapter);
  7946. };
  7947. return MDCFormField;
  7948. }(component_1.MDCComponent);
  7949. exports.MDCFormField = MDCFormField;
  7950. /***/ }),
  7951. /***/ "./packages/mdc-form-field/constants.ts":
  7952. /*!**********************************************!*\
  7953. !*** ./packages/mdc-form-field/constants.ts ***!
  7954. \**********************************************/
  7955. /*! no static exports found */
  7956. /***/ (function(module, exports, __webpack_require__) {
  7957. "use strict";
  7958. /**
  7959. * @license
  7960. * Copyright 2017 Google Inc.
  7961. *
  7962. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7963. * of this software and associated documentation files (the "Software"), to deal
  7964. * in the Software without restriction, including without limitation the rights
  7965. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7966. * copies of the Software, and to permit persons to whom the Software is
  7967. * furnished to do so, subject to the following conditions:
  7968. *
  7969. * The above copyright notice and this permission notice shall be included in
  7970. * all copies or substantial portions of the Software.
  7971. *
  7972. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7973. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7974. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7975. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7976. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7977. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7978. * THE SOFTWARE.
  7979. */
  7980. Object.defineProperty(exports, "__esModule", { value: true });
  7981. exports.cssClasses = {
  7982. ROOT: 'mdc-form-field'
  7983. };
  7984. exports.strings = {
  7985. LABEL_SELECTOR: '.mdc-form-field > label'
  7986. };
  7987. /***/ }),
  7988. /***/ "./packages/mdc-form-field/foundation.ts":
  7989. /*!***********************************************!*\
  7990. !*** ./packages/mdc-form-field/foundation.ts ***!
  7991. \***********************************************/
  7992. /*! no static exports found */
  7993. /***/ (function(module, exports, __webpack_require__) {
  7994. "use strict";
  7995. /**
  7996. * @license
  7997. * Copyright 2017 Google Inc.
  7998. *
  7999. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8000. * of this software and associated documentation files (the "Software"), to deal
  8001. * in the Software without restriction, including without limitation the rights
  8002. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8003. * copies of the Software, and to permit persons to whom the Software is
  8004. * furnished to do so, subject to the following conditions:
  8005. *
  8006. * The above copyright notice and this permission notice shall be included in
  8007. * all copies or substantial portions of the Software.
  8008. *
  8009. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8010. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8011. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8012. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8013. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8014. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8015. * THE SOFTWARE.
  8016. */
  8017. var __extends = this && this.__extends || function () {
  8018. var _extendStatics = function extendStatics(d, b) {
  8019. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8020. d.__proto__ = b;
  8021. } || function (d, b) {
  8022. for (var p in b) {
  8023. if (b.hasOwnProperty(p)) d[p] = b[p];
  8024. }
  8025. };
  8026. return _extendStatics(d, b);
  8027. };
  8028. return function (d, b) {
  8029. _extendStatics(d, b);
  8030. function __() {
  8031. this.constructor = d;
  8032. }
  8033. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8034. };
  8035. }();
  8036. var __assign = this && this.__assign || function () {
  8037. __assign = Object.assign || function (t) {
  8038. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8039. s = arguments[i];
  8040. for (var p in s) {
  8041. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  8042. }
  8043. }
  8044. return t;
  8045. };
  8046. return __assign.apply(this, arguments);
  8047. };
  8048. Object.defineProperty(exports, "__esModule", { value: true });
  8049. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  8050. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-form-field/constants.ts");
  8051. var MDCFormFieldFoundation = /** @class */function (_super) {
  8052. __extends(MDCFormFieldFoundation, _super);
  8053. function MDCFormFieldFoundation(adapter) {
  8054. var _this = _super.call(this, __assign(__assign({}, MDCFormFieldFoundation.defaultAdapter), adapter)) || this;
  8055. _this.click = function () {
  8056. _this.handleClick();
  8057. };
  8058. return _this;
  8059. }
  8060. Object.defineProperty(MDCFormFieldFoundation, "cssClasses", {
  8061. get: function get() {
  8062. return constants_1.cssClasses;
  8063. },
  8064. enumerable: true,
  8065. configurable: true
  8066. });
  8067. Object.defineProperty(MDCFormFieldFoundation, "strings", {
  8068. get: function get() {
  8069. return constants_1.strings;
  8070. },
  8071. enumerable: true,
  8072. configurable: true
  8073. });
  8074. Object.defineProperty(MDCFormFieldFoundation, "defaultAdapter", {
  8075. get: function get() {
  8076. return {
  8077. activateInputRipple: function activateInputRipple() {
  8078. return undefined;
  8079. },
  8080. deactivateInputRipple: function deactivateInputRipple() {
  8081. return undefined;
  8082. },
  8083. deregisterInteractionHandler: function deregisterInteractionHandler() {
  8084. return undefined;
  8085. },
  8086. registerInteractionHandler: function registerInteractionHandler() {
  8087. return undefined;
  8088. }
  8089. };
  8090. },
  8091. enumerable: true,
  8092. configurable: true
  8093. });
  8094. MDCFormFieldFoundation.prototype.init = function () {
  8095. this.adapter.registerInteractionHandler('click', this.click);
  8096. };
  8097. MDCFormFieldFoundation.prototype.destroy = function () {
  8098. this.adapter.deregisterInteractionHandler('click', this.click);
  8099. };
  8100. MDCFormFieldFoundation.prototype.handleClick = function () {
  8101. var _this = this;
  8102. this.adapter.activateInputRipple();
  8103. requestAnimationFrame(function () {
  8104. _this.adapter.deactivateInputRipple();
  8105. });
  8106. };
  8107. return MDCFormFieldFoundation;
  8108. }(foundation_1.MDCFoundation);
  8109. exports.MDCFormFieldFoundation = MDCFormFieldFoundation;
  8110. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  8111. exports.default = MDCFormFieldFoundation;
  8112. /***/ }),
  8113. /***/ "./packages/mdc-form-field/index.ts":
  8114. /*!******************************************!*\
  8115. !*** ./packages/mdc-form-field/index.ts ***!
  8116. \******************************************/
  8117. /*! no static exports found */
  8118. /***/ (function(module, exports, __webpack_require__) {
  8119. "use strict";
  8120. /**
  8121. * @license
  8122. * Copyright 2019 Google Inc.
  8123. *
  8124. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8125. * of this software and associated documentation files (the "Software"), to deal
  8126. * in the Software without restriction, including without limitation the rights
  8127. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8128. * copies of the Software, and to permit persons to whom the Software is
  8129. * furnished to do so, subject to the following conditions:
  8130. *
  8131. * The above copyright notice and this permission notice shall be included in
  8132. * all copies or substantial portions of the Software.
  8133. *
  8134. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8135. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8136. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8137. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8138. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8139. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8140. * THE SOFTWARE.
  8141. */
  8142. function __export(m) {
  8143. for (var p in m) {
  8144. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  8145. }
  8146. }
  8147. Object.defineProperty(exports, "__esModule", { value: true });
  8148. __export(__webpack_require__(/*! ./component */ "./packages/mdc-form-field/component.ts"));
  8149. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-form-field/constants.ts"));
  8150. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-form-field/foundation.ts"));
  8151. /***/ }),
  8152. /***/ "./packages/mdc-icon-button/component.ts":
  8153. /*!***********************************************!*\
  8154. !*** ./packages/mdc-icon-button/component.ts ***!
  8155. \***********************************************/
  8156. /*! no static exports found */
  8157. /***/ (function(module, exports, __webpack_require__) {
  8158. "use strict";
  8159. /**
  8160. * @license
  8161. * Copyright 2018 Google Inc.
  8162. *
  8163. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8164. * of this software and associated documentation files (the "Software"), to deal
  8165. * in the Software without restriction, including without limitation the rights
  8166. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8167. * copies of the Software, and to permit persons to whom the Software is
  8168. * furnished to do so, subject to the following conditions:
  8169. *
  8170. * The above copyright notice and this permission notice shall be included in
  8171. * all copies or substantial portions of the Software.
  8172. *
  8173. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8174. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8175. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8176. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8177. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8178. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8179. * THE SOFTWARE.
  8180. */
  8181. var __extends = this && this.__extends || function () {
  8182. var _extendStatics = function extendStatics(d, b) {
  8183. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8184. d.__proto__ = b;
  8185. } || function (d, b) {
  8186. for (var p in b) {
  8187. if (b.hasOwnProperty(p)) d[p] = b[p];
  8188. }
  8189. };
  8190. return _extendStatics(d, b);
  8191. };
  8192. return function (d, b) {
  8193. _extendStatics(d, b);
  8194. function __() {
  8195. this.constructor = d;
  8196. }
  8197. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8198. };
  8199. }();
  8200. Object.defineProperty(exports, "__esModule", { value: true });
  8201. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  8202. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  8203. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-icon-button/foundation.ts");
  8204. var strings = foundation_1.MDCIconButtonToggleFoundation.strings;
  8205. var MDCIconButtonToggle = /** @class */function (_super) {
  8206. __extends(MDCIconButtonToggle, _super);
  8207. function MDCIconButtonToggle() {
  8208. var _this = _super !== null && _super.apply(this, arguments) || this;
  8209. _this.rippleComponent = _this.createRipple();
  8210. return _this;
  8211. }
  8212. MDCIconButtonToggle.attachTo = function (root) {
  8213. return new MDCIconButtonToggle(root);
  8214. };
  8215. MDCIconButtonToggle.prototype.initialSyncWithDOM = function () {
  8216. var _this = this;
  8217. this.handleClick = function () {
  8218. _this.foundation.handleClick();
  8219. };
  8220. this.listen('click', this.handleClick);
  8221. };
  8222. MDCIconButtonToggle.prototype.destroy = function () {
  8223. this.unlisten('click', this.handleClick);
  8224. this.ripple.destroy();
  8225. _super.prototype.destroy.call(this);
  8226. };
  8227. MDCIconButtonToggle.prototype.getDefaultFoundation = function () {
  8228. var _this = this;
  8229. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  8230. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  8231. var adapter = {
  8232. addClass: function addClass(className) {
  8233. return _this.root.classList.add(className);
  8234. },
  8235. hasClass: function hasClass(className) {
  8236. return _this.root.classList.contains(className);
  8237. },
  8238. notifyChange: function notifyChange(evtData) {
  8239. _this.emit(strings.CHANGE_EVENT, evtData);
  8240. },
  8241. removeClass: function removeClass(className) {
  8242. return _this.root.classList.remove(className);
  8243. },
  8244. getAttr: function getAttr(attrName) {
  8245. return _this.root.getAttribute(attrName);
  8246. },
  8247. setAttr: function setAttr(attrName, attrValue) {
  8248. return _this.root.setAttribute(attrName, attrValue);
  8249. }
  8250. };
  8251. return new foundation_1.MDCIconButtonToggleFoundation(adapter);
  8252. };
  8253. Object.defineProperty(MDCIconButtonToggle.prototype, "ripple", {
  8254. get: function get() {
  8255. return this.rippleComponent;
  8256. },
  8257. enumerable: true,
  8258. configurable: true
  8259. });
  8260. Object.defineProperty(MDCIconButtonToggle.prototype, "on", {
  8261. get: function get() {
  8262. return this.foundation.isOn();
  8263. },
  8264. set: function set(isOn) {
  8265. this.foundation.toggle(isOn);
  8266. },
  8267. enumerable: true,
  8268. configurable: true
  8269. });
  8270. MDCIconButtonToggle.prototype.createRipple = function () {
  8271. var ripple = new component_2.MDCRipple(this.root);
  8272. ripple.unbounded = true;
  8273. return ripple;
  8274. };
  8275. return MDCIconButtonToggle;
  8276. }(component_1.MDCComponent);
  8277. exports.MDCIconButtonToggle = MDCIconButtonToggle;
  8278. /***/ }),
  8279. /***/ "./packages/mdc-icon-button/constants.ts":
  8280. /*!***********************************************!*\
  8281. !*** ./packages/mdc-icon-button/constants.ts ***!
  8282. \***********************************************/
  8283. /*! no static exports found */
  8284. /***/ (function(module, exports, __webpack_require__) {
  8285. "use strict";
  8286. /**
  8287. * @license
  8288. * Copyright 2018 Google Inc.
  8289. *
  8290. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8291. * of this software and associated documentation files (the "Software"), to deal
  8292. * in the Software without restriction, including without limitation the rights
  8293. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8294. * copies of the Software, and to permit persons to whom the Software is
  8295. * furnished to do so, subject to the following conditions:
  8296. *
  8297. * The above copyright notice and this permission notice shall be included in
  8298. * all copies or substantial portions of the Software.
  8299. *
  8300. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8301. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8302. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8303. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8304. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8305. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8306. * THE SOFTWARE.
  8307. */
  8308. Object.defineProperty(exports, "__esModule", { value: true });
  8309. exports.cssClasses = {
  8310. ICON_BUTTON_ON: 'mdc-icon-button--on',
  8311. ROOT: 'mdc-icon-button'
  8312. };
  8313. exports.strings = {
  8314. ARIA_LABEL: 'aria-label',
  8315. ARIA_PRESSED: 'aria-pressed',
  8316. DATA_ARIA_LABEL_OFF: 'data-aria-label-off',
  8317. DATA_ARIA_LABEL_ON: 'data-aria-label-on',
  8318. CHANGE_EVENT: 'MDCIconButtonToggle:change'
  8319. };
  8320. /***/ }),
  8321. /***/ "./packages/mdc-icon-button/foundation.ts":
  8322. /*!************************************************!*\
  8323. !*** ./packages/mdc-icon-button/foundation.ts ***!
  8324. \************************************************/
  8325. /*! no static exports found */
  8326. /***/ (function(module, exports, __webpack_require__) {
  8327. "use strict";
  8328. /**
  8329. * @license
  8330. * Copyright 2018 Google Inc.
  8331. *
  8332. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8333. * of this software and associated documentation files (the "Software"), to deal
  8334. * in the Software without restriction, including without limitation the rights
  8335. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8336. * copies of the Software, and to permit persons to whom the Software is
  8337. * furnished to do so, subject to the following conditions:
  8338. *
  8339. * The above copyright notice and this permission notice shall be included in
  8340. * all copies or substantial portions of the Software.
  8341. *
  8342. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8343. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8344. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8345. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8346. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8347. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8348. * THE SOFTWARE.
  8349. */
  8350. var __extends = this && this.__extends || function () {
  8351. var _extendStatics = function extendStatics(d, b) {
  8352. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8353. d.__proto__ = b;
  8354. } || function (d, b) {
  8355. for (var p in b) {
  8356. if (b.hasOwnProperty(p)) d[p] = b[p];
  8357. }
  8358. };
  8359. return _extendStatics(d, b);
  8360. };
  8361. return function (d, b) {
  8362. _extendStatics(d, b);
  8363. function __() {
  8364. this.constructor = d;
  8365. }
  8366. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8367. };
  8368. }();
  8369. var __assign = this && this.__assign || function () {
  8370. __assign = Object.assign || function (t) {
  8371. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8372. s = arguments[i];
  8373. for (var p in s) {
  8374. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  8375. }
  8376. }
  8377. return t;
  8378. };
  8379. return __assign.apply(this, arguments);
  8380. };
  8381. Object.defineProperty(exports, "__esModule", { value: true });
  8382. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  8383. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-icon-button/constants.ts");
  8384. var MDCIconButtonToggleFoundation = /** @class */function (_super) {
  8385. __extends(MDCIconButtonToggleFoundation, _super);
  8386. function MDCIconButtonToggleFoundation(adapter) {
  8387. var _this = _super.call(this, __assign(__assign({}, MDCIconButtonToggleFoundation.defaultAdapter), adapter)) || this;
  8388. /**
  8389. * Whether the icon button has an aria label that changes depending on
  8390. * toggled state.
  8391. */
  8392. _this.hasToggledAriaLabel = false;
  8393. return _this;
  8394. }
  8395. Object.defineProperty(MDCIconButtonToggleFoundation, "cssClasses", {
  8396. get: function get() {
  8397. return constants_1.cssClasses;
  8398. },
  8399. enumerable: true,
  8400. configurable: true
  8401. });
  8402. Object.defineProperty(MDCIconButtonToggleFoundation, "strings", {
  8403. get: function get() {
  8404. return constants_1.strings;
  8405. },
  8406. enumerable: true,
  8407. configurable: true
  8408. });
  8409. Object.defineProperty(MDCIconButtonToggleFoundation, "defaultAdapter", {
  8410. get: function get() {
  8411. return {
  8412. addClass: function addClass() {
  8413. return undefined;
  8414. },
  8415. hasClass: function hasClass() {
  8416. return false;
  8417. },
  8418. notifyChange: function notifyChange() {
  8419. return undefined;
  8420. },
  8421. removeClass: function removeClass() {
  8422. return undefined;
  8423. },
  8424. getAttr: function getAttr() {
  8425. return null;
  8426. },
  8427. setAttr: function setAttr() {
  8428. return undefined;
  8429. }
  8430. };
  8431. },
  8432. enumerable: true,
  8433. configurable: true
  8434. });
  8435. MDCIconButtonToggleFoundation.prototype.init = function () {
  8436. var ariaLabelOn = this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_ON);
  8437. var ariaLabelOff = this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_OFF);
  8438. if (ariaLabelOn && ariaLabelOff) {
  8439. if (this.adapter.getAttr(constants_1.strings.ARIA_PRESSED) !== null) {
  8440. throw new Error('MDCIconButtonToggleFoundation: Button should not set ' + '`aria-pressed` if it has a toggled aria label.');
  8441. }
  8442. this.hasToggledAriaLabel = true;
  8443. } else {
  8444. this.adapter.setAttr(constants_1.strings.ARIA_PRESSED, String(this.isOn()));
  8445. }
  8446. };
  8447. MDCIconButtonToggleFoundation.prototype.handleClick = function () {
  8448. this.toggle();
  8449. this.adapter.notifyChange({ isOn: this.isOn() });
  8450. };
  8451. MDCIconButtonToggleFoundation.prototype.isOn = function () {
  8452. return this.adapter.hasClass(constants_1.cssClasses.ICON_BUTTON_ON);
  8453. };
  8454. MDCIconButtonToggleFoundation.prototype.toggle = function (isOn) {
  8455. if (isOn === void 0) {
  8456. isOn = !this.isOn();
  8457. }
  8458. // Toggle UI based on state.
  8459. if (isOn) {
  8460. this.adapter.addClass(constants_1.cssClasses.ICON_BUTTON_ON);
  8461. } else {
  8462. this.adapter.removeClass(constants_1.cssClasses.ICON_BUTTON_ON);
  8463. }
  8464. // Toggle aria attributes based on state.
  8465. if (this.hasToggledAriaLabel) {
  8466. var ariaLabel = isOn ? this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_ON) : this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_OFF);
  8467. this.adapter.setAttr(constants_1.strings.ARIA_LABEL, ariaLabel || '');
  8468. } else {
  8469. this.adapter.setAttr(constants_1.strings.ARIA_PRESSED, "" + isOn);
  8470. }
  8471. };
  8472. return MDCIconButtonToggleFoundation;
  8473. }(foundation_1.MDCFoundation);
  8474. exports.MDCIconButtonToggleFoundation = MDCIconButtonToggleFoundation;
  8475. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  8476. exports.default = MDCIconButtonToggleFoundation;
  8477. /***/ }),
  8478. /***/ "./packages/mdc-icon-button/index.ts":
  8479. /*!*******************************************!*\
  8480. !*** ./packages/mdc-icon-button/index.ts ***!
  8481. \*******************************************/
  8482. /*! no static exports found */
  8483. /***/ (function(module, exports, __webpack_require__) {
  8484. "use strict";
  8485. /**
  8486. * @license
  8487. * Copyright 2019 Google Inc.
  8488. *
  8489. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8490. * of this software and associated documentation files (the "Software"), to deal
  8491. * in the Software without restriction, including without limitation the rights
  8492. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8493. * copies of the Software, and to permit persons to whom the Software is
  8494. * furnished to do so, subject to the following conditions:
  8495. *
  8496. * The above copyright notice and this permission notice shall be included in
  8497. * all copies or substantial portions of the Software.
  8498. *
  8499. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8500. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8501. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8502. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8503. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8504. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8505. * THE SOFTWARE.
  8506. */
  8507. function __export(m) {
  8508. for (var p in m) {
  8509. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  8510. }
  8511. }
  8512. Object.defineProperty(exports, "__esModule", { value: true });
  8513. __export(__webpack_require__(/*! ./component */ "./packages/mdc-icon-button/component.ts"));
  8514. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-icon-button/constants.ts"));
  8515. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-icon-button/foundation.ts"));
  8516. /***/ }),
  8517. /***/ "./packages/mdc-line-ripple/component.ts":
  8518. /*!***********************************************!*\
  8519. !*** ./packages/mdc-line-ripple/component.ts ***!
  8520. \***********************************************/
  8521. /*! no static exports found */
  8522. /***/ (function(module, exports, __webpack_require__) {
  8523. "use strict";
  8524. /**
  8525. * @license
  8526. * Copyright 2018 Google Inc.
  8527. *
  8528. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8529. * of this software and associated documentation files (the "Software"), to deal
  8530. * in the Software without restriction, including without limitation the rights
  8531. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8532. * copies of the Software, and to permit persons to whom the Software is
  8533. * furnished to do so, subject to the following conditions:
  8534. *
  8535. * The above copyright notice and this permission notice shall be included in
  8536. * all copies or substantial portions of the Software.
  8537. *
  8538. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8539. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8540. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8541. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8542. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8543. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8544. * THE SOFTWARE.
  8545. */
  8546. var __extends = this && this.__extends || function () {
  8547. var _extendStatics = function extendStatics(d, b) {
  8548. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8549. d.__proto__ = b;
  8550. } || function (d, b) {
  8551. for (var p in b) {
  8552. if (b.hasOwnProperty(p)) d[p] = b[p];
  8553. }
  8554. };
  8555. return _extendStatics(d, b);
  8556. };
  8557. return function (d, b) {
  8558. _extendStatics(d, b);
  8559. function __() {
  8560. this.constructor = d;
  8561. }
  8562. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8563. };
  8564. }();
  8565. Object.defineProperty(exports, "__esModule", { value: true });
  8566. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  8567. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-line-ripple/foundation.ts");
  8568. var MDCLineRipple = /** @class */function (_super) {
  8569. __extends(MDCLineRipple, _super);
  8570. function MDCLineRipple() {
  8571. return _super !== null && _super.apply(this, arguments) || this;
  8572. }
  8573. MDCLineRipple.attachTo = function (root) {
  8574. return new MDCLineRipple(root);
  8575. };
  8576. /**
  8577. * Activates the line ripple
  8578. */
  8579. MDCLineRipple.prototype.activate = function () {
  8580. this.foundation.activate();
  8581. };
  8582. /**
  8583. * Deactivates the line ripple
  8584. */
  8585. MDCLineRipple.prototype.deactivate = function () {
  8586. this.foundation.deactivate();
  8587. };
  8588. /**
  8589. * Sets the transform origin given a user's click location.
  8590. * The `rippleCenter` is the x-coordinate of the middle of the ripple.
  8591. */
  8592. MDCLineRipple.prototype.setRippleCenter = function (xCoordinate) {
  8593. this.foundation.setRippleCenter(xCoordinate);
  8594. };
  8595. MDCLineRipple.prototype.getDefaultFoundation = function () {
  8596. var _this = this;
  8597. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  8598. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  8599. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  8600. var adapter = {
  8601. addClass: function addClass(className) {
  8602. return _this.root.classList.add(className);
  8603. },
  8604. removeClass: function removeClass(className) {
  8605. return _this.root.classList.remove(className);
  8606. },
  8607. hasClass: function hasClass(className) {
  8608. return _this.root.classList.contains(className);
  8609. },
  8610. setStyle: function setStyle(propertyName, value) {
  8611. return _this.root.style.setProperty(propertyName, value);
  8612. },
  8613. registerEventHandler: function registerEventHandler(evtType, handler) {
  8614. return _this.listen(evtType, handler);
  8615. },
  8616. deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
  8617. return _this.unlisten(evtType, handler);
  8618. }
  8619. };
  8620. // tslint:enable:object-literal-sort-keys
  8621. return new foundation_1.MDCLineRippleFoundation(adapter);
  8622. };
  8623. return MDCLineRipple;
  8624. }(component_1.MDCComponent);
  8625. exports.MDCLineRipple = MDCLineRipple;
  8626. /***/ }),
  8627. /***/ "./packages/mdc-line-ripple/constants.ts":
  8628. /*!***********************************************!*\
  8629. !*** ./packages/mdc-line-ripple/constants.ts ***!
  8630. \***********************************************/
  8631. /*! no static exports found */
  8632. /***/ (function(module, exports, __webpack_require__) {
  8633. "use strict";
  8634. /**
  8635. * @license
  8636. * Copyright 2018 Google Inc.
  8637. *
  8638. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8639. * of this software and associated documentation files (the "Software"), to deal
  8640. * in the Software without restriction, including without limitation the rights
  8641. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8642. * copies of the Software, and to permit persons to whom the Software is
  8643. * furnished to do so, subject to the following conditions:
  8644. *
  8645. * The above copyright notice and this permission notice shall be included in
  8646. * all copies or substantial portions of the Software.
  8647. *
  8648. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8649. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8650. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8651. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8652. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8653. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8654. * THE SOFTWARE.
  8655. */
  8656. Object.defineProperty(exports, "__esModule", { value: true });
  8657. var cssClasses = {
  8658. LINE_RIPPLE_ACTIVE: 'mdc-line-ripple--active',
  8659. LINE_RIPPLE_DEACTIVATING: 'mdc-line-ripple--deactivating'
  8660. };
  8661. exports.cssClasses = cssClasses;
  8662. /***/ }),
  8663. /***/ "./packages/mdc-line-ripple/foundation.ts":
  8664. /*!************************************************!*\
  8665. !*** ./packages/mdc-line-ripple/foundation.ts ***!
  8666. \************************************************/
  8667. /*! no static exports found */
  8668. /***/ (function(module, exports, __webpack_require__) {
  8669. "use strict";
  8670. /**
  8671. * @license
  8672. * Copyright 2018 Google Inc.
  8673. *
  8674. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8675. * of this software and associated documentation files (the "Software"), to deal
  8676. * in the Software without restriction, including without limitation the rights
  8677. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8678. * copies of the Software, and to permit persons to whom the Software is
  8679. * furnished to do so, subject to the following conditions:
  8680. *
  8681. * The above copyright notice and this permission notice shall be included in
  8682. * all copies or substantial portions of the Software.
  8683. *
  8684. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8685. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8686. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8687. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8688. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8689. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8690. * THE SOFTWARE.
  8691. */
  8692. var __extends = this && this.__extends || function () {
  8693. var _extendStatics = function extendStatics(d, b) {
  8694. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8695. d.__proto__ = b;
  8696. } || function (d, b) {
  8697. for (var p in b) {
  8698. if (b.hasOwnProperty(p)) d[p] = b[p];
  8699. }
  8700. };
  8701. return _extendStatics(d, b);
  8702. };
  8703. return function (d, b) {
  8704. _extendStatics(d, b);
  8705. function __() {
  8706. this.constructor = d;
  8707. }
  8708. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8709. };
  8710. }();
  8711. var __assign = this && this.__assign || function () {
  8712. __assign = Object.assign || function (t) {
  8713. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8714. s = arguments[i];
  8715. for (var p in s) {
  8716. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  8717. }
  8718. }
  8719. return t;
  8720. };
  8721. return __assign.apply(this, arguments);
  8722. };
  8723. Object.defineProperty(exports, "__esModule", { value: true });
  8724. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  8725. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-line-ripple/constants.ts");
  8726. var MDCLineRippleFoundation = /** @class */function (_super) {
  8727. __extends(MDCLineRippleFoundation, _super);
  8728. function MDCLineRippleFoundation(adapter) {
  8729. var _this = _super.call(this, __assign(__assign({}, MDCLineRippleFoundation.defaultAdapter), adapter)) || this;
  8730. _this.transitionEndHandler_ = function (evt) {
  8731. return _this.handleTransitionEnd(evt);
  8732. };
  8733. return _this;
  8734. }
  8735. Object.defineProperty(MDCLineRippleFoundation, "cssClasses", {
  8736. get: function get() {
  8737. return constants_1.cssClasses;
  8738. },
  8739. enumerable: true,
  8740. configurable: true
  8741. });
  8742. Object.defineProperty(MDCLineRippleFoundation, "defaultAdapter", {
  8743. /**
  8744. * See {@link MDCLineRippleAdapter} for typing information on parameters and return types.
  8745. */
  8746. get: function get() {
  8747. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  8748. return {
  8749. addClass: function addClass() {
  8750. return undefined;
  8751. },
  8752. removeClass: function removeClass() {
  8753. return undefined;
  8754. },
  8755. hasClass: function hasClass() {
  8756. return false;
  8757. },
  8758. setStyle: function setStyle() {
  8759. return undefined;
  8760. },
  8761. registerEventHandler: function registerEventHandler() {
  8762. return undefined;
  8763. },
  8764. deregisterEventHandler: function deregisterEventHandler() {
  8765. return undefined;
  8766. }
  8767. };
  8768. // tslint:enable:object-literal-sort-keys
  8769. },
  8770. enumerable: true,
  8771. configurable: true
  8772. });
  8773. MDCLineRippleFoundation.prototype.init = function () {
  8774. this.adapter.registerEventHandler('transitionend', this.transitionEndHandler_);
  8775. };
  8776. MDCLineRippleFoundation.prototype.destroy = function () {
  8777. this.adapter.deregisterEventHandler('transitionend', this.transitionEndHandler_);
  8778. };
  8779. MDCLineRippleFoundation.prototype.activate = function () {
  8780. this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  8781. this.adapter.addClass(constants_1.cssClasses.LINE_RIPPLE_ACTIVE);
  8782. };
  8783. MDCLineRippleFoundation.prototype.setRippleCenter = function (xCoordinate) {
  8784. this.adapter.setStyle('transform-origin', xCoordinate + "px center");
  8785. };
  8786. MDCLineRippleFoundation.prototype.deactivate = function () {
  8787. this.adapter.addClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  8788. };
  8789. MDCLineRippleFoundation.prototype.handleTransitionEnd = function (evt) {
  8790. // Wait for the line ripple to be either transparent or opaque
  8791. // before emitting the animation end event
  8792. var isDeactivating = this.adapter.hasClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  8793. if (evt.propertyName === 'opacity') {
  8794. if (isDeactivating) {
  8795. this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_ACTIVE);
  8796. this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  8797. }
  8798. }
  8799. };
  8800. return MDCLineRippleFoundation;
  8801. }(foundation_1.MDCFoundation);
  8802. exports.MDCLineRippleFoundation = MDCLineRippleFoundation;
  8803. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  8804. exports.default = MDCLineRippleFoundation;
  8805. /***/ }),
  8806. /***/ "./packages/mdc-line-ripple/index.ts":
  8807. /*!*******************************************!*\
  8808. !*** ./packages/mdc-line-ripple/index.ts ***!
  8809. \*******************************************/
  8810. /*! no static exports found */
  8811. /***/ (function(module, exports, __webpack_require__) {
  8812. "use strict";
  8813. /**
  8814. * @license
  8815. * Copyright 2019 Google Inc.
  8816. *
  8817. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8818. * of this software and associated documentation files (the "Software"), to deal
  8819. * in the Software without restriction, including without limitation the rights
  8820. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8821. * copies of the Software, and to permit persons to whom the Software is
  8822. * furnished to do so, subject to the following conditions:
  8823. *
  8824. * The above copyright notice and this permission notice shall be included in
  8825. * all copies or substantial portions of the Software.
  8826. *
  8827. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8828. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8829. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8830. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8831. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8832. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8833. * THE SOFTWARE.
  8834. */
  8835. function __export(m) {
  8836. for (var p in m) {
  8837. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  8838. }
  8839. }
  8840. Object.defineProperty(exports, "__esModule", { value: true });
  8841. __export(__webpack_require__(/*! ./component */ "./packages/mdc-line-ripple/component.ts"));
  8842. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-line-ripple/constants.ts"));
  8843. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-line-ripple/foundation.ts"));
  8844. /***/ }),
  8845. /***/ "./packages/mdc-linear-progress/component.ts":
  8846. /*!***************************************************!*\
  8847. !*** ./packages/mdc-linear-progress/component.ts ***!
  8848. \***************************************************/
  8849. /*! no static exports found */
  8850. /***/ (function(module, exports, __webpack_require__) {
  8851. "use strict";
  8852. /**
  8853. * @license
  8854. * Copyright 2017 Google Inc.
  8855. *
  8856. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8857. * of this software and associated documentation files (the "Software"), to deal
  8858. * in the Software without restriction, including without limitation the rights
  8859. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8860. * copies of the Software, and to permit persons to whom the Software is
  8861. * furnished to do so, subject to the following conditions:
  8862. *
  8863. * The above copyright notice and this permission notice shall be included in
  8864. * all copies or substantial portions of the Software.
  8865. *
  8866. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8867. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8868. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8869. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8870. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8871. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8872. * THE SOFTWARE.
  8873. */
  8874. var __extends = this && this.__extends || function () {
  8875. var _extendStatics = function extendStatics(d, b) {
  8876. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8877. d.__proto__ = b;
  8878. } || function (d, b) {
  8879. for (var p in b) {
  8880. if (b.hasOwnProperty(p)) d[p] = b[p];
  8881. }
  8882. };
  8883. return _extendStatics(d, b);
  8884. };
  8885. return function (d, b) {
  8886. _extendStatics(d, b);
  8887. function __() {
  8888. this.constructor = d;
  8889. }
  8890. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8891. };
  8892. }();
  8893. Object.defineProperty(exports, "__esModule", { value: true });
  8894. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  8895. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-linear-progress/foundation.ts");
  8896. var MDCLinearProgress = /** @class */function (_super) {
  8897. __extends(MDCLinearProgress, _super);
  8898. function MDCLinearProgress() {
  8899. return _super !== null && _super.apply(this, arguments) || this;
  8900. }
  8901. MDCLinearProgress.attachTo = function (root) {
  8902. return new MDCLinearProgress(root);
  8903. };
  8904. Object.defineProperty(MDCLinearProgress.prototype, "determinate", {
  8905. set: function set(value) {
  8906. this.foundation.setDeterminate(value);
  8907. },
  8908. enumerable: true,
  8909. configurable: true
  8910. });
  8911. Object.defineProperty(MDCLinearProgress.prototype, "progress", {
  8912. set: function set(value) {
  8913. this.foundation.setProgress(value);
  8914. },
  8915. enumerable: true,
  8916. configurable: true
  8917. });
  8918. Object.defineProperty(MDCLinearProgress.prototype, "buffer", {
  8919. set: function set(value) {
  8920. this.foundation.setBuffer(value);
  8921. },
  8922. enumerable: true,
  8923. configurable: true
  8924. });
  8925. MDCLinearProgress.prototype.open = function () {
  8926. this.foundation.open();
  8927. };
  8928. MDCLinearProgress.prototype.close = function () {
  8929. this.foundation.close();
  8930. };
  8931. MDCLinearProgress.prototype.initialSyncWithDOM = function () {
  8932. var _this = this;
  8933. this.root.addEventListener('transitionend', function () {
  8934. _this.foundation.handleTransitionEnd();
  8935. });
  8936. };
  8937. MDCLinearProgress.prototype.getDefaultFoundation = function () {
  8938. var _this = this;
  8939. // DO NOT INLINE this variable. For backward compatibility, foundations take
  8940. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  8941. // methods, we need a separate, strongly typed adapter variable.
  8942. var adapter = {
  8943. addClass: function addClass(className) {
  8944. _this.root.classList.add(className);
  8945. },
  8946. forceLayout: function forceLayout() {
  8947. _this.root.getBoundingClientRect();
  8948. },
  8949. setBufferBarStyle: function setBufferBarStyle(styleProperty, value) {
  8950. var bufferBar = _this.root.querySelector(foundation_1.MDCLinearProgressFoundation.strings.BUFFER_BAR_SELECTOR);
  8951. if (bufferBar) {
  8952. bufferBar.style.setProperty(styleProperty, value);
  8953. }
  8954. },
  8955. setPrimaryBarStyle: function setPrimaryBarStyle(styleProperty, value) {
  8956. var primaryBar = _this.root.querySelector(foundation_1.MDCLinearProgressFoundation.strings.PRIMARY_BAR_SELECTOR);
  8957. if (primaryBar) {
  8958. primaryBar.style.setProperty(styleProperty, value);
  8959. }
  8960. },
  8961. hasClass: function hasClass(className) {
  8962. return _this.root.classList.contains(className);
  8963. },
  8964. removeAttribute: function removeAttribute(attributeName) {
  8965. _this.root.removeAttribute(attributeName);
  8966. },
  8967. removeClass: function removeClass(className) {
  8968. _this.root.classList.remove(className);
  8969. },
  8970. setAttribute: function setAttribute(attributeName, value) {
  8971. _this.root.setAttribute(attributeName, value);
  8972. },
  8973. setStyle: function setStyle(name, value) {
  8974. _this.root.style.setProperty(name, value);
  8975. },
  8976. attachResizeObserver: function attachResizeObserver(callback) {
  8977. var RO = window.ResizeObserver;
  8978. if (RO) {
  8979. var ro = new RO(callback);
  8980. ro.observe(_this.root);
  8981. return ro;
  8982. }
  8983. return null;
  8984. },
  8985. getWidth: function getWidth() {
  8986. return _this.root.offsetWidth;
  8987. }
  8988. };
  8989. return new foundation_1.MDCLinearProgressFoundation(adapter);
  8990. };
  8991. return MDCLinearProgress;
  8992. }(component_1.MDCComponent);
  8993. exports.MDCLinearProgress = MDCLinearProgress;
  8994. /***/ }),
  8995. /***/ "./packages/mdc-linear-progress/constants.ts":
  8996. /*!***************************************************!*\
  8997. !*** ./packages/mdc-linear-progress/constants.ts ***!
  8998. \***************************************************/
  8999. /*! no static exports found */
  9000. /***/ (function(module, exports, __webpack_require__) {
  9001. "use strict";
  9002. /**
  9003. * @license
  9004. * Copyright 2017 Google Inc.
  9005. *
  9006. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9007. * of this software and associated documentation files (the "Software"), to deal
  9008. * in the Software without restriction, including without limitation the rights
  9009. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9010. * copies of the Software, and to permit persons to whom the Software is
  9011. * furnished to do so, subject to the following conditions:
  9012. *
  9013. * The above copyright notice and this permission notice shall be included in
  9014. * all copies or substantial portions of the Software.
  9015. *
  9016. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9017. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9018. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9019. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9020. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9021. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9022. * THE SOFTWARE.
  9023. */
  9024. Object.defineProperty(exports, "__esModule", { value: true });
  9025. exports.cssClasses = {
  9026. CLOSED_CLASS: 'mdc-linear-progress--closed',
  9027. CLOSED_ANIMATION_OFF_CLASS: 'mdc-linear-progress--closed-animation-off',
  9028. INDETERMINATE_CLASS: 'mdc-linear-progress--indeterminate',
  9029. REVERSED_CLASS: 'mdc-linear-progress--reversed',
  9030. ANIMATION_READY_CLASS: 'mdc-linear-progress--animation-ready'
  9031. };
  9032. exports.strings = {
  9033. ARIA_VALUEMAX: 'aria-valuemax',
  9034. ARIA_VALUEMIN: 'aria-valuemin',
  9035. ARIA_VALUENOW: 'aria-valuenow',
  9036. BUFFER_BAR_SELECTOR: '.mdc-linear-progress__buffer-bar',
  9037. FLEX_BASIS: 'flex-basis',
  9038. PRIMARY_BAR_SELECTOR: '.mdc-linear-progress__primary-bar'
  9039. };
  9040. // these are percentages pulled from keyframes.scss
  9041. exports.animationDimensionPercentages = {
  9042. PRIMARY_HALF: .8367142,
  9043. PRIMARY_FULL: 2.00611057,
  9044. SECONDARY_QUARTER: .37651913,
  9045. SECONDARY_HALF: .84386165,
  9046. SECONDARY_FULL: 1.60277782
  9047. };
  9048. /***/ }),
  9049. /***/ "./packages/mdc-linear-progress/foundation.ts":
  9050. /*!****************************************************!*\
  9051. !*** ./packages/mdc-linear-progress/foundation.ts ***!
  9052. \****************************************************/
  9053. /*! no static exports found */
  9054. /***/ (function(module, exports, __webpack_require__) {
  9055. "use strict";
  9056. /**
  9057. * @license
  9058. * Copyright 2017 Google Inc.
  9059. *
  9060. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9061. * of this software and associated documentation files (the "Software"), to deal
  9062. * in the Software without restriction, including without limitation the rights
  9063. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9064. * copies of the Software, and to permit persons to whom the Software is
  9065. * furnished to do so, subject to the following conditions:
  9066. *
  9067. * The above copyright notice and this permission notice shall be included in
  9068. * all copies or substantial portions of the Software.
  9069. *
  9070. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9071. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9072. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9073. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9074. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9075. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9076. * THE SOFTWARE.
  9077. */
  9078. var __extends = this && this.__extends || function () {
  9079. var _extendStatics = function extendStatics(d, b) {
  9080. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  9081. d.__proto__ = b;
  9082. } || function (d, b) {
  9083. for (var p in b) {
  9084. if (b.hasOwnProperty(p)) d[p] = b[p];
  9085. }
  9086. };
  9087. return _extendStatics(d, b);
  9088. };
  9089. return function (d, b) {
  9090. _extendStatics(d, b);
  9091. function __() {
  9092. this.constructor = d;
  9093. }
  9094. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9095. };
  9096. }();
  9097. var __assign = this && this.__assign || function () {
  9098. __assign = Object.assign || function (t) {
  9099. for (var s, i = 1, n = arguments.length; i < n; i++) {
  9100. s = arguments[i];
  9101. for (var p in s) {
  9102. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  9103. }
  9104. }
  9105. return t;
  9106. };
  9107. return __assign.apply(this, arguments);
  9108. };
  9109. var __values = this && this.__values || function (o) {
  9110. var s = typeof Symbol === "function" && Symbol.iterator,
  9111. m = s && o[s],
  9112. i = 0;
  9113. if (m) return m.call(o);
  9114. if (o && typeof o.length === "number") return {
  9115. next: function next() {
  9116. if (o && i >= o.length) o = void 0;
  9117. return { value: o && o[i++], done: !o };
  9118. }
  9119. };
  9120. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  9121. };
  9122. Object.defineProperty(exports, "__esModule", { value: true });
  9123. var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
  9124. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  9125. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-linear-progress/constants.ts");
  9126. var MDCLinearProgressFoundation = /** @class */function (_super) {
  9127. __extends(MDCLinearProgressFoundation, _super);
  9128. function MDCLinearProgressFoundation(adapter) {
  9129. var _this = _super.call(this, __assign(__assign({}, MDCLinearProgressFoundation.defaultAdapter), adapter)) || this;
  9130. _this.observer = null;
  9131. return _this;
  9132. }
  9133. Object.defineProperty(MDCLinearProgressFoundation, "cssClasses", {
  9134. get: function get() {
  9135. return constants_1.cssClasses;
  9136. },
  9137. enumerable: true,
  9138. configurable: true
  9139. });
  9140. Object.defineProperty(MDCLinearProgressFoundation, "strings", {
  9141. get: function get() {
  9142. return constants_1.strings;
  9143. },
  9144. enumerable: true,
  9145. configurable: true
  9146. });
  9147. Object.defineProperty(MDCLinearProgressFoundation, "defaultAdapter", {
  9148. get: function get() {
  9149. return {
  9150. addClass: function addClass() {
  9151. return undefined;
  9152. },
  9153. attachResizeObserver: function attachResizeObserver() {
  9154. return null;
  9155. },
  9156. forceLayout: function forceLayout() {
  9157. return undefined;
  9158. },
  9159. getWidth: function getWidth() {
  9160. return 0;
  9161. },
  9162. hasClass: function hasClass() {
  9163. return false;
  9164. },
  9165. setBufferBarStyle: function setBufferBarStyle() {
  9166. return null;
  9167. },
  9168. setPrimaryBarStyle: function setPrimaryBarStyle() {
  9169. return null;
  9170. },
  9171. setStyle: function setStyle() {
  9172. return undefined;
  9173. },
  9174. removeAttribute: function removeAttribute() {
  9175. return undefined;
  9176. },
  9177. removeClass: function removeClass() {
  9178. return undefined;
  9179. },
  9180. setAttribute: function setAttribute() {
  9181. return undefined;
  9182. }
  9183. };
  9184. },
  9185. enumerable: true,
  9186. configurable: true
  9187. });
  9188. MDCLinearProgressFoundation.prototype.init = function () {
  9189. var _this = this;
  9190. this.isDeterminate = !this.adapter.hasClass(constants_1.cssClasses.INDETERMINATE_CLASS);
  9191. this.adapter.addClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
  9192. this.progress = 0;
  9193. this.buffer = 1;
  9194. this.observer = this.adapter.attachResizeObserver(function (entries) {
  9195. var e_1, _a;
  9196. if (_this.isDeterminate) {
  9197. return;
  9198. }
  9199. try {
  9200. for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
  9201. var entry = entries_1_1.value;
  9202. if (entry.contentRect) {
  9203. _this.calculateAndSetDimensions(entry.contentRect.width);
  9204. }
  9205. }
  9206. } catch (e_1_1) {
  9207. e_1 = { error: e_1_1 };
  9208. } finally {
  9209. try {
  9210. if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
  9211. } finally {
  9212. if (e_1) throw e_1.error;
  9213. }
  9214. }
  9215. });
  9216. if (!this.isDeterminate && this.observer) {
  9217. this.calculateAndSetDimensions(this.adapter.getWidth());
  9218. }
  9219. };
  9220. MDCLinearProgressFoundation.prototype.setDeterminate = function (isDeterminate) {
  9221. this.isDeterminate = isDeterminate;
  9222. if (this.isDeterminate) {
  9223. this.adapter.removeClass(constants_1.cssClasses.INDETERMINATE_CLASS);
  9224. this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress.toString());
  9225. this.adapter.setAttribute(constants_1.strings.ARIA_VALUEMAX, '1');
  9226. this.adapter.setAttribute(constants_1.strings.ARIA_VALUEMIN, '0');
  9227. this.setPrimaryBarProgress(this.progress);
  9228. this.setBufferBarProgress(this.buffer);
  9229. return;
  9230. }
  9231. if (this.observer) {
  9232. this.calculateAndSetDimensions(this.adapter.getWidth());
  9233. }
  9234. this.adapter.addClass(constants_1.cssClasses.INDETERMINATE_CLASS);
  9235. this.adapter.removeAttribute(constants_1.strings.ARIA_VALUENOW);
  9236. this.adapter.removeAttribute(constants_1.strings.ARIA_VALUEMAX);
  9237. this.adapter.removeAttribute(constants_1.strings.ARIA_VALUEMIN);
  9238. this.setPrimaryBarProgress(1);
  9239. this.setBufferBarProgress(1);
  9240. };
  9241. MDCLinearProgressFoundation.prototype.getDeterminate = function () {
  9242. return this.isDeterminate;
  9243. };
  9244. MDCLinearProgressFoundation.prototype.setProgress = function (value) {
  9245. this.progress = value;
  9246. if (this.isDeterminate) {
  9247. this.setPrimaryBarProgress(value);
  9248. this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, value.toString());
  9249. }
  9250. };
  9251. MDCLinearProgressFoundation.prototype.getProgress = function () {
  9252. return this.progress;
  9253. };
  9254. MDCLinearProgressFoundation.prototype.setBuffer = function (value) {
  9255. this.buffer = value;
  9256. if (this.isDeterminate) {
  9257. this.setBufferBarProgress(value);
  9258. }
  9259. };
  9260. MDCLinearProgressFoundation.prototype.open = function () {
  9261. this.adapter.removeClass(constants_1.cssClasses.CLOSED_CLASS);
  9262. this.adapter.removeClass(constants_1.cssClasses.CLOSED_ANIMATION_OFF_CLASS);
  9263. };
  9264. MDCLinearProgressFoundation.prototype.close = function () {
  9265. this.adapter.addClass(constants_1.cssClasses.CLOSED_CLASS);
  9266. };
  9267. /**
  9268. * Handles the transitionend event emitted after `close()` is called and the
  9269. * opacity fades out. This is so that animations are removed only after the
  9270. * progress indicator is completely hidden.
  9271. */
  9272. MDCLinearProgressFoundation.prototype.handleTransitionEnd = function () {
  9273. if (this.adapter.hasClass(constants_1.cssClasses.CLOSED_CLASS)) {
  9274. this.adapter.addClass(constants_1.cssClasses.CLOSED_ANIMATION_OFF_CLASS);
  9275. }
  9276. };
  9277. MDCLinearProgressFoundation.prototype.destroy = function () {
  9278. _super.prototype.destroy.call(this);
  9279. if (this.observer) {
  9280. this.observer.disconnect();
  9281. }
  9282. };
  9283. MDCLinearProgressFoundation.prototype.restartAnimation = function () {
  9284. this.adapter.removeClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
  9285. this.adapter.forceLayout();
  9286. this.adapter.addClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
  9287. };
  9288. MDCLinearProgressFoundation.prototype.setPrimaryBarProgress = function (progressValue) {
  9289. var value = "scaleX(" + progressValue + ")";
  9290. // Accessing `window` without a `typeof` check will throw on Node
  9291. // environments.
  9292. var transformProp = typeof window !== 'undefined' ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
  9293. this.adapter.setPrimaryBarStyle(transformProp, value);
  9294. };
  9295. MDCLinearProgressFoundation.prototype.setBufferBarProgress = function (progressValue) {
  9296. var value = progressValue * 100 + "%";
  9297. this.adapter.setBufferBarStyle(constants_1.strings.FLEX_BASIS, value);
  9298. };
  9299. MDCLinearProgressFoundation.prototype.calculateAndSetDimensions = function (width) {
  9300. var primaryHalf = width * constants_1.animationDimensionPercentages.PRIMARY_HALF;
  9301. var primaryFull = width * constants_1.animationDimensionPercentages.PRIMARY_FULL;
  9302. var secondaryQuarter = width * constants_1.animationDimensionPercentages.SECONDARY_QUARTER;
  9303. var secondaryHalf = width * constants_1.animationDimensionPercentages.SECONDARY_HALF;
  9304. var secondaryFull = width * constants_1.animationDimensionPercentages.SECONDARY_FULL;
  9305. this.adapter.setStyle('--mdc-linear-progress-primary-half', primaryHalf + "px");
  9306. this.adapter.setStyle('--mdc-linear-progress-primary-half-neg', -primaryHalf + "px");
  9307. this.adapter.setStyle('--mdc-linear-progress-primary-full', primaryFull + "px");
  9308. this.adapter.setStyle('--mdc-linear-progress-primary-full-neg', -primaryFull + "px");
  9309. this.adapter.setStyle('--mdc-linear-progress-secondary-quarter', secondaryQuarter + "px");
  9310. this.adapter.setStyle('--mdc-linear-progress-secondary-quarter-neg', -secondaryQuarter + "px");
  9311. this.adapter.setStyle('--mdc-linear-progress-secondary-half', secondaryHalf + "px");
  9312. this.adapter.setStyle('--mdc-linear-progress-secondary-half-neg', -secondaryHalf + "px");
  9313. this.adapter.setStyle('--mdc-linear-progress-secondary-full', secondaryFull + "px");
  9314. this.adapter.setStyle('--mdc-linear-progress-secondary-full-neg', -secondaryFull + "px");
  9315. // need to restart animation for custom props to apply to keyframes
  9316. this.restartAnimation();
  9317. };
  9318. return MDCLinearProgressFoundation;
  9319. }(foundation_1.MDCFoundation);
  9320. exports.MDCLinearProgressFoundation = MDCLinearProgressFoundation;
  9321. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  9322. exports.default = MDCLinearProgressFoundation;
  9323. /***/ }),
  9324. /***/ "./packages/mdc-linear-progress/index.ts":
  9325. /*!***********************************************!*\
  9326. !*** ./packages/mdc-linear-progress/index.ts ***!
  9327. \***********************************************/
  9328. /*! no static exports found */
  9329. /***/ (function(module, exports, __webpack_require__) {
  9330. "use strict";
  9331. /**
  9332. * @license
  9333. * Copyright 2019 Google Inc.
  9334. *
  9335. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9336. * of this software and associated documentation files (the "Software"), to deal
  9337. * in the Software without restriction, including without limitation the rights
  9338. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9339. * copies of the Software, and to permit persons to whom the Software is
  9340. * furnished to do so, subject to the following conditions:
  9341. *
  9342. * The above copyright notice and this permission notice shall be included in
  9343. * all copies or substantial portions of the Software.
  9344. *
  9345. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9346. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9347. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9348. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9349. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9350. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9351. * THE SOFTWARE.
  9352. */
  9353. function __export(m) {
  9354. for (var p in m) {
  9355. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  9356. }
  9357. }
  9358. Object.defineProperty(exports, "__esModule", { value: true });
  9359. __export(__webpack_require__(/*! ./component */ "./packages/mdc-linear-progress/component.ts"));
  9360. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-linear-progress/constants.ts"));
  9361. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-linear-progress/foundation.ts"));
  9362. /***/ }),
  9363. /***/ "./packages/mdc-list/component.ts":
  9364. /*!****************************************!*\
  9365. !*** ./packages/mdc-list/component.ts ***!
  9366. \****************************************/
  9367. /*! no static exports found */
  9368. /***/ (function(module, exports, __webpack_require__) {
  9369. "use strict";
  9370. /**
  9371. * @license
  9372. * Copyright 2018 Google Inc.
  9373. *
  9374. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9375. * of this software and associated documentation files (the "Software"), to deal
  9376. * in the Software without restriction, including without limitation the rights
  9377. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9378. * copies of the Software, and to permit persons to whom the Software is
  9379. * furnished to do so, subject to the following conditions:
  9380. *
  9381. * The above copyright notice and this permission notice shall be included in
  9382. * all copies or substantial portions of the Software.
  9383. *
  9384. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9385. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9386. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9387. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9388. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9389. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9390. * THE SOFTWARE.
  9391. */
  9392. var __extends = this && this.__extends || function () {
  9393. var _extendStatics = function extendStatics(d, b) {
  9394. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  9395. d.__proto__ = b;
  9396. } || function (d, b) {
  9397. for (var p in b) {
  9398. if (b.hasOwnProperty(p)) d[p] = b[p];
  9399. }
  9400. };
  9401. return _extendStatics(d, b);
  9402. };
  9403. return function (d, b) {
  9404. _extendStatics(d, b);
  9405. function __() {
  9406. this.constructor = d;
  9407. }
  9408. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9409. };
  9410. }();
  9411. Object.defineProperty(exports, "__esModule", { value: true });
  9412. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  9413. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  9414. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  9415. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-list/foundation.ts");
  9416. var MDCList = /** @class */function (_super) {
  9417. __extends(MDCList, _super);
  9418. function MDCList() {
  9419. return _super !== null && _super.apply(this, arguments) || this;
  9420. }
  9421. Object.defineProperty(MDCList.prototype, "vertical", {
  9422. set: function set(value) {
  9423. this.foundation.setVerticalOrientation(value);
  9424. },
  9425. enumerable: true,
  9426. configurable: true
  9427. });
  9428. Object.defineProperty(MDCList.prototype, "listElements", {
  9429. get: function get() {
  9430. return Array.from(this.root.querySelectorAll("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]));
  9431. },
  9432. enumerable: true,
  9433. configurable: true
  9434. });
  9435. Object.defineProperty(MDCList.prototype, "wrapFocus", {
  9436. set: function set(value) {
  9437. this.foundation.setWrapFocus(value);
  9438. },
  9439. enumerable: true,
  9440. configurable: true
  9441. });
  9442. Object.defineProperty(MDCList.prototype, "typeaheadInProgress", {
  9443. /**
  9444. * @return Whether typeahead is currently matching a user-specified prefix.
  9445. */
  9446. get: function get() {
  9447. return this.foundation.isTypeaheadInProgress();
  9448. },
  9449. enumerable: true,
  9450. configurable: true
  9451. });
  9452. Object.defineProperty(MDCList.prototype, "hasTypeahead", {
  9453. /**
  9454. * Sets whether typeahead functionality is enabled on the list.
  9455. * @param hasTypeahead Whether typeahead is enabled.
  9456. */
  9457. set: function set(hasTypeahead) {
  9458. this.foundation.setHasTypeahead(hasTypeahead);
  9459. },
  9460. enumerable: true,
  9461. configurable: true
  9462. });
  9463. Object.defineProperty(MDCList.prototype, "singleSelection", {
  9464. set: function set(isSingleSelectionList) {
  9465. this.foundation.setSingleSelection(isSingleSelectionList);
  9466. },
  9467. enumerable: true,
  9468. configurable: true
  9469. });
  9470. Object.defineProperty(MDCList.prototype, "selectedIndex", {
  9471. get: function get() {
  9472. return this.foundation.getSelectedIndex();
  9473. },
  9474. set: function set(index) {
  9475. this.foundation.setSelectedIndex(index);
  9476. },
  9477. enumerable: true,
  9478. configurable: true
  9479. });
  9480. MDCList.attachTo = function (root) {
  9481. return new MDCList(root);
  9482. };
  9483. MDCList.prototype.initialSyncWithDOM = function () {
  9484. this.isEvolutionEnabled = constants_1.evolutionAttribute in this.root.dataset;
  9485. this.classNameMap = this.isEvolutionEnabled ? constants_1.evolutionClassNameMap : Object.values(constants_1.cssClasses).reduce(function (obj, className) {
  9486. obj[className] = className;
  9487. return obj;
  9488. }, {});
  9489. this.handleClick = this.handleClickEvent.bind(this);
  9490. this.handleKeydown = this.handleKeydownEvent.bind(this);
  9491. this.focusInEventListener = this.handleFocusInEvent.bind(this);
  9492. this.focusOutEventListener = this.handleFocusOutEvent.bind(this);
  9493. this.listen('keydown', this.handleKeydown);
  9494. this.listen('click', this.handleClick);
  9495. this.listen('focusin', this.focusInEventListener);
  9496. this.listen('focusout', this.focusOutEventListener);
  9497. this.layout();
  9498. this.initializeListType();
  9499. this.ensureFocusable();
  9500. };
  9501. MDCList.prototype.destroy = function () {
  9502. this.unlisten('keydown', this.handleKeydown);
  9503. this.unlisten('click', this.handleClick);
  9504. this.unlisten('focusin', this.focusInEventListener);
  9505. this.unlisten('focusout', this.focusOutEventListener);
  9506. };
  9507. MDCList.prototype.layout = function () {
  9508. var direction = this.root.getAttribute(constants_1.strings.ARIA_ORIENTATION);
  9509. this.vertical = direction !== constants_1.strings.ARIA_ORIENTATION_HORIZONTAL;
  9510. var itemSelector = "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not([tabindex])";
  9511. var childSelector = "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + " " + constants_1.strings.FOCUSABLE_CHILD_ELEMENTS;
  9512. // List items need to have at least tabindex=-1 to be focusable.
  9513. Array.prototype.forEach.call(this.root.querySelectorAll(itemSelector), function (el) {
  9514. el.setAttribute('tabindex', '-1');
  9515. });
  9516. // Child button/a elements are not tabbable until the list item is focused.
  9517. Array.prototype.forEach.call(this.root.querySelectorAll(childSelector), function (el) {
  9518. el.setAttribute('tabindex', '-1');
  9519. });
  9520. if (this.isEvolutionEnabled) {
  9521. this.foundation.setUseSelectedAttribute(true);
  9522. }
  9523. this.foundation.layout();
  9524. };
  9525. /**
  9526. * Extracts the primary text from a list item.
  9527. * @param item The list item element.
  9528. * @return The primary text in the element.
  9529. */
  9530. MDCList.prototype.getPrimaryText = function (item) {
  9531. var _a;
  9532. var primaryText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS]);
  9533. if (this.isEvolutionEnabled || primaryText) {
  9534. return (_a = primaryText === null || primaryText === void 0 ? void 0 : primaryText.textContent) !== null && _a !== void 0 ? _a : '';
  9535. }
  9536. var singleLineText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_TEXT_CLASS]);
  9537. return singleLineText && singleLineText.textContent || '';
  9538. };
  9539. /**
  9540. * Initialize selectedIndex value based on pre-selected list items.
  9541. */
  9542. MDCList.prototype.initializeListType = function () {
  9543. var _this = this;
  9544. this.isInteractive = ponyfill_1.matches(this.root, constants_1.strings.ARIA_INTERACTIVE_ROLES_SELECTOR);
  9545. if (this.isEvolutionEnabled && this.isInteractive) {
  9546. var selection = Array.from(this.root.querySelectorAll(constants_1.strings.SELECTED_ITEM_SELECTOR), function (listItem) {
  9547. return _this.listElements.indexOf(listItem);
  9548. });
  9549. if (ponyfill_1.matches(this.root, constants_1.strings.ARIA_MULTI_SELECTABLE_SELECTOR)) {
  9550. this.selectedIndex = selection;
  9551. } else if (selection.length > 0) {
  9552. this.selectedIndex = selection[0];
  9553. }
  9554. return;
  9555. }
  9556. var checkboxListItems = this.root.querySelectorAll(constants_1.strings.ARIA_ROLE_CHECKBOX_SELECTOR);
  9557. var radioSelectedListItem = this.root.querySelector(constants_1.strings.ARIA_CHECKED_RADIO_SELECTOR);
  9558. if (checkboxListItems.length) {
  9559. var preselectedItems = this.root.querySelectorAll(constants_1.strings.ARIA_CHECKED_CHECKBOX_SELECTOR);
  9560. this.selectedIndex = Array.from(preselectedItems, function (listItem) {
  9561. return _this.listElements.indexOf(listItem);
  9562. });
  9563. } else if (radioSelectedListItem) {
  9564. this.selectedIndex = this.listElements.indexOf(radioSelectedListItem);
  9565. }
  9566. };
  9567. /**
  9568. * Updates the list item at itemIndex to the desired isEnabled state.
  9569. * @param itemIndex Index of the list item
  9570. * @param isEnabled Sets the list item to enabled or disabled.
  9571. */
  9572. MDCList.prototype.setEnabled = function (itemIndex, isEnabled) {
  9573. this.foundation.setEnabled(itemIndex, isEnabled);
  9574. };
  9575. /**
  9576. * Given the next desired character from the user, adds it to the typeahead
  9577. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  9578. * around if at the end of options.
  9579. *
  9580. * @param nextChar The next character to add to the prefix buffer.
  9581. * @param startingIndex The index from which to start matching. Defaults to
  9582. * the currently focused index.
  9583. * @return The index of the matched item.
  9584. */
  9585. MDCList.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
  9586. return this.foundation.typeaheadMatchItem(nextChar, startingIndex, /** skipFocus */true);
  9587. };
  9588. MDCList.prototype.getDefaultFoundation = function () {
  9589. var _this = this;
  9590. // DO NOT INLINE this variable. For backward compatibility, foundations take
  9591. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  9592. // methods, we need a separate, strongly typed adapter variable.
  9593. var adapter = {
  9594. addClassForElementIndex: function addClassForElementIndex(index, className) {
  9595. var element = _this.listElements[index];
  9596. if (element) {
  9597. element.classList.add(_this.classNameMap[className]);
  9598. }
  9599. },
  9600. focusItemAtIndex: function focusItemAtIndex(index) {
  9601. var element = _this.listElements[index];
  9602. if (element) {
  9603. element.focus();
  9604. }
  9605. },
  9606. getAttributeForElementIndex: function getAttributeForElementIndex(index, attr) {
  9607. return _this.listElements[index].getAttribute(attr);
  9608. },
  9609. getFocusedElementIndex: function getFocusedElementIndex() {
  9610. return _this.listElements.indexOf(document.activeElement);
  9611. },
  9612. getListItemCount: function getListItemCount() {
  9613. return _this.listElements.length;
  9614. },
  9615. getPrimaryTextAtIndex: function getPrimaryTextAtIndex(index) {
  9616. return _this.getPrimaryText(_this.listElements[index]);
  9617. },
  9618. hasCheckboxAtIndex: function hasCheckboxAtIndex(index) {
  9619. var listItem = _this.listElements[index];
  9620. return !!listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
  9621. },
  9622. hasRadioAtIndex: function hasRadioAtIndex(index) {
  9623. var listItem = _this.listElements[index];
  9624. return !!listItem.querySelector(constants_1.strings.RADIO_SELECTOR);
  9625. },
  9626. isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex(index) {
  9627. var listItem = _this.listElements[index];
  9628. var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
  9629. return toggleEl.checked;
  9630. },
  9631. isFocusInsideList: function isFocusInsideList() {
  9632. return _this.root !== document.activeElement && _this.root.contains(document.activeElement);
  9633. },
  9634. isRootFocused: function isRootFocused() {
  9635. return document.activeElement === _this.root;
  9636. },
  9637. listItemAtIndexHasClass: function listItemAtIndexHasClass(index, className) {
  9638. return _this.listElements[index].classList.contains(_this.classNameMap[className]);
  9639. },
  9640. notifyAction: function notifyAction(index) {
  9641. _this.emit(constants_1.strings.ACTION_EVENT, { index: index }, /** shouldBubble */true);
  9642. },
  9643. removeClassForElementIndex: function removeClassForElementIndex(index, className) {
  9644. var element = _this.listElements[index];
  9645. if (element) {
  9646. element.classList.remove(_this.classNameMap[className]);
  9647. }
  9648. },
  9649. setAttributeForElementIndex: function setAttributeForElementIndex(index, attr, value) {
  9650. var element = _this.listElements[index];
  9651. if (element) {
  9652. element.setAttribute(attr, value);
  9653. }
  9654. },
  9655. setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex(index, isChecked) {
  9656. var listItem = _this.listElements[index];
  9657. var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_RADIO_SELECTOR);
  9658. toggleEl.checked = isChecked;
  9659. var event = document.createEvent('Event');
  9660. event.initEvent('change', true, true);
  9661. toggleEl.dispatchEvent(event);
  9662. },
  9663. setTabIndexForListItemChildren: function setTabIndexForListItemChildren(listItemIndex, tabIndexValue) {
  9664. var element = _this.listElements[listItemIndex];
  9665. var selector = "." + _this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + " " + constants_1.strings.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX;
  9666. Array.prototype.forEach.call(element.querySelectorAll(selector), function (el) {
  9667. el.setAttribute('tabindex', tabIndexValue);
  9668. });
  9669. }
  9670. };
  9671. return new foundation_1.MDCListFoundation(adapter);
  9672. };
  9673. /**
  9674. * Ensures that at least one item is focusable if the list is interactive and
  9675. * doesn't specify a suitable tabindex.
  9676. */
  9677. MDCList.prototype.ensureFocusable = function () {
  9678. if (this.isEvolutionEnabled && this.isInteractive) {
  9679. if (!this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + "[tabindex=\"0\"]")) {
  9680. var index = this.initialFocusIndex();
  9681. if (index !== -1) {
  9682. this.listElements[index].tabIndex = 0;
  9683. }
  9684. }
  9685. }
  9686. };
  9687. MDCList.prototype.initialFocusIndex = function () {
  9688. if (this.selectedIndex instanceof Array && this.selectedIndex.length > 0) {
  9689. return this.selectedIndex[0];
  9690. }
  9691. if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  9692. return this.selectedIndex;
  9693. }
  9694. var el = this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not(." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS] + ")");
  9695. if (el === null) {
  9696. return -1;
  9697. }
  9698. return this.getListItemIndex(el);
  9699. };
  9700. /**
  9701. * Used to figure out which list item this event is targetting. Or returns -1
  9702. * if there is no list item
  9703. */
  9704. MDCList.prototype.getListItemIndex = function (el) {
  9705. var nearestParent = ponyfill_1.closest(el, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ", ." + this.classNameMap[constants_1.cssClasses.ROOT]);
  9706. // Get the index of the element if it is a list item.
  9707. if (nearestParent && ponyfill_1.matches(nearestParent, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS])) {
  9708. return this.listElements.indexOf(nearestParent);
  9709. }
  9710. return -1;
  9711. };
  9712. /**
  9713. * Used to figure out which element was clicked before sending the event to
  9714. * the foundation.
  9715. */
  9716. MDCList.prototype.handleFocusInEvent = function (evt) {
  9717. var index = this.getListItemIndex(evt.target);
  9718. this.foundation.handleFocusIn(evt, index);
  9719. };
  9720. /**
  9721. * Used to figure out which element was clicked before sending the event to
  9722. * the foundation.
  9723. */
  9724. MDCList.prototype.handleFocusOutEvent = function (evt) {
  9725. var index = this.getListItemIndex(evt.target);
  9726. this.foundation.handleFocusOut(evt, index);
  9727. };
  9728. /**
  9729. * Used to figure out which element was focused when keydown event occurred
  9730. * before sending the event to the foundation.
  9731. */
  9732. MDCList.prototype.handleKeydownEvent = function (evt) {
  9733. var index = this.getListItemIndex(evt.target);
  9734. var target = evt.target;
  9735. this.foundation.handleKeydown(evt, target.classList.contains(this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]), index);
  9736. };
  9737. /**
  9738. * Used to figure out which element was clicked before sending the event to
  9739. * the foundation.
  9740. */
  9741. MDCList.prototype.handleClickEvent = function (evt) {
  9742. var index = this.getListItemIndex(evt.target);
  9743. var target = evt.target;
  9744. // Toggle the checkbox only if it's not the target of the event, or the
  9745. // checkbox will have 2 change events.
  9746. var toggleCheckbox = !ponyfill_1.matches(target, constants_1.strings.CHECKBOX_RADIO_SELECTOR);
  9747. this.foundation.handleClick(index, toggleCheckbox);
  9748. };
  9749. return MDCList;
  9750. }(component_1.MDCComponent);
  9751. exports.MDCList = MDCList;
  9752. /***/ }),
  9753. /***/ "./packages/mdc-list/constants.ts":
  9754. /*!****************************************!*\
  9755. !*** ./packages/mdc-list/constants.ts ***!
  9756. \****************************************/
  9757. /*! no static exports found */
  9758. /***/ (function(module, exports, __webpack_require__) {
  9759. "use strict";
  9760. /**
  9761. * @license
  9762. * Copyright 2018 Google Inc.
  9763. *
  9764. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9765. * of this software and associated documentation files (the "Software"), to deal
  9766. * in the Software without restriction, including without limitation the rights
  9767. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9768. * copies of the Software, and to permit persons to whom the Software is
  9769. * furnished to do so, subject to the following conditions:
  9770. *
  9771. * The above copyright notice and this permission notice shall be included in
  9772. * all copies or substantial portions of the Software.
  9773. *
  9774. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9775. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9776. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9777. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9778. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9779. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9780. * THE SOFTWARE.
  9781. */
  9782. var _a;
  9783. Object.defineProperty(exports, "__esModule", { value: true });
  9784. var cssClasses = {
  9785. LIST_ITEM_ACTIVATED_CLASS: 'mdc-list-item--activated',
  9786. LIST_ITEM_CLASS: 'mdc-list-item',
  9787. LIST_ITEM_DISABLED_CLASS: 'mdc-list-item--disabled',
  9788. LIST_ITEM_SELECTED_CLASS: 'mdc-list-item--selected',
  9789. LIST_ITEM_TEXT_CLASS: 'mdc-list-item__text',
  9790. LIST_ITEM_PRIMARY_TEXT_CLASS: 'mdc-list-item__primary-text',
  9791. ROOT: 'mdc-list'
  9792. };
  9793. exports.cssClasses = cssClasses;
  9794. var strings = {
  9795. ACTION_EVENT: 'MDCList:action',
  9796. ARIA_CHECKED: 'aria-checked',
  9797. ARIA_CHECKED_CHECKBOX_SELECTOR: '[role="checkbox"][aria-checked="true"]',
  9798. ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]',
  9799. ARIA_CURRENT: 'aria-current',
  9800. ARIA_DISABLED: 'aria-disabled',
  9801. ARIA_ORIENTATION: 'aria-orientation',
  9802. ARIA_ORIENTATION_HORIZONTAL: 'horizontal',
  9803. ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]',
  9804. ARIA_SELECTED: 'aria-selected',
  9805. ARIA_INTERACTIVE_ROLES_SELECTOR: '[role="listbox"], [role="menu"]',
  9806. ARIA_MULTI_SELECTABLE_SELECTOR: '[aria-multiselectable="true"]',
  9807. CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"], input[type="radio"]',
  9808. CHECKBOX_SELECTOR: 'input[type="checkbox"]',
  9809. CHILD_ELEMENTS_TO_TOGGLE_TABINDEX: 'button:not(:disabled), a',
  9810. FOCUSABLE_CHILD_ELEMENTS: 'button:not(:disabled), a, input[type="radio"]:not(:disabled), input[type="checkbox"]:not(:disabled)',
  9811. RADIO_SELECTOR: 'input[type="radio"]',
  9812. SELECTED_ITEM_SELECTOR: '[aria-selected="true"], [aria-current="true"]'
  9813. };
  9814. exports.strings = strings;
  9815. var numbers = {
  9816. UNSET_INDEX: -1,
  9817. TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS: 300
  9818. };
  9819. exports.numbers = numbers;
  9820. var evolutionClassNameMap = (_a = {}, _a["" + cssClasses.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-evolution-list-item--activated', _a["" + cssClasses.LIST_ITEM_CLASS] = 'mdc-evolution-list-item', _a["" + cssClasses.LIST_ITEM_DISABLED_CLASS] = 'mdc-evolution-list-item--disabled', _a["" + cssClasses.LIST_ITEM_SELECTED_CLASS] = 'mdc-evolution-list-item--selected', _a["" + cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-evolution-list-item__primary-text', _a["" + cssClasses.ROOT] = 'mdc-evolution-list', _a);
  9821. exports.evolutionClassNameMap = evolutionClassNameMap;
  9822. var evolutionAttribute = 'evolution';
  9823. exports.evolutionAttribute = evolutionAttribute;
  9824. /***/ }),
  9825. /***/ "./packages/mdc-list/events.ts":
  9826. /*!*************************************!*\
  9827. !*** ./packages/mdc-list/events.ts ***!
  9828. \*************************************/
  9829. /*! no static exports found */
  9830. /***/ (function(module, exports, __webpack_require__) {
  9831. "use strict";
  9832. /**
  9833. * @license
  9834. * Copyright 2020 Google Inc.
  9835. *
  9836. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9837. * of this software and associated documentation files (the "Software"), to deal
  9838. * in the Software without restriction, including without limitation the rights
  9839. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9840. * copies of the Software, and to permit persons to whom the Software is
  9841. * furnished to do so, subject to the following conditions:
  9842. *
  9843. * The above copyright notice and this permission notice shall be included in
  9844. * all copies or substantial portions of the Software.
  9845. *
  9846. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9847. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9848. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9849. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9850. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9851. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9852. * THE SOFTWARE.
  9853. */
  9854. Object.defineProperty(exports, "__esModule", { value: true });
  9855. var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select'];
  9856. /**
  9857. * Ensures that preventDefault is only called if the containing element
  9858. * doesn't consume the event, and it will cause an unintended scroll.
  9859. *
  9860. * @param evt keyboard event to be prevented.
  9861. */
  9862. exports.preventDefaultEvent = function (evt) {
  9863. var target = evt.target;
  9864. if (!target) {
  9865. return;
  9866. }
  9867. var tagName = ("" + target.tagName).toLowerCase();
  9868. if (ELEMENTS_KEY_ALLOWED_IN.indexOf(tagName) === -1) {
  9869. evt.preventDefault();
  9870. }
  9871. };
  9872. /***/ }),
  9873. /***/ "./packages/mdc-list/foundation.ts":
  9874. /*!*****************************************!*\
  9875. !*** ./packages/mdc-list/foundation.ts ***!
  9876. \*****************************************/
  9877. /*! no static exports found */
  9878. /***/ (function(module, exports, __webpack_require__) {
  9879. "use strict";
  9880. /**
  9881. * @license
  9882. * Copyright 2018 Google Inc.
  9883. *
  9884. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9885. * of this software and associated documentation files (the "Software"), to deal
  9886. * in the Software without restriction, including without limitation the rights
  9887. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9888. * copies of the Software, and to permit persons to whom the Software is
  9889. * furnished to do so, subject to the following conditions:
  9890. *
  9891. * The above copyright notice and this permission notice shall be included in
  9892. * all copies or substantial portions of the Software.
  9893. *
  9894. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9895. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9896. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9897. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9898. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9899. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9900. * THE SOFTWARE.
  9901. */
  9902. var __extends = this && this.__extends || function () {
  9903. var _extendStatics = function extendStatics(d, b) {
  9904. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  9905. d.__proto__ = b;
  9906. } || function (d, b) {
  9907. for (var p in b) {
  9908. if (b.hasOwnProperty(p)) d[p] = b[p];
  9909. }
  9910. };
  9911. return _extendStatics(d, b);
  9912. };
  9913. return function (d, b) {
  9914. _extendStatics(d, b);
  9915. function __() {
  9916. this.constructor = d;
  9917. }
  9918. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9919. };
  9920. }();
  9921. var __assign = this && this.__assign || function () {
  9922. __assign = Object.assign || function (t) {
  9923. for (var s, i = 1, n = arguments.length; i < n; i++) {
  9924. s = arguments[i];
  9925. for (var p in s) {
  9926. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  9927. }
  9928. }
  9929. return t;
  9930. };
  9931. return __assign.apply(this, arguments);
  9932. };
  9933. var __importStar = this && this.__importStar || function (mod) {
  9934. if (mod && mod.__esModule) return mod;
  9935. var result = {};
  9936. if (mod != null) for (var k in mod) {
  9937. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  9938. }result["default"] = mod;
  9939. return result;
  9940. };
  9941. Object.defineProperty(exports, "__esModule", { value: true });
  9942. // TODO(b/152410470): Remove trailing underscores from private properties
  9943. // tslint:disable:strip-private-property-underscore
  9944. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  9945. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  9946. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  9947. var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
  9948. var typeahead = __importStar(__webpack_require__(/*! ./typeahead */ "./packages/mdc-list/typeahead.ts"));
  9949. function isNumberArray(selectedIndex) {
  9950. return selectedIndex instanceof Array;
  9951. }
  9952. var MDCListFoundation = /** @class */function (_super) {
  9953. __extends(MDCListFoundation, _super);
  9954. function MDCListFoundation(adapter) {
  9955. var _this = _super.call(this, __assign(__assign({}, MDCListFoundation.defaultAdapter), adapter)) || this;
  9956. _this.wrapFocus_ = false;
  9957. _this.isVertical_ = true;
  9958. _this.isSingleSelectionList_ = false;
  9959. _this.selectedIndex_ = constants_1.numbers.UNSET_INDEX;
  9960. _this.focusedItemIndex = constants_1.numbers.UNSET_INDEX;
  9961. _this.useActivatedClass_ = false;
  9962. _this.useSelectedAttr_ = false;
  9963. _this.ariaCurrentAttrValue_ = null;
  9964. _this.isCheckboxList_ = false;
  9965. _this.isRadioList_ = false;
  9966. _this.hasTypeahead = false;
  9967. // Transiently holds current typeahead prefix from user.
  9968. _this.typeaheadState = typeahead.initState();
  9969. _this.sortedIndexByFirstChar = new Map();
  9970. return _this;
  9971. }
  9972. Object.defineProperty(MDCListFoundation, "strings", {
  9973. get: function get() {
  9974. return constants_1.strings;
  9975. },
  9976. enumerable: true,
  9977. configurable: true
  9978. });
  9979. Object.defineProperty(MDCListFoundation, "cssClasses", {
  9980. get: function get() {
  9981. return constants_1.cssClasses;
  9982. },
  9983. enumerable: true,
  9984. configurable: true
  9985. });
  9986. Object.defineProperty(MDCListFoundation, "numbers", {
  9987. get: function get() {
  9988. return constants_1.numbers;
  9989. },
  9990. enumerable: true,
  9991. configurable: true
  9992. });
  9993. Object.defineProperty(MDCListFoundation, "defaultAdapter", {
  9994. get: function get() {
  9995. return {
  9996. addClassForElementIndex: function addClassForElementIndex() {
  9997. return undefined;
  9998. },
  9999. focusItemAtIndex: function focusItemAtIndex() {
  10000. return undefined;
  10001. },
  10002. getAttributeForElementIndex: function getAttributeForElementIndex() {
  10003. return null;
  10004. },
  10005. getFocusedElementIndex: function getFocusedElementIndex() {
  10006. return 0;
  10007. },
  10008. getListItemCount: function getListItemCount() {
  10009. return 0;
  10010. },
  10011. hasCheckboxAtIndex: function hasCheckboxAtIndex() {
  10012. return false;
  10013. },
  10014. hasRadioAtIndex: function hasRadioAtIndex() {
  10015. return false;
  10016. },
  10017. isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex() {
  10018. return false;
  10019. },
  10020. isFocusInsideList: function isFocusInsideList() {
  10021. return false;
  10022. },
  10023. isRootFocused: function isRootFocused() {
  10024. return false;
  10025. },
  10026. listItemAtIndexHasClass: function listItemAtIndexHasClass() {
  10027. return false;
  10028. },
  10029. notifyAction: function notifyAction() {
  10030. return undefined;
  10031. },
  10032. removeClassForElementIndex: function removeClassForElementIndex() {
  10033. return undefined;
  10034. },
  10035. setAttributeForElementIndex: function setAttributeForElementIndex() {
  10036. return undefined;
  10037. },
  10038. setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex() {
  10039. return undefined;
  10040. },
  10041. setTabIndexForListItemChildren: function setTabIndexForListItemChildren() {
  10042. return undefined;
  10043. },
  10044. getPrimaryTextAtIndex: function getPrimaryTextAtIndex() {
  10045. return '';
  10046. }
  10047. };
  10048. },
  10049. enumerable: true,
  10050. configurable: true
  10051. });
  10052. MDCListFoundation.prototype.layout = function () {
  10053. if (this.adapter.getListItemCount() === 0) {
  10054. return;
  10055. }
  10056. // TODO(b/172274142): consider all items when determining the list's type.
  10057. if (this.adapter.hasCheckboxAtIndex(0)) {
  10058. this.isCheckboxList_ = true;
  10059. } else if (this.adapter.hasRadioAtIndex(0)) {
  10060. this.isRadioList_ = true;
  10061. } else {
  10062. this.maybeInitializeSingleSelection();
  10063. }
  10064. if (this.hasTypeahead) {
  10065. this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
  10066. }
  10067. };
  10068. /**
  10069. * Sets the private wrapFocus_ variable.
  10070. */
  10071. MDCListFoundation.prototype.setWrapFocus = function (value) {
  10072. this.wrapFocus_ = value;
  10073. };
  10074. /**
  10075. * Sets the isVertical_ private variable.
  10076. */
  10077. MDCListFoundation.prototype.setVerticalOrientation = function (value) {
  10078. this.isVertical_ = value;
  10079. };
  10080. /**
  10081. * Sets the isSingleSelectionList_ private variable.
  10082. */
  10083. MDCListFoundation.prototype.setSingleSelection = function (value) {
  10084. this.isSingleSelectionList_ = value;
  10085. if (value) {
  10086. this.maybeInitializeSingleSelection();
  10087. }
  10088. };
  10089. /**
  10090. * Automatically determines whether the list is single selection list. If so,
  10091. * initializes the internal state to match the selected item.
  10092. */
  10093. MDCListFoundation.prototype.maybeInitializeSingleSelection = function () {
  10094. var listItemsCount = this.adapter.getListItemCount();
  10095. for (var i = 0; i < listItemsCount; i++) {
  10096. var hasSelectedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS);
  10097. var hasActivatedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
  10098. if (!(hasSelectedClass || hasActivatedClass)) {
  10099. continue;
  10100. }
  10101. if (hasActivatedClass) {
  10102. this.setUseActivatedClass(true);
  10103. }
  10104. this.isSingleSelectionList_ = true;
  10105. this.selectedIndex_ = i;
  10106. return;
  10107. }
  10108. };
  10109. /**
  10110. * Sets whether typeahead is enabled on the list.
  10111. * @param hasTypeahead Whether typeahead is enabled.
  10112. */
  10113. MDCListFoundation.prototype.setHasTypeahead = function (hasTypeahead) {
  10114. this.hasTypeahead = hasTypeahead;
  10115. if (hasTypeahead) {
  10116. this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
  10117. }
  10118. };
  10119. /**
  10120. * @return Whether typeahead is currently matching a user-specified prefix.
  10121. */
  10122. MDCListFoundation.prototype.isTypeaheadInProgress = function () {
  10123. return this.hasTypeahead && typeahead.isTypingInProgress(this.typeaheadState);
  10124. };
  10125. /**
  10126. * Sets the useActivatedClass_ private variable.
  10127. */
  10128. MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) {
  10129. this.useActivatedClass_ = useActivated;
  10130. };
  10131. /**
  10132. * Sets the useSelectedAttr_ private variable.
  10133. */
  10134. MDCListFoundation.prototype.setUseSelectedAttribute = function (useSelected) {
  10135. this.useSelectedAttr_ = useSelected;
  10136. };
  10137. MDCListFoundation.prototype.getSelectedIndex = function () {
  10138. return this.selectedIndex_;
  10139. };
  10140. MDCListFoundation.prototype.setSelectedIndex = function (index) {
  10141. if (!this.isIndexValid_(index)) {
  10142. return;
  10143. }
  10144. if (this.isCheckboxList_) {
  10145. this.setCheckboxAtIndex_(index);
  10146. } else if (this.isRadioList_) {
  10147. this.setRadioAtIndex_(index);
  10148. } else {
  10149. this.setSingleSelectionAtIndex_(index);
  10150. }
  10151. };
  10152. /**
  10153. * Focus in handler for the list items.
  10154. */
  10155. MDCListFoundation.prototype.handleFocusIn = function (_, listItemIndex) {
  10156. if (listItemIndex >= 0) {
  10157. this.focusedItemIndex = listItemIndex;
  10158. this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '0');
  10159. this.adapter.setTabIndexForListItemChildren(listItemIndex, '0');
  10160. }
  10161. };
  10162. /**
  10163. * Focus out handler for the list items.
  10164. */
  10165. MDCListFoundation.prototype.handleFocusOut = function (_, listItemIndex) {
  10166. var _this = this;
  10167. if (listItemIndex >= 0) {
  10168. this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '-1');
  10169. this.adapter.setTabIndexForListItemChildren(listItemIndex, '-1');
  10170. }
  10171. /**
  10172. * Between Focusout & Focusin some browsers do not have focus on any
  10173. * element. Setting a delay to wait till the focus is moved to next element.
  10174. */
  10175. setTimeout(function () {
  10176. if (!_this.adapter.isFocusInsideList()) {
  10177. _this.setTabindexToFirstSelectedOrFocusedItem();
  10178. }
  10179. }, 0);
  10180. };
  10181. /**
  10182. * Key handler for the list.
  10183. */
  10184. MDCListFoundation.prototype.handleKeydown = function (event, isRootListItem, listItemIndex) {
  10185. var _this = this;
  10186. var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
  10187. var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
  10188. var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
  10189. var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
  10190. var isHome = keyboard_1.normalizeKey(event) === 'Home';
  10191. var isEnd = keyboard_1.normalizeKey(event) === 'End';
  10192. var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
  10193. var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
  10194. // Have to check both upper and lower case, because having caps lock on affects the value.
  10195. var isLetterA = event.key === 'A' || event.key === 'a';
  10196. if (this.adapter.isRootFocused()) {
  10197. if (isArrowUp || isEnd) {
  10198. event.preventDefault();
  10199. this.focusLastElement();
  10200. } else if (isArrowDown || isHome) {
  10201. event.preventDefault();
  10202. this.focusFirstElement();
  10203. }
  10204. if (this.hasTypeahead) {
  10205. var handleKeydownOpts = {
  10206. event: event,
  10207. focusItemAtIndex: function focusItemAtIndex(index) {
  10208. _this.focusItemAtIndex(index);
  10209. },
  10210. focusedItemIndex: -1,
  10211. isTargetListItem: isRootListItem,
  10212. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  10213. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  10214. return _this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  10215. }
  10216. };
  10217. typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
  10218. }
  10219. return;
  10220. }
  10221. var currentIndex = this.adapter.getFocusedElementIndex();
  10222. if (currentIndex === -1) {
  10223. currentIndex = listItemIndex;
  10224. if (currentIndex < 0) {
  10225. // If this event doesn't have a mdc-list-item ancestor from the
  10226. // current list (not from a sublist), return early.
  10227. return;
  10228. }
  10229. }
  10230. if (this.isVertical_ && isArrowDown || !this.isVertical_ && isArrowRight) {
  10231. events_1.preventDefaultEvent(event);
  10232. this.focusNextElement(currentIndex);
  10233. } else if (this.isVertical_ && isArrowUp || !this.isVertical_ && isArrowLeft) {
  10234. events_1.preventDefaultEvent(event);
  10235. this.focusPrevElement(currentIndex);
  10236. } else if (isHome) {
  10237. events_1.preventDefaultEvent(event);
  10238. this.focusFirstElement();
  10239. } else if (isEnd) {
  10240. events_1.preventDefaultEvent(event);
  10241. this.focusLastElement();
  10242. } else if (isLetterA && event.ctrlKey && this.isCheckboxList_) {
  10243. event.preventDefault();
  10244. this.toggleAll(this.selectedIndex_ === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex_);
  10245. } else if (isEnter || isSpace) {
  10246. if (isRootListItem) {
  10247. // Return early if enter key is pressed on anchor element which triggers
  10248. // synthetic MouseEvent event.
  10249. var target = event.target;
  10250. if (target && target.tagName === 'A' && isEnter) {
  10251. return;
  10252. }
  10253. events_1.preventDefaultEvent(event);
  10254. if (this.adapter.listItemAtIndexHasClass(currentIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS)) {
  10255. return;
  10256. }
  10257. if (!this.isTypeaheadInProgress()) {
  10258. if (this.isSelectableList_()) {
  10259. this.setSelectedIndexOnAction_(currentIndex);
  10260. }
  10261. this.adapter.notifyAction(currentIndex);
  10262. }
  10263. }
  10264. }
  10265. if (this.hasTypeahead) {
  10266. var handleKeydownOpts = {
  10267. event: event,
  10268. focusItemAtIndex: function focusItemAtIndex(index) {
  10269. _this.focusItemAtIndex(index);
  10270. },
  10271. focusedItemIndex: this.focusedItemIndex,
  10272. isTargetListItem: isRootListItem,
  10273. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  10274. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  10275. return _this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  10276. }
  10277. };
  10278. typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
  10279. }
  10280. };
  10281. /**
  10282. * Click handler for the list.
  10283. */
  10284. MDCListFoundation.prototype.handleClick = function (index, toggleCheckbox) {
  10285. if (index === constants_1.numbers.UNSET_INDEX) {
  10286. return;
  10287. }
  10288. if (this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS)) {
  10289. return;
  10290. }
  10291. if (this.isSelectableList_()) {
  10292. this.setSelectedIndexOnAction_(index, toggleCheckbox);
  10293. }
  10294. this.adapter.notifyAction(index);
  10295. };
  10296. /**
  10297. * Focuses the next element on the list.
  10298. */
  10299. MDCListFoundation.prototype.focusNextElement = function (index) {
  10300. var count = this.adapter.getListItemCount();
  10301. var nextIndex = index + 1;
  10302. if (nextIndex >= count) {
  10303. if (this.wrapFocus_) {
  10304. nextIndex = 0;
  10305. } else {
  10306. // Return early because last item is already focused.
  10307. return index;
  10308. }
  10309. }
  10310. this.focusItemAtIndex(nextIndex);
  10311. return nextIndex;
  10312. };
  10313. /**
  10314. * Focuses the previous element on the list.
  10315. */
  10316. MDCListFoundation.prototype.focusPrevElement = function (index) {
  10317. var prevIndex = index - 1;
  10318. if (prevIndex < 0) {
  10319. if (this.wrapFocus_) {
  10320. prevIndex = this.adapter.getListItemCount() - 1;
  10321. } else {
  10322. // Return early because first item is already focused.
  10323. return index;
  10324. }
  10325. }
  10326. this.focusItemAtIndex(prevIndex);
  10327. return prevIndex;
  10328. };
  10329. MDCListFoundation.prototype.focusFirstElement = function () {
  10330. this.focusItemAtIndex(0);
  10331. return 0;
  10332. };
  10333. MDCListFoundation.prototype.focusLastElement = function () {
  10334. var lastIndex = this.adapter.getListItemCount() - 1;
  10335. this.focusItemAtIndex(lastIndex);
  10336. return lastIndex;
  10337. };
  10338. MDCListFoundation.prototype.focusInitialElement = function () {
  10339. var initialIndex = this.getFirstSelectedOrFocusedItemIndex();
  10340. this.focusItemAtIndex(initialIndex);
  10341. return initialIndex;
  10342. };
  10343. /**
  10344. * @param itemIndex Index of the list item
  10345. * @param isEnabled Sets the list item to enabled or disabled.
  10346. */
  10347. MDCListFoundation.prototype.setEnabled = function (itemIndex, isEnabled) {
  10348. if (!this.isIndexValid_(itemIndex)) {
  10349. return;
  10350. }
  10351. if (isEnabled) {
  10352. this.adapter.removeClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  10353. this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'false');
  10354. } else {
  10355. this.adapter.addClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  10356. this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'true');
  10357. }
  10358. };
  10359. MDCListFoundation.prototype.setSingleSelectionAtIndex_ = function (index) {
  10360. if (this.selectedIndex_ === index) {
  10361. return;
  10362. }
  10363. var selectedClassName = constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS;
  10364. if (this.useActivatedClass_) {
  10365. selectedClassName = constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS;
  10366. }
  10367. if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
  10368. this.adapter.removeClassForElementIndex(this.selectedIndex_, selectedClassName);
  10369. }
  10370. this.setAriaForSingleSelectionAtIndex_(index);
  10371. this.setTabindexAtIndex(index);
  10372. if (index !== constants_1.numbers.UNSET_INDEX) {
  10373. this.adapter.addClassForElementIndex(index, selectedClassName);
  10374. }
  10375. this.selectedIndex_ = index;
  10376. };
  10377. /**
  10378. * Sets aria attribute for single selection at given index.
  10379. */
  10380. MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex_ = function (index) {
  10381. // Detect the presence of aria-current and get the value only during list
  10382. // initialization when it is in unset state.
  10383. if (this.selectedIndex_ === constants_1.numbers.UNSET_INDEX) {
  10384. this.ariaCurrentAttrValue_ = this.adapter.getAttributeForElementIndex(index, constants_1.strings.ARIA_CURRENT);
  10385. }
  10386. var isAriaCurrent = this.ariaCurrentAttrValue_ !== null;
  10387. var ariaAttribute = isAriaCurrent ? constants_1.strings.ARIA_CURRENT : constants_1.strings.ARIA_SELECTED;
  10388. if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
  10389. this.adapter.setAttributeForElementIndex(this.selectedIndex_, ariaAttribute, 'false');
  10390. }
  10391. if (index !== constants_1.numbers.UNSET_INDEX) {
  10392. var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue_ : 'true';
  10393. this.adapter.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
  10394. }
  10395. };
  10396. /**
  10397. * Returns the attribute to use for indicating selection status.
  10398. */
  10399. MDCListFoundation.prototype.getSelectionAttribute = function () {
  10400. return this.useSelectedAttr_ ? constants_1.strings.ARIA_SELECTED : constants_1.strings.ARIA_CHECKED;
  10401. };
  10402. /**
  10403. * Toggles radio at give index. Radio doesn't change the checked state if it
  10404. * is already checked.
  10405. */
  10406. MDCListFoundation.prototype.setRadioAtIndex_ = function (index) {
  10407. var selectionAttribute = this.getSelectionAttribute();
  10408. this.adapter.setCheckedCheckboxOrRadioAtIndex(index, true);
  10409. if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
  10410. this.adapter.setAttributeForElementIndex(this.selectedIndex_, selectionAttribute, 'false');
  10411. }
  10412. this.adapter.setAttributeForElementIndex(index, selectionAttribute, 'true');
  10413. this.selectedIndex_ = index;
  10414. };
  10415. MDCListFoundation.prototype.setCheckboxAtIndex_ = function (index) {
  10416. var selectionAttribute = this.getSelectionAttribute();
  10417. for (var i = 0; i < this.adapter.getListItemCount(); i++) {
  10418. var isChecked = false;
  10419. if (index.indexOf(i) >= 0) {
  10420. isChecked = true;
  10421. }
  10422. this.adapter.setCheckedCheckboxOrRadioAtIndex(i, isChecked);
  10423. this.adapter.setAttributeForElementIndex(i, selectionAttribute, isChecked ? 'true' : 'false');
  10424. }
  10425. this.selectedIndex_ = index;
  10426. };
  10427. MDCListFoundation.prototype.setTabindexAtIndex = function (index) {
  10428. if (this.focusedItemIndex === constants_1.numbers.UNSET_INDEX && index !== 0) {
  10429. // If some list item was selected set first list item's tabindex to -1.
  10430. // Generally, tabindex is set to 0 on first list item of list that has no
  10431. // preselected items.
  10432. this.adapter.setAttributeForElementIndex(0, 'tabindex', '-1');
  10433. } else if (this.focusedItemIndex >= 0 && this.focusedItemIndex !== index) {
  10434. this.adapter.setAttributeForElementIndex(this.focusedItemIndex, 'tabindex', '-1');
  10435. }
  10436. // Set the previous selection's tabindex to -1. We need this because
  10437. // in selection menus that are not visible, programmatically setting an
  10438. // option will not change focus but will change where tabindex should be 0.
  10439. if (!(this.selectedIndex_ instanceof Array) && this.selectedIndex_ !== index) {
  10440. this.adapter.setAttributeForElementIndex(this.selectedIndex_, 'tabindex', '-1');
  10441. }
  10442. if (index !== constants_1.numbers.UNSET_INDEX) {
  10443. this.adapter.setAttributeForElementIndex(index, 'tabindex', '0');
  10444. }
  10445. };
  10446. /**
  10447. * @return Return true if it is single selectin list, checkbox list or radio
  10448. * list.
  10449. */
  10450. MDCListFoundation.prototype.isSelectableList_ = function () {
  10451. return this.isSingleSelectionList_ || this.isCheckboxList_ || this.isRadioList_;
  10452. };
  10453. MDCListFoundation.prototype.setTabindexToFirstSelectedOrFocusedItem = function () {
  10454. var targetIndex = this.getFirstSelectedOrFocusedItemIndex();
  10455. this.setTabindexAtIndex(targetIndex);
  10456. };
  10457. MDCListFoundation.prototype.getFirstSelectedOrFocusedItemIndex = function () {
  10458. var targetIndex = this.focusedItemIndex >= 0 ? this.focusedItemIndex : 0;
  10459. if (this.isSelectableList_()) {
  10460. if (typeof this.selectedIndex_ === 'number' && this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
  10461. targetIndex = this.selectedIndex_;
  10462. } else if (isNumberArray(this.selectedIndex_) && this.selectedIndex_.length > 0) {
  10463. targetIndex = this.selectedIndex_.reduce(function (currentIndex, minIndex) {
  10464. return Math.min(currentIndex, minIndex);
  10465. });
  10466. }
  10467. }
  10468. return targetIndex;
  10469. };
  10470. MDCListFoundation.prototype.isIndexValid_ = function (index) {
  10471. var _this = this;
  10472. if (index instanceof Array) {
  10473. if (!this.isCheckboxList_) {
  10474. throw new Error('MDCListFoundation: Array of index is only supported for checkbox based list');
  10475. }
  10476. if (index.length === 0) {
  10477. return true;
  10478. } else {
  10479. return index.some(function (i) {
  10480. return _this.isIndexInRange_(i);
  10481. });
  10482. }
  10483. } else if (typeof index === 'number') {
  10484. if (this.isCheckboxList_) {
  10485. throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: " + index);
  10486. }
  10487. return this.isIndexInRange_(index) || this.isSingleSelectionList_ && index === constants_1.numbers.UNSET_INDEX;
  10488. } else {
  10489. return false;
  10490. }
  10491. };
  10492. MDCListFoundation.prototype.isIndexInRange_ = function (index) {
  10493. var listSize = this.adapter.getListItemCount();
  10494. return index >= 0 && index < listSize;
  10495. };
  10496. /**
  10497. * Sets selected index on user action, toggles checkbox / radio based on
  10498. * toggleCheckbox value. User interaction should not toggle list item(s) when
  10499. * disabled.
  10500. */
  10501. MDCListFoundation.prototype.setSelectedIndexOnAction_ = function (index, toggleCheckbox) {
  10502. if (toggleCheckbox === void 0) {
  10503. toggleCheckbox = true;
  10504. }
  10505. if (this.isCheckboxList_) {
  10506. this.toggleCheckboxAtIndex_(index, toggleCheckbox);
  10507. } else {
  10508. this.setSelectedIndex(index);
  10509. }
  10510. };
  10511. MDCListFoundation.prototype.toggleCheckboxAtIndex_ = function (index, toggleCheckbox) {
  10512. var selectionAttribute = this.getSelectionAttribute();
  10513. var isChecked = this.adapter.isCheckboxCheckedAtIndex(index);
  10514. if (toggleCheckbox) {
  10515. isChecked = !isChecked;
  10516. this.adapter.setCheckedCheckboxOrRadioAtIndex(index, isChecked);
  10517. }
  10518. this.adapter.setAttributeForElementIndex(index, selectionAttribute, isChecked ? 'true' : 'false');
  10519. // If none of the checkbox items are selected and selectedIndex is not
  10520. // initialized then provide a default value.
  10521. var selectedIndexes = this.selectedIndex_ === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex_.slice();
  10522. if (isChecked) {
  10523. selectedIndexes.push(index);
  10524. } else {
  10525. selectedIndexes = selectedIndexes.filter(function (i) {
  10526. return i !== index;
  10527. });
  10528. }
  10529. this.selectedIndex_ = selectedIndexes;
  10530. };
  10531. MDCListFoundation.prototype.focusItemAtIndex = function (index) {
  10532. this.adapter.focusItemAtIndex(index);
  10533. this.focusedItemIndex = index;
  10534. };
  10535. MDCListFoundation.prototype.toggleAll = function (currentlySelectedIndexes) {
  10536. var count = this.adapter.getListItemCount();
  10537. // If all items are selected, deselect everything.
  10538. if (currentlySelectedIndexes.length === count) {
  10539. this.setCheckboxAtIndex_([]);
  10540. } else {
  10541. // Otherwise select all enabled options.
  10542. var allIndexes = [];
  10543. for (var i = 0; i < count; i++) {
  10544. if (!this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS) || currentlySelectedIndexes.indexOf(i) > -1) {
  10545. allIndexes.push(i);
  10546. }
  10547. }
  10548. this.setCheckboxAtIndex_(allIndexes);
  10549. }
  10550. };
  10551. /**
  10552. * Given the next desired character from the user, adds it to the typeahead
  10553. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  10554. * around if at the end of options.
  10555. *
  10556. * @param nextChar The next character to add to the prefix buffer.
  10557. * @param startingIndex The index from which to start matching. Only relevant
  10558. * when starting a new match sequence. To start a new match sequence,
  10559. * clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
  10560. * to clear after a set interval defined in list foundation. Defaults to
  10561. * the currently focused index.
  10562. * @return The index of the matched item, or -1 if no match.
  10563. */
  10564. MDCListFoundation.prototype.typeaheadMatchItem = function (nextChar, startingIndex, skipFocus) {
  10565. var _this = this;
  10566. if (skipFocus === void 0) {
  10567. skipFocus = false;
  10568. }
  10569. var opts = {
  10570. focusItemAtIndex: function focusItemAtIndex(index) {
  10571. _this.focusItemAtIndex(index);
  10572. },
  10573. focusedItemIndex: startingIndex ? startingIndex : this.focusedItemIndex,
  10574. nextChar: nextChar,
  10575. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  10576. skipFocus: skipFocus,
  10577. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  10578. return _this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  10579. }
  10580. };
  10581. return typeahead.matchItem(opts, this.typeaheadState);
  10582. };
  10583. /**
  10584. * Initializes the MDCListTextAndIndex data structure by indexing the current
  10585. * list items by primary text.
  10586. *
  10587. * @return The primary texts of all the list items sorted by first character.
  10588. */
  10589. MDCListFoundation.prototype.typeaheadInitSortedIndex = function () {
  10590. return typeahead.initSortedIndex(this.adapter.getListItemCount(), this.adapter.getPrimaryTextAtIndex);
  10591. };
  10592. /**
  10593. * Clears the typeahead buffer.
  10594. */
  10595. MDCListFoundation.prototype.clearTypeaheadBuffer = function () {
  10596. typeahead.clearBuffer(this.typeaheadState);
  10597. };
  10598. return MDCListFoundation;
  10599. }(foundation_1.MDCFoundation);
  10600. exports.MDCListFoundation = MDCListFoundation;
  10601. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  10602. exports.default = MDCListFoundation;
  10603. /***/ }),
  10604. /***/ "./packages/mdc-list/index.ts":
  10605. /*!************************************!*\
  10606. !*** ./packages/mdc-list/index.ts ***!
  10607. \************************************/
  10608. /*! no static exports found */
  10609. /***/ (function(module, exports, __webpack_require__) {
  10610. "use strict";
  10611. /**
  10612. * @license
  10613. * Copyright 2019 Google Inc.
  10614. *
  10615. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10616. * of this software and associated documentation files (the "Software"), to deal
  10617. * in the Software without restriction, including without limitation the rights
  10618. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10619. * copies of the Software, and to permit persons to whom the Software is
  10620. * furnished to do so, subject to the following conditions:
  10621. *
  10622. * The above copyright notice and this permission notice shall be included in
  10623. * all copies or substantial portions of the Software.
  10624. *
  10625. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10626. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10627. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10628. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10629. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10630. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  10631. * THE SOFTWARE.
  10632. */
  10633. function __export(m) {
  10634. for (var p in m) {
  10635. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  10636. }
  10637. }
  10638. Object.defineProperty(exports, "__esModule", { value: true });
  10639. __export(__webpack_require__(/*! ./component */ "./packages/mdc-list/component.ts"));
  10640. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts"));
  10641. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-list/foundation.ts"));
  10642. /***/ }),
  10643. /***/ "./packages/mdc-list/typeahead.ts":
  10644. /*!****************************************!*\
  10645. !*** ./packages/mdc-list/typeahead.ts ***!
  10646. \****************************************/
  10647. /*! no static exports found */
  10648. /***/ (function(module, exports, __webpack_require__) {
  10649. "use strict";
  10650. /**
  10651. * @license
  10652. * Copyright 2020 Google Inc.
  10653. *
  10654. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10655. * of this software and associated documentation files (the "Software"), to deal
  10656. * in the Software without restriction, including without limitation the rights
  10657. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10658. * copies of the Software, and to permit persons to whom the Software is
  10659. * furnished to do so, subject to the following conditions:
  10660. *
  10661. * The above copyright notice and this permission notice shall be included in
  10662. * all copies or substantial portions of the Software.
  10663. *
  10664. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10665. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10666. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10667. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10668. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10669. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  10670. * THE SOFTWARE.
  10671. */
  10672. Object.defineProperty(exports, "__esModule", { value: true });
  10673. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  10674. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  10675. var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
  10676. /**
  10677. * Initializes a state object for typeahead. Use the same reference for calls to
  10678. * typeahead functions.
  10679. *
  10680. * @return The current state of the typeahead process. Each state reference
  10681. * represents a typeahead instance as the reference is typically mutated
  10682. * in-place.
  10683. */
  10684. function initState() {
  10685. var state = {
  10686. bufferClearTimeout: 0,
  10687. currentFirstChar: '',
  10688. sortedIndexCursor: 0,
  10689. typeaheadBuffer: ''
  10690. };
  10691. return state;
  10692. }
  10693. exports.initState = initState;
  10694. /**
  10695. * Initializes typeahead state by indexing the current list items by primary
  10696. * text into the sortedIndexByFirstChar data structure.
  10697. *
  10698. * @param listItemCount numer of items in the list
  10699. * @param getPrimaryTextByItemIndex function that returns the primary text at a
  10700. * given index
  10701. *
  10702. * @return Map that maps the first character of the primary text to the full
  10703. * list text and it's index
  10704. */
  10705. function initSortedIndex(listItemCount, getPrimaryTextByItemIndex) {
  10706. var sortedIndexByFirstChar = new Map();
  10707. // Aggregate item text to index mapping
  10708. for (var i = 0; i < listItemCount; i++) {
  10709. var primaryText = getPrimaryTextByItemIndex(i).trim();
  10710. if (!primaryText) {
  10711. continue;
  10712. }
  10713. var firstChar = primaryText[0].toLowerCase();
  10714. if (!sortedIndexByFirstChar.has(firstChar)) {
  10715. sortedIndexByFirstChar.set(firstChar, []);
  10716. }
  10717. sortedIndexByFirstChar.get(firstChar).push({ text: primaryText.toLowerCase(), index: i });
  10718. }
  10719. // Sort the mapping
  10720. // TODO(b/157162694): Investigate replacing forEach with Map.values()
  10721. sortedIndexByFirstChar.forEach(function (values) {
  10722. values.sort(function (first, second) {
  10723. return first.index - second.index;
  10724. });
  10725. });
  10726. return sortedIndexByFirstChar;
  10727. }
  10728. exports.initSortedIndex = initSortedIndex;
  10729. /**
  10730. * Given the next desired character from the user, it attempts to find the next
  10731. * list option matching the buffer. Wraps around if at the end of options.
  10732. *
  10733. * @param opts Options and accessors
  10734. * - nextChar - the next character to match against items
  10735. * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
  10736. * - focusedItemIndex - the index of the currently focused item
  10737. * - focusItemAtIndex - function that focuses a list item at given index
  10738. * - skipFocus - whether or not to focus the matched item
  10739. * - isItemAtIndexDisabled - function that determines whether an item at a
  10740. * given index is disabled
  10741. * @param state The typeahead state instance. See `initState`.
  10742. *
  10743. * @return The index of the matched item, or -1 if no match.
  10744. */
  10745. function matchItem(opts, state) {
  10746. var nextChar = opts.nextChar,
  10747. focusItemAtIndex = opts.focusItemAtIndex,
  10748. sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
  10749. focusedItemIndex = opts.focusedItemIndex,
  10750. skipFocus = opts.skipFocus,
  10751. isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
  10752. clearTimeout(state.bufferClearTimeout);
  10753. state.bufferClearTimeout = setTimeout(function () {
  10754. clearBuffer(state);
  10755. }, constants_1.numbers.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS);
  10756. state.typeaheadBuffer = state.typeaheadBuffer + nextChar;
  10757. var index;
  10758. if (state.typeaheadBuffer.length === 1) {
  10759. index = matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state);
  10760. } else {
  10761. index = matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state);
  10762. }
  10763. if (index !== -1 && !skipFocus) {
  10764. focusItemAtIndex(index);
  10765. }
  10766. return index;
  10767. }
  10768. exports.matchItem = matchItem;
  10769. /**
  10770. * Matches the user's single input character in the buffer to the
  10771. * next option that begins with such character. Wraps around if at
  10772. * end of options. Returns -1 if no match is found.
  10773. */
  10774. function matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state) {
  10775. var firstChar = state.typeaheadBuffer[0];
  10776. var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
  10777. if (!itemsMatchingFirstChar) {
  10778. return -1;
  10779. }
  10780. // Has the same firstChar been recently matched?
  10781. // Also, did starting index remain the same between key presses?
  10782. // If both hold true, simply increment index.
  10783. if (firstChar === state.currentFirstChar && itemsMatchingFirstChar[state.sortedIndexCursor].index === focusedItemIndex) {
  10784. state.sortedIndexCursor = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
  10785. var newIndex = itemsMatchingFirstChar[state.sortedIndexCursor].index;
  10786. if (!isItemAtIndexDisabled(newIndex)) {
  10787. return newIndex;
  10788. }
  10789. }
  10790. // If we're here, it means one of the following happened:
  10791. // - either firstChar or startingIndex has changed, invalidating the
  10792. // cursor.
  10793. // - The next item of typeahead is disabled, so we have to look further.
  10794. state.currentFirstChar = firstChar;
  10795. var newCursorPosition = -1;
  10796. var cursorPosition;
  10797. // Find the first non-disabled item as a fallback.
  10798. for (cursorPosition = 0; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
  10799. if (!isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
  10800. newCursorPosition = cursorPosition;
  10801. break;
  10802. }
  10803. }
  10804. // Advance cursor to first item matching the firstChar that is positioned
  10805. // after starting item. Cursor is unchanged from fallback if there's no
  10806. // such item.
  10807. for (; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
  10808. if (itemsMatchingFirstChar[cursorPosition].index > focusedItemIndex && !isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
  10809. newCursorPosition = cursorPosition;
  10810. break;
  10811. }
  10812. }
  10813. if (newCursorPosition !== -1) {
  10814. state.sortedIndexCursor = newCursorPosition;
  10815. return itemsMatchingFirstChar[state.sortedIndexCursor].index;
  10816. }
  10817. return -1;
  10818. }
  10819. /**
  10820. * Attempts to find the next item that matches all of the typeahead buffer.
  10821. * Wraps around if at end of options. Returns -1 if no match is found.
  10822. */
  10823. function matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state) {
  10824. var firstChar = state.typeaheadBuffer[0];
  10825. var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
  10826. if (!itemsMatchingFirstChar) {
  10827. return -1;
  10828. }
  10829. // Do nothing if text already matches
  10830. var startingItem = itemsMatchingFirstChar[state.sortedIndexCursor];
  10831. if (startingItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0 && !isItemAtIndexDisabled(startingItem.index)) {
  10832. return startingItem.index;
  10833. }
  10834. // Find next item that matches completely; if no match, we'll eventually
  10835. // loop around to same position
  10836. var cursorPosition = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
  10837. var nextCursorPosition = -1;
  10838. while (cursorPosition !== state.sortedIndexCursor) {
  10839. var currentItem = itemsMatchingFirstChar[cursorPosition];
  10840. var matches = currentItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0;
  10841. var isEnabled = !isItemAtIndexDisabled(currentItem.index);
  10842. if (matches && isEnabled) {
  10843. nextCursorPosition = cursorPosition;
  10844. break;
  10845. }
  10846. cursorPosition = (cursorPosition + 1) % itemsMatchingFirstChar.length;
  10847. }
  10848. if (nextCursorPosition !== -1) {
  10849. state.sortedIndexCursor = nextCursorPosition;
  10850. return itemsMatchingFirstChar[state.sortedIndexCursor].index;
  10851. }
  10852. return -1;
  10853. }
  10854. /**
  10855. * Whether or not the given typeahead instaance state is currently typing.
  10856. *
  10857. * @param state The typeahead state instance. See `initState`.
  10858. */
  10859. function isTypingInProgress(state) {
  10860. return state.typeaheadBuffer.length > 0;
  10861. }
  10862. exports.isTypingInProgress = isTypingInProgress;
  10863. /**
  10864. * Clears the typeahaed buffer so that it resets item matching to the first
  10865. * character.
  10866. *
  10867. * @param state The typeahead state instance. See `initState`.
  10868. */
  10869. function clearBuffer(state) {
  10870. state.typeaheadBuffer = '';
  10871. }
  10872. exports.clearBuffer = clearBuffer;
  10873. /**
  10874. * Given a keydown event, it calculates whether or not to automatically focus a
  10875. * list item depending on what was typed mimicing the typeahead functionality of
  10876. * a standard <select> element that is open.
  10877. *
  10878. * @param opts Options and accessors
  10879. * - event - the KeyboardEvent to handle and parse
  10880. * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
  10881. * - focusedItemIndex - the index of the currently focused item
  10882. * - focusItemAtIndex - function that focuses a list item at given index
  10883. * - isItemAtFocusedIndexDisabled - whether or not the currently focused item
  10884. * is disabled
  10885. * - isTargetListItem - whether or not the event target is a list item
  10886. * @param state The typeahead state instance. See `initState`.
  10887. *
  10888. * @returns index of the item matched by the keydown. -1 if not matched.
  10889. */
  10890. function handleKeydown(opts, state) {
  10891. var event = opts.event,
  10892. isTargetListItem = opts.isTargetListItem,
  10893. focusedItemIndex = opts.focusedItemIndex,
  10894. focusItemAtIndex = opts.focusItemAtIndex,
  10895. sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
  10896. isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
  10897. var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
  10898. var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
  10899. var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
  10900. var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
  10901. var isHome = keyboard_1.normalizeKey(event) === 'Home';
  10902. var isEnd = keyboard_1.normalizeKey(event) === 'End';
  10903. var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
  10904. var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
  10905. if (isArrowLeft || isArrowUp || isArrowRight || isArrowDown || isHome || isEnd || isEnter) {
  10906. return -1;
  10907. }
  10908. var isCharacterKey = !isSpace && event.key.length === 1;
  10909. if (isCharacterKey) {
  10910. events_1.preventDefaultEvent(event);
  10911. var matchItemOpts = {
  10912. focusItemAtIndex: focusItemAtIndex,
  10913. focusedItemIndex: focusedItemIndex,
  10914. nextChar: event.key.toLowerCase(),
  10915. sortedIndexByFirstChar: sortedIndexByFirstChar,
  10916. skipFocus: false,
  10917. isItemAtIndexDisabled: isItemAtIndexDisabled
  10918. };
  10919. return matchItem(matchItemOpts, state);
  10920. }
  10921. if (!isSpace) {
  10922. return -1;
  10923. }
  10924. if (isTargetListItem) {
  10925. events_1.preventDefaultEvent(event);
  10926. }
  10927. var typeaheadOnListItem = isTargetListItem && isTypingInProgress(state);
  10928. if (typeaheadOnListItem) {
  10929. var matchItemOpts = {
  10930. focusItemAtIndex: focusItemAtIndex,
  10931. focusedItemIndex: focusedItemIndex,
  10932. nextChar: ' ',
  10933. sortedIndexByFirstChar: sortedIndexByFirstChar,
  10934. skipFocus: false,
  10935. isItemAtIndexDisabled: isItemAtIndexDisabled
  10936. };
  10937. // space participates in typeahead matching if in rapid typing mode
  10938. return matchItem(matchItemOpts, state);
  10939. }
  10940. return -1;
  10941. }
  10942. exports.handleKeydown = handleKeydown;
  10943. /***/ }),
  10944. /***/ "./packages/mdc-menu-surface/component.ts":
  10945. /*!************************************************!*\
  10946. !*** ./packages/mdc-menu-surface/component.ts ***!
  10947. \************************************************/
  10948. /*! no static exports found */
  10949. /***/ (function(module, exports, __webpack_require__) {
  10950. "use strict";
  10951. /**
  10952. * @license
  10953. * Copyright 2018 Google Inc.
  10954. *
  10955. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10956. * of this software and associated documentation files (the "Software"), to deal
  10957. * in the Software without restriction, including without limitation the rights
  10958. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10959. * copies of the Software, and to permit persons to whom the Software is
  10960. * furnished to do so, subject to the following conditions:
  10961. *
  10962. * The above copyright notice and this permission notice shall be included in
  10963. * all copies or substantial portions of the Software.
  10964. *
  10965. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10966. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10967. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10968. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10969. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10970. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  10971. * THE SOFTWARE.
  10972. */
  10973. var __extends = this && this.__extends || function () {
  10974. var _extendStatics = function extendStatics(d, b) {
  10975. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  10976. d.__proto__ = b;
  10977. } || function (d, b) {
  10978. for (var p in b) {
  10979. if (b.hasOwnProperty(p)) d[p] = b[p];
  10980. }
  10981. };
  10982. return _extendStatics(d, b);
  10983. };
  10984. return function (d, b) {
  10985. _extendStatics(d, b);
  10986. function __() {
  10987. this.constructor = d;
  10988. }
  10989. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10990. };
  10991. }();
  10992. Object.defineProperty(exports, "__esModule", { value: true });
  10993. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  10994. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
  10995. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu-surface/foundation.ts");
  10996. var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
  10997. var MDCMenuSurface = /** @class */function (_super) {
  10998. __extends(MDCMenuSurface, _super);
  10999. function MDCMenuSurface() {
  11000. return _super !== null && _super.apply(this, arguments) || this;
  11001. }
  11002. MDCMenuSurface.attachTo = function (root) {
  11003. return new MDCMenuSurface(root);
  11004. };
  11005. MDCMenuSurface.prototype.initialSyncWithDOM = function () {
  11006. var _this = this;
  11007. var parentEl = this.root.parentElement;
  11008. this.anchorElement = parentEl && parentEl.classList.contains(constants_1.cssClasses.ANCHOR) ? parentEl : null;
  11009. if (this.root.classList.contains(constants_1.cssClasses.FIXED)) {
  11010. this.setFixedPosition(true);
  11011. }
  11012. this.handleKeydown = function (event) {
  11013. _this.foundation.handleKeydown(event);
  11014. };
  11015. this.handleBodyClick = function (event) {
  11016. _this.foundation.handleBodyClick(event);
  11017. };
  11018. // capture so that no race between handleBodyClick and quickOpen when
  11019. // menusurface opened on button click which registers this listener
  11020. this.registerBodyClickListener = function () {
  11021. document.body.addEventListener('click', _this.handleBodyClick, { capture: true });
  11022. };
  11023. this.deregisterBodyClickListener = function () {
  11024. document.body.removeEventListener('click', _this.handleBodyClick, { capture: true });
  11025. };
  11026. this.listen('keydown', this.handleKeydown);
  11027. this.listen(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
  11028. this.listen(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
  11029. };
  11030. MDCMenuSurface.prototype.destroy = function () {
  11031. this.unlisten('keydown', this.handleKeydown);
  11032. this.unlisten(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
  11033. this.unlisten(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
  11034. _super.prototype.destroy.call(this);
  11035. };
  11036. MDCMenuSurface.prototype.isOpen = function () {
  11037. return this.foundation.isOpen();
  11038. };
  11039. MDCMenuSurface.prototype.open = function () {
  11040. this.foundation.open();
  11041. };
  11042. MDCMenuSurface.prototype.close = function (skipRestoreFocus) {
  11043. if (skipRestoreFocus === void 0) {
  11044. skipRestoreFocus = false;
  11045. }
  11046. this.foundation.close(skipRestoreFocus);
  11047. };
  11048. Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", {
  11049. set: function set(quickOpen) {
  11050. this.foundation.setQuickOpen(quickOpen);
  11051. },
  11052. enumerable: true,
  11053. configurable: true
  11054. });
  11055. /** Sets the foundation to use page offsets for an positioning when the menu is hoisted to the body. */
  11056. MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) {
  11057. this.foundation.setIsHoisted(isHoisted);
  11058. };
  11059. /** Sets the element that the menu-surface is anchored to. */
  11060. MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) {
  11061. this.anchorElement = element;
  11062. };
  11063. /** Sets the menu-surface to position: fixed. */
  11064. MDCMenuSurface.prototype.setFixedPosition = function (isFixed) {
  11065. if (isFixed) {
  11066. this.root.classList.add(constants_1.cssClasses.FIXED);
  11067. } else {
  11068. this.root.classList.remove(constants_1.cssClasses.FIXED);
  11069. }
  11070. this.foundation.setFixedPosition(isFixed);
  11071. };
  11072. /** Sets the absolute x/y position to position based on. Requires the menu to be hoisted. */
  11073. MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) {
  11074. this.foundation.setAbsolutePosition(x, y);
  11075. this.setIsHoisted(true);
  11076. };
  11077. /**
  11078. * @param corner Default anchor corner alignment of top-left surface corner.
  11079. */
  11080. MDCMenuSurface.prototype.setAnchorCorner = function (corner) {
  11081. this.foundation.setAnchorCorner(corner);
  11082. };
  11083. MDCMenuSurface.prototype.setAnchorMargin = function (margin) {
  11084. this.foundation.setAnchorMargin(margin);
  11085. };
  11086. MDCMenuSurface.prototype.getDefaultFoundation = function () {
  11087. var _this = this;
  11088. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  11089. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  11090. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  11091. var adapter = {
  11092. addClass: function addClass(className) {
  11093. return _this.root.classList.add(className);
  11094. },
  11095. removeClass: function removeClass(className) {
  11096. return _this.root.classList.remove(className);
  11097. },
  11098. hasClass: function hasClass(className) {
  11099. return _this.root.classList.contains(className);
  11100. },
  11101. hasAnchor: function hasAnchor() {
  11102. return !!_this.anchorElement;
  11103. },
  11104. notifyClose: function notifyClose() {
  11105. return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {});
  11106. },
  11107. notifyClosing: function notifyClosing() {
  11108. _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSING_EVENT, {});
  11109. },
  11110. notifyOpen: function notifyOpen() {
  11111. return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {});
  11112. },
  11113. isElementInContainer: function isElementInContainer(el) {
  11114. return _this.root.contains(el);
  11115. },
  11116. isRtl: function isRtl() {
  11117. return getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
  11118. },
  11119. setTransformOrigin: function setTransformOrigin(origin) {
  11120. var propertyName = util_1.getCorrectPropertyName(window, 'transform') + "-origin";
  11121. _this.root.style.setProperty(propertyName, origin);
  11122. },
  11123. isFocused: function isFocused() {
  11124. return document.activeElement === _this.root;
  11125. },
  11126. saveFocus: function saveFocus() {
  11127. _this.previousFocus = document.activeElement;
  11128. },
  11129. restoreFocus: function restoreFocus() {
  11130. if (_this.root.contains(document.activeElement)) {
  11131. if (_this.previousFocus && _this.previousFocus.focus) {
  11132. _this.previousFocus.focus();
  11133. }
  11134. }
  11135. },
  11136. getInnerDimensions: function getInnerDimensions() {
  11137. return {
  11138. width: _this.root.offsetWidth,
  11139. height: _this.root.offsetHeight
  11140. };
  11141. },
  11142. getAnchorDimensions: function getAnchorDimensions() {
  11143. return _this.anchorElement ? _this.anchorElement.getBoundingClientRect() : null;
  11144. },
  11145. getWindowDimensions: function getWindowDimensions() {
  11146. return { width: window.innerWidth, height: window.innerHeight };
  11147. },
  11148. getBodyDimensions: function getBodyDimensions() {
  11149. return { width: document.body.clientWidth, height: document.body.clientHeight };
  11150. },
  11151. getWindowScroll: function getWindowScroll() {
  11152. return { x: window.pageXOffset, y: window.pageYOffset };
  11153. },
  11154. setPosition: function setPosition(position) {
  11155. var rootHTML = _this.root;
  11156. rootHTML.style.left = 'left' in position ? position.left + "px" : '';
  11157. rootHTML.style.right = 'right' in position ? position.right + "px" : '';
  11158. rootHTML.style.top = 'top' in position ? position.top + "px" : '';
  11159. rootHTML.style.bottom = 'bottom' in position ? position.bottom + "px" : '';
  11160. },
  11161. setMaxHeight: function setMaxHeight(height) {
  11162. _this.root.style.maxHeight = height;
  11163. }
  11164. };
  11165. // tslint:enable:object-literal-sort-keys
  11166. return new foundation_1.MDCMenuSurfaceFoundation(adapter);
  11167. };
  11168. return MDCMenuSurface;
  11169. }(component_1.MDCComponent);
  11170. exports.MDCMenuSurface = MDCMenuSurface;
  11171. /***/ }),
  11172. /***/ "./packages/mdc-menu-surface/constants.ts":
  11173. /*!************************************************!*\
  11174. !*** ./packages/mdc-menu-surface/constants.ts ***!
  11175. \************************************************/
  11176. /*! no static exports found */
  11177. /***/ (function(module, exports, __webpack_require__) {
  11178. "use strict";
  11179. /**
  11180. * @license
  11181. * Copyright 2018 Google Inc.
  11182. *
  11183. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11184. * of this software and associated documentation files (the "Software"), to deal
  11185. * in the Software without restriction, including without limitation the rights
  11186. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11187. * copies of the Software, and to permit persons to whom the Software is
  11188. * furnished to do so, subject to the following conditions:
  11189. *
  11190. * The above copyright notice and this permission notice shall be included in
  11191. * all copies or substantial portions of the Software.
  11192. *
  11193. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11194. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11195. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11196. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11197. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11198. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11199. * THE SOFTWARE.
  11200. */
  11201. Object.defineProperty(exports, "__esModule", { value: true });
  11202. var cssClasses = {
  11203. ANCHOR: 'mdc-menu-surface--anchor',
  11204. ANIMATING_CLOSED: 'mdc-menu-surface--animating-closed',
  11205. ANIMATING_OPEN: 'mdc-menu-surface--animating-open',
  11206. FIXED: 'mdc-menu-surface--fixed',
  11207. IS_OPEN_BELOW: 'mdc-menu-surface--is-open-below',
  11208. OPEN: 'mdc-menu-surface--open',
  11209. ROOT: 'mdc-menu-surface'
  11210. };
  11211. exports.cssClasses = cssClasses;
  11212. // tslint:disable:object-literal-sort-keys
  11213. var strings = {
  11214. CLOSED_EVENT: 'MDCMenuSurface:closed',
  11215. CLOSING_EVENT: 'MDCMenuSurface:closing',
  11216. OPENED_EVENT: 'MDCMenuSurface:opened',
  11217. FOCUSABLE_ELEMENTS: ['button:not(:disabled)', '[href]:not([aria-disabled="true"])', 'input:not(:disabled)', 'select:not(:disabled)', 'textarea:not(:disabled)', '[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])'].join(', ')
  11218. };
  11219. exports.strings = strings;
  11220. // tslint:enable:object-literal-sort-keys
  11221. var numbers = {
  11222. /** Total duration of menu-surface open animation. */
  11223. TRANSITION_OPEN_DURATION: 120,
  11224. /** Total duration of menu-surface close animation. */
  11225. TRANSITION_CLOSE_DURATION: 75,
  11226. /** Margin left to the edge of the viewport when menu-surface is at maximum possible height. Also used as a viewport margin. */
  11227. MARGIN_TO_EDGE: 32,
  11228. /** Ratio of anchor width to menu-surface width for switching from corner positioning to center positioning. */
  11229. ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67
  11230. };
  11231. exports.numbers = numbers;
  11232. /**
  11233. * Enum for bits in the {@see Corner) bitmap.
  11234. */
  11235. var CornerBit;
  11236. (function (CornerBit) {
  11237. CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM";
  11238. CornerBit[CornerBit["CENTER"] = 2] = "CENTER";
  11239. CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT";
  11240. CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL";
  11241. })(CornerBit || (CornerBit = {}));
  11242. exports.CornerBit = CornerBit;
  11243. /**
  11244. * Enum for representing an element corner for positioning the menu-surface.
  11245. *
  11246. * The START constants map to LEFT if element directionality is left
  11247. * to right and RIGHT if the directionality is right to left.
  11248. * Likewise END maps to RIGHT or LEFT depending on the directionality.
  11249. */
  11250. var Corner;
  11251. (function (Corner) {
  11252. Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT";
  11253. Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT";
  11254. Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT";
  11255. Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT";
  11256. Corner[Corner["TOP_START"] = 8] = "TOP_START";
  11257. Corner[Corner["TOP_END"] = 12] = "TOP_END";
  11258. Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START";
  11259. Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END";
  11260. })(Corner || (Corner = {}));
  11261. exports.Corner = Corner;
  11262. /***/ }),
  11263. /***/ "./packages/mdc-menu-surface/foundation.ts":
  11264. /*!*************************************************!*\
  11265. !*** ./packages/mdc-menu-surface/foundation.ts ***!
  11266. \*************************************************/
  11267. /*! no static exports found */
  11268. /***/ (function(module, exports, __webpack_require__) {
  11269. "use strict";
  11270. /**
  11271. * @license
  11272. * Copyright 2018 Google Inc.
  11273. *
  11274. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11275. * of this software and associated documentation files (the "Software"), to deal
  11276. * in the Software without restriction, including without limitation the rights
  11277. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11278. * copies of the Software, and to permit persons to whom the Software is
  11279. * furnished to do so, subject to the following conditions:
  11280. *
  11281. * The above copyright notice and this permission notice shall be included in
  11282. * all copies or substantial portions of the Software.
  11283. *
  11284. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11285. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11286. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11287. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11288. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11289. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11290. * THE SOFTWARE.
  11291. */
  11292. var __extends = this && this.__extends || function () {
  11293. var _extendStatics = function extendStatics(d, b) {
  11294. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  11295. d.__proto__ = b;
  11296. } || function (d, b) {
  11297. for (var p in b) {
  11298. if (b.hasOwnProperty(p)) d[p] = b[p];
  11299. }
  11300. };
  11301. return _extendStatics(d, b);
  11302. };
  11303. return function (d, b) {
  11304. _extendStatics(d, b);
  11305. function __() {
  11306. this.constructor = d;
  11307. }
  11308. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11309. };
  11310. }();
  11311. var __assign = this && this.__assign || function () {
  11312. __assign = Object.assign || function (t) {
  11313. for (var s, i = 1, n = arguments.length; i < n; i++) {
  11314. s = arguments[i];
  11315. for (var p in s) {
  11316. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  11317. }
  11318. }
  11319. return t;
  11320. };
  11321. return __assign.apply(this, arguments);
  11322. };
  11323. var __values = this && this.__values || function (o) {
  11324. var s = typeof Symbol === "function" && Symbol.iterator,
  11325. m = s && o[s],
  11326. i = 0;
  11327. if (m) return m.call(o);
  11328. if (o && typeof o.length === "number") return {
  11329. next: function next() {
  11330. if (o && i >= o.length) o = void 0;
  11331. return { value: o && o[i++], done: !o };
  11332. }
  11333. };
  11334. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  11335. };
  11336. Object.defineProperty(exports, "__esModule", { value: true });
  11337. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  11338. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
  11339. var MDCMenuSurfaceFoundation = /** @class */function (_super) {
  11340. __extends(MDCMenuSurfaceFoundation, _super);
  11341. function MDCMenuSurfaceFoundation(adapter) {
  11342. var _this = _super.call(this, __assign(__assign({}, MDCMenuSurfaceFoundation.defaultAdapter), adapter)) || this;
  11343. _this.isSurfaceOpen = false;
  11344. _this.isQuickOpen = false;
  11345. _this.isHoistedElement = false;
  11346. _this.isFixedPosition = false;
  11347. _this.openAnimationEndTimerId = 0;
  11348. _this.closeAnimationEndTimerId = 0;
  11349. _this.animationRequestId = 0;
  11350. _this.anchorCorner = constants_1.Corner.TOP_START;
  11351. /**
  11352. * Corner of the menu surface to which menu surface is attached to anchor.
  11353. *
  11354. * Anchor corner --->+----------+
  11355. * | ANCHOR |
  11356. * +----------+
  11357. * Origin corner --->+--------------+
  11358. * | |
  11359. * | |
  11360. * | MENU SURFACE |
  11361. * | |
  11362. * | |
  11363. * +--------------+
  11364. */
  11365. _this.originCorner = constants_1.Corner.TOP_START;
  11366. _this.anchorMargin = { top: 0, right: 0, bottom: 0, left: 0 };
  11367. _this.position = { x: 0, y: 0 };
  11368. return _this;
  11369. }
  11370. Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", {
  11371. get: function get() {
  11372. return constants_1.cssClasses;
  11373. },
  11374. enumerable: true,
  11375. configurable: true
  11376. });
  11377. Object.defineProperty(MDCMenuSurfaceFoundation, "strings", {
  11378. get: function get() {
  11379. return constants_1.strings;
  11380. },
  11381. enumerable: true,
  11382. configurable: true
  11383. });
  11384. Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", {
  11385. get: function get() {
  11386. return constants_1.numbers;
  11387. },
  11388. enumerable: true,
  11389. configurable: true
  11390. });
  11391. Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", {
  11392. get: function get() {
  11393. return constants_1.Corner;
  11394. },
  11395. enumerable: true,
  11396. configurable: true
  11397. });
  11398. Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", {
  11399. /**
  11400. * @see {@link MDCMenuSurfaceAdapter} for typing information on parameters and return types.
  11401. */
  11402. get: function get() {
  11403. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  11404. return {
  11405. addClass: function addClass() {
  11406. return undefined;
  11407. },
  11408. removeClass: function removeClass() {
  11409. return undefined;
  11410. },
  11411. hasClass: function hasClass() {
  11412. return false;
  11413. },
  11414. hasAnchor: function hasAnchor() {
  11415. return false;
  11416. },
  11417. isElementInContainer: function isElementInContainer() {
  11418. return false;
  11419. },
  11420. isFocused: function isFocused() {
  11421. return false;
  11422. },
  11423. isRtl: function isRtl() {
  11424. return false;
  11425. },
  11426. getInnerDimensions: function getInnerDimensions() {
  11427. return { height: 0, width: 0 };
  11428. },
  11429. getAnchorDimensions: function getAnchorDimensions() {
  11430. return null;
  11431. },
  11432. getWindowDimensions: function getWindowDimensions() {
  11433. return { height: 0, width: 0 };
  11434. },
  11435. getBodyDimensions: function getBodyDimensions() {
  11436. return { height: 0, width: 0 };
  11437. },
  11438. getWindowScroll: function getWindowScroll() {
  11439. return { x: 0, y: 0 };
  11440. },
  11441. setPosition: function setPosition() {
  11442. return undefined;
  11443. },
  11444. setMaxHeight: function setMaxHeight() {
  11445. return undefined;
  11446. },
  11447. setTransformOrigin: function setTransformOrigin() {
  11448. return undefined;
  11449. },
  11450. saveFocus: function saveFocus() {
  11451. return undefined;
  11452. },
  11453. restoreFocus: function restoreFocus() {
  11454. return undefined;
  11455. },
  11456. notifyClose: function notifyClose() {
  11457. return undefined;
  11458. },
  11459. notifyOpen: function notifyOpen() {
  11460. return undefined;
  11461. },
  11462. notifyClosing: function notifyClosing() {
  11463. return undefined;
  11464. }
  11465. };
  11466. // tslint:enable:object-literal-sort-keys
  11467. },
  11468. enumerable: true,
  11469. configurable: true
  11470. });
  11471. MDCMenuSurfaceFoundation.prototype.init = function () {
  11472. var _a = MDCMenuSurfaceFoundation.cssClasses,
  11473. ROOT = _a.ROOT,
  11474. OPEN = _a.OPEN;
  11475. if (!this.adapter.hasClass(ROOT)) {
  11476. throw new Error(ROOT + " class required in root element.");
  11477. }
  11478. if (this.adapter.hasClass(OPEN)) {
  11479. this.isSurfaceOpen = true;
  11480. }
  11481. };
  11482. MDCMenuSurfaceFoundation.prototype.destroy = function () {
  11483. clearTimeout(this.openAnimationEndTimerId);
  11484. clearTimeout(this.closeAnimationEndTimerId);
  11485. // Cancel any currently running animations.
  11486. cancelAnimationFrame(this.animationRequestId);
  11487. };
  11488. /**
  11489. * @param corner Default anchor corner alignment of top-left menu surface corner.
  11490. */
  11491. MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) {
  11492. this.anchorCorner = corner;
  11493. };
  11494. /**
  11495. * Flip menu corner horizontally.
  11496. */
  11497. MDCMenuSurfaceFoundation.prototype.flipCornerHorizontally = function () {
  11498. this.originCorner = this.originCorner ^ constants_1.CornerBit.RIGHT;
  11499. };
  11500. /**
  11501. * @param margin Set of margin values from anchor.
  11502. */
  11503. MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) {
  11504. this.anchorMargin.top = margin.top || 0;
  11505. this.anchorMargin.right = margin.right || 0;
  11506. this.anchorMargin.bottom = margin.bottom || 0;
  11507. this.anchorMargin.left = margin.left || 0;
  11508. };
  11509. /** Used to indicate if the menu-surface is hoisted to the body. */
  11510. MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) {
  11511. this.isHoistedElement = isHoisted;
  11512. };
  11513. /** Used to set the menu-surface calculations based on a fixed position menu. */
  11514. MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) {
  11515. this.isFixedPosition = isFixedPosition;
  11516. };
  11517. /** Sets the menu-surface position on the page. */
  11518. MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) {
  11519. this.position.x = this.isFinite(x) ? x : 0;
  11520. this.position.y = this.isFinite(y) ? y : 0;
  11521. };
  11522. MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) {
  11523. this.isQuickOpen = quickOpen;
  11524. };
  11525. MDCMenuSurfaceFoundation.prototype.isOpen = function () {
  11526. return this.isSurfaceOpen;
  11527. };
  11528. /**
  11529. * Open the menu surface.
  11530. */
  11531. MDCMenuSurfaceFoundation.prototype.open = function () {
  11532. var _this = this;
  11533. if (this.isSurfaceOpen) {
  11534. return;
  11535. }
  11536. this.adapter.saveFocus();
  11537. if (this.isQuickOpen) {
  11538. this.isSurfaceOpen = true;
  11539. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  11540. this.dimensions = this.adapter.getInnerDimensions();
  11541. this.autoposition();
  11542. this.adapter.notifyOpen();
  11543. } else {
  11544. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
  11545. this.animationRequestId = requestAnimationFrame(function () {
  11546. _this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  11547. _this.dimensions = _this.adapter.getInnerDimensions();
  11548. _this.autoposition();
  11549. _this.openAnimationEndTimerId = setTimeout(function () {
  11550. _this.openAnimationEndTimerId = 0;
  11551. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
  11552. _this.adapter.notifyOpen();
  11553. }, constants_1.numbers.TRANSITION_OPEN_DURATION);
  11554. });
  11555. this.isSurfaceOpen = true;
  11556. }
  11557. };
  11558. /**
  11559. * Closes the menu surface.
  11560. */
  11561. MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) {
  11562. var _this = this;
  11563. if (skipRestoreFocus === void 0) {
  11564. skipRestoreFocus = false;
  11565. }
  11566. if (!this.isSurfaceOpen) {
  11567. return;
  11568. }
  11569. this.adapter.notifyClosing();
  11570. if (this.isQuickOpen) {
  11571. this.isSurfaceOpen = false;
  11572. if (!skipRestoreFocus) {
  11573. this.maybeRestoreFocus();
  11574. }
  11575. this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  11576. this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
  11577. this.adapter.notifyClose();
  11578. return;
  11579. }
  11580. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
  11581. requestAnimationFrame(function () {
  11582. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  11583. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
  11584. _this.closeAnimationEndTimerId = setTimeout(function () {
  11585. _this.closeAnimationEndTimerId = 0;
  11586. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
  11587. _this.adapter.notifyClose();
  11588. }, constants_1.numbers.TRANSITION_CLOSE_DURATION);
  11589. });
  11590. this.isSurfaceOpen = false;
  11591. if (!skipRestoreFocus) {
  11592. this.maybeRestoreFocus();
  11593. }
  11594. };
  11595. /** Handle clicks and close if not within menu-surface element. */
  11596. MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) {
  11597. var el = evt.target;
  11598. if (this.adapter.isElementInContainer(el)) {
  11599. return;
  11600. }
  11601. this.close();
  11602. };
  11603. /** Handle keys that close the surface. */
  11604. MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) {
  11605. var keyCode = evt.keyCode,
  11606. key = evt.key;
  11607. var isEscape = key === 'Escape' || keyCode === 27;
  11608. if (isEscape) {
  11609. this.close();
  11610. }
  11611. };
  11612. MDCMenuSurfaceFoundation.prototype.autoposition = function () {
  11613. var _a;
  11614. // Compute measurements for autoposition methods reuse.
  11615. this.measurements = this.getAutoLayoutmeasurements();
  11616. var corner = this.getoriginCorner();
  11617. var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight(corner);
  11618. var verticalAlignment = this.hasBit(corner, constants_1.CornerBit.BOTTOM) ? 'bottom' : 'top';
  11619. var horizontalAlignment = this.hasBit(corner, constants_1.CornerBit.RIGHT) ? 'right' : 'left';
  11620. var horizontalOffset = this.getHorizontalOriginOffset(corner);
  11621. var verticalOffset = this.getVerticalOriginOffset(corner);
  11622. var _b = this.measurements,
  11623. anchorSize = _b.anchorSize,
  11624. surfaceSize = _b.surfaceSize;
  11625. var position = (_a = {}, _a[horizontalAlignment] = horizontalOffset, _a[verticalAlignment] = verticalOffset, _a);
  11626. // Center align when anchor width is comparable or greater than menu surface, otherwise keep corner.
  11627. if (anchorSize.width / surfaceSize.width > constants_1.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) {
  11628. horizontalAlignment = 'center';
  11629. }
  11630. // If the menu-surface has been hoisted to the body, it's no longer relative to the anchor element
  11631. if (this.isHoistedElement || this.isFixedPosition) {
  11632. this.adjustPositionForHoistedElement(position);
  11633. }
  11634. this.adapter.setTransformOrigin(horizontalAlignment + " " + verticalAlignment);
  11635. this.adapter.setPosition(position);
  11636. this.adapter.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : '');
  11637. // If it is opened from the top then add is-open-below class
  11638. if (!this.hasBit(corner, constants_1.CornerBit.BOTTOM)) {
  11639. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
  11640. }
  11641. };
  11642. /**
  11643. * @return Measurements used to position menu surface popup.
  11644. */
  11645. MDCMenuSurfaceFoundation.prototype.getAutoLayoutmeasurements = function () {
  11646. var anchorRect = this.adapter.getAnchorDimensions();
  11647. var bodySize = this.adapter.getBodyDimensions();
  11648. var viewportSize = this.adapter.getWindowDimensions();
  11649. var windowScroll = this.adapter.getWindowScroll();
  11650. if (!anchorRect) {
  11651. // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
  11652. anchorRect = {
  11653. top: this.position.y,
  11654. right: this.position.x,
  11655. bottom: this.position.y,
  11656. left: this.position.x,
  11657. width: 0,
  11658. height: 0
  11659. };
  11660. // tslint:enable:object-literal-sort-keys
  11661. }
  11662. return {
  11663. anchorSize: anchorRect,
  11664. bodySize: bodySize,
  11665. surfaceSize: this.dimensions,
  11666. viewportDistance: {
  11667. // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
  11668. top: anchorRect.top,
  11669. right: viewportSize.width - anchorRect.right,
  11670. bottom: viewportSize.height - anchorRect.bottom,
  11671. left: anchorRect.left
  11672. },
  11673. viewportSize: viewportSize,
  11674. windowScroll: windowScroll
  11675. };
  11676. };
  11677. /**
  11678. * Computes the corner of the anchor from which to animate and position the
  11679. * menu surface.
  11680. *
  11681. * Only LEFT or RIGHT bit is used to position the menu surface ignoring RTL
  11682. * context. E.g., menu surface will be positioned from right side on TOP_END.
  11683. */
  11684. MDCMenuSurfaceFoundation.prototype.getoriginCorner = function () {
  11685. var corner = this.originCorner;
  11686. var _a = this.measurements,
  11687. viewportDistance = _a.viewportDistance,
  11688. anchorSize = _a.anchorSize,
  11689. surfaceSize = _a.surfaceSize;
  11690. var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
  11691. var isAnchoredToBottom = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
  11692. var availableTop;
  11693. var availableBottom;
  11694. if (isAnchoredToBottom) {
  11695. availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.bottom;
  11696. availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE - this.anchorMargin.bottom;
  11697. } else {
  11698. availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.top;
  11699. availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE + anchorSize.height - this.anchorMargin.top;
  11700. }
  11701. var isAvailableBottom = availableBottom - surfaceSize.height > 0;
  11702. if (!isAvailableBottom && availableTop > availableBottom) {
  11703. // Attach bottom side of surface to the anchor.
  11704. corner = this.setBit(corner, constants_1.CornerBit.BOTTOM);
  11705. }
  11706. var isRtl = this.adapter.isRtl();
  11707. var isFlipRtl = this.hasBit(this.anchorCorner, constants_1.CornerBit.FLIP_RTL);
  11708. var hasRightBit = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT) || this.hasBit(corner, constants_1.CornerBit.RIGHT);
  11709. // Whether surface attached to right side of anchor element.
  11710. var isAnchoredToRight = false;
  11711. // Anchored to start
  11712. if (isRtl && isFlipRtl) {
  11713. isAnchoredToRight = !hasRightBit;
  11714. } else {
  11715. // Anchored to right
  11716. isAnchoredToRight = hasRightBit;
  11717. }
  11718. var availableLeft;
  11719. var availableRight;
  11720. if (isAnchoredToRight) {
  11721. availableLeft = viewportDistance.left + anchorSize.width + this.anchorMargin.right;
  11722. availableRight = viewportDistance.right - this.anchorMargin.right;
  11723. } else {
  11724. availableLeft = viewportDistance.left + this.anchorMargin.left;
  11725. availableRight = viewportDistance.right + anchorSize.width - this.anchorMargin.left;
  11726. }
  11727. var isAvailableLeft = availableLeft - surfaceSize.width > 0;
  11728. var isAvailableRight = availableRight - surfaceSize.width > 0;
  11729. var isOriginCornerAlignedToEnd = this.hasBit(corner, constants_1.CornerBit.FLIP_RTL) && this.hasBit(corner, constants_1.CornerBit.RIGHT);
  11730. if (isAvailableRight && isOriginCornerAlignedToEnd && isRtl || !isAvailableLeft && isOriginCornerAlignedToEnd) {
  11731. // Attach left side of surface to the anchor.
  11732. corner = this.unsetBit(corner, constants_1.CornerBit.RIGHT);
  11733. } else if (isAvailableLeft && isAnchoredToRight && isRtl || isAvailableLeft && !isAnchoredToRight && hasRightBit || !isAvailableRight && availableLeft >= availableRight) {
  11734. // Attach right side of surface to the anchor.
  11735. corner = this.setBit(corner, constants_1.CornerBit.RIGHT);
  11736. }
  11737. return corner;
  11738. };
  11739. /**
  11740. * @param corner Origin corner of the menu surface.
  11741. * @return Maximum height of the menu surface, based on available space. 0 indicates should not be set.
  11742. */
  11743. MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) {
  11744. var viewportDistance = this.measurements.viewportDistance;
  11745. var maxHeight = 0;
  11746. var isBottomAligned = this.hasBit(corner, constants_1.CornerBit.BOTTOM);
  11747. var isBottomAnchored = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
  11748. var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
  11749. // When maximum height is not specified, it is handled from CSS.
  11750. if (isBottomAligned) {
  11751. maxHeight = viewportDistance.top + this.anchorMargin.top - MARGIN_TO_EDGE;
  11752. if (!isBottomAnchored) {
  11753. maxHeight += this.measurements.anchorSize.height;
  11754. }
  11755. } else {
  11756. maxHeight = viewportDistance.bottom - this.anchorMargin.bottom + this.measurements.anchorSize.height - MARGIN_TO_EDGE;
  11757. if (isBottomAnchored) {
  11758. maxHeight -= this.measurements.anchorSize.height;
  11759. }
  11760. }
  11761. return maxHeight;
  11762. };
  11763. /**
  11764. * @param corner Origin corner of the menu surface.
  11765. * @return Horizontal offset of menu surface origin corner from corresponding anchor corner.
  11766. */
  11767. MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset = function (corner) {
  11768. var anchorSize = this.measurements.anchorSize;
  11769. // isRightAligned corresponds to using the 'right' property on the surface.
  11770. var isRightAligned = this.hasBit(corner, constants_1.CornerBit.RIGHT);
  11771. var avoidHorizontalOverlap = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT);
  11772. if (isRightAligned) {
  11773. var rightOffset = avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.left : this.anchorMargin.right;
  11774. // For hoisted or fixed elements, adjust the offset by the difference
  11775. // between viewport width and body width so when we calculate the right
  11776. // value (`adjustPositionForHoistedElement`) based on the element
  11777. // position, the right property is correct.
  11778. if (this.isHoistedElement || this.isFixedPosition) {
  11779. return rightOffset - (this.measurements.viewportSize.width - this.measurements.bodySize.width);
  11780. }
  11781. return rightOffset;
  11782. }
  11783. return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.right : this.anchorMargin.left;
  11784. };
  11785. /**
  11786. * @param corner Origin corner of the menu surface.
  11787. * @return Vertical offset of menu surface origin corner from corresponding anchor corner.
  11788. */
  11789. MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset = function (corner) {
  11790. var anchorSize = this.measurements.anchorSize;
  11791. var isBottomAligned = this.hasBit(corner, constants_1.CornerBit.BOTTOM);
  11792. var avoidVerticalOverlap = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
  11793. var y = 0;
  11794. if (isBottomAligned) {
  11795. y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin.top : -this.anchorMargin.bottom;
  11796. } else {
  11797. y = avoidVerticalOverlap ? anchorSize.height + this.anchorMargin.bottom : this.anchorMargin.top;
  11798. }
  11799. return y;
  11800. };
  11801. /** Calculates the offsets for positioning the menu-surface when the menu-surface has been hoisted to the body. */
  11802. MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement = function (position) {
  11803. var e_1, _a;
  11804. var _b = this.measurements,
  11805. windowScroll = _b.windowScroll,
  11806. viewportDistance = _b.viewportDistance;
  11807. var props = Object.keys(position);
  11808. try {
  11809. for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
  11810. var prop = props_1_1.value;
  11811. var value = position[prop] || 0;
  11812. // Hoisted surfaces need to have the anchor elements location on the page added to the
  11813. // position properties for proper alignment on the body.
  11814. value += viewportDistance[prop];
  11815. // Surfaces that are absolutely positioned need to have additional calculations for scroll
  11816. // and bottom positioning.
  11817. if (!this.isFixedPosition) {
  11818. if (prop === 'top') {
  11819. value += windowScroll.y;
  11820. } else if (prop === 'bottom') {
  11821. value -= windowScroll.y;
  11822. } else if (prop === 'left') {
  11823. value += windowScroll.x;
  11824. } else {
  11825. // prop === 'right'
  11826. value -= windowScroll.x;
  11827. }
  11828. }
  11829. position[prop] = value;
  11830. }
  11831. } catch (e_1_1) {
  11832. e_1 = { error: e_1_1 };
  11833. } finally {
  11834. try {
  11835. if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
  11836. } finally {
  11837. if (e_1) throw e_1.error;
  11838. }
  11839. }
  11840. };
  11841. /**
  11842. * The last focused element when the menu surface was opened should regain focus, if the user is
  11843. * focused on or within the menu surface when it is closed.
  11844. */
  11845. MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus = function () {
  11846. var isRootFocused = this.adapter.isFocused();
  11847. var childHasFocus = document.activeElement && this.adapter.isElementInContainer(document.activeElement);
  11848. if (isRootFocused || childHasFocus) {
  11849. this.adapter.restoreFocus();
  11850. }
  11851. };
  11852. MDCMenuSurfaceFoundation.prototype.hasBit = function (corner, bit) {
  11853. return Boolean(corner & bit); // tslint:disable-line:no-bitwise
  11854. };
  11855. MDCMenuSurfaceFoundation.prototype.setBit = function (corner, bit) {
  11856. return corner | bit; // tslint:disable-line:no-bitwise
  11857. };
  11858. MDCMenuSurfaceFoundation.prototype.unsetBit = function (corner, bit) {
  11859. return corner ^ bit;
  11860. };
  11861. /**
  11862. * isFinite that doesn't force conversion to number type.
  11863. * Equivalent to Number.isFinite in ES2015, which is not supported in IE.
  11864. */
  11865. MDCMenuSurfaceFoundation.prototype.isFinite = function (num) {
  11866. return typeof num === 'number' && isFinite(num);
  11867. };
  11868. return MDCMenuSurfaceFoundation;
  11869. }(foundation_1.MDCFoundation);
  11870. exports.MDCMenuSurfaceFoundation = MDCMenuSurfaceFoundation;
  11871. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  11872. exports.default = MDCMenuSurfaceFoundation;
  11873. /***/ }),
  11874. /***/ "./packages/mdc-menu-surface/index.ts":
  11875. /*!********************************************!*\
  11876. !*** ./packages/mdc-menu-surface/index.ts ***!
  11877. \********************************************/
  11878. /*! no static exports found */
  11879. /***/ (function(module, exports, __webpack_require__) {
  11880. "use strict";
  11881. /**
  11882. * @license
  11883. * Copyright 2019 Google Inc.
  11884. *
  11885. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11886. * of this software and associated documentation files (the "Software"), to deal
  11887. * in the Software without restriction, including without limitation the rights
  11888. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11889. * copies of the Software, and to permit persons to whom the Software is
  11890. * furnished to do so, subject to the following conditions:
  11891. *
  11892. * The above copyright notice and this permission notice shall be included in
  11893. * all copies or substantial portions of the Software.
  11894. *
  11895. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11896. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11897. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11898. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11899. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11900. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11901. * THE SOFTWARE.
  11902. */
  11903. function __export(m) {
  11904. for (var p in m) {
  11905. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  11906. }
  11907. }
  11908. Object.defineProperty(exports, "__esModule", { value: true });
  11909. __export(__webpack_require__(/*! ./component */ "./packages/mdc-menu-surface/component.ts"));
  11910. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts"));
  11911. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-menu-surface/foundation.ts"));
  11912. /***/ }),
  11913. /***/ "./packages/mdc-menu/component.ts":
  11914. /*!****************************************!*\
  11915. !*** ./packages/mdc-menu/component.ts ***!
  11916. \****************************************/
  11917. /*! no static exports found */
  11918. /***/ (function(module, exports, __webpack_require__) {
  11919. "use strict";
  11920. /**
  11921. * @license
  11922. * Copyright 2018 Google Inc.
  11923. *
  11924. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11925. * of this software and associated documentation files (the "Software"), to deal
  11926. * in the Software without restriction, including without limitation the rights
  11927. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11928. * copies of the Software, and to permit persons to whom the Software is
  11929. * furnished to do so, subject to the following conditions:
  11930. *
  11931. * The above copyright notice and this permission notice shall be included in
  11932. * all copies or substantial portions of the Software.
  11933. *
  11934. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11935. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11936. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11937. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11938. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11939. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11940. * THE SOFTWARE.
  11941. */
  11942. var __extends = this && this.__extends || function () {
  11943. var _extendStatics = function extendStatics(d, b) {
  11944. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  11945. d.__proto__ = b;
  11946. } || function (d, b) {
  11947. for (var p in b) {
  11948. if (b.hasOwnProperty(p)) d[p] = b[p];
  11949. }
  11950. };
  11951. return _extendStatics(d, b);
  11952. };
  11953. return function (d, b) {
  11954. _extendStatics(d, b);
  11955. function __() {
  11956. this.constructor = d;
  11957. }
  11958. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11959. };
  11960. }();
  11961. Object.defineProperty(exports, "__esModule", { value: true });
  11962. // TODO(b/152410470): Remove trailing underscores from private properties
  11963. // tslint:disable:strip-private-property-underscore
  11964. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  11965. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  11966. var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
  11967. var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
  11968. var foundation_1 = __webpack_require__(/*! @material/list/foundation */ "./packages/mdc-list/foundation.ts");
  11969. var component_3 = __webpack_require__(/*! @material/menu-surface/component */ "./packages/mdc-menu-surface/component.ts");
  11970. var foundation_2 = __webpack_require__(/*! @material/menu-surface/foundation */ "./packages/mdc-menu-surface/foundation.ts");
  11971. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
  11972. var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts");
  11973. var MDCMenu = /** @class */function (_super) {
  11974. __extends(MDCMenu, _super);
  11975. function MDCMenu() {
  11976. return _super !== null && _super.apply(this, arguments) || this;
  11977. }
  11978. MDCMenu.attachTo = function (root) {
  11979. return new MDCMenu(root);
  11980. };
  11981. MDCMenu.prototype.initialize = function (menuSurfaceFactory, listFactory) {
  11982. if (menuSurfaceFactory === void 0) {
  11983. menuSurfaceFactory = function menuSurfaceFactory(el) {
  11984. return new component_3.MDCMenuSurface(el);
  11985. };
  11986. }
  11987. if (listFactory === void 0) {
  11988. listFactory = function listFactory(el) {
  11989. return new component_2.MDCList(el);
  11990. };
  11991. }
  11992. this.menuSurfaceFactory_ = menuSurfaceFactory;
  11993. this.listFactory_ = listFactory;
  11994. };
  11995. MDCMenu.prototype.initialSyncWithDOM = function () {
  11996. var _this = this;
  11997. this.menuSurface_ = this.menuSurfaceFactory_(this.root);
  11998. var list = this.root.querySelector(constants_2.strings.LIST_SELECTOR);
  11999. if (list) {
  12000. this.list_ = this.listFactory_(list);
  12001. this.list_.wrapFocus = true;
  12002. } else {
  12003. this.list_ = null;
  12004. }
  12005. this.handleKeydown_ = function (evt) {
  12006. return _this.foundation.handleKeydown(evt);
  12007. };
  12008. this.handleItemAction_ = function (evt) {
  12009. return _this.foundation.handleItemAction(_this.items[evt.detail.index]);
  12010. };
  12011. this.handleMenuSurfaceOpened_ = function () {
  12012. return _this.foundation.handleMenuSurfaceOpened();
  12013. };
  12014. this.menuSurface_.listen(foundation_2.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened_);
  12015. this.listen('keydown', this.handleKeydown_);
  12016. this.listen(foundation_1.MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction_);
  12017. };
  12018. MDCMenu.prototype.destroy = function () {
  12019. if (this.list_) {
  12020. this.list_.destroy();
  12021. }
  12022. this.menuSurface_.destroy();
  12023. this.menuSurface_.unlisten(foundation_2.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened_);
  12024. this.unlisten('keydown', this.handleKeydown_);
  12025. this.unlisten(foundation_1.MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction_);
  12026. _super.prototype.destroy.call(this);
  12027. };
  12028. Object.defineProperty(MDCMenu.prototype, "open", {
  12029. get: function get() {
  12030. return this.menuSurface_.isOpen();
  12031. },
  12032. set: function set(value) {
  12033. if (value) {
  12034. this.menuSurface_.open();
  12035. } else {
  12036. this.menuSurface_.close();
  12037. }
  12038. },
  12039. enumerable: true,
  12040. configurable: true
  12041. });
  12042. Object.defineProperty(MDCMenu.prototype, "wrapFocus", {
  12043. get: function get() {
  12044. return this.list_ ? this.list_.wrapFocus : false;
  12045. },
  12046. set: function set(value) {
  12047. if (this.list_) {
  12048. this.list_.wrapFocus = value;
  12049. }
  12050. },
  12051. enumerable: true,
  12052. configurable: true
  12053. });
  12054. Object.defineProperty(MDCMenu.prototype, "hasTypeahead", {
  12055. /**
  12056. * Sets whether the menu has typeahead functionality.
  12057. * @param value Whether typeahead is enabled.
  12058. */
  12059. set: function set(value) {
  12060. if (this.list_) {
  12061. this.list_.hasTypeahead = value;
  12062. }
  12063. },
  12064. enumerable: true,
  12065. configurable: true
  12066. });
  12067. Object.defineProperty(MDCMenu.prototype, "typeaheadInProgress", {
  12068. /**
  12069. * @return Whether typeahead logic is currently matching some user prefix.
  12070. */
  12071. get: function get() {
  12072. return this.list_ ? this.list_.typeaheadInProgress : false;
  12073. },
  12074. enumerable: true,
  12075. configurable: true
  12076. });
  12077. /**
  12078. * Given the next desired character from the user, adds it to the typeahead
  12079. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  12080. * around if at the end of options.
  12081. *
  12082. * @param nextChar The next character to add to the prefix buffer.
  12083. * @param startingIndex The index from which to start matching. Only relevant
  12084. * when starting a new match sequence. To start a new match sequence,
  12085. * clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
  12086. * to clear after a set interval defined in list foundation. Defaults to
  12087. * the currently focused index.
  12088. * @return The index of the matched item, or -1 if no match.
  12089. */
  12090. MDCMenu.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
  12091. if (this.list_) {
  12092. return this.list_.typeaheadMatchItem(nextChar, startingIndex);
  12093. }
  12094. return -1;
  12095. };
  12096. /**
  12097. * Layout the underlying list element in the case of any dynamic updates
  12098. * to its structure.
  12099. */
  12100. MDCMenu.prototype.layout = function () {
  12101. if (this.list_) {
  12102. this.list_.layout();
  12103. }
  12104. };
  12105. Object.defineProperty(MDCMenu.prototype, "items", {
  12106. /**
  12107. * Return the items within the menu. Note that this only contains the set of elements within
  12108. * the items container that are proper list items, and not supplemental / presentational DOM
  12109. * elements.
  12110. */
  12111. get: function get() {
  12112. return this.list_ ? this.list_.listElements : [];
  12113. },
  12114. enumerable: true,
  12115. configurable: true
  12116. });
  12117. Object.defineProperty(MDCMenu.prototype, "singleSelection", {
  12118. /**
  12119. * Turns on/off the underlying list's single selection mode. Used mainly
  12120. * by select menu.
  12121. *
  12122. * @param singleSelection Whether to enable single selection mode.
  12123. */
  12124. set: function set(singleSelection) {
  12125. if (this.list_) {
  12126. this.list_.singleSelection = singleSelection;
  12127. }
  12128. },
  12129. enumerable: true,
  12130. configurable: true
  12131. });
  12132. Object.defineProperty(MDCMenu.prototype, "selectedIndex", {
  12133. /**
  12134. * Retrieves the selected index. Only applicable to select menus.
  12135. * @return The selected index, which is a number for single selection and
  12136. * radio lists, and an array of numbers for checkbox lists.
  12137. */
  12138. get: function get() {
  12139. return this.list_ ? this.list_.selectedIndex : constants_1.numbers.UNSET_INDEX;
  12140. },
  12141. /**
  12142. * Sets the selected index of the list. Only applicable to select menus.
  12143. * @param index The selected index, which is a number for single selection and
  12144. * radio lists, and an array of numbers for checkbox lists.
  12145. */
  12146. set: function set(index) {
  12147. if (this.list_) {
  12148. this.list_.selectedIndex = index;
  12149. }
  12150. },
  12151. enumerable: true,
  12152. configurable: true
  12153. });
  12154. Object.defineProperty(MDCMenu.prototype, "quickOpen", {
  12155. set: function set(quickOpen) {
  12156. this.menuSurface_.quickOpen = quickOpen;
  12157. },
  12158. enumerable: true,
  12159. configurable: true
  12160. });
  12161. /**
  12162. * Sets default focus state where the menu should focus every time when menu
  12163. * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
  12164. * default.
  12165. * @param focusState Default focus state.
  12166. */
  12167. MDCMenu.prototype.setDefaultFocusState = function (focusState) {
  12168. this.foundation.setDefaultFocusState(focusState);
  12169. };
  12170. /**
  12171. * @param corner Default anchor corner alignment of top-left menu corner.
  12172. */
  12173. MDCMenu.prototype.setAnchorCorner = function (corner) {
  12174. this.menuSurface_.setAnchorCorner(corner);
  12175. };
  12176. MDCMenu.prototype.setAnchorMargin = function (margin) {
  12177. this.menuSurface_.setAnchorMargin(margin);
  12178. };
  12179. /**
  12180. * Sets the list item as the selected row at the specified index.
  12181. * @param index Index of list item within menu.
  12182. */
  12183. MDCMenu.prototype.setSelectedIndex = function (index) {
  12184. this.foundation.setSelectedIndex(index);
  12185. };
  12186. /**
  12187. * Sets the enabled state to isEnabled for the menu item at the given index.
  12188. * @param index Index of the menu item
  12189. * @param isEnabled The desired enabled state of the menu item.
  12190. */
  12191. MDCMenu.prototype.setEnabled = function (index, isEnabled) {
  12192. this.foundation.setEnabled(index, isEnabled);
  12193. };
  12194. /**
  12195. * @return The item within the menu at the index specified.
  12196. */
  12197. MDCMenu.prototype.getOptionByIndex = function (index) {
  12198. var items = this.items;
  12199. if (index < items.length) {
  12200. return this.items[index];
  12201. } else {
  12202. return null;
  12203. }
  12204. };
  12205. /**
  12206. * @param index A menu item's index.
  12207. * @return The primary text within the menu at the index specified.
  12208. */
  12209. MDCMenu.prototype.getPrimaryTextAtIndex = function (index) {
  12210. var item = this.getOptionByIndex(index);
  12211. if (item && this.list_) {
  12212. return this.list_.getPrimaryText(item) || '';
  12213. }
  12214. return '';
  12215. };
  12216. MDCMenu.prototype.setFixedPosition = function (isFixed) {
  12217. this.menuSurface_.setFixedPosition(isFixed);
  12218. };
  12219. MDCMenu.prototype.setIsHoisted = function (isHoisted) {
  12220. this.menuSurface_.setIsHoisted(isHoisted);
  12221. };
  12222. MDCMenu.prototype.setAbsolutePosition = function (x, y) {
  12223. this.menuSurface_.setAbsolutePosition(x, y);
  12224. };
  12225. /**
  12226. * Sets the element that the menu-surface is anchored to.
  12227. */
  12228. MDCMenu.prototype.setAnchorElement = function (element) {
  12229. this.menuSurface_.anchorElement = element;
  12230. };
  12231. MDCMenu.prototype.getDefaultFoundation = function () {
  12232. var _this = this;
  12233. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  12234. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  12235. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  12236. var adapter = {
  12237. addClassToElementAtIndex: function addClassToElementAtIndex(index, className) {
  12238. var list = _this.items;
  12239. list[index].classList.add(className);
  12240. },
  12241. removeClassFromElementAtIndex: function removeClassFromElementAtIndex(index, className) {
  12242. var list = _this.items;
  12243. list[index].classList.remove(className);
  12244. },
  12245. addAttributeToElementAtIndex: function addAttributeToElementAtIndex(index, attr, value) {
  12246. var list = _this.items;
  12247. list[index].setAttribute(attr, value);
  12248. },
  12249. removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex(index, attr) {
  12250. var list = _this.items;
  12251. list[index].removeAttribute(attr);
  12252. },
  12253. elementContainsClass: function elementContainsClass(element, className) {
  12254. return element.classList.contains(className);
  12255. },
  12256. closeSurface: function closeSurface(skipRestoreFocus) {
  12257. return _this.menuSurface_.close(skipRestoreFocus);
  12258. },
  12259. getElementIndex: function getElementIndex(element) {
  12260. return _this.items.indexOf(element);
  12261. },
  12262. notifySelected: function notifySelected(evtData) {
  12263. return _this.emit(constants_2.strings.SELECTED_EVENT, {
  12264. index: evtData.index,
  12265. item: _this.items[evtData.index]
  12266. });
  12267. },
  12268. getMenuItemCount: function getMenuItemCount() {
  12269. return _this.items.length;
  12270. },
  12271. focusItemAtIndex: function focusItemAtIndex(index) {
  12272. return _this.items[index].focus();
  12273. },
  12274. focusListRoot: function focusListRoot() {
  12275. return _this.root.querySelector(constants_2.strings.LIST_SELECTOR).focus();
  12276. },
  12277. isSelectableItemAtIndex: function isSelectableItemAtIndex(index) {
  12278. return !!ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
  12279. },
  12280. getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex(index) {
  12281. var selectionGroupEl = ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
  12282. var selectedItemEl = selectionGroupEl.querySelector("." + constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
  12283. return selectedItemEl ? _this.items.indexOf(selectedItemEl) : -1;
  12284. }
  12285. };
  12286. // tslint:enable:object-literal-sort-keys
  12287. return new foundation_3.MDCMenuFoundation(adapter);
  12288. };
  12289. return MDCMenu;
  12290. }(component_1.MDCComponent);
  12291. exports.MDCMenu = MDCMenu;
  12292. /***/ }),
  12293. /***/ "./packages/mdc-menu/constants.ts":
  12294. /*!****************************************!*\
  12295. !*** ./packages/mdc-menu/constants.ts ***!
  12296. \****************************************/
  12297. /*! no static exports found */
  12298. /***/ (function(module, exports, __webpack_require__) {
  12299. "use strict";
  12300. /**
  12301. * @license
  12302. * Copyright 2018 Google Inc.
  12303. *
  12304. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12305. * of this software and associated documentation files (the "Software"), to deal
  12306. * in the Software without restriction, including without limitation the rights
  12307. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12308. * copies of the Software, and to permit persons to whom the Software is
  12309. * furnished to do so, subject to the following conditions:
  12310. *
  12311. * The above copyright notice and this permission notice shall be included in
  12312. * all copies or substantial portions of the Software.
  12313. *
  12314. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12315. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12316. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12317. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12318. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12319. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12320. * THE SOFTWARE.
  12321. */
  12322. Object.defineProperty(exports, "__esModule", { value: true });
  12323. var cssClasses = {
  12324. MENU_SELECTED_LIST_ITEM: 'mdc-menu-item--selected',
  12325. MENU_SELECTION_GROUP: 'mdc-menu__selection-group',
  12326. ROOT: 'mdc-menu'
  12327. };
  12328. exports.cssClasses = cssClasses;
  12329. var strings = {
  12330. ARIA_CHECKED_ATTR: 'aria-checked',
  12331. ARIA_DISABLED_ATTR: 'aria-disabled',
  12332. CHECKBOX_SELECTOR: 'input[type="checkbox"]',
  12333. LIST_SELECTOR: '.mdc-list',
  12334. SELECTED_EVENT: 'MDCMenu:selected'
  12335. };
  12336. exports.strings = strings;
  12337. var numbers = {
  12338. FOCUS_ROOT_INDEX: -1
  12339. };
  12340. exports.numbers = numbers;
  12341. var DefaultFocusState;
  12342. (function (DefaultFocusState) {
  12343. DefaultFocusState[DefaultFocusState["NONE"] = 0] = "NONE";
  12344. DefaultFocusState[DefaultFocusState["LIST_ROOT"] = 1] = "LIST_ROOT";
  12345. DefaultFocusState[DefaultFocusState["FIRST_ITEM"] = 2] = "FIRST_ITEM";
  12346. DefaultFocusState[DefaultFocusState["LAST_ITEM"] = 3] = "LAST_ITEM";
  12347. })(DefaultFocusState || (DefaultFocusState = {}));
  12348. exports.DefaultFocusState = DefaultFocusState;
  12349. /***/ }),
  12350. /***/ "./packages/mdc-menu/foundation.ts":
  12351. /*!*****************************************!*\
  12352. !*** ./packages/mdc-menu/foundation.ts ***!
  12353. \*****************************************/
  12354. /*! no static exports found */
  12355. /***/ (function(module, exports, __webpack_require__) {
  12356. "use strict";
  12357. /**
  12358. * @license
  12359. * Copyright 2018 Google Inc.
  12360. *
  12361. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12362. * of this software and associated documentation files (the "Software"), to deal
  12363. * in the Software without restriction, including without limitation the rights
  12364. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12365. * copies of the Software, and to permit persons to whom the Software is
  12366. * furnished to do so, subject to the following conditions:
  12367. *
  12368. * The above copyright notice and this permission notice shall be included in
  12369. * all copies or substantial portions of the Software.
  12370. *
  12371. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12372. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12373. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12374. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12375. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12376. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12377. * THE SOFTWARE.
  12378. */
  12379. var __extends = this && this.__extends || function () {
  12380. var _extendStatics = function extendStatics(d, b) {
  12381. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  12382. d.__proto__ = b;
  12383. } || function (d, b) {
  12384. for (var p in b) {
  12385. if (b.hasOwnProperty(p)) d[p] = b[p];
  12386. }
  12387. };
  12388. return _extendStatics(d, b);
  12389. };
  12390. return function (d, b) {
  12391. _extendStatics(d, b);
  12392. function __() {
  12393. this.constructor = d;
  12394. }
  12395. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12396. };
  12397. }();
  12398. var __assign = this && this.__assign || function () {
  12399. __assign = Object.assign || function (t) {
  12400. for (var s, i = 1, n = arguments.length; i < n; i++) {
  12401. s = arguments[i];
  12402. for (var p in s) {
  12403. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  12404. }
  12405. }
  12406. return t;
  12407. };
  12408. return __assign.apply(this, arguments);
  12409. };
  12410. Object.defineProperty(exports, "__esModule", { value: true });
  12411. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  12412. var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
  12413. var foundation_2 = __webpack_require__(/*! @material/menu-surface/foundation */ "./packages/mdc-menu-surface/foundation.ts");
  12414. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
  12415. var MDCMenuFoundation = /** @class */function (_super) {
  12416. __extends(MDCMenuFoundation, _super);
  12417. function MDCMenuFoundation(adapter) {
  12418. var _this = _super.call(this, __assign(__assign({}, MDCMenuFoundation.defaultAdapter), adapter)) || this;
  12419. _this.closeAnimationEndTimerId_ = 0;
  12420. _this.defaultFocusState_ = constants_2.DefaultFocusState.LIST_ROOT;
  12421. return _this;
  12422. }
  12423. Object.defineProperty(MDCMenuFoundation, "cssClasses", {
  12424. get: function get() {
  12425. return constants_2.cssClasses;
  12426. },
  12427. enumerable: true,
  12428. configurable: true
  12429. });
  12430. Object.defineProperty(MDCMenuFoundation, "strings", {
  12431. get: function get() {
  12432. return constants_2.strings;
  12433. },
  12434. enumerable: true,
  12435. configurable: true
  12436. });
  12437. Object.defineProperty(MDCMenuFoundation, "numbers", {
  12438. get: function get() {
  12439. return constants_2.numbers;
  12440. },
  12441. enumerable: true,
  12442. configurable: true
  12443. });
  12444. Object.defineProperty(MDCMenuFoundation, "defaultAdapter", {
  12445. /**
  12446. * @see {@link MDCMenuAdapter} for typing information on parameters and return types.
  12447. */
  12448. get: function get() {
  12449. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  12450. return {
  12451. addClassToElementAtIndex: function addClassToElementAtIndex() {
  12452. return undefined;
  12453. },
  12454. removeClassFromElementAtIndex: function removeClassFromElementAtIndex() {
  12455. return undefined;
  12456. },
  12457. addAttributeToElementAtIndex: function addAttributeToElementAtIndex() {
  12458. return undefined;
  12459. },
  12460. removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex() {
  12461. return undefined;
  12462. },
  12463. elementContainsClass: function elementContainsClass() {
  12464. return false;
  12465. },
  12466. closeSurface: function closeSurface() {
  12467. return undefined;
  12468. },
  12469. getElementIndex: function getElementIndex() {
  12470. return -1;
  12471. },
  12472. notifySelected: function notifySelected() {
  12473. return undefined;
  12474. },
  12475. getMenuItemCount: function getMenuItemCount() {
  12476. return 0;
  12477. },
  12478. focusItemAtIndex: function focusItemAtIndex() {
  12479. return undefined;
  12480. },
  12481. focusListRoot: function focusListRoot() {
  12482. return undefined;
  12483. },
  12484. getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex() {
  12485. return -1;
  12486. },
  12487. isSelectableItemAtIndex: function isSelectableItemAtIndex() {
  12488. return false;
  12489. }
  12490. };
  12491. // tslint:enable:object-literal-sort-keys
  12492. },
  12493. enumerable: true,
  12494. configurable: true
  12495. });
  12496. MDCMenuFoundation.prototype.destroy = function () {
  12497. if (this.closeAnimationEndTimerId_) {
  12498. clearTimeout(this.closeAnimationEndTimerId_);
  12499. }
  12500. this.adapter.closeSurface();
  12501. };
  12502. MDCMenuFoundation.prototype.handleKeydown = function (evt) {
  12503. var key = evt.key,
  12504. keyCode = evt.keyCode;
  12505. var isTab = key === 'Tab' || keyCode === 9;
  12506. if (isTab) {
  12507. this.adapter.closeSurface( /** skipRestoreFocus */true);
  12508. }
  12509. };
  12510. MDCMenuFoundation.prototype.handleItemAction = function (listItem) {
  12511. var _this = this;
  12512. var index = this.adapter.getElementIndex(listItem);
  12513. if (index < 0) {
  12514. return;
  12515. }
  12516. this.adapter.notifySelected({ index: index });
  12517. this.adapter.closeSurface();
  12518. // Wait for the menu to close before adding/removing classes that affect styles.
  12519. this.closeAnimationEndTimerId_ = setTimeout(function () {
  12520. // Recompute the index in case the menu contents have changed.
  12521. var recomputedIndex = _this.adapter.getElementIndex(listItem);
  12522. if (recomputedIndex >= 0 && _this.adapter.isSelectableItemAtIndex(recomputedIndex)) {
  12523. _this.setSelectedIndex(recomputedIndex);
  12524. }
  12525. }, foundation_2.MDCMenuSurfaceFoundation.numbers.TRANSITION_CLOSE_DURATION);
  12526. };
  12527. MDCMenuFoundation.prototype.handleMenuSurfaceOpened = function () {
  12528. switch (this.defaultFocusState_) {
  12529. case constants_2.DefaultFocusState.FIRST_ITEM:
  12530. this.adapter.focusItemAtIndex(0);
  12531. break;
  12532. case constants_2.DefaultFocusState.LAST_ITEM:
  12533. this.adapter.focusItemAtIndex(this.adapter.getMenuItemCount() - 1);
  12534. break;
  12535. case constants_2.DefaultFocusState.NONE:
  12536. // Do nothing.
  12537. break;
  12538. default:
  12539. this.adapter.focusListRoot();
  12540. break;
  12541. }
  12542. };
  12543. /**
  12544. * Sets default focus state where the menu should focus every time when menu
  12545. * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
  12546. * default.
  12547. */
  12548. MDCMenuFoundation.prototype.setDefaultFocusState = function (focusState) {
  12549. this.defaultFocusState_ = focusState;
  12550. };
  12551. /**
  12552. * Selects the list item at `index` within the menu.
  12553. * @param index Index of list item within the menu.
  12554. */
  12555. MDCMenuFoundation.prototype.setSelectedIndex = function (index) {
  12556. this.validatedIndex_(index);
  12557. if (!this.adapter.isSelectableItemAtIndex(index)) {
  12558. throw new Error('MDCMenuFoundation: No selection group at specified index.');
  12559. }
  12560. var prevSelectedIndex = this.adapter.getSelectedSiblingOfItemAtIndex(index);
  12561. if (prevSelectedIndex >= 0) {
  12562. this.adapter.removeAttributeFromElementAtIndex(prevSelectedIndex, constants_2.strings.ARIA_CHECKED_ATTR);
  12563. this.adapter.removeClassFromElementAtIndex(prevSelectedIndex, constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
  12564. }
  12565. this.adapter.addClassToElementAtIndex(index, constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
  12566. this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_CHECKED_ATTR, 'true');
  12567. };
  12568. /**
  12569. * Sets the enabled state to isEnabled for the menu item at the given index.
  12570. * @param index Index of the menu item
  12571. * @param isEnabled The desired enabled state of the menu item.
  12572. */
  12573. MDCMenuFoundation.prototype.setEnabled = function (index, isEnabled) {
  12574. this.validatedIndex_(index);
  12575. if (isEnabled) {
  12576. this.adapter.removeClassFromElementAtIndex(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  12577. this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_DISABLED_ATTR, 'false');
  12578. } else {
  12579. this.adapter.addClassToElementAtIndex(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  12580. this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_DISABLED_ATTR, 'true');
  12581. }
  12582. };
  12583. MDCMenuFoundation.prototype.validatedIndex_ = function (index) {
  12584. var menuSize = this.adapter.getMenuItemCount();
  12585. var isIndexInRange = index >= 0 && index < menuSize;
  12586. if (!isIndexInRange) {
  12587. throw new Error('MDCMenuFoundation: No list item at specified index.');
  12588. }
  12589. };
  12590. return MDCMenuFoundation;
  12591. }(foundation_1.MDCFoundation);
  12592. exports.MDCMenuFoundation = MDCMenuFoundation;
  12593. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  12594. exports.default = MDCMenuFoundation;
  12595. /***/ }),
  12596. /***/ "./packages/mdc-menu/index.ts":
  12597. /*!************************************!*\
  12598. !*** ./packages/mdc-menu/index.ts ***!
  12599. \************************************/
  12600. /*! no static exports found */
  12601. /***/ (function(module, exports, __webpack_require__) {
  12602. "use strict";
  12603. /**
  12604. * @license
  12605. * Copyright 2019 Google Inc.
  12606. *
  12607. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12608. * of this software and associated documentation files (the "Software"), to deal
  12609. * in the Software without restriction, including without limitation the rights
  12610. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12611. * copies of the Software, and to permit persons to whom the Software is
  12612. * furnished to do so, subject to the following conditions:
  12613. *
  12614. * The above copyright notice and this permission notice shall be included in
  12615. * all copies or substantial portions of the Software.
  12616. *
  12617. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12618. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12619. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12620. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12621. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12622. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12623. * THE SOFTWARE.
  12624. */
  12625. function __export(m) {
  12626. for (var p in m) {
  12627. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  12628. }
  12629. }
  12630. Object.defineProperty(exports, "__esModule", { value: true });
  12631. var constants_1 = __webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts"); // for backward compatibility
  12632. exports.Corner = constants_1.Corner;
  12633. __export(__webpack_require__(/*! ./component */ "./packages/mdc-menu/component.ts"));
  12634. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts"));
  12635. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts"));
  12636. /***/ }),
  12637. /***/ "./packages/mdc-notched-outline/component.ts":
  12638. /*!***************************************************!*\
  12639. !*** ./packages/mdc-notched-outline/component.ts ***!
  12640. \***************************************************/
  12641. /*! no static exports found */
  12642. /***/ (function(module, exports, __webpack_require__) {
  12643. "use strict";
  12644. /**
  12645. * @license
  12646. * Copyright 2017 Google Inc.
  12647. *
  12648. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12649. * of this software and associated documentation files (the "Software"), to deal
  12650. * in the Software without restriction, including without limitation the rights
  12651. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12652. * copies of the Software, and to permit persons to whom the Software is
  12653. * furnished to do so, subject to the following conditions:
  12654. *
  12655. * The above copyright notice and this permission notice shall be included in
  12656. * all copies or substantial portions of the Software.
  12657. *
  12658. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12659. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12660. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12661. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12662. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12663. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12664. * THE SOFTWARE.
  12665. */
  12666. var __extends = this && this.__extends || function () {
  12667. var _extendStatics = function extendStatics(d, b) {
  12668. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  12669. d.__proto__ = b;
  12670. } || function (d, b) {
  12671. for (var p in b) {
  12672. if (b.hasOwnProperty(p)) d[p] = b[p];
  12673. }
  12674. };
  12675. return _extendStatics(d, b);
  12676. };
  12677. return function (d, b) {
  12678. _extendStatics(d, b);
  12679. function __() {
  12680. this.constructor = d;
  12681. }
  12682. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12683. };
  12684. }();
  12685. Object.defineProperty(exports, "__esModule", { value: true });
  12686. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  12687. var foundation_1 = __webpack_require__(/*! @material/floating-label/foundation */ "./packages/mdc-floating-label/foundation.ts");
  12688. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts");
  12689. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-notched-outline/foundation.ts");
  12690. var MDCNotchedOutline = /** @class */function (_super) {
  12691. __extends(MDCNotchedOutline, _super);
  12692. function MDCNotchedOutline() {
  12693. return _super !== null && _super.apply(this, arguments) || this;
  12694. }
  12695. MDCNotchedOutline.attachTo = function (root) {
  12696. return new MDCNotchedOutline(root);
  12697. };
  12698. MDCNotchedOutline.prototype.initialSyncWithDOM = function () {
  12699. this.notchElement_ = this.root.querySelector(constants_1.strings.NOTCH_ELEMENT_SELECTOR);
  12700. var label = this.root.querySelector('.' + foundation_1.MDCFloatingLabelFoundation.cssClasses.ROOT);
  12701. if (label) {
  12702. label.style.transitionDuration = '0s';
  12703. this.root.classList.add(constants_1.cssClasses.OUTLINE_UPGRADED);
  12704. requestAnimationFrame(function () {
  12705. label.style.transitionDuration = '';
  12706. });
  12707. } else {
  12708. this.root.classList.add(constants_1.cssClasses.NO_LABEL);
  12709. }
  12710. };
  12711. /**
  12712. * Updates classes and styles to open the notch to the specified width.
  12713. * @param notchWidth The notch width in the outline.
  12714. */
  12715. MDCNotchedOutline.prototype.notch = function (notchWidth) {
  12716. this.foundation.notch(notchWidth);
  12717. };
  12718. /**
  12719. * Updates classes and styles to close the notch.
  12720. */
  12721. MDCNotchedOutline.prototype.closeNotch = function () {
  12722. this.foundation.closeNotch();
  12723. };
  12724. MDCNotchedOutline.prototype.getDefaultFoundation = function () {
  12725. var _this = this;
  12726. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  12727. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  12728. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  12729. var adapter = {
  12730. addClass: function addClass(className) {
  12731. return _this.root.classList.add(className);
  12732. },
  12733. removeClass: function removeClass(className) {
  12734. return _this.root.classList.remove(className);
  12735. },
  12736. setNotchWidthProperty: function setNotchWidthProperty(width) {
  12737. return _this.notchElement_.style.setProperty('width', width + 'px');
  12738. },
  12739. removeNotchWidthProperty: function removeNotchWidthProperty() {
  12740. return _this.notchElement_.style.removeProperty('width');
  12741. }
  12742. };
  12743. // tslint:enable:object-literal-sort-keys
  12744. return new foundation_2.MDCNotchedOutlineFoundation(adapter);
  12745. };
  12746. return MDCNotchedOutline;
  12747. }(component_1.MDCComponent);
  12748. exports.MDCNotchedOutline = MDCNotchedOutline;
  12749. /***/ }),
  12750. /***/ "./packages/mdc-notched-outline/constants.ts":
  12751. /*!***************************************************!*\
  12752. !*** ./packages/mdc-notched-outline/constants.ts ***!
  12753. \***************************************************/
  12754. /*! no static exports found */
  12755. /***/ (function(module, exports, __webpack_require__) {
  12756. "use strict";
  12757. /**
  12758. * @license
  12759. * Copyright 2018 Google Inc.
  12760. *
  12761. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12762. * of this software and associated documentation files (the "Software"), to deal
  12763. * in the Software without restriction, including without limitation the rights
  12764. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12765. * copies of the Software, and to permit persons to whom the Software is
  12766. * furnished to do so, subject to the following conditions:
  12767. *
  12768. * The above copyright notice and this permission notice shall be included in
  12769. * all copies or substantial portions of the Software.
  12770. *
  12771. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12772. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12773. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12774. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12775. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12776. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12777. * THE SOFTWARE.
  12778. */
  12779. Object.defineProperty(exports, "__esModule", { value: true });
  12780. var strings = {
  12781. NOTCH_ELEMENT_SELECTOR: '.mdc-notched-outline__notch'
  12782. };
  12783. exports.strings = strings;
  12784. var numbers = {
  12785. // This should stay in sync with $mdc-notched-outline-padding * 2.
  12786. NOTCH_ELEMENT_PADDING: 8
  12787. };
  12788. exports.numbers = numbers;
  12789. var cssClasses = {
  12790. NO_LABEL: 'mdc-notched-outline--no-label',
  12791. OUTLINE_NOTCHED: 'mdc-notched-outline--notched',
  12792. OUTLINE_UPGRADED: 'mdc-notched-outline--upgraded'
  12793. };
  12794. exports.cssClasses = cssClasses;
  12795. /***/ }),
  12796. /***/ "./packages/mdc-notched-outline/foundation.ts":
  12797. /*!****************************************************!*\
  12798. !*** ./packages/mdc-notched-outline/foundation.ts ***!
  12799. \****************************************************/
  12800. /*! no static exports found */
  12801. /***/ (function(module, exports, __webpack_require__) {
  12802. "use strict";
  12803. /**
  12804. * @license
  12805. * Copyright 2017 Google Inc.
  12806. *
  12807. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12808. * of this software and associated documentation files (the "Software"), to deal
  12809. * in the Software without restriction, including without limitation the rights
  12810. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12811. * copies of the Software, and to permit persons to whom the Software is
  12812. * furnished to do so, subject to the following conditions:
  12813. *
  12814. * The above copyright notice and this permission notice shall be included in
  12815. * all copies or substantial portions of the Software.
  12816. *
  12817. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12818. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12819. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12820. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12821. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12822. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12823. * THE SOFTWARE.
  12824. */
  12825. var __extends = this && this.__extends || function () {
  12826. var _extendStatics = function extendStatics(d, b) {
  12827. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  12828. d.__proto__ = b;
  12829. } || function (d, b) {
  12830. for (var p in b) {
  12831. if (b.hasOwnProperty(p)) d[p] = b[p];
  12832. }
  12833. };
  12834. return _extendStatics(d, b);
  12835. };
  12836. return function (d, b) {
  12837. _extendStatics(d, b);
  12838. function __() {
  12839. this.constructor = d;
  12840. }
  12841. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12842. };
  12843. }();
  12844. var __assign = this && this.__assign || function () {
  12845. __assign = Object.assign || function (t) {
  12846. for (var s, i = 1, n = arguments.length; i < n; i++) {
  12847. s = arguments[i];
  12848. for (var p in s) {
  12849. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  12850. }
  12851. }
  12852. return t;
  12853. };
  12854. return __assign.apply(this, arguments);
  12855. };
  12856. Object.defineProperty(exports, "__esModule", { value: true });
  12857. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  12858. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts");
  12859. var MDCNotchedOutlineFoundation = /** @class */function (_super) {
  12860. __extends(MDCNotchedOutlineFoundation, _super);
  12861. function MDCNotchedOutlineFoundation(adapter) {
  12862. return _super.call(this, __assign(__assign({}, MDCNotchedOutlineFoundation.defaultAdapter), adapter)) || this;
  12863. }
  12864. Object.defineProperty(MDCNotchedOutlineFoundation, "strings", {
  12865. get: function get() {
  12866. return constants_1.strings;
  12867. },
  12868. enumerable: true,
  12869. configurable: true
  12870. });
  12871. Object.defineProperty(MDCNotchedOutlineFoundation, "cssClasses", {
  12872. get: function get() {
  12873. return constants_1.cssClasses;
  12874. },
  12875. enumerable: true,
  12876. configurable: true
  12877. });
  12878. Object.defineProperty(MDCNotchedOutlineFoundation, "numbers", {
  12879. get: function get() {
  12880. return constants_1.numbers;
  12881. },
  12882. enumerable: true,
  12883. configurable: true
  12884. });
  12885. Object.defineProperty(MDCNotchedOutlineFoundation, "defaultAdapter", {
  12886. /**
  12887. * See {@link MDCNotchedOutlineAdapter} for typing information on parameters and return types.
  12888. */
  12889. get: function get() {
  12890. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  12891. return {
  12892. addClass: function addClass() {
  12893. return undefined;
  12894. },
  12895. removeClass: function removeClass() {
  12896. return undefined;
  12897. },
  12898. setNotchWidthProperty: function setNotchWidthProperty() {
  12899. return undefined;
  12900. },
  12901. removeNotchWidthProperty: function removeNotchWidthProperty() {
  12902. return undefined;
  12903. }
  12904. };
  12905. // tslint:enable:object-literal-sort-keys
  12906. },
  12907. enumerable: true,
  12908. configurable: true
  12909. });
  12910. /**
  12911. * Adds the outline notched selector and updates the notch width calculated based off of notchWidth.
  12912. */
  12913. MDCNotchedOutlineFoundation.prototype.notch = function (notchWidth) {
  12914. var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED;
  12915. if (notchWidth > 0) {
  12916. notchWidth += constants_1.numbers.NOTCH_ELEMENT_PADDING; // Add padding from left/right.
  12917. }
  12918. this.adapter.setNotchWidthProperty(notchWidth);
  12919. this.adapter.addClass(OUTLINE_NOTCHED);
  12920. };
  12921. /**
  12922. * Removes notched outline selector to close the notch in the outline.
  12923. */
  12924. MDCNotchedOutlineFoundation.prototype.closeNotch = function () {
  12925. var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED;
  12926. this.adapter.removeClass(OUTLINE_NOTCHED);
  12927. this.adapter.removeNotchWidthProperty();
  12928. };
  12929. return MDCNotchedOutlineFoundation;
  12930. }(foundation_1.MDCFoundation);
  12931. exports.MDCNotchedOutlineFoundation = MDCNotchedOutlineFoundation;
  12932. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  12933. exports.default = MDCNotchedOutlineFoundation;
  12934. /***/ }),
  12935. /***/ "./packages/mdc-notched-outline/index.ts":
  12936. /*!***********************************************!*\
  12937. !*** ./packages/mdc-notched-outline/index.ts ***!
  12938. \***********************************************/
  12939. /*! no static exports found */
  12940. /***/ (function(module, exports, __webpack_require__) {
  12941. "use strict";
  12942. /**
  12943. * @license
  12944. * Copyright 2019 Google Inc.
  12945. *
  12946. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12947. * of this software and associated documentation files (the "Software"), to deal
  12948. * in the Software without restriction, including without limitation the rights
  12949. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12950. * copies of the Software, and to permit persons to whom the Software is
  12951. * furnished to do so, subject to the following conditions:
  12952. *
  12953. * The above copyright notice and this permission notice shall be included in
  12954. * all copies or substantial portions of the Software.
  12955. *
  12956. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12957. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12958. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12959. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12960. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12961. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12962. * THE SOFTWARE.
  12963. */
  12964. function __export(m) {
  12965. for (var p in m) {
  12966. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  12967. }
  12968. }
  12969. Object.defineProperty(exports, "__esModule", { value: true });
  12970. __export(__webpack_require__(/*! ./component */ "./packages/mdc-notched-outline/component.ts"));
  12971. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts"));
  12972. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-notched-outline/foundation.ts"));
  12973. /***/ }),
  12974. /***/ "./packages/mdc-radio/component.ts":
  12975. /*!*****************************************!*\
  12976. !*** ./packages/mdc-radio/component.ts ***!
  12977. \*****************************************/
  12978. /*! no static exports found */
  12979. /***/ (function(module, exports, __webpack_require__) {
  12980. "use strict";
  12981. /**
  12982. * @license
  12983. * Copyright 2016 Google Inc.
  12984. *
  12985. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12986. * of this software and associated documentation files (the "Software"), to deal
  12987. * in the Software without restriction, including without limitation the rights
  12988. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12989. * copies of the Software, and to permit persons to whom the Software is
  12990. * furnished to do so, subject to the following conditions:
  12991. *
  12992. * The above copyright notice and this permission notice shall be included in
  12993. * all copies or substantial portions of the Software.
  12994. *
  12995. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12996. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12997. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12998. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12999. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13000. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13001. * THE SOFTWARE.
  13002. */
  13003. var __extends = this && this.__extends || function () {
  13004. var _extendStatics = function extendStatics(d, b) {
  13005. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  13006. d.__proto__ = b;
  13007. } || function (d, b) {
  13008. for (var p in b) {
  13009. if (b.hasOwnProperty(p)) d[p] = b[p];
  13010. }
  13011. };
  13012. return _extendStatics(d, b);
  13013. };
  13014. return function (d, b) {
  13015. _extendStatics(d, b);
  13016. function __() {
  13017. this.constructor = d;
  13018. }
  13019. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13020. };
  13021. }();
  13022. var __assign = this && this.__assign || function () {
  13023. __assign = Object.assign || function (t) {
  13024. for (var s, i = 1, n = arguments.length; i < n; i++) {
  13025. s = arguments[i];
  13026. for (var p in s) {
  13027. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  13028. }
  13029. }
  13030. return t;
  13031. };
  13032. return __assign.apply(this, arguments);
  13033. };
  13034. Object.defineProperty(exports, "__esModule", { value: true });
  13035. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  13036. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  13037. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  13038. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  13039. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-radio/foundation.ts");
  13040. var MDCRadio = /** @class */function (_super) {
  13041. __extends(MDCRadio, _super);
  13042. function MDCRadio() {
  13043. var _this = _super !== null && _super.apply(this, arguments) || this;
  13044. _this.ripple_ = _this.createRipple_();
  13045. return _this;
  13046. }
  13047. MDCRadio.attachTo = function (root) {
  13048. return new MDCRadio(root);
  13049. };
  13050. Object.defineProperty(MDCRadio.prototype, "checked", {
  13051. get: function get() {
  13052. return this.nativeControl_.checked;
  13053. },
  13054. set: function set(checked) {
  13055. this.nativeControl_.checked = checked;
  13056. },
  13057. enumerable: true,
  13058. configurable: true
  13059. });
  13060. Object.defineProperty(MDCRadio.prototype, "disabled", {
  13061. get: function get() {
  13062. return this.nativeControl_.disabled;
  13063. },
  13064. set: function set(disabled) {
  13065. this.foundation.setDisabled(disabled);
  13066. },
  13067. enumerable: true,
  13068. configurable: true
  13069. });
  13070. Object.defineProperty(MDCRadio.prototype, "value", {
  13071. get: function get() {
  13072. return this.nativeControl_.value;
  13073. },
  13074. set: function set(value) {
  13075. this.nativeControl_.value = value;
  13076. },
  13077. enumerable: true,
  13078. configurable: true
  13079. });
  13080. Object.defineProperty(MDCRadio.prototype, "ripple", {
  13081. get: function get() {
  13082. return this.ripple_;
  13083. },
  13084. enumerable: true,
  13085. configurable: true
  13086. });
  13087. MDCRadio.prototype.destroy = function () {
  13088. this.ripple_.destroy();
  13089. _super.prototype.destroy.call(this);
  13090. };
  13091. MDCRadio.prototype.getDefaultFoundation = function () {
  13092. var _this = this;
  13093. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  13094. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  13095. var adapter = {
  13096. addClass: function addClass(className) {
  13097. return _this.root.classList.add(className);
  13098. },
  13099. removeClass: function removeClass(className) {
  13100. return _this.root.classList.remove(className);
  13101. },
  13102. setNativeControlDisabled: function setNativeControlDisabled(disabled) {
  13103. return _this.nativeControl_.disabled = disabled;
  13104. }
  13105. };
  13106. return new foundation_2.MDCRadioFoundation(adapter);
  13107. };
  13108. MDCRadio.prototype.createRipple_ = function () {
  13109. var _this = this;
  13110. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  13111. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  13112. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  13113. var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  13114. return _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
  13115. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  13116. return _this.nativeControl_.removeEventListener(evtType, handler, events_1.applyPassive());
  13117. },
  13118. // Radio buttons technically go "active" whenever there is *any* keyboard interaction.
  13119. // This is not the UI we desire.
  13120. isSurfaceActive: function isSurfaceActive() {
  13121. return false;
  13122. }, isUnbounded: function isUnbounded() {
  13123. return true;
  13124. } });
  13125. // tslint:enable:object-literal-sort-keys
  13126. return new component_2.MDCRipple(this.root, new foundation_1.MDCRippleFoundation(adapter));
  13127. };
  13128. Object.defineProperty(MDCRadio.prototype, "nativeControl_", {
  13129. get: function get() {
  13130. var NATIVE_CONTROL_SELECTOR = foundation_2.MDCRadioFoundation.strings.NATIVE_CONTROL_SELECTOR;
  13131. var el = this.root.querySelector(NATIVE_CONTROL_SELECTOR);
  13132. if (!el) {
  13133. throw new Error("Radio component requires a " + NATIVE_CONTROL_SELECTOR + " element");
  13134. }
  13135. return el;
  13136. },
  13137. enumerable: true,
  13138. configurable: true
  13139. });
  13140. return MDCRadio;
  13141. }(component_1.MDCComponent);
  13142. exports.MDCRadio = MDCRadio;
  13143. /***/ }),
  13144. /***/ "./packages/mdc-radio/constants.ts":
  13145. /*!*****************************************!*\
  13146. !*** ./packages/mdc-radio/constants.ts ***!
  13147. \*****************************************/
  13148. /*! no static exports found */
  13149. /***/ (function(module, exports, __webpack_require__) {
  13150. "use strict";
  13151. /**
  13152. * @license
  13153. * Copyright 2016 Google Inc.
  13154. *
  13155. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13156. * of this software and associated documentation files (the "Software"), to deal
  13157. * in the Software without restriction, including without limitation the rights
  13158. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13159. * copies of the Software, and to permit persons to whom the Software is
  13160. * furnished to do so, subject to the following conditions:
  13161. *
  13162. * The above copyright notice and this permission notice shall be included in
  13163. * all copies or substantial portions of the Software.
  13164. *
  13165. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13166. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13167. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13168. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13169. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13170. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13171. * THE SOFTWARE.
  13172. */
  13173. Object.defineProperty(exports, "__esModule", { value: true });
  13174. var strings = {
  13175. NATIVE_CONTROL_SELECTOR: '.mdc-radio__native-control'
  13176. };
  13177. exports.strings = strings;
  13178. var cssClasses = {
  13179. DISABLED: 'mdc-radio--disabled',
  13180. ROOT: 'mdc-radio'
  13181. };
  13182. exports.cssClasses = cssClasses;
  13183. /***/ }),
  13184. /***/ "./packages/mdc-radio/foundation.ts":
  13185. /*!******************************************!*\
  13186. !*** ./packages/mdc-radio/foundation.ts ***!
  13187. \******************************************/
  13188. /*! no static exports found */
  13189. /***/ (function(module, exports, __webpack_require__) {
  13190. "use strict";
  13191. /**
  13192. * @license
  13193. * Copyright 2016 Google Inc.
  13194. *
  13195. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13196. * of this software and associated documentation files (the "Software"), to deal
  13197. * in the Software without restriction, including without limitation the rights
  13198. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13199. * copies of the Software, and to permit persons to whom the Software is
  13200. * furnished to do so, subject to the following conditions:
  13201. *
  13202. * The above copyright notice and this permission notice shall be included in
  13203. * all copies or substantial portions of the Software.
  13204. *
  13205. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13206. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13207. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13208. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13209. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13210. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13211. * THE SOFTWARE.
  13212. */
  13213. var __extends = this && this.__extends || function () {
  13214. var _extendStatics = function extendStatics(d, b) {
  13215. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  13216. d.__proto__ = b;
  13217. } || function (d, b) {
  13218. for (var p in b) {
  13219. if (b.hasOwnProperty(p)) d[p] = b[p];
  13220. }
  13221. };
  13222. return _extendStatics(d, b);
  13223. };
  13224. return function (d, b) {
  13225. _extendStatics(d, b);
  13226. function __() {
  13227. this.constructor = d;
  13228. }
  13229. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13230. };
  13231. }();
  13232. var __assign = this && this.__assign || function () {
  13233. __assign = Object.assign || function (t) {
  13234. for (var s, i = 1, n = arguments.length; i < n; i++) {
  13235. s = arguments[i];
  13236. for (var p in s) {
  13237. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  13238. }
  13239. }
  13240. return t;
  13241. };
  13242. return __assign.apply(this, arguments);
  13243. };
  13244. Object.defineProperty(exports, "__esModule", { value: true });
  13245. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  13246. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-radio/constants.ts");
  13247. var MDCRadioFoundation = /** @class */function (_super) {
  13248. __extends(MDCRadioFoundation, _super);
  13249. function MDCRadioFoundation(adapter) {
  13250. return _super.call(this, __assign(__assign({}, MDCRadioFoundation.defaultAdapter), adapter)) || this;
  13251. }
  13252. Object.defineProperty(MDCRadioFoundation, "cssClasses", {
  13253. get: function get() {
  13254. return constants_1.cssClasses;
  13255. },
  13256. enumerable: true,
  13257. configurable: true
  13258. });
  13259. Object.defineProperty(MDCRadioFoundation, "strings", {
  13260. get: function get() {
  13261. return constants_1.strings;
  13262. },
  13263. enumerable: true,
  13264. configurable: true
  13265. });
  13266. Object.defineProperty(MDCRadioFoundation, "defaultAdapter", {
  13267. get: function get() {
  13268. return {
  13269. addClass: function addClass() {
  13270. return undefined;
  13271. },
  13272. removeClass: function removeClass() {
  13273. return undefined;
  13274. },
  13275. setNativeControlDisabled: function setNativeControlDisabled() {
  13276. return undefined;
  13277. }
  13278. };
  13279. },
  13280. enumerable: true,
  13281. configurable: true
  13282. });
  13283. MDCRadioFoundation.prototype.setDisabled = function (disabled) {
  13284. var DISABLED = MDCRadioFoundation.cssClasses.DISABLED;
  13285. this.adapter.setNativeControlDisabled(disabled);
  13286. if (disabled) {
  13287. this.adapter.addClass(DISABLED);
  13288. } else {
  13289. this.adapter.removeClass(DISABLED);
  13290. }
  13291. };
  13292. return MDCRadioFoundation;
  13293. }(foundation_1.MDCFoundation);
  13294. exports.MDCRadioFoundation = MDCRadioFoundation;
  13295. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  13296. exports.default = MDCRadioFoundation;
  13297. /***/ }),
  13298. /***/ "./packages/mdc-radio/index.ts":
  13299. /*!*************************************!*\
  13300. !*** ./packages/mdc-radio/index.ts ***!
  13301. \*************************************/
  13302. /*! no static exports found */
  13303. /***/ (function(module, exports, __webpack_require__) {
  13304. "use strict";
  13305. /**
  13306. * @license
  13307. * Copyright 2019 Google Inc.
  13308. *
  13309. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13310. * of this software and associated documentation files (the "Software"), to deal
  13311. * in the Software without restriction, including without limitation the rights
  13312. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13313. * copies of the Software, and to permit persons to whom the Software is
  13314. * furnished to do so, subject to the following conditions:
  13315. *
  13316. * The above copyright notice and this permission notice shall be included in
  13317. * all copies or substantial portions of the Software.
  13318. *
  13319. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13320. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13321. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13322. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13323. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13324. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13325. * THE SOFTWARE.
  13326. */
  13327. function __export(m) {
  13328. for (var p in m) {
  13329. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  13330. }
  13331. }
  13332. Object.defineProperty(exports, "__esModule", { value: true });
  13333. __export(__webpack_require__(/*! ./component */ "./packages/mdc-radio/component.ts"));
  13334. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-radio/constants.ts"));
  13335. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-radio/foundation.ts"));
  13336. /***/ }),
  13337. /***/ "./packages/mdc-ripple/component.ts":
  13338. /*!******************************************!*\
  13339. !*** ./packages/mdc-ripple/component.ts ***!
  13340. \******************************************/
  13341. /*! no static exports found */
  13342. /***/ (function(module, exports, __webpack_require__) {
  13343. "use strict";
  13344. /**
  13345. * @license
  13346. * Copyright 2016 Google Inc.
  13347. *
  13348. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13349. * of this software and associated documentation files (the "Software"), to deal
  13350. * in the Software without restriction, including without limitation the rights
  13351. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13352. * copies of the Software, and to permit persons to whom the Software is
  13353. * furnished to do so, subject to the following conditions:
  13354. *
  13355. * The above copyright notice and this permission notice shall be included in
  13356. * all copies or substantial portions of the Software.
  13357. *
  13358. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13359. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13360. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13361. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13362. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13363. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13364. * THE SOFTWARE.
  13365. */
  13366. var __extends = this && this.__extends || function () {
  13367. var _extendStatics = function extendStatics(d, b) {
  13368. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  13369. d.__proto__ = b;
  13370. } || function (d, b) {
  13371. for (var p in b) {
  13372. if (b.hasOwnProperty(p)) d[p] = b[p];
  13373. }
  13374. };
  13375. return _extendStatics(d, b);
  13376. };
  13377. return function (d, b) {
  13378. _extendStatics(d, b);
  13379. function __() {
  13380. this.constructor = d;
  13381. }
  13382. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13383. };
  13384. }();
  13385. var __importStar = this && this.__importStar || function (mod) {
  13386. if (mod && mod.__esModule) return mod;
  13387. var result = {};
  13388. if (mod != null) for (var k in mod) {
  13389. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  13390. }result["default"] = mod;
  13391. return result;
  13392. };
  13393. Object.defineProperty(exports, "__esModule", { value: true });
  13394. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  13395. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  13396. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  13397. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
  13398. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
  13399. var MDCRipple = /** @class */function (_super) {
  13400. __extends(MDCRipple, _super);
  13401. function MDCRipple() {
  13402. var _this = _super !== null && _super.apply(this, arguments) || this;
  13403. _this.disabled = false;
  13404. return _this;
  13405. }
  13406. MDCRipple.attachTo = function (root, opts) {
  13407. if (opts === void 0) {
  13408. opts = { isUnbounded: undefined };
  13409. }
  13410. var ripple = new MDCRipple(root);
  13411. // Only override unbounded behavior if option is explicitly specified
  13412. if (opts.isUnbounded !== undefined) {
  13413. ripple.unbounded = opts.isUnbounded;
  13414. }
  13415. return ripple;
  13416. };
  13417. MDCRipple.createAdapter = function (instance) {
  13418. return {
  13419. addClass: function addClass(className) {
  13420. return instance.root.classList.add(className);
  13421. },
  13422. browserSupportsCssVars: function browserSupportsCssVars() {
  13423. return util.supportsCssVariables(window);
  13424. },
  13425. computeBoundingRect: function computeBoundingRect() {
  13426. return instance.root.getBoundingClientRect();
  13427. },
  13428. containsEventTarget: function containsEventTarget(target) {
  13429. return instance.root.contains(target);
  13430. },
  13431. deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
  13432. return document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
  13433. },
  13434. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  13435. return instance.root.removeEventListener(evtType, handler, events_1.applyPassive());
  13436. },
  13437. deregisterResizeHandler: function deregisterResizeHandler(handler) {
  13438. return window.removeEventListener('resize', handler);
  13439. },
  13440. getWindowPageOffset: function getWindowPageOffset() {
  13441. return { x: window.pageXOffset, y: window.pageYOffset };
  13442. },
  13443. isSurfaceActive: function isSurfaceActive() {
  13444. return ponyfill_1.matches(instance.root, ':active');
  13445. },
  13446. isSurfaceDisabled: function isSurfaceDisabled() {
  13447. return Boolean(instance.disabled);
  13448. },
  13449. isUnbounded: function isUnbounded() {
  13450. return Boolean(instance.unbounded);
  13451. },
  13452. registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
  13453. return document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
  13454. },
  13455. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  13456. return instance.root.addEventListener(evtType, handler, events_1.applyPassive());
  13457. },
  13458. registerResizeHandler: function registerResizeHandler(handler) {
  13459. return window.addEventListener('resize', handler);
  13460. },
  13461. removeClass: function removeClass(className) {
  13462. return instance.root.classList.remove(className);
  13463. },
  13464. updateCssVariable: function updateCssVariable(varName, value) {
  13465. return instance.root.style.setProperty(varName, value);
  13466. }
  13467. };
  13468. };
  13469. Object.defineProperty(MDCRipple.prototype, "unbounded", {
  13470. get: function get() {
  13471. return Boolean(this.unbounded_);
  13472. },
  13473. set: function set(unbounded) {
  13474. this.unbounded_ = Boolean(unbounded);
  13475. this.setUnbounded_();
  13476. },
  13477. enumerable: true,
  13478. configurable: true
  13479. });
  13480. MDCRipple.prototype.activate = function () {
  13481. this.foundation.activate();
  13482. };
  13483. MDCRipple.prototype.deactivate = function () {
  13484. this.foundation.deactivate();
  13485. };
  13486. MDCRipple.prototype.layout = function () {
  13487. this.foundation.layout();
  13488. };
  13489. MDCRipple.prototype.getDefaultFoundation = function () {
  13490. return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
  13491. };
  13492. MDCRipple.prototype.initialSyncWithDOM = function () {
  13493. var root = this.root;
  13494. this.unbounded = 'mdcRippleIsUnbounded' in root.dataset;
  13495. };
  13496. /**
  13497. * Closure Compiler throws an access control error when directly accessing a
  13498. * protected or private property inside a getter/setter, like unbounded above.
  13499. * By accessing the protected property inside a method, we solve that problem.
  13500. * That's why this function exists.
  13501. */
  13502. MDCRipple.prototype.setUnbounded_ = function () {
  13503. this.foundation.setUnbounded(Boolean(this.unbounded_));
  13504. };
  13505. return MDCRipple;
  13506. }(component_1.MDCComponent);
  13507. exports.MDCRipple = MDCRipple;
  13508. /***/ }),
  13509. /***/ "./packages/mdc-ripple/constants.ts":
  13510. /*!******************************************!*\
  13511. !*** ./packages/mdc-ripple/constants.ts ***!
  13512. \******************************************/
  13513. /*! no static exports found */
  13514. /***/ (function(module, exports, __webpack_require__) {
  13515. "use strict";
  13516. /**
  13517. * @license
  13518. * Copyright 2016 Google Inc.
  13519. *
  13520. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13521. * of this software and associated documentation files (the "Software"), to deal
  13522. * in the Software without restriction, including without limitation the rights
  13523. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13524. * copies of the Software, and to permit persons to whom the Software is
  13525. * furnished to do so, subject to the following conditions:
  13526. *
  13527. * The above copyright notice and this permission notice shall be included in
  13528. * all copies or substantial portions of the Software.
  13529. *
  13530. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13531. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13532. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13533. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13534. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13535. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13536. * THE SOFTWARE.
  13537. */
  13538. Object.defineProperty(exports, "__esModule", { value: true });
  13539. exports.cssClasses = {
  13540. // Ripple is a special case where the "root" component is really a "mixin" of sorts,
  13541. // given that it's an 'upgrade' to an existing component. That being said it is the root
  13542. // CSS class that all other CSS classes derive from.
  13543. BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
  13544. FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
  13545. FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
  13546. ROOT: 'mdc-ripple-upgraded',
  13547. UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
  13548. };
  13549. exports.strings = {
  13550. VAR_FG_SCALE: '--mdc-ripple-fg-scale',
  13551. VAR_FG_SIZE: '--mdc-ripple-fg-size',
  13552. VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
  13553. VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
  13554. VAR_LEFT: '--mdc-ripple-left',
  13555. VAR_TOP: '--mdc-ripple-top'
  13556. };
  13557. exports.numbers = {
  13558. DEACTIVATION_TIMEOUT_MS: 225,
  13559. FG_DEACTIVATION_MS: 150,
  13560. INITIAL_ORIGIN_SCALE: 0.6,
  13561. PADDING: 10,
  13562. TAP_DELAY_MS: 300
  13563. };
  13564. /***/ }),
  13565. /***/ "./packages/mdc-ripple/foundation.ts":
  13566. /*!*******************************************!*\
  13567. !*** ./packages/mdc-ripple/foundation.ts ***!
  13568. \*******************************************/
  13569. /*! no static exports found */
  13570. /***/ (function(module, exports, __webpack_require__) {
  13571. "use strict";
  13572. /**
  13573. * @license
  13574. * Copyright 2016 Google Inc.
  13575. *
  13576. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13577. * of this software and associated documentation files (the "Software"), to deal
  13578. * in the Software without restriction, including without limitation the rights
  13579. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13580. * copies of the Software, and to permit persons to whom the Software is
  13581. * furnished to do so, subject to the following conditions:
  13582. *
  13583. * The above copyright notice and this permission notice shall be included in
  13584. * all copies or substantial portions of the Software.
  13585. *
  13586. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13587. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13588. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13589. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13590. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13591. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13592. * THE SOFTWARE.
  13593. */
  13594. var __extends = this && this.__extends || function () {
  13595. var _extendStatics = function extendStatics(d, b) {
  13596. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  13597. d.__proto__ = b;
  13598. } || function (d, b) {
  13599. for (var p in b) {
  13600. if (b.hasOwnProperty(p)) d[p] = b[p];
  13601. }
  13602. };
  13603. return _extendStatics(d, b);
  13604. };
  13605. return function (d, b) {
  13606. _extendStatics(d, b);
  13607. function __() {
  13608. this.constructor = d;
  13609. }
  13610. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13611. };
  13612. }();
  13613. var __assign = this && this.__assign || function () {
  13614. __assign = Object.assign || function (t) {
  13615. for (var s, i = 1, n = arguments.length; i < n; i++) {
  13616. s = arguments[i];
  13617. for (var p in s) {
  13618. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  13619. }
  13620. }
  13621. return t;
  13622. };
  13623. return __assign.apply(this, arguments);
  13624. };
  13625. Object.defineProperty(exports, "__esModule", { value: true });
  13626. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  13627. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
  13628. var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
  13629. // Activation events registered on the root element of each instance for activation
  13630. var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
  13631. // Deactivation events registered on documentElement when a pointer-related down event occurs
  13632. var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
  13633. // simultaneous nested activations
  13634. var activatedTargets = [];
  13635. var MDCRippleFoundation = /** @class */function (_super) {
  13636. __extends(MDCRippleFoundation, _super);
  13637. function MDCRippleFoundation(adapter) {
  13638. var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
  13639. _this.activationAnimationHasEnded_ = false;
  13640. _this.activationTimer_ = 0;
  13641. _this.fgDeactivationRemovalTimer_ = 0;
  13642. _this.fgScale_ = '0';
  13643. _this.frame_ = { width: 0, height: 0 };
  13644. _this.initialSize_ = 0;
  13645. _this.layoutFrame_ = 0;
  13646. _this.maxRadius_ = 0;
  13647. _this.unboundedCoords_ = { left: 0, top: 0 };
  13648. _this.activationState_ = _this.defaultActivationState_();
  13649. _this.activationTimerCallback_ = function () {
  13650. _this.activationAnimationHasEnded_ = true;
  13651. _this.runDeactivationUXLogicIfReady_();
  13652. };
  13653. _this.activateHandler_ = function (e) {
  13654. return _this.activate_(e);
  13655. };
  13656. _this.deactivateHandler_ = function () {
  13657. return _this.deactivate_();
  13658. };
  13659. _this.focusHandler_ = function () {
  13660. return _this.handleFocus();
  13661. };
  13662. _this.blurHandler_ = function () {
  13663. return _this.handleBlur();
  13664. };
  13665. _this.resizeHandler_ = function () {
  13666. return _this.layout();
  13667. };
  13668. return _this;
  13669. }
  13670. Object.defineProperty(MDCRippleFoundation, "cssClasses", {
  13671. get: function get() {
  13672. return constants_1.cssClasses;
  13673. },
  13674. enumerable: true,
  13675. configurable: true
  13676. });
  13677. Object.defineProperty(MDCRippleFoundation, "strings", {
  13678. get: function get() {
  13679. return constants_1.strings;
  13680. },
  13681. enumerable: true,
  13682. configurable: true
  13683. });
  13684. Object.defineProperty(MDCRippleFoundation, "numbers", {
  13685. get: function get() {
  13686. return constants_1.numbers;
  13687. },
  13688. enumerable: true,
  13689. configurable: true
  13690. });
  13691. Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
  13692. get: function get() {
  13693. return {
  13694. addClass: function addClass() {
  13695. return undefined;
  13696. },
  13697. browserSupportsCssVars: function browserSupportsCssVars() {
  13698. return true;
  13699. },
  13700. computeBoundingRect: function computeBoundingRect() {
  13701. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  13702. },
  13703. containsEventTarget: function containsEventTarget() {
  13704. return true;
  13705. },
  13706. deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
  13707. return undefined;
  13708. },
  13709. deregisterInteractionHandler: function deregisterInteractionHandler() {
  13710. return undefined;
  13711. },
  13712. deregisterResizeHandler: function deregisterResizeHandler() {
  13713. return undefined;
  13714. },
  13715. getWindowPageOffset: function getWindowPageOffset() {
  13716. return { x: 0, y: 0 };
  13717. },
  13718. isSurfaceActive: function isSurfaceActive() {
  13719. return true;
  13720. },
  13721. isSurfaceDisabled: function isSurfaceDisabled() {
  13722. return true;
  13723. },
  13724. isUnbounded: function isUnbounded() {
  13725. return true;
  13726. },
  13727. registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
  13728. return undefined;
  13729. },
  13730. registerInteractionHandler: function registerInteractionHandler() {
  13731. return undefined;
  13732. },
  13733. registerResizeHandler: function registerResizeHandler() {
  13734. return undefined;
  13735. },
  13736. removeClass: function removeClass() {
  13737. return undefined;
  13738. },
  13739. updateCssVariable: function updateCssVariable() {
  13740. return undefined;
  13741. }
  13742. };
  13743. },
  13744. enumerable: true,
  13745. configurable: true
  13746. });
  13747. MDCRippleFoundation.prototype.init = function () {
  13748. var _this = this;
  13749. var supportsPressRipple = this.supportsPressRipple_();
  13750. this.registerRootHandlers_(supportsPressRipple);
  13751. if (supportsPressRipple) {
  13752. var _a = MDCRippleFoundation.cssClasses,
  13753. ROOT_1 = _a.ROOT,
  13754. UNBOUNDED_1 = _a.UNBOUNDED;
  13755. requestAnimationFrame(function () {
  13756. _this.adapter.addClass(ROOT_1);
  13757. if (_this.adapter.isUnbounded()) {
  13758. _this.adapter.addClass(UNBOUNDED_1);
  13759. // Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple
  13760. _this.layoutInternal_();
  13761. }
  13762. });
  13763. }
  13764. };
  13765. MDCRippleFoundation.prototype.destroy = function () {
  13766. var _this = this;
  13767. if (this.supportsPressRipple_()) {
  13768. if (this.activationTimer_) {
  13769. clearTimeout(this.activationTimer_);
  13770. this.activationTimer_ = 0;
  13771. this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
  13772. }
  13773. if (this.fgDeactivationRemovalTimer_) {
  13774. clearTimeout(this.fgDeactivationRemovalTimer_);
  13775. this.fgDeactivationRemovalTimer_ = 0;
  13776. this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
  13777. }
  13778. var _a = MDCRippleFoundation.cssClasses,
  13779. ROOT_2 = _a.ROOT,
  13780. UNBOUNDED_2 = _a.UNBOUNDED;
  13781. requestAnimationFrame(function () {
  13782. _this.adapter.removeClass(ROOT_2);
  13783. _this.adapter.removeClass(UNBOUNDED_2);
  13784. _this.removeCssVars_();
  13785. });
  13786. }
  13787. this.deregisterRootHandlers_();
  13788. this.deregisterDeactivationHandlers_();
  13789. };
  13790. /**
  13791. * @param evt Optional event containing position information.
  13792. */
  13793. MDCRippleFoundation.prototype.activate = function (evt) {
  13794. this.activate_(evt);
  13795. };
  13796. MDCRippleFoundation.prototype.deactivate = function () {
  13797. this.deactivate_();
  13798. };
  13799. MDCRippleFoundation.prototype.layout = function () {
  13800. var _this = this;
  13801. if (this.layoutFrame_) {
  13802. cancelAnimationFrame(this.layoutFrame_);
  13803. }
  13804. this.layoutFrame_ = requestAnimationFrame(function () {
  13805. _this.layoutInternal_();
  13806. _this.layoutFrame_ = 0;
  13807. });
  13808. };
  13809. MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
  13810. var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
  13811. if (unbounded) {
  13812. this.adapter.addClass(UNBOUNDED);
  13813. } else {
  13814. this.adapter.removeClass(UNBOUNDED);
  13815. }
  13816. };
  13817. MDCRippleFoundation.prototype.handleFocus = function () {
  13818. var _this = this;
  13819. requestAnimationFrame(function () {
  13820. return _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  13821. });
  13822. };
  13823. MDCRippleFoundation.prototype.handleBlur = function () {
  13824. var _this = this;
  13825. requestAnimationFrame(function () {
  13826. return _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  13827. });
  13828. };
  13829. /**
  13830. * We compute this property so that we are not querying information about the client
  13831. * until the point in time where the foundation requests it. This prevents scenarios where
  13832. * client-side feature-detection may happen too early, such as when components are rendered on the server
  13833. * and then initialized at mount time on the client.
  13834. */
  13835. MDCRippleFoundation.prototype.supportsPressRipple_ = function () {
  13836. return this.adapter.browserSupportsCssVars();
  13837. };
  13838. MDCRippleFoundation.prototype.defaultActivationState_ = function () {
  13839. return {
  13840. activationEvent: undefined,
  13841. hasDeactivationUXRun: false,
  13842. isActivated: false,
  13843. isProgrammatic: false,
  13844. wasActivatedByPointer: false,
  13845. wasElementMadeActive: false
  13846. };
  13847. };
  13848. /**
  13849. * supportsPressRipple Passed from init to save a redundant function call
  13850. */
  13851. MDCRippleFoundation.prototype.registerRootHandlers_ = function (supportsPressRipple) {
  13852. var _this = this;
  13853. if (supportsPressRipple) {
  13854. ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  13855. _this.adapter.registerInteractionHandler(evtType, _this.activateHandler_);
  13856. });
  13857. if (this.adapter.isUnbounded()) {
  13858. this.adapter.registerResizeHandler(this.resizeHandler_);
  13859. }
  13860. }
  13861. this.adapter.registerInteractionHandler('focus', this.focusHandler_);
  13862. this.adapter.registerInteractionHandler('blur', this.blurHandler_);
  13863. };
  13864. MDCRippleFoundation.prototype.registerDeactivationHandlers_ = function (evt) {
  13865. var _this = this;
  13866. if (evt.type === 'keydown') {
  13867. this.adapter.registerInteractionHandler('keyup', this.deactivateHandler_);
  13868. } else {
  13869. POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  13870. _this.adapter.registerDocumentInteractionHandler(evtType, _this.deactivateHandler_);
  13871. });
  13872. }
  13873. };
  13874. MDCRippleFoundation.prototype.deregisterRootHandlers_ = function () {
  13875. var _this = this;
  13876. ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  13877. _this.adapter.deregisterInteractionHandler(evtType, _this.activateHandler_);
  13878. });
  13879. this.adapter.deregisterInteractionHandler('focus', this.focusHandler_);
  13880. this.adapter.deregisterInteractionHandler('blur', this.blurHandler_);
  13881. if (this.adapter.isUnbounded()) {
  13882. this.adapter.deregisterResizeHandler(this.resizeHandler_);
  13883. }
  13884. };
  13885. MDCRippleFoundation.prototype.deregisterDeactivationHandlers_ = function () {
  13886. var _this = this;
  13887. this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler_);
  13888. POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  13889. _this.adapter.deregisterDocumentInteractionHandler(evtType, _this.deactivateHandler_);
  13890. });
  13891. };
  13892. MDCRippleFoundation.prototype.removeCssVars_ = function () {
  13893. var _this = this;
  13894. var rippleStrings = MDCRippleFoundation.strings;
  13895. var keys = Object.keys(rippleStrings);
  13896. keys.forEach(function (key) {
  13897. if (key.indexOf('VAR_') === 0) {
  13898. _this.adapter.updateCssVariable(rippleStrings[key], null);
  13899. }
  13900. });
  13901. };
  13902. MDCRippleFoundation.prototype.activate_ = function (evt) {
  13903. var _this = this;
  13904. if (this.adapter.isSurfaceDisabled()) {
  13905. return;
  13906. }
  13907. var activationState = this.activationState_;
  13908. if (activationState.isActivated) {
  13909. return;
  13910. }
  13911. // Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
  13912. var previousActivationEvent = this.previousActivationEvent_;
  13913. var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
  13914. if (isSameInteraction) {
  13915. return;
  13916. }
  13917. activationState.isActivated = true;
  13918. activationState.isProgrammatic = evt === undefined;
  13919. activationState.activationEvent = evt;
  13920. activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
  13921. var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
  13922. return _this.adapter.containsEventTarget(target);
  13923. });
  13924. if (hasActivatedChild) {
  13925. // Immediately reset activation state, while preserving logic that prevents touch follow-on events
  13926. this.resetActivationState_();
  13927. return;
  13928. }
  13929. if (evt !== undefined) {
  13930. activatedTargets.push(evt.target);
  13931. this.registerDeactivationHandlers_(evt);
  13932. }
  13933. activationState.wasElementMadeActive = this.checkElementMadeActive_(evt);
  13934. if (activationState.wasElementMadeActive) {
  13935. this.animateActivation_();
  13936. }
  13937. requestAnimationFrame(function () {
  13938. // Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples
  13939. activatedTargets = [];
  13940. if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
  13941. // If space was pressed, try again within an rAF call to detect :active, because different UAs report
  13942. // active states inconsistently when they're called within event handling code:
  13943. // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
  13944. // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
  13945. // We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS
  13946. // variable is set within a rAF callback for a submit button interaction (#2241).
  13947. activationState.wasElementMadeActive = _this.checkElementMadeActive_(evt);
  13948. if (activationState.wasElementMadeActive) {
  13949. _this.animateActivation_();
  13950. }
  13951. }
  13952. if (!activationState.wasElementMadeActive) {
  13953. // Reset activation state immediately if element was not made active.
  13954. _this.activationState_ = _this.defaultActivationState_();
  13955. }
  13956. });
  13957. };
  13958. MDCRippleFoundation.prototype.checkElementMadeActive_ = function (evt) {
  13959. return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
  13960. };
  13961. MDCRippleFoundation.prototype.animateActivation_ = function () {
  13962. var _this = this;
  13963. var _a = MDCRippleFoundation.strings,
  13964. VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
  13965. VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
  13966. var _b = MDCRippleFoundation.cssClasses,
  13967. FG_DEACTIVATION = _b.FG_DEACTIVATION,
  13968. FG_ACTIVATION = _b.FG_ACTIVATION;
  13969. var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
  13970. this.layoutInternal_();
  13971. var translateStart = '';
  13972. var translateEnd = '';
  13973. if (!this.adapter.isUnbounded()) {
  13974. var _c = this.getFgTranslationCoordinates_(),
  13975. startPoint = _c.startPoint,
  13976. endPoint = _c.endPoint;
  13977. translateStart = startPoint.x + "px, " + startPoint.y + "px";
  13978. translateEnd = endPoint.x + "px, " + endPoint.y + "px";
  13979. }
  13980. this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
  13981. this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
  13982. // Cancel any ongoing activation/deactivation animations
  13983. clearTimeout(this.activationTimer_);
  13984. clearTimeout(this.fgDeactivationRemovalTimer_);
  13985. this.rmBoundedActivationClasses_();
  13986. this.adapter.removeClass(FG_DEACTIVATION);
  13987. // Force layout in order to re-trigger the animation.
  13988. this.adapter.computeBoundingRect();
  13989. this.adapter.addClass(FG_ACTIVATION);
  13990. this.activationTimer_ = setTimeout(function () {
  13991. return _this.activationTimerCallback_();
  13992. }, DEACTIVATION_TIMEOUT_MS);
  13993. };
  13994. MDCRippleFoundation.prototype.getFgTranslationCoordinates_ = function () {
  13995. var _a = this.activationState_,
  13996. activationEvent = _a.activationEvent,
  13997. wasActivatedByPointer = _a.wasActivatedByPointer;
  13998. var startPoint;
  13999. if (wasActivatedByPointer) {
  14000. startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
  14001. } else {
  14002. startPoint = {
  14003. x: this.frame_.width / 2,
  14004. y: this.frame_.height / 2
  14005. };
  14006. }
  14007. // Center the element around the start point.
  14008. startPoint = {
  14009. x: startPoint.x - this.initialSize_ / 2,
  14010. y: startPoint.y - this.initialSize_ / 2
  14011. };
  14012. var endPoint = {
  14013. x: this.frame_.width / 2 - this.initialSize_ / 2,
  14014. y: this.frame_.height / 2 - this.initialSize_ / 2
  14015. };
  14016. return { startPoint: startPoint, endPoint: endPoint };
  14017. };
  14018. MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady_ = function () {
  14019. var _this = this;
  14020. // This method is called both when a pointing device is released, and when the activation animation ends.
  14021. // The deactivation animation should only run after both of those occur.
  14022. var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
  14023. var _a = this.activationState_,
  14024. hasDeactivationUXRun = _a.hasDeactivationUXRun,
  14025. isActivated = _a.isActivated;
  14026. var activationHasEnded = hasDeactivationUXRun || !isActivated;
  14027. if (activationHasEnded && this.activationAnimationHasEnded_) {
  14028. this.rmBoundedActivationClasses_();
  14029. this.adapter.addClass(FG_DEACTIVATION);
  14030. this.fgDeactivationRemovalTimer_ = setTimeout(function () {
  14031. _this.adapter.removeClass(FG_DEACTIVATION);
  14032. }, constants_1.numbers.FG_DEACTIVATION_MS);
  14033. }
  14034. };
  14035. MDCRippleFoundation.prototype.rmBoundedActivationClasses_ = function () {
  14036. var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
  14037. this.adapter.removeClass(FG_ACTIVATION);
  14038. this.activationAnimationHasEnded_ = false;
  14039. this.adapter.computeBoundingRect();
  14040. };
  14041. MDCRippleFoundation.prototype.resetActivationState_ = function () {
  14042. var _this = this;
  14043. this.previousActivationEvent_ = this.activationState_.activationEvent;
  14044. this.activationState_ = this.defaultActivationState_();
  14045. // Touch devices may fire additional events for the same interaction within a short time.
  14046. // Store the previous event until it's safe to assume that subsequent events are for new interactions.
  14047. setTimeout(function () {
  14048. return _this.previousActivationEvent_ = undefined;
  14049. }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
  14050. };
  14051. MDCRippleFoundation.prototype.deactivate_ = function () {
  14052. var _this = this;
  14053. var activationState = this.activationState_;
  14054. // This can happen in scenarios such as when you have a keyup event that blurs the element.
  14055. if (!activationState.isActivated) {
  14056. return;
  14057. }
  14058. var state = __assign({}, activationState);
  14059. if (activationState.isProgrammatic) {
  14060. requestAnimationFrame(function () {
  14061. return _this.animateDeactivation_(state);
  14062. });
  14063. this.resetActivationState_();
  14064. } else {
  14065. this.deregisterDeactivationHandlers_();
  14066. requestAnimationFrame(function () {
  14067. _this.activationState_.hasDeactivationUXRun = true;
  14068. _this.animateDeactivation_(state);
  14069. _this.resetActivationState_();
  14070. });
  14071. }
  14072. };
  14073. MDCRippleFoundation.prototype.animateDeactivation_ = function (_a) {
  14074. var wasActivatedByPointer = _a.wasActivatedByPointer,
  14075. wasElementMadeActive = _a.wasElementMadeActive;
  14076. if (wasActivatedByPointer || wasElementMadeActive) {
  14077. this.runDeactivationUXLogicIfReady_();
  14078. }
  14079. };
  14080. MDCRippleFoundation.prototype.layoutInternal_ = function () {
  14081. var _this = this;
  14082. this.frame_ = this.adapter.computeBoundingRect();
  14083. var maxDim = Math.max(this.frame_.height, this.frame_.width);
  14084. // Surface diameter is treated differently for unbounded vs. bounded ripples.
  14085. // Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately
  14086. // to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically
  14087. // square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter
  14088. // (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via
  14089. // `overflow: hidden`.
  14090. var getBoundedRadius = function getBoundedRadius() {
  14091. var hypotenuse = Math.sqrt(Math.pow(_this.frame_.width, 2) + Math.pow(_this.frame_.height, 2));
  14092. return hypotenuse + MDCRippleFoundation.numbers.PADDING;
  14093. };
  14094. this.maxRadius_ = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
  14095. // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform
  14096. var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
  14097. // Unbounded ripple size should always be even number to equally center align.
  14098. if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
  14099. this.initialSize_ = initialSize - 1;
  14100. } else {
  14101. this.initialSize_ = initialSize;
  14102. }
  14103. this.fgScale_ = "" + this.maxRadius_ / this.initialSize_;
  14104. this.updateLayoutCssVars_();
  14105. };
  14106. MDCRippleFoundation.prototype.updateLayoutCssVars_ = function () {
  14107. var _a = MDCRippleFoundation.strings,
  14108. VAR_FG_SIZE = _a.VAR_FG_SIZE,
  14109. VAR_LEFT = _a.VAR_LEFT,
  14110. VAR_TOP = _a.VAR_TOP,
  14111. VAR_FG_SCALE = _a.VAR_FG_SCALE;
  14112. this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize_ + "px");
  14113. this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale_);
  14114. if (this.adapter.isUnbounded()) {
  14115. this.unboundedCoords_ = {
  14116. left: Math.round(this.frame_.width / 2 - this.initialSize_ / 2),
  14117. top: Math.round(this.frame_.height / 2 - this.initialSize_ / 2)
  14118. };
  14119. this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords_.left + "px");
  14120. this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords_.top + "px");
  14121. }
  14122. };
  14123. return MDCRippleFoundation;
  14124. }(foundation_1.MDCFoundation);
  14125. exports.MDCRippleFoundation = MDCRippleFoundation;
  14126. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  14127. exports.default = MDCRippleFoundation;
  14128. /***/ }),
  14129. /***/ "./packages/mdc-ripple/index.ts":
  14130. /*!**************************************!*\
  14131. !*** ./packages/mdc-ripple/index.ts ***!
  14132. \**************************************/
  14133. /*! no static exports found */
  14134. /***/ (function(module, exports, __webpack_require__) {
  14135. "use strict";
  14136. /**
  14137. * @license
  14138. * Copyright 2019 Google Inc.
  14139. *
  14140. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14141. * of this software and associated documentation files (the "Software"), to deal
  14142. * in the Software without restriction, including without limitation the rights
  14143. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14144. * copies of the Software, and to permit persons to whom the Software is
  14145. * furnished to do so, subject to the following conditions:
  14146. *
  14147. * The above copyright notice and this permission notice shall be included in
  14148. * all copies or substantial portions of the Software.
  14149. *
  14150. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14151. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14152. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14153. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14154. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14155. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14156. * THE SOFTWARE.
  14157. */
  14158. function __export(m) {
  14159. for (var p in m) {
  14160. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  14161. }
  14162. }
  14163. var __importStar = this && this.__importStar || function (mod) {
  14164. if (mod && mod.__esModule) return mod;
  14165. var result = {};
  14166. if (mod != null) for (var k in mod) {
  14167. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  14168. }result["default"] = mod;
  14169. return result;
  14170. };
  14171. Object.defineProperty(exports, "__esModule", { value: true });
  14172. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
  14173. exports.util = util;
  14174. __export(__webpack_require__(/*! ./component */ "./packages/mdc-ripple/component.ts"));
  14175. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts"));
  14176. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts"));
  14177. /***/ }),
  14178. /***/ "./packages/mdc-ripple/util.ts":
  14179. /*!*************************************!*\
  14180. !*** ./packages/mdc-ripple/util.ts ***!
  14181. \*************************************/
  14182. /*! no static exports found */
  14183. /***/ (function(module, exports, __webpack_require__) {
  14184. "use strict";
  14185. Object.defineProperty(exports, "__esModule", { value: true });
  14186. /**
  14187. * Stores result from supportsCssVariables to avoid redundant processing to
  14188. * detect CSS custom variable support.
  14189. */
  14190. var supportsCssVariables_;
  14191. function supportsCssVariables(windowObj, forceRefresh) {
  14192. if (forceRefresh === void 0) {
  14193. forceRefresh = false;
  14194. }
  14195. var CSS = windowObj.CSS;
  14196. var supportsCssVars = supportsCssVariables_;
  14197. if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
  14198. return supportsCssVariables_;
  14199. }
  14200. var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
  14201. if (!supportsFunctionPresent) {
  14202. return false;
  14203. }
  14204. var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
  14205. // See: https://bugs.webkit.org/show_bug.cgi?id=154669
  14206. // See: README section on Safari
  14207. var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
  14208. supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
  14209. if (!forceRefresh) {
  14210. supportsCssVariables_ = supportsCssVars;
  14211. }
  14212. return supportsCssVars;
  14213. }
  14214. exports.supportsCssVariables = supportsCssVariables;
  14215. function getNormalizedEventCoords(evt, pageOffset, clientRect) {
  14216. if (!evt) {
  14217. return { x: 0, y: 0 };
  14218. }
  14219. var x = pageOffset.x,
  14220. y = pageOffset.y;
  14221. var documentX = x + clientRect.left;
  14222. var documentY = y + clientRect.top;
  14223. var normalizedX;
  14224. var normalizedY;
  14225. // Determine touch point relative to the ripple container.
  14226. if (evt.type === 'touchstart') {
  14227. var touchEvent = evt;
  14228. normalizedX = touchEvent.changedTouches[0].pageX - documentX;
  14229. normalizedY = touchEvent.changedTouches[0].pageY - documentY;
  14230. } else {
  14231. var mouseEvent = evt;
  14232. normalizedX = mouseEvent.pageX - documentX;
  14233. normalizedY = mouseEvent.pageY - documentY;
  14234. }
  14235. return { x: normalizedX, y: normalizedY };
  14236. }
  14237. exports.getNormalizedEventCoords = getNormalizedEventCoords;
  14238. /***/ }),
  14239. /***/ "./packages/mdc-segmented-button/index.ts":
  14240. /*!************************************************!*\
  14241. !*** ./packages/mdc-segmented-button/index.ts ***!
  14242. \************************************************/
  14243. /*! no static exports found */
  14244. /***/ (function(module, exports, __webpack_require__) {
  14245. "use strict";
  14246. /**
  14247. * @license
  14248. * Copyright 2020 Google Inc.
  14249. *
  14250. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14251. * of this software and associated documentation files (the "Software"), to deal
  14252. * in the Software without restriction, including without limitation the rights
  14253. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14254. * copies of the Software, and to permit persons to whom the Software is
  14255. * furnished to do so, subject to the following conditions:
  14256. *
  14257. * The above copyright notice and this permission notice shall be included in
  14258. * all copies or substantial portions of the Software.
  14259. *
  14260. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14261. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14262. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14263. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14264. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14265. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14266. * THE SOFTWARE.
  14267. */
  14268. function __export(m) {
  14269. for (var p in m) {
  14270. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  14271. }
  14272. }
  14273. Object.defineProperty(exports, "__esModule", { value: true });
  14274. __export(__webpack_require__(/*! ./segmented-button/index */ "./packages/mdc-segmented-button/segmented-button/index.ts"));
  14275. __export(__webpack_require__(/*! ./segment/index */ "./packages/mdc-segmented-button/segment/index.ts"));
  14276. /***/ }),
  14277. /***/ "./packages/mdc-segmented-button/segment/component.ts":
  14278. /*!************************************************************!*\
  14279. !*** ./packages/mdc-segmented-button/segment/component.ts ***!
  14280. \************************************************************/
  14281. /*! no static exports found */
  14282. /***/ (function(module, exports, __webpack_require__) {
  14283. "use strict";
  14284. /**
  14285. * @license
  14286. * Copyright 2020 Google Inc.
  14287. *
  14288. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14289. * of this software and associated documentation files (the "Software"), to deal
  14290. * in the Software without restriction, including without limitation the rights
  14291. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14292. * copies of the Software, and to permit persons to whom the Software is
  14293. * furnished to do so, subject to the following conditions:
  14294. *
  14295. * The above copyright notice and this permission notice shall be included in
  14296. * all copies or substantial portions of the Software.
  14297. *
  14298. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14299. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14300. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14301. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14302. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14303. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14304. * THE SOFTWARE.
  14305. */
  14306. var __extends = this && this.__extends || function () {
  14307. var _extendStatics = function extendStatics(d, b) {
  14308. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  14309. d.__proto__ = b;
  14310. } || function (d, b) {
  14311. for (var p in b) {
  14312. if (b.hasOwnProperty(p)) d[p] = b[p];
  14313. }
  14314. };
  14315. return _extendStatics(d, b);
  14316. };
  14317. return function (d, b) {
  14318. _extendStatics(d, b);
  14319. function __() {
  14320. this.constructor = d;
  14321. }
  14322. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14323. };
  14324. }();
  14325. var __assign = this && this.__assign || function () {
  14326. __assign = Object.assign || function (t) {
  14327. for (var s, i = 1, n = arguments.length; i < n; i++) {
  14328. s = arguments[i];
  14329. for (var p in s) {
  14330. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  14331. }
  14332. }
  14333. return t;
  14334. };
  14335. return __assign.apply(this, arguments);
  14336. };
  14337. Object.defineProperty(exports, "__esModule", { value: true });
  14338. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  14339. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  14340. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  14341. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segment/constants.ts");
  14342. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segment/foundation.ts");
  14343. /**
  14344. * Implementation of MDCSegmentedButtonSegmentFoundation
  14345. */
  14346. var MDCSegmentedButtonSegment = /** @class */function (_super) {
  14347. __extends(MDCSegmentedButtonSegment, _super);
  14348. function MDCSegmentedButtonSegment() {
  14349. return _super !== null && _super.apply(this, arguments) || this;
  14350. }
  14351. Object.defineProperty(MDCSegmentedButtonSegment.prototype, "ripple", {
  14352. get: function get() {
  14353. return this.rippleComponent;
  14354. },
  14355. enumerable: true,
  14356. configurable: true
  14357. });
  14358. MDCSegmentedButtonSegment.attachTo = function (root) {
  14359. return new MDCSegmentedButtonSegment(root);
  14360. };
  14361. MDCSegmentedButtonSegment.prototype.initialize = function (rippleFactory) {
  14362. var _this = this;
  14363. if (rippleFactory === void 0) {
  14364. rippleFactory = function rippleFactory(el, foundation) {
  14365. return new component_2.MDCRipple(el, foundation);
  14366. };
  14367. }
  14368. var rippleAdapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { computeBoundingRect: function computeBoundingRect() {
  14369. return _this.foundation.getDimensions();
  14370. } });
  14371. this.rippleComponent = rippleFactory(this.root, new foundation_1.MDCRippleFoundation(rippleAdapter));
  14372. };
  14373. MDCSegmentedButtonSegment.prototype.initialSyncWithDOM = function () {
  14374. var _this = this;
  14375. this.handleClick = function () {
  14376. _this.foundation.handleClick();
  14377. };
  14378. this.listen(constants_1.events.CLICK, this.handleClick);
  14379. };
  14380. MDCSegmentedButtonSegment.prototype.destroy = function () {
  14381. this.ripple.destroy();
  14382. this.unlisten(constants_1.events.CLICK, this.handleClick);
  14383. _super.prototype.destroy.call(this);
  14384. };
  14385. MDCSegmentedButtonSegment.prototype.getDefaultFoundation = function () {
  14386. var _this = this;
  14387. // DO NOT INLINE this variable. For backward compatibility, foundations take
  14388. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  14389. // methods, we need a separate, strongly typed adapter variable.
  14390. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  14391. var adapter = {
  14392. isSingleSelect: function isSingleSelect() {
  14393. return _this.isSingleSelect;
  14394. },
  14395. getAttr: function getAttr(attrName) {
  14396. return _this.root.getAttribute(attrName);
  14397. },
  14398. setAttr: function setAttr(attrName, value) {
  14399. _this.root.setAttribute(attrName, value);
  14400. },
  14401. addClass: function addClass(className) {
  14402. _this.root.classList.add(className);
  14403. },
  14404. removeClass: function removeClass(className) {
  14405. _this.root.classList.remove(className);
  14406. },
  14407. hasClass: function hasClass(className) {
  14408. return _this.root.classList.contains(className);
  14409. },
  14410. notifySelectedChange: function notifySelectedChange(selected) {
  14411. _this.emit(constants_1.events.SELECTED, {
  14412. index: _this.index,
  14413. selected: selected,
  14414. segmentId: _this.getSegmentId()
  14415. }, true /* shouldBubble */);
  14416. },
  14417. getRootBoundingClientRect: function getRootBoundingClientRect() {
  14418. return _this.root.getBoundingClientRect();
  14419. }
  14420. };
  14421. return new foundation_2.MDCSegmentedButtonSegmentFoundation(adapter);
  14422. };
  14423. /**
  14424. * Sets segment's index value
  14425. *
  14426. * @param index Segment's index within wrapping segmented button
  14427. */
  14428. MDCSegmentedButtonSegment.prototype.setIndex = function (index) {
  14429. this.index = index;
  14430. };
  14431. /**
  14432. * Sets segment's isSingleSelect value
  14433. *
  14434. * @param isSingleSelect True if wrapping segmented button is single select
  14435. */
  14436. MDCSegmentedButtonSegment.prototype.setIsSingleSelect = function (isSingleSelect) {
  14437. this.isSingleSelect = isSingleSelect;
  14438. };
  14439. /**
  14440. * @return Returns true if segment is currently selected, otherwise returns
  14441. * false
  14442. */
  14443. MDCSegmentedButtonSegment.prototype.isSelected = function () {
  14444. return this.foundation.isSelected();
  14445. };
  14446. /**
  14447. * Sets segment to be selected
  14448. */
  14449. MDCSegmentedButtonSegment.prototype.setSelected = function () {
  14450. this.foundation.setSelected();
  14451. };
  14452. /**
  14453. * Sets segment to be not selected
  14454. */
  14455. MDCSegmentedButtonSegment.prototype.setUnselected = function () {
  14456. this.foundation.setUnselected();
  14457. };
  14458. /**
  14459. * @return Returns segment's segmentId if it was set by client
  14460. */
  14461. MDCSegmentedButtonSegment.prototype.getSegmentId = function () {
  14462. return this.foundation.getSegmentId();
  14463. };
  14464. return MDCSegmentedButtonSegment;
  14465. }(component_1.MDCComponent);
  14466. exports.MDCSegmentedButtonSegment = MDCSegmentedButtonSegment;
  14467. /***/ }),
  14468. /***/ "./packages/mdc-segmented-button/segment/constants.ts":
  14469. /*!************************************************************!*\
  14470. !*** ./packages/mdc-segmented-button/segment/constants.ts ***!
  14471. \************************************************************/
  14472. /*! no static exports found */
  14473. /***/ (function(module, exports, __webpack_require__) {
  14474. "use strict";
  14475. /**
  14476. * @license
  14477. * Copyright 2020 Google Inc.
  14478. *
  14479. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14480. * of this software and associated documentation files (the "Software"), to deal
  14481. * in the Software without restriction, including without limitation the rights
  14482. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14483. * copies of the Software, and to permit persons to whom the Software is
  14484. * furnished to do so, subject to the following conditions:
  14485. *
  14486. * The above copyright notice and this permission notice shall be included in
  14487. * all copies or substantial portions of the Software.
  14488. *
  14489. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14490. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14491. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14492. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14493. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14494. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14495. * THE SOFTWARE.
  14496. */
  14497. Object.defineProperty(exports, "__esModule", { value: true });
  14498. /**
  14499. * Boolean strings for segment
  14500. */
  14501. exports.booleans = {
  14502. TRUE: 'true',
  14503. FALSE: 'false'
  14504. };
  14505. /**
  14506. * Attributes referenced by segment
  14507. */
  14508. exports.attributes = {
  14509. ARIA_CHECKED: 'aria-checked',
  14510. ARIA_PRESSED: 'aria-pressed',
  14511. DATA_SEGMENT_ID: 'data-segment-id'
  14512. };
  14513. /**
  14514. * Events received or emitted by segment
  14515. */
  14516. exports.events = {
  14517. CLICK: 'click',
  14518. SELECTED: 'selected'
  14519. };
  14520. /**
  14521. * Style classes for segment
  14522. */
  14523. exports.cssClasses = {
  14524. SELECTED: 'mdc-segmented-button__segment--selected'
  14525. };
  14526. /***/ }),
  14527. /***/ "./packages/mdc-segmented-button/segment/foundation.ts":
  14528. /*!*************************************************************!*\
  14529. !*** ./packages/mdc-segmented-button/segment/foundation.ts ***!
  14530. \*************************************************************/
  14531. /*! no static exports found */
  14532. /***/ (function(module, exports, __webpack_require__) {
  14533. "use strict";
  14534. /**
  14535. * @license
  14536. * Copyright 2020 Google Inc.
  14537. *
  14538. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14539. * of this software and associated documentation files (the "Software"), to deal
  14540. * in the Software without restriction, including without limitation the rights
  14541. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14542. * copies of the Software, and to permit persons to whom the Software is
  14543. * furnished to do so, subject to the following conditions:
  14544. *
  14545. * The above copyright notice and this permission notice shall be included in
  14546. * all copies or substantial portions of the Software.
  14547. *
  14548. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14549. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14550. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14551. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14552. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14553. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14554. * THE SOFTWARE.
  14555. */
  14556. var __extends = this && this.__extends || function () {
  14557. var _extendStatics = function extendStatics(d, b) {
  14558. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  14559. d.__proto__ = b;
  14560. } || function (d, b) {
  14561. for (var p in b) {
  14562. if (b.hasOwnProperty(p)) d[p] = b[p];
  14563. }
  14564. };
  14565. return _extendStatics(d, b);
  14566. };
  14567. return function (d, b) {
  14568. _extendStatics(d, b);
  14569. function __() {
  14570. this.constructor = d;
  14571. }
  14572. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14573. };
  14574. }();
  14575. var __assign = this && this.__assign || function () {
  14576. __assign = Object.assign || function (t) {
  14577. for (var s, i = 1, n = arguments.length; i < n; i++) {
  14578. s = arguments[i];
  14579. for (var p in s) {
  14580. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  14581. }
  14582. }
  14583. return t;
  14584. };
  14585. return __assign.apply(this, arguments);
  14586. };
  14587. Object.defineProperty(exports, "__esModule", { value: true });
  14588. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  14589. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segment/constants.ts");
  14590. var emptyClientRect = {
  14591. bottom: 0,
  14592. height: 0,
  14593. left: 0,
  14594. right: 0,
  14595. top: 0,
  14596. width: 0
  14597. };
  14598. var MDCSegmentedButtonSegmentFoundation = /** @class */function (_super) {
  14599. __extends(MDCSegmentedButtonSegmentFoundation, _super);
  14600. function MDCSegmentedButtonSegmentFoundation(adapter) {
  14601. return _super.call(this, __assign(__assign({}, MDCSegmentedButtonSegmentFoundation.defaultAdapter), adapter)) || this;
  14602. }
  14603. Object.defineProperty(MDCSegmentedButtonSegmentFoundation, "defaultAdapter", {
  14604. get: function get() {
  14605. return {
  14606. isSingleSelect: function isSingleSelect() {
  14607. return false;
  14608. }, getAttr: function getAttr() {
  14609. return '';
  14610. }, setAttr: function setAttr() {
  14611. return undefined;
  14612. },
  14613. addClass: function addClass() {
  14614. return undefined;
  14615. }, removeClass: function removeClass() {
  14616. return undefined;
  14617. },
  14618. hasClass: function hasClass() {
  14619. return false;
  14620. },
  14621. notifySelectedChange: function notifySelectedChange() {
  14622. return undefined;
  14623. },
  14624. getRootBoundingClientRect: function getRootBoundingClientRect() {
  14625. return emptyClientRect;
  14626. }
  14627. };
  14628. },
  14629. enumerable: true,
  14630. configurable: true
  14631. });
  14632. /**
  14633. * @return Returns true if segment is currently selected, otherwise returns
  14634. * false
  14635. */
  14636. MDCSegmentedButtonSegmentFoundation.prototype.isSelected = function () {
  14637. return this.adapter.hasClass(constants_1.cssClasses.SELECTED);
  14638. };
  14639. /**
  14640. * Sets segment to be selected
  14641. */
  14642. MDCSegmentedButtonSegmentFoundation.prototype.setSelected = function () {
  14643. this.adapter.addClass(constants_1.cssClasses.SELECTED);
  14644. this.setAriaAttr(constants_1.booleans.TRUE);
  14645. };
  14646. /**
  14647. * Sets segment to be not selected
  14648. */
  14649. MDCSegmentedButtonSegmentFoundation.prototype.setUnselected = function () {
  14650. this.adapter.removeClass(constants_1.cssClasses.SELECTED);
  14651. this.setAriaAttr(constants_1.booleans.FALSE);
  14652. };
  14653. /**
  14654. * @return Returns segment's segmentId if it was set by client
  14655. */
  14656. MDCSegmentedButtonSegmentFoundation.prototype.getSegmentId = function () {
  14657. var _a;
  14658. return (_a = this.adapter.getAttr(constants_1.attributes.DATA_SEGMENT_ID)) !== null && _a !== void 0 ? _a : undefined;
  14659. };
  14660. /**
  14661. * Called when segment is clicked. If the wrapping segmented button is single
  14662. * select, doesn't allow segment to be set to not selected. Otherwise, toggles
  14663. * segment's selected status. Finally, emits event to wrapping segmented
  14664. * button.
  14665. *
  14666. * @event selected With detail - SegmentDetail
  14667. */
  14668. MDCSegmentedButtonSegmentFoundation.prototype.handleClick = function () {
  14669. if (this.adapter.isSingleSelect()) {
  14670. this.setSelected();
  14671. } else {
  14672. this.toggleSelection();
  14673. }
  14674. this.adapter.notifySelectedChange(this.isSelected());
  14675. };
  14676. /**
  14677. * @return Returns bounding rectangle for ripple effect
  14678. */
  14679. MDCSegmentedButtonSegmentFoundation.prototype.getDimensions = function () {
  14680. return this.adapter.getRootBoundingClientRect();
  14681. };
  14682. /**
  14683. * Sets segment from not selected to selected, or selected to not selected
  14684. */
  14685. MDCSegmentedButtonSegmentFoundation.prototype.toggleSelection = function () {
  14686. if (this.isSelected()) {
  14687. this.setUnselected();
  14688. } else {
  14689. this.setSelected();
  14690. }
  14691. };
  14692. /**
  14693. * Sets appropriate aria attribute, based on wrapping segmented button's
  14694. * single selected value, to new value
  14695. *
  14696. * @param value Value that represents selected status
  14697. */
  14698. MDCSegmentedButtonSegmentFoundation.prototype.setAriaAttr = function (value) {
  14699. if (this.adapter.isSingleSelect()) {
  14700. this.adapter.setAttr(constants_1.attributes.ARIA_CHECKED, value);
  14701. } else {
  14702. this.adapter.setAttr(constants_1.attributes.ARIA_PRESSED, value);
  14703. }
  14704. };
  14705. return MDCSegmentedButtonSegmentFoundation;
  14706. }(foundation_1.MDCFoundation);
  14707. exports.MDCSegmentedButtonSegmentFoundation = MDCSegmentedButtonSegmentFoundation;
  14708. /***/ }),
  14709. /***/ "./packages/mdc-segmented-button/segment/index.ts":
  14710. /*!********************************************************!*\
  14711. !*** ./packages/mdc-segmented-button/segment/index.ts ***!
  14712. \********************************************************/
  14713. /*! no static exports found */
  14714. /***/ (function(module, exports, __webpack_require__) {
  14715. "use strict";
  14716. /**
  14717. * @license
  14718. * Copyright 2020 Google Inc.
  14719. *
  14720. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14721. * of this software and associated documentation files (the "Software"), to deal
  14722. * in the Software without restriction, including without limitation the rights
  14723. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14724. * copies of the Software, and to permit persons to whom the Software is
  14725. * furnished to do so, subject to the following conditions:
  14726. *
  14727. * The above copyright notice and this permission notice shall be included in
  14728. * all copies or substantial portions of the Software.
  14729. *
  14730. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14731. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14732. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14733. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14734. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14735. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14736. * THE SOFTWARE.
  14737. */
  14738. function __export(m) {
  14739. for (var p in m) {
  14740. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  14741. }
  14742. }
  14743. Object.defineProperty(exports, "__esModule", { value: true });
  14744. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segment/foundation.ts"));
  14745. __export(__webpack_require__(/*! ./component */ "./packages/mdc-segmented-button/segment/component.ts"));
  14746. /***/ }),
  14747. /***/ "./packages/mdc-segmented-button/segmented-button/component.ts":
  14748. /*!*********************************************************************!*\
  14749. !*** ./packages/mdc-segmented-button/segmented-button/component.ts ***!
  14750. \*********************************************************************/
  14751. /*! no static exports found */
  14752. /***/ (function(module, exports, __webpack_require__) {
  14753. "use strict";
  14754. /**
  14755. * @license
  14756. * Copyright 2020 Google Inc.
  14757. *
  14758. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14759. * of this software and associated documentation files (the "Software"), to deal
  14760. * in the Software without restriction, including without limitation the rights
  14761. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14762. * copies of the Software, and to permit persons to whom the Software is
  14763. * furnished to do so, subject to the following conditions:
  14764. *
  14765. * The above copyright notice and this permission notice shall be included in
  14766. * all copies or substantial portions of the Software.
  14767. *
  14768. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14769. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14770. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14771. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14772. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14773. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14774. * THE SOFTWARE.
  14775. */
  14776. var __extends = this && this.__extends || function () {
  14777. var _extendStatics = function extendStatics(d, b) {
  14778. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  14779. d.__proto__ = b;
  14780. } || function (d, b) {
  14781. for (var p in b) {
  14782. if (b.hasOwnProperty(p)) d[p] = b[p];
  14783. }
  14784. };
  14785. return _extendStatics(d, b);
  14786. };
  14787. return function (d, b) {
  14788. _extendStatics(d, b);
  14789. function __() {
  14790. this.constructor = d;
  14791. }
  14792. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14793. };
  14794. }();
  14795. Object.defineProperty(exports, "__esModule", { value: true });
  14796. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  14797. var component_2 = __webpack_require__(/*! ../segment/component */ "./packages/mdc-segmented-button/segment/component.ts");
  14798. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segmented-button/constants.ts");
  14799. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segmented-button/foundation.ts");
  14800. // TODO(b/152410470): Remove trailing underscores from private properties
  14801. // tslint:disable:strip-private-property-underscore
  14802. var MDCSegmentedButton = /** @class */function (_super) {
  14803. __extends(MDCSegmentedButton, _super);
  14804. function MDCSegmentedButton() {
  14805. return _super !== null && _super.apply(this, arguments) || this;
  14806. }
  14807. MDCSegmentedButton.attachTo = function (root) {
  14808. return new MDCSegmentedButton(root);
  14809. };
  14810. Object.defineProperty(MDCSegmentedButton.prototype, "segments", {
  14811. get: function get() {
  14812. return this.segments_.slice();
  14813. },
  14814. enumerable: true,
  14815. configurable: true
  14816. });
  14817. // initialSyncWithDOM
  14818. MDCSegmentedButton.prototype.initialize = function (segmentFactory) {
  14819. if (segmentFactory === void 0) {
  14820. segmentFactory = function segmentFactory(el) {
  14821. return new component_2.MDCSegmentedButtonSegment(el);
  14822. };
  14823. }
  14824. this.segmentFactory = segmentFactory;
  14825. this.segments_ = this.instantiateSegments(this.segmentFactory);
  14826. };
  14827. /**
  14828. * @param segmentFactory Factory to create new child segments
  14829. * @return Returns list of child segments found in DOM
  14830. */
  14831. MDCSegmentedButton.prototype.instantiateSegments = function (segmentFactory) {
  14832. var segmentElements = [].slice.call(this.root.querySelectorAll(constants_1.selectors.SEGMENT));
  14833. return segmentElements.map(function (el) {
  14834. return segmentFactory(el);
  14835. });
  14836. };
  14837. MDCSegmentedButton.prototype.initialSyncWithDOM = function () {
  14838. var _this = this;
  14839. this.handleSelected = function (event) {
  14840. _this.foundation.handleSelected(event.detail);
  14841. };
  14842. this.listen(constants_1.events.SELECTED, this.handleSelected);
  14843. var isSingleSelect = this.foundation.isSingleSelect();
  14844. this.segments_.forEach(function (segment, index) {
  14845. segment.setIndex(index);
  14846. segment.setIsSingleSelect(isSingleSelect);
  14847. });
  14848. var selectedSegments = this.segments_.filter(function (segment) {
  14849. return segment.isSelected();
  14850. });
  14851. if (isSingleSelect && selectedSegments.length == 0 && this.segments_.length > 0) {
  14852. throw new Error('No segment selected in singleSelect mdc-segmented-button');
  14853. } else if (isSingleSelect && selectedSegments.length > 1) {
  14854. throw new Error('Multiple segments selected in singleSelect mdc-segmented-button');
  14855. }
  14856. };
  14857. MDCSegmentedButton.prototype.destroy = function () {
  14858. this.segments_.forEach(function (segment) {
  14859. segment.destroy();
  14860. });
  14861. this.unlisten(constants_1.events.SELECTED, this.handleSelected);
  14862. _super.prototype.destroy.call(this);
  14863. };
  14864. MDCSegmentedButton.prototype.getDefaultFoundation = function () {
  14865. var _this = this;
  14866. var adapter = {
  14867. hasClass: function hasClass(className) {
  14868. return _this.root.classList.contains(className);
  14869. },
  14870. getSegments: function getSegments() {
  14871. return _this.mappedSegments();
  14872. },
  14873. selectSegment: function selectSegment(indexOrSegmentId) {
  14874. var segmentDetail = _this.mappedSegments().find(function (_segmentDetail) {
  14875. return _segmentDetail.index === indexOrSegmentId || _segmentDetail.segmentId === indexOrSegmentId;
  14876. });
  14877. if (segmentDetail) {
  14878. _this.segments_[segmentDetail.index].setSelected();
  14879. }
  14880. },
  14881. unselectSegment: function unselectSegment(indexOrSegmentId) {
  14882. var segmentDetail = _this.mappedSegments().find(function (_segmentDetail) {
  14883. return _segmentDetail.index === indexOrSegmentId || _segmentDetail.segmentId === indexOrSegmentId;
  14884. });
  14885. if (segmentDetail) {
  14886. _this.segments_[segmentDetail.index].setUnselected();
  14887. }
  14888. },
  14889. notifySelectedChange: function notifySelectedChange(detail) {
  14890. _this.emit(constants_1.events.CHANGE, detail, true /* shouldBubble */);
  14891. }
  14892. };
  14893. return new foundation_1.MDCSegmentedButtonFoundation(adapter);
  14894. };
  14895. /**
  14896. * @return Returns readonly list of selected child segments as SegmentDetails
  14897. */
  14898. MDCSegmentedButton.prototype.getSelectedSegments = function () {
  14899. return this.foundation.getSelectedSegments();
  14900. };
  14901. /**
  14902. * Sets identified segment to be selected
  14903. *
  14904. * @param indexOrSegmentId Number index or string segmentId that identifies
  14905. * child segment
  14906. */
  14907. MDCSegmentedButton.prototype.selectSegment = function (indexOrSegmentId) {
  14908. this.foundation.selectSegment(indexOrSegmentId);
  14909. };
  14910. /**
  14911. * Sets identified segment to be not selected
  14912. *
  14913. * @param indexOrSegmentId Number index or string segmentId that identifies
  14914. * child segment
  14915. */
  14916. MDCSegmentedButton.prototype.unselectSegment = function (indexOrSegmentId) {
  14917. this.foundation.unselectSegment(indexOrSegmentId);
  14918. };
  14919. /**
  14920. * @param indexOrSegmentId Number index or string segmentId that identifies
  14921. * child segment
  14922. * @return Returns true if identified child segment is currently selected,
  14923. * otherwise returns false
  14924. */
  14925. MDCSegmentedButton.prototype.isSegmentSelected = function (indexOrSegmentId) {
  14926. return this.foundation.isSegmentSelected(indexOrSegmentId);
  14927. };
  14928. /**
  14929. * @return Returns child segments mapped to readonly SegmentDetail list
  14930. */
  14931. MDCSegmentedButton.prototype.mappedSegments = function () {
  14932. return this.segments_.map(function (segment, index) {
  14933. return {
  14934. index: index,
  14935. selected: segment.isSelected(),
  14936. segmentId: segment.getSegmentId()
  14937. };
  14938. });
  14939. };
  14940. return MDCSegmentedButton;
  14941. }(component_1.MDCComponent);
  14942. exports.MDCSegmentedButton = MDCSegmentedButton;
  14943. /***/ }),
  14944. /***/ "./packages/mdc-segmented-button/segmented-button/constants.ts":
  14945. /*!*********************************************************************!*\
  14946. !*** ./packages/mdc-segmented-button/segmented-button/constants.ts ***!
  14947. \*********************************************************************/
  14948. /*! no static exports found */
  14949. /***/ (function(module, exports, __webpack_require__) {
  14950. "use strict";
  14951. /**
  14952. * @license
  14953. * Copyright 2020 Google Inc.
  14954. *
  14955. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14956. * of this software and associated documentation files (the "Software"), to deal
  14957. * in the Software without restriction, including without limitation the rights
  14958. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14959. * copies of the Software, and to permit persons to whom the Software is
  14960. * furnished to do so, subject to the following conditions:
  14961. *
  14962. * The above copyright notice and this permission notice shall be included in
  14963. * all copies or substantial portions of the Software.
  14964. *
  14965. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14966. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14967. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14968. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14969. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14970. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14971. * THE SOFTWARE.
  14972. */
  14973. Object.defineProperty(exports, "__esModule", { value: true });
  14974. /**
  14975. * Selectors used by segmented-button
  14976. */
  14977. exports.selectors = {
  14978. SEGMENT: '.mdc-segmented-button__segment'
  14979. };
  14980. /**
  14981. * Events received or emitted by segmented-button
  14982. */
  14983. exports.events = {
  14984. SELECTED: 'selected',
  14985. CHANGE: 'change'
  14986. };
  14987. /**
  14988. * Style classes for segmented-button
  14989. */
  14990. exports.cssClasses = {
  14991. SINGLE_SELECT: 'mdc-segmented-button--single-select'
  14992. };
  14993. /***/ }),
  14994. /***/ "./packages/mdc-segmented-button/segmented-button/foundation.ts":
  14995. /*!**********************************************************************!*\
  14996. !*** ./packages/mdc-segmented-button/segmented-button/foundation.ts ***!
  14997. \**********************************************************************/
  14998. /*! no static exports found */
  14999. /***/ (function(module, exports, __webpack_require__) {
  15000. "use strict";
  15001. /**
  15002. * @license
  15003. * Copyright 2020 Google Inc.
  15004. *
  15005. * Permission is hereby granted, free of charge, to any person obtaining a copy
  15006. * of this software and associated documentation files (the "Software"), to deal
  15007. * in the Software without restriction, including without limitation the rights
  15008. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15009. * copies of the Software, and to permit persons to whom the Software is
  15010. * furnished to do so, subject to the following conditions:
  15011. *
  15012. * The above copyright notice and this permission notice shall be included in
  15013. * all copies or substantial portions of the Software.
  15014. *
  15015. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15016. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15017. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15018. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15019. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15020. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  15021. * THE SOFTWARE.
  15022. */
  15023. var __extends = this && this.__extends || function () {
  15024. var _extendStatics = function extendStatics(d, b) {
  15025. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  15026. d.__proto__ = b;
  15027. } || function (d, b) {
  15028. for (var p in b) {
  15029. if (b.hasOwnProperty(p)) d[p] = b[p];
  15030. }
  15031. };
  15032. return _extendStatics(d, b);
  15033. };
  15034. return function (d, b) {
  15035. _extendStatics(d, b);
  15036. function __() {
  15037. this.constructor = d;
  15038. }
  15039. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15040. };
  15041. }();
  15042. var __assign = this && this.__assign || function () {
  15043. __assign = Object.assign || function (t) {
  15044. for (var s, i = 1, n = arguments.length; i < n; i++) {
  15045. s = arguments[i];
  15046. for (var p in s) {
  15047. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  15048. }
  15049. }
  15050. return t;
  15051. };
  15052. return __assign.apply(this, arguments);
  15053. };
  15054. var __values = this && this.__values || function (o) {
  15055. var s = typeof Symbol === "function" && Symbol.iterator,
  15056. m = s && o[s],
  15057. i = 0;
  15058. if (m) return m.call(o);
  15059. if (o && typeof o.length === "number") return {
  15060. next: function next() {
  15061. if (o && i >= o.length) o = void 0;
  15062. return { value: o && o[i++], done: !o };
  15063. }
  15064. };
  15065. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  15066. };
  15067. Object.defineProperty(exports, "__esModule", { value: true });
  15068. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  15069. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segmented-button/constants.ts");
  15070. var MDCSegmentedButtonFoundation = /** @class */function (_super) {
  15071. __extends(MDCSegmentedButtonFoundation, _super);
  15072. function MDCSegmentedButtonFoundation(adapter) {
  15073. return _super.call(this, __assign(__assign({}, MDCSegmentedButtonFoundation.defaultAdapter), adapter)) || this;
  15074. }
  15075. Object.defineProperty(MDCSegmentedButtonFoundation, "defaultAdapter", {
  15076. get: function get() {
  15077. return {
  15078. hasClass: function hasClass() {
  15079. return false;
  15080. }, getSegments: function getSegments() {
  15081. return [];
  15082. },
  15083. selectSegment: function selectSegment() {
  15084. return undefined;
  15085. },
  15086. unselectSegment: function unselectSegment() {
  15087. return undefined;
  15088. },
  15089. notifySelectedChange: function notifySelectedChange() {
  15090. return undefined;
  15091. }
  15092. };
  15093. },
  15094. enumerable: true,
  15095. configurable: true
  15096. });
  15097. /**
  15098. * Sets identified child segment to be selected
  15099. *
  15100. * @param indexOrSegmentId Number index or string segmentId that identifies
  15101. * child segment
  15102. */
  15103. MDCSegmentedButtonFoundation.prototype.selectSegment = function (indexOrSegmentId) {
  15104. this.adapter.selectSegment(indexOrSegmentId);
  15105. };
  15106. /**
  15107. * Sets identified child segment to be not selected
  15108. *
  15109. * @param indexOrSegmentId Number index or string segmentId that identifies
  15110. * child segment
  15111. */
  15112. MDCSegmentedButtonFoundation.prototype.unselectSegment = function (indexOrSegmentId) {
  15113. this.adapter.unselectSegment(indexOrSegmentId);
  15114. };
  15115. /**
  15116. * @return Returns currently selected child segments as readonly list of
  15117. * SegmentDetails
  15118. */
  15119. MDCSegmentedButtonFoundation.prototype.getSelectedSegments = function () {
  15120. return this.adapter.getSegments().filter(function (segmentDetail) {
  15121. return segmentDetail.selected;
  15122. });
  15123. };
  15124. /**
  15125. * @param indexOrSegmentId Number index or string segmentId that identifies
  15126. * child segment
  15127. * @return Returns true if identified child segment is currently selected,
  15128. * otherwise returns false
  15129. */
  15130. MDCSegmentedButtonFoundation.prototype.isSegmentSelected = function (indexOrSegmentId) {
  15131. return this.adapter.getSegments().some(function (segmentDetail) {
  15132. return (segmentDetail.index === indexOrSegmentId || segmentDetail.segmentId === indexOrSegmentId) && segmentDetail.selected;
  15133. });
  15134. };
  15135. /**
  15136. * @return Returns true if segmented button is single select, otherwise
  15137. * returns false
  15138. */
  15139. MDCSegmentedButtonFoundation.prototype.isSingleSelect = function () {
  15140. return this.adapter.hasClass(constants_1.cssClasses.SINGLE_SELECT);
  15141. };
  15142. /**
  15143. * Called when child segment's selected status may have changed. If segmented
  15144. * button is single select, unselects all child segments other than identified
  15145. * child segment. Finally, emits event to client.
  15146. *
  15147. * @param detail Child segment affected represented as SegmentDetail
  15148. * @event change With detail - SegmentDetail
  15149. */
  15150. MDCSegmentedButtonFoundation.prototype.handleSelected = function (detail) {
  15151. if (this.isSingleSelect()) {
  15152. this.unselectPrevSelected(detail.index);
  15153. }
  15154. this.adapter.notifySelectedChange(detail);
  15155. };
  15156. /**
  15157. * Sets all child segments to be not selected except for child segment
  15158. * identified by index
  15159. *
  15160. * @param index Index of child segment to not unselect
  15161. */
  15162. MDCSegmentedButtonFoundation.prototype.unselectPrevSelected = function (index) {
  15163. var e_1, _a;
  15164. try {
  15165. for (var _b = __values(this.getSelectedSegments()), _c = _b.next(); !_c.done; _c = _b.next()) {
  15166. var selectedSegment = _c.value;
  15167. if (selectedSegment.index !== index) {
  15168. this.unselectSegment(selectedSegment.index);
  15169. }
  15170. }
  15171. } catch (e_1_1) {
  15172. e_1 = { error: e_1_1 };
  15173. } finally {
  15174. try {
  15175. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  15176. } finally {
  15177. if (e_1) throw e_1.error;
  15178. }
  15179. }
  15180. };
  15181. return MDCSegmentedButtonFoundation;
  15182. }(foundation_1.MDCFoundation);
  15183. exports.MDCSegmentedButtonFoundation = MDCSegmentedButtonFoundation;
  15184. /***/ }),
  15185. /***/ "./packages/mdc-segmented-button/segmented-button/index.ts":
  15186. /*!*****************************************************************!*\
  15187. !*** ./packages/mdc-segmented-button/segmented-button/index.ts ***!
  15188. \*****************************************************************/
  15189. /*! no static exports found */
  15190. /***/ (function(module, exports, __webpack_require__) {
  15191. "use strict";
  15192. /**
  15193. * @license
  15194. * Copyright 2020 Google Inc.
  15195. *
  15196. * Permission is hereby granted, free of charge, to any person obtaining a copy
  15197. * of this software and associated documentation files (the "Software"), to deal
  15198. * in the Software without restriction, including without limitation the rights
  15199. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15200. * copies of the Software, and to permit persons to whom the Software is
  15201. * furnished to do so, subject to the following conditions:
  15202. *
  15203. * The above copyright notice and this permission notice shall be included in
  15204. * all copies or substantial portions of the Software.
  15205. *
  15206. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15207. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15208. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15209. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15210. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15211. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  15212. * THE SOFTWARE.
  15213. */
  15214. function __export(m) {
  15215. for (var p in m) {
  15216. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  15217. }
  15218. }
  15219. Object.defineProperty(exports, "__esModule", { value: true });
  15220. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segmented-button/foundation.ts"));
  15221. __export(__webpack_require__(/*! ./component */ "./packages/mdc-segmented-button/segmented-button/component.ts"));
  15222. /***/ }),
  15223. /***/ "./packages/mdc-select/component.ts":
  15224. /*!******************************************!*\
  15225. !*** ./packages/mdc-select/component.ts ***!
  15226. \******************************************/
  15227. /*! no static exports found */
  15228. /***/ (function(module, exports, __webpack_require__) {
  15229. "use strict";
  15230. /**
  15231. * @license
  15232. * Copyright 2016 Google Inc.
  15233. *
  15234. * Permission is hereby granted, free of charge, to any person obtaining a copy
  15235. * of this software and associated documentation files (the "Software"), to deal
  15236. * in the Software without restriction, including without limitation the rights
  15237. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15238. * copies of the Software, and to permit persons to whom the Software is
  15239. * furnished to do so, subject to the following conditions:
  15240. *
  15241. * The above copyright notice and this permission notice shall be included in
  15242. * all copies or substantial portions of the Software.
  15243. *
  15244. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15245. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15246. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15247. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15248. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15249. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  15250. * THE SOFTWARE.
  15251. */
  15252. var __extends = this && this.__extends || function () {
  15253. var _extendStatics = function extendStatics(d, b) {
  15254. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  15255. d.__proto__ = b;
  15256. } || function (d, b) {
  15257. for (var p in b) {
  15258. if (b.hasOwnProperty(p)) d[p] = b[p];
  15259. }
  15260. };
  15261. return _extendStatics(d, b);
  15262. };
  15263. return function (d, b) {
  15264. _extendStatics(d, b);
  15265. function __() {
  15266. this.constructor = d;
  15267. }
  15268. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15269. };
  15270. }();
  15271. var __assign = this && this.__assign || function () {
  15272. __assign = Object.assign || function (t) {
  15273. for (var s, i = 1, n = arguments.length; i < n; i++) {
  15274. s = arguments[i];
  15275. for (var p in s) {
  15276. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  15277. }
  15278. }
  15279. return t;
  15280. };
  15281. return __assign.apply(this, arguments);
  15282. };
  15283. var __importStar = this && this.__importStar || function (mod) {
  15284. if (mod && mod.__esModule) return mod;
  15285. var result = {};
  15286. if (mod != null) for (var k in mod) {
  15287. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  15288. }result["default"] = mod;
  15289. return result;
  15290. };
  15291. Object.defineProperty(exports, "__esModule", { value: true });
  15292. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  15293. var component_2 = __webpack_require__(/*! @material/floating-label/component */ "./packages/mdc-floating-label/component.ts");
  15294. var component_3 = __webpack_require__(/*! @material/line-ripple/component */ "./packages/mdc-line-ripple/component.ts");
  15295. var menuSurfaceConstants = __importStar(__webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts"));
  15296. var component_4 = __webpack_require__(/*! @material/menu/component */ "./packages/mdc-menu/component.ts");
  15297. var menuConstants = __importStar(__webpack_require__(/*! @material/menu/constants */ "./packages/mdc-menu/constants.ts"));
  15298. var component_5 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
  15299. var component_6 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  15300. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  15301. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
  15302. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts");
  15303. var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-select/helper-text/component.ts");
  15304. var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-select/icon/component.ts");
  15305. var MDCSelect = /** @class */function (_super) {
  15306. __extends(MDCSelect, _super);
  15307. function MDCSelect() {
  15308. return _super !== null && _super.apply(this, arguments) || this;
  15309. }
  15310. MDCSelect.attachTo = function (root) {
  15311. return new MDCSelect(root);
  15312. };
  15313. MDCSelect.prototype.initialize = function (labelFactory, lineRippleFactory, outlineFactory, menuFactory, iconFactory, helperTextFactory) {
  15314. if (labelFactory === void 0) {
  15315. labelFactory = function labelFactory(el) {
  15316. return new component_2.MDCFloatingLabel(el);
  15317. };
  15318. }
  15319. if (lineRippleFactory === void 0) {
  15320. lineRippleFactory = function lineRippleFactory(el) {
  15321. return new component_3.MDCLineRipple(el);
  15322. };
  15323. }
  15324. if (outlineFactory === void 0) {
  15325. outlineFactory = function outlineFactory(el) {
  15326. return new component_5.MDCNotchedOutline(el);
  15327. };
  15328. }
  15329. if (menuFactory === void 0) {
  15330. menuFactory = function menuFactory(el) {
  15331. return new component_4.MDCMenu(el);
  15332. };
  15333. }
  15334. if (iconFactory === void 0) {
  15335. iconFactory = function iconFactory(el) {
  15336. return new component_8.MDCSelectIcon(el);
  15337. };
  15338. }
  15339. if (helperTextFactory === void 0) {
  15340. helperTextFactory = function helperTextFactory(el) {
  15341. return new component_7.MDCSelectHelperText(el);
  15342. };
  15343. }
  15344. this.selectAnchor = this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
  15345. this.selectedText = this.root.querySelector(constants_1.strings.SELECTED_TEXT_SELECTOR);
  15346. this.hiddenInput = this.root.querySelector(constants_1.strings.HIDDEN_INPUT_SELECTOR);
  15347. if (!this.selectedText) {
  15348. throw new Error('MDCSelect: Missing required element: The following selector must be present: ' + ("'" + constants_1.strings.SELECTED_TEXT_SELECTOR + "'"));
  15349. }
  15350. if (this.selectAnchor.hasAttribute(constants_1.strings.ARIA_CONTROLS)) {
  15351. var helperTextElement = document.getElementById(this.selectAnchor.getAttribute(constants_1.strings.ARIA_CONTROLS));
  15352. if (helperTextElement) {
  15353. this.helperText = helperTextFactory(helperTextElement);
  15354. }
  15355. }
  15356. this.menuSetup(menuFactory);
  15357. var labelElement = this.root.querySelector(constants_1.strings.LABEL_SELECTOR);
  15358. this.label = labelElement ? labelFactory(labelElement) : null;
  15359. var lineRippleElement = this.root.querySelector(constants_1.strings.LINE_RIPPLE_SELECTOR);
  15360. this.lineRipple = lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
  15361. var outlineElement = this.root.querySelector(constants_1.strings.OUTLINE_SELECTOR);
  15362. this.outline = outlineElement ? outlineFactory(outlineElement) : null;
  15363. var leadingIcon = this.root.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
  15364. if (leadingIcon) {
  15365. this.leadingIcon = iconFactory(leadingIcon);
  15366. }
  15367. if (!this.root.classList.contains(constants_1.cssClasses.OUTLINED)) {
  15368. this.ripple = this.createRipple();
  15369. }
  15370. };
  15371. /**
  15372. * Initializes the select's event listeners and internal state based
  15373. * on the environment's state.
  15374. */
  15375. MDCSelect.prototype.initialSyncWithDOM = function () {
  15376. var _this = this;
  15377. this.handleFocus = function () {
  15378. _this.foundation.handleFocus();
  15379. };
  15380. this.handleBlur = function () {
  15381. _this.foundation.handleBlur();
  15382. };
  15383. this.handleClick = function (evt) {
  15384. _this.selectAnchor.focus();
  15385. _this.foundation.handleClick(_this.getNormalizedXCoordinate(evt));
  15386. };
  15387. this.handleKeydown = function (evt) {
  15388. _this.foundation.handleKeydown(evt);
  15389. };
  15390. this.handleMenuItemAction = function (evt) {
  15391. _this.foundation.handleMenuItemAction(evt.detail.index);
  15392. };
  15393. this.handleMenuOpened = function () {
  15394. _this.foundation.handleMenuOpened();
  15395. };
  15396. this.handleMenuClosed = function () {
  15397. _this.foundation.handleMenuClosed();
  15398. };
  15399. this.handleMenuClosing = function () {
  15400. _this.foundation.handleMenuClosing();
  15401. };
  15402. this.selectAnchor.addEventListener('focus', this.handleFocus);
  15403. this.selectAnchor.addEventListener('blur', this.handleBlur);
  15404. this.selectAnchor.addEventListener('click', this.handleClick);
  15405. this.selectAnchor.addEventListener('keydown', this.handleKeydown);
  15406. this.menu.listen(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
  15407. this.menu.listen(menuSurfaceConstants.strings.CLOSING_EVENT, this.handleMenuClosing);
  15408. this.menu.listen(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
  15409. this.menu.listen(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
  15410. if (this.hiddenInput) {
  15411. if (this.hiddenInput.value) {
  15412. // If the hidden input already has a value, use it to restore the
  15413. // select's value. This can happen e.g. if the user goes back or (in
  15414. // some browsers) refreshes the page.
  15415. this.foundation.setValue(this.hiddenInput.value, /** skipNotify */true);
  15416. this.foundation.layout();
  15417. return;
  15418. }
  15419. this.hiddenInput.value = this.value;
  15420. }
  15421. };
  15422. MDCSelect.prototype.destroy = function () {
  15423. this.selectAnchor.removeEventListener('focus', this.handleFocus);
  15424. this.selectAnchor.removeEventListener('blur', this.handleBlur);
  15425. this.selectAnchor.removeEventListener('keydown', this.handleKeydown);
  15426. this.selectAnchor.removeEventListener('click', this.handleClick);
  15427. this.menu.unlisten(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
  15428. this.menu.unlisten(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
  15429. this.menu.unlisten(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
  15430. this.menu.destroy();
  15431. if (this.ripple) {
  15432. this.ripple.destroy();
  15433. }
  15434. if (this.outline) {
  15435. this.outline.destroy();
  15436. }
  15437. if (this.leadingIcon) {
  15438. this.leadingIcon.destroy();
  15439. }
  15440. if (this.helperText) {
  15441. this.helperText.destroy();
  15442. }
  15443. _super.prototype.destroy.call(this);
  15444. };
  15445. Object.defineProperty(MDCSelect.prototype, "value", {
  15446. get: function get() {
  15447. return this.foundation.getValue();
  15448. },
  15449. set: function set(value) {
  15450. this.foundation.setValue(value);
  15451. },
  15452. enumerable: true,
  15453. configurable: true
  15454. });
  15455. Object.defineProperty(MDCSelect.prototype, "selectedIndex", {
  15456. get: function get() {
  15457. return this.foundation.getSelectedIndex();
  15458. },
  15459. set: function set(selectedIndex) {
  15460. this.foundation.setSelectedIndex(selectedIndex, /** closeMenu */true);
  15461. },
  15462. enumerable: true,
  15463. configurable: true
  15464. });
  15465. Object.defineProperty(MDCSelect.prototype, "disabled", {
  15466. get: function get() {
  15467. return this.foundation.getDisabled();
  15468. },
  15469. set: function set(disabled) {
  15470. this.foundation.setDisabled(disabled);
  15471. if (this.hiddenInput) {
  15472. this.hiddenInput.disabled = disabled;
  15473. }
  15474. },
  15475. enumerable: true,
  15476. configurable: true
  15477. });
  15478. Object.defineProperty(MDCSelect.prototype, "leadingIconAriaLabel", {
  15479. set: function set(label) {
  15480. this.foundation.setLeadingIconAriaLabel(label);
  15481. },
  15482. enumerable: true,
  15483. configurable: true
  15484. });
  15485. Object.defineProperty(MDCSelect.prototype, "leadingIconContent", {
  15486. /**
  15487. * Sets the text content of the leading icon.
  15488. */
  15489. set: function set(content) {
  15490. this.foundation.setLeadingIconContent(content);
  15491. },
  15492. enumerable: true,
  15493. configurable: true
  15494. });
  15495. Object.defineProperty(MDCSelect.prototype, "helperTextContent", {
  15496. /**
  15497. * Sets the text content of the helper text.
  15498. */
  15499. set: function set(content) {
  15500. this.foundation.setHelperTextContent(content);
  15501. },
  15502. enumerable: true,
  15503. configurable: true
  15504. });
  15505. Object.defineProperty(MDCSelect.prototype, "useDefaultValidation", {
  15506. /**
  15507. * Enables or disables the default validation scheme where a required select
  15508. * must be non-empty. Set to false for custom validation.
  15509. * @param useDefaultValidation Set this to false to ignore default
  15510. * validation scheme.
  15511. */
  15512. set: function set(useDefaultValidation) {
  15513. this.foundation.setUseDefaultValidation(useDefaultValidation);
  15514. },
  15515. enumerable: true,
  15516. configurable: true
  15517. });
  15518. Object.defineProperty(MDCSelect.prototype, "valid", {
  15519. /**
  15520. * Checks if the select is in a valid state.
  15521. */
  15522. get: function get() {
  15523. return this.foundation.isValid();
  15524. },
  15525. /**
  15526. * Sets the current invalid state of the select.
  15527. */
  15528. set: function set(isValid) {
  15529. this.foundation.setValid(isValid);
  15530. },
  15531. enumerable: true,
  15532. configurable: true
  15533. });
  15534. Object.defineProperty(MDCSelect.prototype, "required", {
  15535. /**
  15536. * Returns whether the select is required.
  15537. */
  15538. get: function get() {
  15539. return this.foundation.getRequired();
  15540. },
  15541. /**
  15542. * Sets the control to the required state.
  15543. */
  15544. set: function set(isRequired) {
  15545. this.foundation.setRequired(isRequired);
  15546. },
  15547. enumerable: true,
  15548. configurable: true
  15549. });
  15550. /**
  15551. * Re-calculates if the notched outline should be notched and if the label
  15552. * should float.
  15553. */
  15554. MDCSelect.prototype.layout = function () {
  15555. this.foundation.layout();
  15556. };
  15557. /**
  15558. * Synchronizes the list of options with the state of the foundation. Call
  15559. * this whenever menu options are dynamically updated.
  15560. */
  15561. MDCSelect.prototype.layoutOptions = function () {
  15562. this.foundation.layoutOptions();
  15563. this.menu.layout();
  15564. // Update cached menuItemValues for adapter.
  15565. this.menuItemValues = this.menu.items.map(function (el) {
  15566. return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
  15567. });
  15568. if (this.hiddenInput) {
  15569. this.hiddenInput.value = this.value;
  15570. }
  15571. };
  15572. MDCSelect.prototype.getDefaultFoundation = function () {
  15573. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  15574. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  15575. var adapter = __assign(__assign(__assign(__assign({}, this.getSelectAdapterMethods()), this.getCommonAdapterMethods()), this.getOutlineAdapterMethods()), this.getLabelAdapterMethods());
  15576. return new foundation_2.MDCSelectFoundation(adapter, this.getFoundationMap());
  15577. };
  15578. /**
  15579. * Handles setup for the menu.
  15580. */
  15581. MDCSelect.prototype.menuSetup = function (menuFactory) {
  15582. this.menuElement = this.root.querySelector(constants_1.strings.MENU_SELECTOR);
  15583. this.menu = menuFactory(this.menuElement);
  15584. this.menu.hasTypeahead = true;
  15585. this.menu.singleSelection = true;
  15586. this.menuItemValues = this.menu.items.map(function (el) {
  15587. return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
  15588. });
  15589. };
  15590. MDCSelect.prototype.createRipple = function () {
  15591. var _this = this;
  15592. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  15593. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  15594. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15595. var adapter = __assign(__assign({}, component_6.MDCRipple.createAdapter({ root: this.selectAnchor })), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  15596. _this.selectAnchor.addEventListener(evtType, handler);
  15597. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  15598. _this.selectAnchor.removeEventListener(evtType, handler);
  15599. } });
  15600. // tslint:enable:object-literal-sort-keys
  15601. return new component_6.MDCRipple(this.selectAnchor, new foundation_1.MDCRippleFoundation(adapter));
  15602. };
  15603. MDCSelect.prototype.getSelectAdapterMethods = function () {
  15604. var _this = this;
  15605. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15606. return {
  15607. getMenuItemAttr: function getMenuItemAttr(menuItem, attr) {
  15608. return menuItem.getAttribute(attr);
  15609. },
  15610. setSelectedText: function setSelectedText(text) {
  15611. _this.selectedText.textContent = text;
  15612. },
  15613. isSelectAnchorFocused: function isSelectAnchorFocused() {
  15614. return document.activeElement === _this.selectAnchor;
  15615. },
  15616. getSelectAnchorAttr: function getSelectAnchorAttr(attr) {
  15617. return _this.selectAnchor.getAttribute(attr);
  15618. },
  15619. setSelectAnchorAttr: function setSelectAnchorAttr(attr, value) {
  15620. _this.selectAnchor.setAttribute(attr, value);
  15621. },
  15622. removeSelectAnchorAttr: function removeSelectAnchorAttr(attr) {
  15623. _this.selectAnchor.removeAttribute(attr);
  15624. },
  15625. addMenuClass: function addMenuClass(className) {
  15626. _this.menuElement.classList.add(className);
  15627. },
  15628. removeMenuClass: function removeMenuClass(className) {
  15629. _this.menuElement.classList.remove(className);
  15630. },
  15631. openMenu: function openMenu() {
  15632. _this.menu.open = true;
  15633. },
  15634. closeMenu: function closeMenu() {
  15635. _this.menu.open = false;
  15636. },
  15637. getAnchorElement: function getAnchorElement() {
  15638. return _this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
  15639. },
  15640. setMenuAnchorElement: function setMenuAnchorElement(anchorEl) {
  15641. _this.menu.setAnchorElement(anchorEl);
  15642. },
  15643. setMenuAnchorCorner: function setMenuAnchorCorner(anchorCorner) {
  15644. _this.menu.setAnchorCorner(anchorCorner);
  15645. },
  15646. setMenuWrapFocus: function setMenuWrapFocus(wrapFocus) {
  15647. _this.menu.wrapFocus = wrapFocus;
  15648. },
  15649. getSelectedIndex: function getSelectedIndex() {
  15650. var index = _this.menu.selectedIndex;
  15651. return index instanceof Array ? index[0] : index;
  15652. },
  15653. setSelectedIndex: function setSelectedIndex(index) {
  15654. _this.menu.selectedIndex = index;
  15655. },
  15656. focusMenuItemAtIndex: function focusMenuItemAtIndex(index) {
  15657. _this.menu.items[index].focus();
  15658. },
  15659. getMenuItemCount: function getMenuItemCount() {
  15660. return _this.menu.items.length;
  15661. },
  15662. // Cache menu item values. layoutOptions() updates this cache.
  15663. getMenuItemValues: function getMenuItemValues() {
  15664. return _this.menuItemValues;
  15665. },
  15666. getMenuItemTextAtIndex: function getMenuItemTextAtIndex(index) {
  15667. return _this.menu.getPrimaryTextAtIndex(index);
  15668. },
  15669. isTypeaheadInProgress: function isTypeaheadInProgress() {
  15670. return _this.menu.typeaheadInProgress;
  15671. },
  15672. typeaheadMatchItem: function typeaheadMatchItem(nextChar, startingIndex) {
  15673. return _this.menu.typeaheadMatchItem(nextChar, startingIndex);
  15674. }
  15675. };
  15676. // tslint:enable:object-literal-sort-keys
  15677. };
  15678. MDCSelect.prototype.getCommonAdapterMethods = function () {
  15679. var _this = this;
  15680. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15681. return {
  15682. addClass: function addClass(className) {
  15683. _this.root.classList.add(className);
  15684. },
  15685. removeClass: function removeClass(className) {
  15686. _this.root.classList.remove(className);
  15687. },
  15688. hasClass: function hasClass(className) {
  15689. return _this.root.classList.contains(className);
  15690. },
  15691. setRippleCenter: function setRippleCenter(normalizedX) {
  15692. _this.lineRipple && _this.lineRipple.setRippleCenter(normalizedX);
  15693. },
  15694. activateBottomLine: function activateBottomLine() {
  15695. _this.lineRipple && _this.lineRipple.activate();
  15696. },
  15697. deactivateBottomLine: function deactivateBottomLine() {
  15698. _this.lineRipple && _this.lineRipple.deactivate();
  15699. },
  15700. notifyChange: function notifyChange(value) {
  15701. var index = _this.selectedIndex;
  15702. _this.emit(constants_1.strings.CHANGE_EVENT, { value: value, index: index }, true /* shouldBubble */);
  15703. if (_this.hiddenInput) {
  15704. _this.hiddenInput.value = value;
  15705. }
  15706. }
  15707. };
  15708. // tslint:enable:object-literal-sort-keys
  15709. };
  15710. MDCSelect.prototype.getOutlineAdapterMethods = function () {
  15711. var _this = this;
  15712. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15713. return {
  15714. hasOutline: function hasOutline() {
  15715. return Boolean(_this.outline);
  15716. },
  15717. notchOutline: function notchOutline(labelWidth) {
  15718. _this.outline && _this.outline.notch(labelWidth);
  15719. },
  15720. closeOutline: function closeOutline() {
  15721. _this.outline && _this.outline.closeNotch();
  15722. }
  15723. };
  15724. // tslint:enable:object-literal-sort-keys
  15725. };
  15726. MDCSelect.prototype.getLabelAdapterMethods = function () {
  15727. var _this = this;
  15728. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15729. return {
  15730. hasLabel: function hasLabel() {
  15731. return !!_this.label;
  15732. },
  15733. floatLabel: function floatLabel(shouldFloat) {
  15734. _this.label && _this.label.float(shouldFloat);
  15735. },
  15736. getLabelWidth: function getLabelWidth() {
  15737. return _this.label ? _this.label.getWidth() : 0;
  15738. },
  15739. setLabelRequired: function setLabelRequired(isRequired) {
  15740. _this.label && _this.label.setRequired(isRequired);
  15741. }
  15742. };
  15743. // tslint:enable:object-literal-sort-keys
  15744. };
  15745. /**
  15746. * Calculates where the line ripple should start based on the x coordinate within the component.
  15747. */
  15748. MDCSelect.prototype.getNormalizedXCoordinate = function (evt) {
  15749. var targetClientRect = evt.target.getBoundingClientRect();
  15750. var xCoordinate = this.isTouchEvent(evt) ? evt.touches[0].clientX : evt.clientX;
  15751. return xCoordinate - targetClientRect.left;
  15752. };
  15753. MDCSelect.prototype.isTouchEvent = function (evt) {
  15754. return Boolean(evt.touches);
  15755. };
  15756. /**
  15757. * Returns a map of all subcomponents to subfoundations.
  15758. */
  15759. MDCSelect.prototype.getFoundationMap = function () {
  15760. return {
  15761. helperText: this.helperText ? this.helperText.foundationForSelect : undefined,
  15762. leadingIcon: this.leadingIcon ? this.leadingIcon.foundationForSelect : undefined
  15763. };
  15764. };
  15765. return MDCSelect;
  15766. }(component_1.MDCComponent);
  15767. exports.MDCSelect = MDCSelect;
  15768. /***/ }),
  15769. /***/ "./packages/mdc-select/constants.ts":
  15770. /*!******************************************!*\
  15771. !*** ./packages/mdc-select/constants.ts ***!
  15772. \******************************************/
  15773. /*! no static exports found */
  15774. /***/ (function(module, exports, __webpack_require__) {
  15775. "use strict";
  15776. /**
  15777. * @license
  15778. * Copyright 2016 Google Inc.
  15779. *
  15780. * Permission is hereby granted, free of charge, to any person obtaining a copy
  15781. * of this software and associated documentation files (the "Software"), to deal
  15782. * in the Software without restriction, including without limitation the rights
  15783. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15784. * copies of the Software, and to permit persons to whom the Software is
  15785. * furnished to do so, subject to the following conditions:
  15786. *
  15787. * The above copyright notice and this permission notice shall be included in
  15788. * all copies or substantial portions of the Software.
  15789. *
  15790. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15791. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15792. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15793. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15794. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15795. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  15796. * THE SOFTWARE.
  15797. */
  15798. Object.defineProperty(exports, "__esModule", { value: true });
  15799. var cssClasses = {
  15800. ACTIVATED: 'mdc-select--activated',
  15801. DISABLED: 'mdc-select--disabled',
  15802. FOCUSED: 'mdc-select--focused',
  15803. INVALID: 'mdc-select--invalid',
  15804. MENU_INVALID: 'mdc-select__menu--invalid',
  15805. OUTLINED: 'mdc-select--outlined',
  15806. REQUIRED: 'mdc-select--required',
  15807. ROOT: 'mdc-select',
  15808. WITH_LEADING_ICON: 'mdc-select--with-leading-icon'
  15809. };
  15810. exports.cssClasses = cssClasses;
  15811. var strings = {
  15812. ARIA_CONTROLS: 'aria-controls',
  15813. ARIA_DESCRIBEDBY: 'aria-describedby',
  15814. ARIA_SELECTED_ATTR: 'aria-selected',
  15815. CHANGE_EVENT: 'MDCSelect:change',
  15816. HIDDEN_INPUT_SELECTOR: 'input[type="hidden"]',
  15817. LABEL_SELECTOR: '.mdc-floating-label',
  15818. LEADING_ICON_SELECTOR: '.mdc-select__icon',
  15819. LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
  15820. MENU_SELECTOR: '.mdc-select__menu',
  15821. OUTLINE_SELECTOR: '.mdc-notched-outline',
  15822. SELECTED_TEXT_SELECTOR: '.mdc-select__selected-text',
  15823. SELECT_ANCHOR_SELECTOR: '.mdc-select__anchor',
  15824. VALUE_ATTR: 'data-value'
  15825. };
  15826. exports.strings = strings;
  15827. var numbers = {
  15828. LABEL_SCALE: 0.75,
  15829. UNSET_INDEX: -1,
  15830. CLICK_DEBOUNCE_TIMEOUT_MS: 330
  15831. };
  15832. exports.numbers = numbers;
  15833. /***/ }),
  15834. /***/ "./packages/mdc-select/foundation.ts":
  15835. /*!*******************************************!*\
  15836. !*** ./packages/mdc-select/foundation.ts ***!
  15837. \*******************************************/
  15838. /*! no static exports found */
  15839. /***/ (function(module, exports, __webpack_require__) {
  15840. "use strict";
  15841. /**
  15842. * @license
  15843. * Copyright 2016 Google Inc.
  15844. *
  15845. * Permission is hereby granted, free of charge, to any person obtaining a copy
  15846. * of this software and associated documentation files (the "Software"), to deal
  15847. * in the Software without restriction, including without limitation the rights
  15848. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15849. * copies of the Software, and to permit persons to whom the Software is
  15850. * furnished to do so, subject to the following conditions:
  15851. *
  15852. * The above copyright notice and this permission notice shall be included in
  15853. * all copies or substantial portions of the Software.
  15854. *
  15855. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15856. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15857. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15858. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15859. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15860. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  15861. * THE SOFTWARE.
  15862. */
  15863. var __extends = this && this.__extends || function () {
  15864. var _extendStatics = function extendStatics(d, b) {
  15865. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  15866. d.__proto__ = b;
  15867. } || function (d, b) {
  15868. for (var p in b) {
  15869. if (b.hasOwnProperty(p)) d[p] = b[p];
  15870. }
  15871. };
  15872. return _extendStatics(d, b);
  15873. };
  15874. return function (d, b) {
  15875. _extendStatics(d, b);
  15876. function __() {
  15877. this.constructor = d;
  15878. }
  15879. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15880. };
  15881. }();
  15882. var __assign = this && this.__assign || function () {
  15883. __assign = Object.assign || function (t) {
  15884. for (var s, i = 1, n = arguments.length; i < n; i++) {
  15885. s = arguments[i];
  15886. for (var p in s) {
  15887. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  15888. }
  15889. }
  15890. return t;
  15891. };
  15892. return __assign.apply(this, arguments);
  15893. };
  15894. Object.defineProperty(exports, "__esModule", { value: true });
  15895. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  15896. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  15897. var constants_1 = __webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts");
  15898. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
  15899. var MDCSelectFoundation = /** @class */function (_super) {
  15900. __extends(MDCSelectFoundation, _super);
  15901. /* istanbul ignore next: optional argument is not a branch statement */
  15902. /**
  15903. * @param adapter
  15904. * @param foundationMap Map from subcomponent names to their subfoundations.
  15905. */
  15906. function MDCSelectFoundation(adapter, foundationMap) {
  15907. if (foundationMap === void 0) {
  15908. foundationMap = {};
  15909. }
  15910. var _this = _super.call(this, __assign(__assign({}, MDCSelectFoundation.defaultAdapter), adapter)) || this;
  15911. // Disabled state
  15912. _this.disabled = false;
  15913. // isMenuOpen is used to track the state of the menu by listening to the
  15914. // MDCMenuSurface:closed event For reference, menu.open will return false if
  15915. // the menu is still closing, but isMenuOpen returns false only after the menu
  15916. // has closed
  15917. _this.isMenuOpen = false;
  15918. // By default, select is invalid if it is required but no value is selected.
  15919. _this.useDefaultValidation = true;
  15920. _this.customValidity = true;
  15921. _this.lastSelectedIndex = constants_2.numbers.UNSET_INDEX;
  15922. _this.clickDebounceTimeout = 0;
  15923. _this.recentlyClicked = false;
  15924. _this.leadingIcon = foundationMap.leadingIcon;
  15925. _this.helperText = foundationMap.helperText;
  15926. return _this;
  15927. }
  15928. Object.defineProperty(MDCSelectFoundation, "cssClasses", {
  15929. get: function get() {
  15930. return constants_2.cssClasses;
  15931. },
  15932. enumerable: true,
  15933. configurable: true
  15934. });
  15935. Object.defineProperty(MDCSelectFoundation, "numbers", {
  15936. get: function get() {
  15937. return constants_2.numbers;
  15938. },
  15939. enumerable: true,
  15940. configurable: true
  15941. });
  15942. Object.defineProperty(MDCSelectFoundation, "strings", {
  15943. get: function get() {
  15944. return constants_2.strings;
  15945. },
  15946. enumerable: true,
  15947. configurable: true
  15948. });
  15949. Object.defineProperty(MDCSelectFoundation, "defaultAdapter", {
  15950. /**
  15951. * See {@link MDCSelectAdapter} for typing information on parameters and return types.
  15952. */
  15953. get: function get() {
  15954. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15955. return {
  15956. addClass: function addClass() {
  15957. return undefined;
  15958. },
  15959. removeClass: function removeClass() {
  15960. return undefined;
  15961. },
  15962. hasClass: function hasClass() {
  15963. return false;
  15964. },
  15965. activateBottomLine: function activateBottomLine() {
  15966. return undefined;
  15967. },
  15968. deactivateBottomLine: function deactivateBottomLine() {
  15969. return undefined;
  15970. },
  15971. getSelectedIndex: function getSelectedIndex() {
  15972. return -1;
  15973. },
  15974. setSelectedIndex: function setSelectedIndex() {
  15975. return undefined;
  15976. },
  15977. hasLabel: function hasLabel() {
  15978. return false;
  15979. },
  15980. floatLabel: function floatLabel() {
  15981. return undefined;
  15982. },
  15983. getLabelWidth: function getLabelWidth() {
  15984. return 0;
  15985. },
  15986. setLabelRequired: function setLabelRequired() {
  15987. return undefined;
  15988. },
  15989. hasOutline: function hasOutline() {
  15990. return false;
  15991. },
  15992. notchOutline: function notchOutline() {
  15993. return undefined;
  15994. },
  15995. closeOutline: function closeOutline() {
  15996. return undefined;
  15997. },
  15998. setRippleCenter: function setRippleCenter() {
  15999. return undefined;
  16000. },
  16001. notifyChange: function notifyChange() {
  16002. return undefined;
  16003. },
  16004. setSelectedText: function setSelectedText() {
  16005. return undefined;
  16006. },
  16007. isSelectAnchorFocused: function isSelectAnchorFocused() {
  16008. return false;
  16009. },
  16010. getSelectAnchorAttr: function getSelectAnchorAttr() {
  16011. return '';
  16012. },
  16013. setSelectAnchorAttr: function setSelectAnchorAttr() {
  16014. return undefined;
  16015. },
  16016. removeSelectAnchorAttr: function removeSelectAnchorAttr() {
  16017. return undefined;
  16018. },
  16019. addMenuClass: function addMenuClass() {
  16020. return undefined;
  16021. },
  16022. removeMenuClass: function removeMenuClass() {
  16023. return undefined;
  16024. },
  16025. openMenu: function openMenu() {
  16026. return undefined;
  16027. },
  16028. closeMenu: function closeMenu() {
  16029. return undefined;
  16030. },
  16031. getAnchorElement: function getAnchorElement() {
  16032. return null;
  16033. },
  16034. setMenuAnchorElement: function setMenuAnchorElement() {
  16035. return undefined;
  16036. },
  16037. setMenuAnchorCorner: function setMenuAnchorCorner() {
  16038. return undefined;
  16039. },
  16040. setMenuWrapFocus: function setMenuWrapFocus() {
  16041. return undefined;
  16042. },
  16043. focusMenuItemAtIndex: function focusMenuItemAtIndex() {
  16044. return undefined;
  16045. },
  16046. getMenuItemCount: function getMenuItemCount() {
  16047. return 0;
  16048. },
  16049. getMenuItemValues: function getMenuItemValues() {
  16050. return [];
  16051. },
  16052. getMenuItemTextAtIndex: function getMenuItemTextAtIndex() {
  16053. return '';
  16054. },
  16055. isTypeaheadInProgress: function isTypeaheadInProgress() {
  16056. return false;
  16057. },
  16058. typeaheadMatchItem: function typeaheadMatchItem() {
  16059. return -1;
  16060. }
  16061. };
  16062. // tslint:enable:object-literal-sort-keys
  16063. },
  16064. enumerable: true,
  16065. configurable: true
  16066. });
  16067. /** Returns the index of the currently selected menu item, or -1 if none. */
  16068. MDCSelectFoundation.prototype.getSelectedIndex = function () {
  16069. return this.adapter.getSelectedIndex();
  16070. };
  16071. MDCSelectFoundation.prototype.setSelectedIndex = function (index, closeMenu, skipNotify) {
  16072. if (closeMenu === void 0) {
  16073. closeMenu = false;
  16074. }
  16075. if (skipNotify === void 0) {
  16076. skipNotify = false;
  16077. }
  16078. if (index >= this.adapter.getMenuItemCount()) {
  16079. return;
  16080. }
  16081. if (index === constants_2.numbers.UNSET_INDEX) {
  16082. this.adapter.setSelectedText('');
  16083. } else {
  16084. this.adapter.setSelectedText(this.adapter.getMenuItemTextAtIndex(index).trim());
  16085. }
  16086. this.adapter.setSelectedIndex(index);
  16087. if (closeMenu) {
  16088. this.adapter.closeMenu();
  16089. }
  16090. if (!skipNotify && this.lastSelectedIndex !== index) {
  16091. this.handleChange();
  16092. }
  16093. this.lastSelectedIndex = index;
  16094. };
  16095. MDCSelectFoundation.prototype.setValue = function (value, skipNotify) {
  16096. if (skipNotify === void 0) {
  16097. skipNotify = false;
  16098. }
  16099. var index = this.adapter.getMenuItemValues().indexOf(value);
  16100. this.setSelectedIndex(index, /** closeMenu */false, skipNotify);
  16101. };
  16102. MDCSelectFoundation.prototype.getValue = function () {
  16103. var index = this.adapter.getSelectedIndex();
  16104. var menuItemValues = this.adapter.getMenuItemValues();
  16105. return index !== constants_2.numbers.UNSET_INDEX ? menuItemValues[index] : '';
  16106. };
  16107. MDCSelectFoundation.prototype.getDisabled = function () {
  16108. return this.disabled;
  16109. };
  16110. MDCSelectFoundation.prototype.setDisabled = function (isDisabled) {
  16111. this.disabled = isDisabled;
  16112. if (this.disabled) {
  16113. this.adapter.addClass(constants_2.cssClasses.DISABLED);
  16114. this.adapter.closeMenu();
  16115. } else {
  16116. this.adapter.removeClass(constants_2.cssClasses.DISABLED);
  16117. }
  16118. if (this.leadingIcon) {
  16119. this.leadingIcon.setDisabled(this.disabled);
  16120. }
  16121. if (this.disabled) {
  16122. // Prevent click events from focusing select. Simply pointer-events: none
  16123. // is not enough since screenreader clicks may bypass this.
  16124. this.adapter.removeSelectAnchorAttr('tabindex');
  16125. } else {
  16126. this.adapter.setSelectAnchorAttr('tabindex', '0');
  16127. }
  16128. this.adapter.setSelectAnchorAttr('aria-disabled', this.disabled.toString());
  16129. };
  16130. /** Opens the menu. */
  16131. MDCSelectFoundation.prototype.openMenu = function () {
  16132. this.adapter.addClass(constants_2.cssClasses.ACTIVATED);
  16133. this.adapter.openMenu();
  16134. this.isMenuOpen = true;
  16135. this.adapter.setSelectAnchorAttr('aria-expanded', 'true');
  16136. };
  16137. /**
  16138. * @param content Sets the content of the helper text.
  16139. */
  16140. MDCSelectFoundation.prototype.setHelperTextContent = function (content) {
  16141. if (this.helperText) {
  16142. this.helperText.setContent(content);
  16143. }
  16144. };
  16145. /**
  16146. * Re-calculates if the notched outline should be notched and if the label
  16147. * should float.
  16148. */
  16149. MDCSelectFoundation.prototype.layout = function () {
  16150. if (this.adapter.hasLabel()) {
  16151. var optionHasValue = this.getValue().length > 0;
  16152. var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
  16153. var shouldFloatAndNotch = optionHasValue || isFocused;
  16154. var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
  16155. this.notchOutline(shouldFloatAndNotch);
  16156. this.adapter.floatLabel(shouldFloatAndNotch);
  16157. this.adapter.setLabelRequired(isRequired);
  16158. }
  16159. };
  16160. /**
  16161. * Synchronizes the list of options with the state of the foundation. Call
  16162. * this whenever menu options are dynamically updated.
  16163. */
  16164. MDCSelectFoundation.prototype.layoutOptions = function () {
  16165. var menuItemValues = this.adapter.getMenuItemValues();
  16166. var selectedIndex = menuItemValues.indexOf(this.getValue());
  16167. this.setSelectedIndex(selectedIndex, /** closeMenu */false, /** skipNotify */true);
  16168. };
  16169. MDCSelectFoundation.prototype.handleMenuOpened = function () {
  16170. if (this.adapter.getMenuItemValues().length === 0) {
  16171. return;
  16172. }
  16173. // Menu should open to the last selected element, should open to first menu item otherwise.
  16174. var selectedIndex = this.getSelectedIndex();
  16175. var focusItemIndex = selectedIndex >= 0 ? selectedIndex : 0;
  16176. this.adapter.focusMenuItemAtIndex(focusItemIndex);
  16177. };
  16178. MDCSelectFoundation.prototype.handleMenuClosing = function () {
  16179. this.adapter.setSelectAnchorAttr('aria-expanded', 'false');
  16180. };
  16181. MDCSelectFoundation.prototype.handleMenuClosed = function () {
  16182. this.adapter.removeClass(constants_2.cssClasses.ACTIVATED);
  16183. this.isMenuOpen = false;
  16184. // Unfocus the select if menu is closed without a selection
  16185. if (!this.adapter.isSelectAnchorFocused()) {
  16186. this.blur();
  16187. }
  16188. };
  16189. /**
  16190. * Handles value changes, via change event or programmatic updates.
  16191. */
  16192. MDCSelectFoundation.prototype.handleChange = function () {
  16193. this.layout();
  16194. this.adapter.notifyChange(this.getValue());
  16195. var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
  16196. if (isRequired && this.useDefaultValidation) {
  16197. this.setValid(this.isValid());
  16198. }
  16199. };
  16200. MDCSelectFoundation.prototype.handleMenuItemAction = function (index) {
  16201. this.setSelectedIndex(index, /** closeMenu */true);
  16202. };
  16203. /**
  16204. * Handles focus events from select element.
  16205. */
  16206. MDCSelectFoundation.prototype.handleFocus = function () {
  16207. this.adapter.addClass(constants_2.cssClasses.FOCUSED);
  16208. this.layout();
  16209. this.adapter.activateBottomLine();
  16210. };
  16211. /**
  16212. * Handles blur events from select element.
  16213. */
  16214. MDCSelectFoundation.prototype.handleBlur = function () {
  16215. if (this.isMenuOpen) {
  16216. return;
  16217. }
  16218. this.blur();
  16219. };
  16220. MDCSelectFoundation.prototype.handleClick = function (normalizedX) {
  16221. if (this.disabled || this.recentlyClicked) {
  16222. return;
  16223. }
  16224. this.setClickDebounceTimeout();
  16225. if (this.isMenuOpen) {
  16226. this.adapter.closeMenu();
  16227. return;
  16228. }
  16229. this.adapter.setRippleCenter(normalizedX);
  16230. this.openMenu();
  16231. };
  16232. /**
  16233. * Handles keydown events on select element. Depending on the type of
  16234. * character typed, does typeahead matching or opens menu.
  16235. */
  16236. MDCSelectFoundation.prototype.handleKeydown = function (event) {
  16237. if (this.isMenuOpen || !this.adapter.hasClass(constants_2.cssClasses.FOCUSED)) {
  16238. return;
  16239. }
  16240. var isEnter = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ENTER;
  16241. var isSpace = keyboard_1.normalizeKey(event) === keyboard_1.KEY.SPACEBAR;
  16242. var arrowUp = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_UP;
  16243. var arrowDown = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_DOWN;
  16244. // Typeahead
  16245. if (!isSpace && event.key && event.key.length === 1 || isSpace && this.adapter.isTypeaheadInProgress()) {
  16246. var key = isSpace ? ' ' : event.key;
  16247. var typeaheadNextIndex = this.adapter.typeaheadMatchItem(key, this.getSelectedIndex());
  16248. if (typeaheadNextIndex >= 0) {
  16249. this.setSelectedIndex(typeaheadNextIndex);
  16250. }
  16251. event.preventDefault();
  16252. return;
  16253. }
  16254. if (!isEnter && !isSpace && !arrowUp && !arrowDown) {
  16255. return;
  16256. }
  16257. // Increment/decrement index as necessary and open menu.
  16258. if (arrowUp && this.getSelectedIndex() > 0) {
  16259. this.setSelectedIndex(this.getSelectedIndex() - 1);
  16260. } else if (arrowDown && this.getSelectedIndex() < this.adapter.getMenuItemCount() - 1) {
  16261. this.setSelectedIndex(this.getSelectedIndex() + 1);
  16262. }
  16263. this.openMenu();
  16264. event.preventDefault();
  16265. };
  16266. /**
  16267. * Opens/closes the notched outline.
  16268. */
  16269. MDCSelectFoundation.prototype.notchOutline = function (openNotch) {
  16270. if (!this.adapter.hasOutline()) {
  16271. return;
  16272. }
  16273. var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
  16274. if (openNotch) {
  16275. var labelScale = constants_2.numbers.LABEL_SCALE;
  16276. var labelWidth = this.adapter.getLabelWidth() * labelScale;
  16277. this.adapter.notchOutline(labelWidth);
  16278. } else if (!isFocused) {
  16279. this.adapter.closeOutline();
  16280. }
  16281. };
  16282. /**
  16283. * Sets the aria label of the leading icon.
  16284. */
  16285. MDCSelectFoundation.prototype.setLeadingIconAriaLabel = function (label) {
  16286. if (this.leadingIcon) {
  16287. this.leadingIcon.setAriaLabel(label);
  16288. }
  16289. };
  16290. /**
  16291. * Sets the text content of the leading icon.
  16292. */
  16293. MDCSelectFoundation.prototype.setLeadingIconContent = function (content) {
  16294. if (this.leadingIcon) {
  16295. this.leadingIcon.setContent(content);
  16296. }
  16297. };
  16298. MDCSelectFoundation.prototype.setUseDefaultValidation = function (useDefaultValidation) {
  16299. this.useDefaultValidation = useDefaultValidation;
  16300. };
  16301. MDCSelectFoundation.prototype.setValid = function (isValid) {
  16302. if (!this.useDefaultValidation) {
  16303. this.customValidity = isValid;
  16304. }
  16305. this.adapter.setSelectAnchorAttr('aria-invalid', (!isValid).toString());
  16306. if (isValid) {
  16307. this.adapter.removeClass(constants_2.cssClasses.INVALID);
  16308. this.adapter.removeMenuClass(constants_2.cssClasses.MENU_INVALID);
  16309. } else {
  16310. this.adapter.addClass(constants_2.cssClasses.INVALID);
  16311. this.adapter.addMenuClass(constants_2.cssClasses.MENU_INVALID);
  16312. }
  16313. this.syncHelperTextValidity(isValid);
  16314. };
  16315. MDCSelectFoundation.prototype.isValid = function () {
  16316. if (this.useDefaultValidation && this.adapter.hasClass(constants_2.cssClasses.REQUIRED) && !this.adapter.hasClass(constants_2.cssClasses.DISABLED)) {
  16317. // See notes for required attribute under https://www.w3.org/TR/html52/sec-forms.html#the-select-element
  16318. // TL;DR: Invalid if no index is selected, or if the first index is selected and has an empty value.
  16319. return this.getSelectedIndex() !== constants_2.numbers.UNSET_INDEX && (this.getSelectedIndex() !== 0 || Boolean(this.getValue()));
  16320. }
  16321. return this.customValidity;
  16322. };
  16323. MDCSelectFoundation.prototype.setRequired = function (isRequired) {
  16324. if (isRequired) {
  16325. this.adapter.addClass(constants_2.cssClasses.REQUIRED);
  16326. } else {
  16327. this.adapter.removeClass(constants_2.cssClasses.REQUIRED);
  16328. }
  16329. this.adapter.setSelectAnchorAttr('aria-required', isRequired.toString());
  16330. this.adapter.setLabelRequired(isRequired);
  16331. };
  16332. MDCSelectFoundation.prototype.getRequired = function () {
  16333. return this.adapter.getSelectAnchorAttr('aria-required') === 'true';
  16334. };
  16335. MDCSelectFoundation.prototype.init = function () {
  16336. var anchorEl = this.adapter.getAnchorElement();
  16337. if (anchorEl) {
  16338. this.adapter.setMenuAnchorElement(anchorEl);
  16339. this.adapter.setMenuAnchorCorner(constants_1.Corner.BOTTOM_START);
  16340. }
  16341. this.adapter.setMenuWrapFocus(false);
  16342. this.setDisabled(this.adapter.hasClass(constants_2.cssClasses.DISABLED));
  16343. this.syncHelperTextValidity(!this.adapter.hasClass(constants_2.cssClasses.INVALID));
  16344. this.layout();
  16345. this.layoutOptions();
  16346. };
  16347. /**
  16348. * Unfocuses the select component.
  16349. */
  16350. MDCSelectFoundation.prototype.blur = function () {
  16351. this.adapter.removeClass(constants_2.cssClasses.FOCUSED);
  16352. this.layout();
  16353. this.adapter.deactivateBottomLine();
  16354. var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
  16355. if (isRequired && this.useDefaultValidation) {
  16356. this.setValid(this.isValid());
  16357. }
  16358. };
  16359. MDCSelectFoundation.prototype.syncHelperTextValidity = function (isValid) {
  16360. if (!this.helperText) {
  16361. return;
  16362. }
  16363. this.helperText.setValidity(isValid);
  16364. var helperTextVisible = this.helperText.isVisible();
  16365. var helperTextId = this.helperText.getId();
  16366. if (helperTextVisible && helperTextId) {
  16367. this.adapter.setSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY, helperTextId);
  16368. } else {
  16369. // Needed because screenreaders will read labels pointed to by
  16370. // `aria-describedby` even if they are `aria-hidden`.
  16371. this.adapter.removeSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY);
  16372. }
  16373. };
  16374. MDCSelectFoundation.prototype.setClickDebounceTimeout = function () {
  16375. var _this = this;
  16376. clearTimeout(this.clickDebounceTimeout);
  16377. this.clickDebounceTimeout = setTimeout(function () {
  16378. _this.recentlyClicked = false;
  16379. }, constants_2.numbers.CLICK_DEBOUNCE_TIMEOUT_MS);
  16380. this.recentlyClicked = true;
  16381. };
  16382. return MDCSelectFoundation;
  16383. }(foundation_1.MDCFoundation);
  16384. exports.MDCSelectFoundation = MDCSelectFoundation;
  16385. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  16386. exports.default = MDCSelectFoundation;
  16387. /***/ }),
  16388. /***/ "./packages/mdc-select/helper-text/component.ts":
  16389. /*!******************************************************!*\
  16390. !*** ./packages/mdc-select/helper-text/component.ts ***!
  16391. \******************************************************/
  16392. /*! no static exports found */
  16393. /***/ (function(module, exports, __webpack_require__) {
  16394. "use strict";
  16395. /**
  16396. * @license
  16397. * Copyright 2018 Google Inc.
  16398. *
  16399. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16400. * of this software and associated documentation files (the "Software"), to deal
  16401. * in the Software without restriction, including without limitation the rights
  16402. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16403. * copies of the Software, and to permit persons to whom the Software is
  16404. * furnished to do so, subject to the following conditions:
  16405. *
  16406. * The above copyright notice and this permission notice shall be included in
  16407. * all copies or substantial portions of the Software.
  16408. *
  16409. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16410. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16411. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16412. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16413. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16414. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16415. * THE SOFTWARE.
  16416. */
  16417. var __extends = this && this.__extends || function () {
  16418. var _extendStatics = function extendStatics(d, b) {
  16419. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  16420. d.__proto__ = b;
  16421. } || function (d, b) {
  16422. for (var p in b) {
  16423. if (b.hasOwnProperty(p)) d[p] = b[p];
  16424. }
  16425. };
  16426. return _extendStatics(d, b);
  16427. };
  16428. return function (d, b) {
  16429. _extendStatics(d, b);
  16430. function __() {
  16431. this.constructor = d;
  16432. }
  16433. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16434. };
  16435. }();
  16436. Object.defineProperty(exports, "__esModule", { value: true });
  16437. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  16438. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts");
  16439. var MDCSelectHelperText = /** @class */function (_super) {
  16440. __extends(MDCSelectHelperText, _super);
  16441. function MDCSelectHelperText() {
  16442. return _super !== null && _super.apply(this, arguments) || this;
  16443. }
  16444. MDCSelectHelperText.attachTo = function (root) {
  16445. return new MDCSelectHelperText(root);
  16446. };
  16447. Object.defineProperty(MDCSelectHelperText.prototype, "foundationForSelect", {
  16448. // Provided for access by MDCSelect component
  16449. get: function get() {
  16450. return this.foundation;
  16451. },
  16452. enumerable: true,
  16453. configurable: true
  16454. });
  16455. MDCSelectHelperText.prototype.getDefaultFoundation = function () {
  16456. var _this = this;
  16457. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  16458. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  16459. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  16460. var adapter = {
  16461. addClass: function addClass(className) {
  16462. return _this.root.classList.add(className);
  16463. },
  16464. removeClass: function removeClass(className) {
  16465. return _this.root.classList.remove(className);
  16466. },
  16467. hasClass: function hasClass(className) {
  16468. return _this.root.classList.contains(className);
  16469. },
  16470. getAttr: function getAttr(attr) {
  16471. return _this.root.getAttribute(attr);
  16472. },
  16473. setAttr: function setAttr(attr, value) {
  16474. return _this.root.setAttribute(attr, value);
  16475. },
  16476. removeAttr: function removeAttr(attr) {
  16477. return _this.root.removeAttribute(attr);
  16478. },
  16479. setContent: function setContent(content) {
  16480. _this.root.textContent = content;
  16481. }
  16482. };
  16483. // tslint:enable:object-literal-sort-keys
  16484. return new foundation_1.MDCSelectHelperTextFoundation(adapter);
  16485. };
  16486. return MDCSelectHelperText;
  16487. }(component_1.MDCComponent);
  16488. exports.MDCSelectHelperText = MDCSelectHelperText;
  16489. /***/ }),
  16490. /***/ "./packages/mdc-select/helper-text/constants.ts":
  16491. /*!******************************************************!*\
  16492. !*** ./packages/mdc-select/helper-text/constants.ts ***!
  16493. \******************************************************/
  16494. /*! no static exports found */
  16495. /***/ (function(module, exports, __webpack_require__) {
  16496. "use strict";
  16497. /**
  16498. * @license
  16499. * Copyright 2018 Google Inc.
  16500. *
  16501. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16502. * of this software and associated documentation files (the "Software"), to deal
  16503. * in the Software without restriction, including without limitation the rights
  16504. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16505. * copies of the Software, and to permit persons to whom the Software is
  16506. * furnished to do so, subject to the following conditions:
  16507. *
  16508. * The above copyright notice and this permission notice shall be included in
  16509. * all copies or substantial portions of the Software.
  16510. *
  16511. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16512. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16513. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16514. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16515. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16516. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16517. * THE SOFTWARE.
  16518. */
  16519. Object.defineProperty(exports, "__esModule", { value: true });
  16520. var strings = {
  16521. ARIA_HIDDEN: 'aria-hidden',
  16522. ROLE: 'role'
  16523. };
  16524. exports.strings = strings;
  16525. var cssClasses = {
  16526. HELPER_TEXT_VALIDATION_MSG: 'mdc-select-helper-text--validation-msg',
  16527. HELPER_TEXT_VALIDATION_MSG_PERSISTENT: 'mdc-select-helper-text--validation-msg-persistent'
  16528. };
  16529. exports.cssClasses = cssClasses;
  16530. /***/ }),
  16531. /***/ "./packages/mdc-select/helper-text/foundation.ts":
  16532. /*!*******************************************************!*\
  16533. !*** ./packages/mdc-select/helper-text/foundation.ts ***!
  16534. \*******************************************************/
  16535. /*! no static exports found */
  16536. /***/ (function(module, exports, __webpack_require__) {
  16537. "use strict";
  16538. /**
  16539. * @license
  16540. * Copyright 2018 Google Inc.
  16541. *
  16542. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16543. * of this software and associated documentation files (the "Software"), to deal
  16544. * in the Software without restriction, including without limitation the rights
  16545. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16546. * copies of the Software, and to permit persons to whom the Software is
  16547. * furnished to do so, subject to the following conditions:
  16548. *
  16549. * The above copyright notice and this permission notice shall be included in
  16550. * all copies or substantial portions of the Software.
  16551. *
  16552. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16553. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16554. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16555. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16556. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16557. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16558. * THE SOFTWARE.
  16559. */
  16560. var __extends = this && this.__extends || function () {
  16561. var _extendStatics = function extendStatics(d, b) {
  16562. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  16563. d.__proto__ = b;
  16564. } || function (d, b) {
  16565. for (var p in b) {
  16566. if (b.hasOwnProperty(p)) d[p] = b[p];
  16567. }
  16568. };
  16569. return _extendStatics(d, b);
  16570. };
  16571. return function (d, b) {
  16572. _extendStatics(d, b);
  16573. function __() {
  16574. this.constructor = d;
  16575. }
  16576. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16577. };
  16578. }();
  16579. var __assign = this && this.__assign || function () {
  16580. __assign = Object.assign || function (t) {
  16581. for (var s, i = 1, n = arguments.length; i < n; i++) {
  16582. s = arguments[i];
  16583. for (var p in s) {
  16584. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  16585. }
  16586. }
  16587. return t;
  16588. };
  16589. return __assign.apply(this, arguments);
  16590. };
  16591. Object.defineProperty(exports, "__esModule", { value: true });
  16592. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  16593. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
  16594. var MDCSelectHelperTextFoundation = /** @class */function (_super) {
  16595. __extends(MDCSelectHelperTextFoundation, _super);
  16596. function MDCSelectHelperTextFoundation(adapter) {
  16597. return _super.call(this, __assign(__assign({}, MDCSelectHelperTextFoundation.defaultAdapter), adapter)) || this;
  16598. }
  16599. Object.defineProperty(MDCSelectHelperTextFoundation, "cssClasses", {
  16600. get: function get() {
  16601. return constants_1.cssClasses;
  16602. },
  16603. enumerable: true,
  16604. configurable: true
  16605. });
  16606. Object.defineProperty(MDCSelectHelperTextFoundation, "strings", {
  16607. get: function get() {
  16608. return constants_1.strings;
  16609. },
  16610. enumerable: true,
  16611. configurable: true
  16612. });
  16613. Object.defineProperty(MDCSelectHelperTextFoundation, "defaultAdapter", {
  16614. /**
  16615. * See {@link MDCSelectHelperTextAdapter} for typing information on parameters and return types.
  16616. */
  16617. get: function get() {
  16618. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  16619. return {
  16620. addClass: function addClass() {
  16621. return undefined;
  16622. },
  16623. removeClass: function removeClass() {
  16624. return undefined;
  16625. },
  16626. hasClass: function hasClass() {
  16627. return false;
  16628. },
  16629. setAttr: function setAttr() {
  16630. return undefined;
  16631. },
  16632. getAttr: function getAttr() {
  16633. return null;
  16634. },
  16635. removeAttr: function removeAttr() {
  16636. return undefined;
  16637. },
  16638. setContent: function setContent() {
  16639. return undefined;
  16640. }
  16641. };
  16642. // tslint:enable:object-literal-sort-keys
  16643. },
  16644. enumerable: true,
  16645. configurable: true
  16646. });
  16647. /**
  16648. * @return The ID of the helper text, or null if none is set.
  16649. */
  16650. MDCSelectHelperTextFoundation.prototype.getId = function () {
  16651. return this.adapter.getAttr('id');
  16652. };
  16653. /**
  16654. * @return Whether the helper text is currently visible.
  16655. */
  16656. MDCSelectHelperTextFoundation.prototype.isVisible = function () {
  16657. return this.adapter.getAttr(constants_1.strings.ARIA_HIDDEN) !== 'true';
  16658. };
  16659. /**
  16660. * Sets the content of the helper text field.
  16661. */
  16662. MDCSelectHelperTextFoundation.prototype.setContent = function (content) {
  16663. this.adapter.setContent(content);
  16664. };
  16665. /**
  16666. * Sets the helper text to act as a validation message.
  16667. * By default, validation messages are hidden when the select is valid and
  16668. * visible when the select is invalid.
  16669. *
  16670. * @param isValidation True to make the helper text act as an error validation
  16671. * message.
  16672. */
  16673. MDCSelectHelperTextFoundation.prototype.setValidation = function (isValidation) {
  16674. if (isValidation) {
  16675. this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  16676. } else {
  16677. this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  16678. }
  16679. };
  16680. /**
  16681. * Sets the persistency of the validation helper text.
  16682. * This keeps the validation message visible even if the select is valid,
  16683. * though it will be displayed in the normal (grey) color.
  16684. */
  16685. MDCSelectHelperTextFoundation.prototype.setValidationMsgPersistent = function (isPersistent) {
  16686. if (isPersistent) {
  16687. this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
  16688. } else {
  16689. this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
  16690. }
  16691. };
  16692. /**
  16693. * When acting as a validation message, shows/hides the helper text and
  16694. * triggers alerts as necessary based on the select's validity.
  16695. */
  16696. MDCSelectHelperTextFoundation.prototype.setValidity = function (selectIsValid) {
  16697. var isValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  16698. if (!isValidationMsg) {
  16699. // Non-validating helper-text is always displayed and does not participate
  16700. // in validation logic.
  16701. return;
  16702. }
  16703. var isPersistentValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
  16704. // Validating helper text is displayed if select is invalid, unless it is
  16705. // set as persistent, in which case it always displays.
  16706. var msgShouldDisplay = !selectIsValid || isPersistentValidationMsg;
  16707. if (msgShouldDisplay) {
  16708. this.showToScreenReader();
  16709. // In addition to displaying, also trigger an alert if the select
  16710. // has become invalid.
  16711. if (!selectIsValid) {
  16712. this.adapter.setAttr(constants_1.strings.ROLE, 'alert');
  16713. } else {
  16714. this.adapter.removeAttr(constants_1.strings.ROLE);
  16715. }
  16716. return;
  16717. }
  16718. // Hide everything.
  16719. this.adapter.removeAttr(constants_1.strings.ROLE);
  16720. this.hide();
  16721. };
  16722. /**
  16723. * Makes the helper text visible to screen readers.
  16724. */
  16725. MDCSelectHelperTextFoundation.prototype.showToScreenReader = function () {
  16726. this.adapter.removeAttr(constants_1.strings.ARIA_HIDDEN);
  16727. };
  16728. /**
  16729. * Hides the help text from screen readers.
  16730. */
  16731. MDCSelectHelperTextFoundation.prototype.hide = function () {
  16732. this.adapter.setAttr(constants_1.strings.ARIA_HIDDEN, 'true');
  16733. };
  16734. return MDCSelectHelperTextFoundation;
  16735. }(foundation_1.MDCFoundation);
  16736. exports.MDCSelectHelperTextFoundation = MDCSelectHelperTextFoundation;
  16737. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  16738. exports.default = MDCSelectHelperTextFoundation;
  16739. /***/ }),
  16740. /***/ "./packages/mdc-select/helper-text/index.ts":
  16741. /*!**************************************************!*\
  16742. !*** ./packages/mdc-select/helper-text/index.ts ***!
  16743. \**************************************************/
  16744. /*! no static exports found */
  16745. /***/ (function(module, exports, __webpack_require__) {
  16746. "use strict";
  16747. /**
  16748. * @license
  16749. * Copyright 2019 Google Inc.
  16750. *
  16751. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16752. * of this software and associated documentation files (the "Software"), to deal
  16753. * in the Software without restriction, including without limitation the rights
  16754. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16755. * copies of the Software, and to permit persons to whom the Software is
  16756. * furnished to do so, subject to the following conditions:
  16757. *
  16758. * The above copyright notice and this permission notice shall be included in
  16759. * all copies or substantial portions of the Software.
  16760. *
  16761. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16762. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16763. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16764. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16765. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16766. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16767. * THE SOFTWARE.
  16768. */
  16769. function __export(m) {
  16770. for (var p in m) {
  16771. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  16772. }
  16773. }
  16774. Object.defineProperty(exports, "__esModule", { value: true });
  16775. __export(__webpack_require__(/*! ./component */ "./packages/mdc-select/helper-text/component.ts"));
  16776. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts"));
  16777. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
  16778. exports.helperTextCssClasses = constants_1.cssClasses;
  16779. exports.helperTextStrings = constants_1.strings;
  16780. /***/ }),
  16781. /***/ "./packages/mdc-select/icon/component.ts":
  16782. /*!***********************************************!*\
  16783. !*** ./packages/mdc-select/icon/component.ts ***!
  16784. \***********************************************/
  16785. /*! no static exports found */
  16786. /***/ (function(module, exports, __webpack_require__) {
  16787. "use strict";
  16788. /**
  16789. * @license
  16790. * Copyright 2018 Google Inc.
  16791. *
  16792. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16793. * of this software and associated documentation files (the "Software"), to deal
  16794. * in the Software without restriction, including without limitation the rights
  16795. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16796. * copies of the Software, and to permit persons to whom the Software is
  16797. * furnished to do so, subject to the following conditions:
  16798. *
  16799. * The above copyright notice and this permission notice shall be included in
  16800. * all copies or substantial portions of the Software.
  16801. *
  16802. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16803. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16804. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16805. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16806. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16807. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16808. * THE SOFTWARE.
  16809. */
  16810. var __extends = this && this.__extends || function () {
  16811. var _extendStatics = function extendStatics(d, b) {
  16812. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  16813. d.__proto__ = b;
  16814. } || function (d, b) {
  16815. for (var p in b) {
  16816. if (b.hasOwnProperty(p)) d[p] = b[p];
  16817. }
  16818. };
  16819. return _extendStatics(d, b);
  16820. };
  16821. return function (d, b) {
  16822. _extendStatics(d, b);
  16823. function __() {
  16824. this.constructor = d;
  16825. }
  16826. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16827. };
  16828. }();
  16829. Object.defineProperty(exports, "__esModule", { value: true });
  16830. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  16831. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts");
  16832. var MDCSelectIcon = /** @class */function (_super) {
  16833. __extends(MDCSelectIcon, _super);
  16834. function MDCSelectIcon() {
  16835. return _super !== null && _super.apply(this, arguments) || this;
  16836. }
  16837. MDCSelectIcon.attachTo = function (root) {
  16838. return new MDCSelectIcon(root);
  16839. };
  16840. Object.defineProperty(MDCSelectIcon.prototype, "foundationForSelect", {
  16841. // Provided for access by MDCSelect component
  16842. get: function get() {
  16843. return this.foundation;
  16844. },
  16845. enumerable: true,
  16846. configurable: true
  16847. });
  16848. MDCSelectIcon.prototype.getDefaultFoundation = function () {
  16849. var _this = this;
  16850. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  16851. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  16852. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  16853. var adapter = {
  16854. getAttr: function getAttr(attr) {
  16855. return _this.root.getAttribute(attr);
  16856. },
  16857. setAttr: function setAttr(attr, value) {
  16858. return _this.root.setAttribute(attr, value);
  16859. },
  16860. removeAttr: function removeAttr(attr) {
  16861. return _this.root.removeAttribute(attr);
  16862. },
  16863. setContent: function setContent(content) {
  16864. _this.root.textContent = content;
  16865. },
  16866. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  16867. return _this.listen(evtType, handler);
  16868. },
  16869. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  16870. return _this.unlisten(evtType, handler);
  16871. },
  16872. notifyIconAction: function notifyIconAction() {
  16873. return _this.emit(foundation_1.MDCSelectIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */);
  16874. }
  16875. };
  16876. // tslint:enable:object-literal-sort-keys
  16877. return new foundation_1.MDCSelectIconFoundation(adapter);
  16878. };
  16879. return MDCSelectIcon;
  16880. }(component_1.MDCComponent);
  16881. exports.MDCSelectIcon = MDCSelectIcon;
  16882. /***/ }),
  16883. /***/ "./packages/mdc-select/icon/constants.ts":
  16884. /*!***********************************************!*\
  16885. !*** ./packages/mdc-select/icon/constants.ts ***!
  16886. \***********************************************/
  16887. /*! no static exports found */
  16888. /***/ (function(module, exports, __webpack_require__) {
  16889. "use strict";
  16890. /**
  16891. * @license
  16892. * Copyright 2018 Google Inc.
  16893. *
  16894. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16895. * of this software and associated documentation files (the "Software"), to deal
  16896. * in the Software without restriction, including without limitation the rights
  16897. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16898. * copies of the Software, and to permit persons to whom the Software is
  16899. * furnished to do so, subject to the following conditions:
  16900. *
  16901. * The above copyright notice and this permission notice shall be included in
  16902. * all copies or substantial portions of the Software.
  16903. *
  16904. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16905. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16906. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16907. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16908. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16909. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16910. * THE SOFTWARE.
  16911. */
  16912. Object.defineProperty(exports, "__esModule", { value: true });
  16913. var strings = {
  16914. ICON_EVENT: 'MDCSelect:icon',
  16915. ICON_ROLE: 'button'
  16916. };
  16917. exports.strings = strings;
  16918. /***/ }),
  16919. /***/ "./packages/mdc-select/icon/foundation.ts":
  16920. /*!************************************************!*\
  16921. !*** ./packages/mdc-select/icon/foundation.ts ***!
  16922. \************************************************/
  16923. /*! no static exports found */
  16924. /***/ (function(module, exports, __webpack_require__) {
  16925. "use strict";
  16926. /**
  16927. * @license
  16928. * Copyright 2018 Google Inc.
  16929. *
  16930. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16931. * of this software and associated documentation files (the "Software"), to deal
  16932. * in the Software without restriction, including without limitation the rights
  16933. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16934. * copies of the Software, and to permit persons to whom the Software is
  16935. * furnished to do so, subject to the following conditions:
  16936. *
  16937. * The above copyright notice and this permission notice shall be included in
  16938. * all copies or substantial portions of the Software.
  16939. *
  16940. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16941. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16942. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16943. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16944. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16945. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16946. * THE SOFTWARE.
  16947. */
  16948. var __extends = this && this.__extends || function () {
  16949. var _extendStatics = function extendStatics(d, b) {
  16950. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  16951. d.__proto__ = b;
  16952. } || function (d, b) {
  16953. for (var p in b) {
  16954. if (b.hasOwnProperty(p)) d[p] = b[p];
  16955. }
  16956. };
  16957. return _extendStatics(d, b);
  16958. };
  16959. return function (d, b) {
  16960. _extendStatics(d, b);
  16961. function __() {
  16962. this.constructor = d;
  16963. }
  16964. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16965. };
  16966. }();
  16967. var __assign = this && this.__assign || function () {
  16968. __assign = Object.assign || function (t) {
  16969. for (var s, i = 1, n = arguments.length; i < n; i++) {
  16970. s = arguments[i];
  16971. for (var p in s) {
  16972. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  16973. }
  16974. }
  16975. return t;
  16976. };
  16977. return __assign.apply(this, arguments);
  16978. };
  16979. Object.defineProperty(exports, "__esModule", { value: true });
  16980. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  16981. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
  16982. var INTERACTION_EVENTS = ['click', 'keydown'];
  16983. var MDCSelectIconFoundation = /** @class */function (_super) {
  16984. __extends(MDCSelectIconFoundation, _super);
  16985. function MDCSelectIconFoundation(adapter) {
  16986. var _this = _super.call(this, __assign(__assign({}, MDCSelectIconFoundation.defaultAdapter), adapter)) || this;
  16987. _this.savedTabIndex_ = null;
  16988. _this.interactionHandler_ = function (evt) {
  16989. return _this.handleInteraction(evt);
  16990. };
  16991. return _this;
  16992. }
  16993. Object.defineProperty(MDCSelectIconFoundation, "strings", {
  16994. get: function get() {
  16995. return constants_1.strings;
  16996. },
  16997. enumerable: true,
  16998. configurable: true
  16999. });
  17000. Object.defineProperty(MDCSelectIconFoundation, "defaultAdapter", {
  17001. /**
  17002. * See {@link MDCSelectIconAdapter} for typing information on parameters and return types.
  17003. */
  17004. get: function get() {
  17005. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  17006. return {
  17007. getAttr: function getAttr() {
  17008. return null;
  17009. },
  17010. setAttr: function setAttr() {
  17011. return undefined;
  17012. },
  17013. removeAttr: function removeAttr() {
  17014. return undefined;
  17015. },
  17016. setContent: function setContent() {
  17017. return undefined;
  17018. },
  17019. registerInteractionHandler: function registerInteractionHandler() {
  17020. return undefined;
  17021. },
  17022. deregisterInteractionHandler: function deregisterInteractionHandler() {
  17023. return undefined;
  17024. },
  17025. notifyIconAction: function notifyIconAction() {
  17026. return undefined;
  17027. }
  17028. };
  17029. // tslint:enable:object-literal-sort-keys
  17030. },
  17031. enumerable: true,
  17032. configurable: true
  17033. });
  17034. MDCSelectIconFoundation.prototype.init = function () {
  17035. var _this = this;
  17036. this.savedTabIndex_ = this.adapter.getAttr('tabindex');
  17037. INTERACTION_EVENTS.forEach(function (evtType) {
  17038. _this.adapter.registerInteractionHandler(evtType, _this.interactionHandler_);
  17039. });
  17040. };
  17041. MDCSelectIconFoundation.prototype.destroy = function () {
  17042. var _this = this;
  17043. INTERACTION_EVENTS.forEach(function (evtType) {
  17044. _this.adapter.deregisterInteractionHandler(evtType, _this.interactionHandler_);
  17045. });
  17046. };
  17047. MDCSelectIconFoundation.prototype.setDisabled = function (disabled) {
  17048. if (!this.savedTabIndex_) {
  17049. return;
  17050. }
  17051. if (disabled) {
  17052. this.adapter.setAttr('tabindex', '-1');
  17053. this.adapter.removeAttr('role');
  17054. } else {
  17055. this.adapter.setAttr('tabindex', this.savedTabIndex_);
  17056. this.adapter.setAttr('role', constants_1.strings.ICON_ROLE);
  17057. }
  17058. };
  17059. MDCSelectIconFoundation.prototype.setAriaLabel = function (label) {
  17060. this.adapter.setAttr('aria-label', label);
  17061. };
  17062. MDCSelectIconFoundation.prototype.setContent = function (content) {
  17063. this.adapter.setContent(content);
  17064. };
  17065. MDCSelectIconFoundation.prototype.handleInteraction = function (evt) {
  17066. var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
  17067. if (evt.type === 'click' || isEnterKey) {
  17068. this.adapter.notifyIconAction();
  17069. }
  17070. };
  17071. return MDCSelectIconFoundation;
  17072. }(foundation_1.MDCFoundation);
  17073. exports.MDCSelectIconFoundation = MDCSelectIconFoundation;
  17074. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  17075. exports.default = MDCSelectIconFoundation;
  17076. /***/ }),
  17077. /***/ "./packages/mdc-select/icon/index.ts":
  17078. /*!*******************************************!*\
  17079. !*** ./packages/mdc-select/icon/index.ts ***!
  17080. \*******************************************/
  17081. /*! no static exports found */
  17082. /***/ (function(module, exports, __webpack_require__) {
  17083. "use strict";
  17084. /**
  17085. * @license
  17086. * Copyright 2019 Google Inc.
  17087. *
  17088. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17089. * of this software and associated documentation files (the "Software"), to deal
  17090. * in the Software without restriction, including without limitation the rights
  17091. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17092. * copies of the Software, and to permit persons to whom the Software is
  17093. * furnished to do so, subject to the following conditions:
  17094. *
  17095. * The above copyright notice and this permission notice shall be included in
  17096. * all copies or substantial portions of the Software.
  17097. *
  17098. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17099. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17100. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17101. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17102. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17103. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17104. * THE SOFTWARE.
  17105. */
  17106. function __export(m) {
  17107. for (var p in m) {
  17108. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  17109. }
  17110. }
  17111. Object.defineProperty(exports, "__esModule", { value: true });
  17112. __export(__webpack_require__(/*! ./component */ "./packages/mdc-select/icon/component.ts"));
  17113. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts"));
  17114. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
  17115. exports.iconStrings = constants_1.strings;
  17116. /***/ }),
  17117. /***/ "./packages/mdc-select/index.ts":
  17118. /*!**************************************!*\
  17119. !*** ./packages/mdc-select/index.ts ***!
  17120. \**************************************/
  17121. /*! no static exports found */
  17122. /***/ (function(module, exports, __webpack_require__) {
  17123. "use strict";
  17124. /**
  17125. * @license
  17126. * Copyright 2019 Google Inc.
  17127. *
  17128. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17129. * of this software and associated documentation files (the "Software"), to deal
  17130. * in the Software without restriction, including without limitation the rights
  17131. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17132. * copies of the Software, and to permit persons to whom the Software is
  17133. * furnished to do so, subject to the following conditions:
  17134. *
  17135. * The above copyright notice and this permission notice shall be included in
  17136. * all copies or substantial portions of the Software.
  17137. *
  17138. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17139. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17140. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17141. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17142. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17143. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17144. * THE SOFTWARE.
  17145. */
  17146. function __export(m) {
  17147. for (var p in m) {
  17148. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  17149. }
  17150. }
  17151. Object.defineProperty(exports, "__esModule", { value: true });
  17152. __export(__webpack_require__(/*! ./component */ "./packages/mdc-select/component.ts"));
  17153. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts"));
  17154. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts"));
  17155. __export(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-select/helper-text/index.ts"));
  17156. __export(__webpack_require__(/*! ./icon/index */ "./packages/mdc-select/icon/index.ts"));
  17157. /***/ }),
  17158. /***/ "./packages/mdc-slider/component.ts":
  17159. /*!******************************************!*\
  17160. !*** ./packages/mdc-slider/component.ts ***!
  17161. \******************************************/
  17162. /*! no static exports found */
  17163. /***/ (function(module, exports, __webpack_require__) {
  17164. "use strict";
  17165. /**
  17166. * @license
  17167. * Copyright 2020 Google Inc.
  17168. *
  17169. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17170. * of this software and associated documentation files (the "Software"), to deal
  17171. * in the Software without restriction, including without limitation the rights
  17172. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17173. * copies of the Software, and to permit persons to whom the Software is
  17174. * furnished to do so, subject to the following conditions:
  17175. *
  17176. * The above copyright notice and this permission notice shall be included in
  17177. * all copies or substantial portions of the Software.
  17178. *
  17179. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17180. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17181. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17182. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17183. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17184. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17185. * THE SOFTWARE.
  17186. */
  17187. var __extends = this && this.__extends || function () {
  17188. var _extendStatics = function extendStatics(d, b) {
  17189. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  17190. d.__proto__ = b;
  17191. } || function (d, b) {
  17192. for (var p in b) {
  17193. if (b.hasOwnProperty(p)) d[p] = b[p];
  17194. }
  17195. };
  17196. return _extendStatics(d, b);
  17197. };
  17198. return function (d, b) {
  17199. _extendStatics(d, b);
  17200. function __() {
  17201. this.constructor = d;
  17202. }
  17203. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17204. };
  17205. }();
  17206. var __assign = this && this.__assign || function () {
  17207. __assign = Object.assign || function (t) {
  17208. for (var s, i = 1, n = arguments.length; i < n; i++) {
  17209. s = arguments[i];
  17210. for (var p in s) {
  17211. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  17212. }
  17213. }
  17214. return t;
  17215. };
  17216. return __assign.apply(this, arguments);
  17217. };
  17218. Object.defineProperty(exports, "__esModule", { value: true });
  17219. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  17220. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  17221. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  17222. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  17223. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  17224. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
  17225. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts");
  17226. var types_1 = __webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts");
  17227. /** Vanilla JS implementation of slider component. */
  17228. var MDCSlider = /** @class */function (_super) {
  17229. __extends(MDCSlider, _super);
  17230. function MDCSlider() {
  17231. var _this = _super !== null && _super.apply(this, arguments) || this;
  17232. _this.skipInitialUIUpdate = false;
  17233. // Function that maps a slider value to the value of the `aria-valuetext`
  17234. // attribute on the thumb element.
  17235. _this.valueToAriaValueTextFn = null;
  17236. return _this;
  17237. }
  17238. MDCSlider.attachTo = function (root, options) {
  17239. if (options === void 0) {
  17240. options = {};
  17241. }
  17242. return new MDCSlider(root, undefined, options);
  17243. };
  17244. MDCSlider.prototype.getDefaultFoundation = function () {
  17245. var _this = this;
  17246. // tslint:disable:object-literal-sort-keys Methods should be in the same
  17247. // order as the adapter interface.
  17248. var adapter = {
  17249. hasClass: function hasClass(className) {
  17250. return _this.root.classList.contains(className);
  17251. },
  17252. addClass: function addClass(className) {
  17253. _this.root.classList.add(className);
  17254. },
  17255. removeClass: function removeClass(className) {
  17256. _this.root.classList.remove(className);
  17257. },
  17258. addThumbClass: function addThumbClass(className, thumb) {
  17259. _this.getThumbEl(thumb).classList.add(className);
  17260. },
  17261. removeThumbClass: function removeThumbClass(className, thumb) {
  17262. _this.getThumbEl(thumb).classList.remove(className);
  17263. },
  17264. getAttribute: function getAttribute(attribute) {
  17265. return _this.root.getAttribute(attribute);
  17266. },
  17267. getInputValue: function getInputValue(thumb) {
  17268. return _this.getInput(thumb).value;
  17269. },
  17270. setInputValue: function setInputValue(value, thumb) {
  17271. _this.getInput(thumb).value = value;
  17272. },
  17273. getInputAttribute: function getInputAttribute(attribute, thumb) {
  17274. return _this.getInput(thumb).getAttribute(attribute);
  17275. },
  17276. setInputAttribute: function setInputAttribute(attribute, value, thumb) {
  17277. _this.getInput(thumb).setAttribute(attribute, value);
  17278. },
  17279. removeInputAttribute: function removeInputAttribute(attribute, thumb) {
  17280. _this.getInput(thumb).removeAttribute(attribute);
  17281. },
  17282. focusInput: function focusInput(thumb) {
  17283. _this.getInput(thumb).focus();
  17284. },
  17285. isInputFocused: function isInputFocused(thumb) {
  17286. return _this.getInput(thumb) === document.activeElement;
  17287. },
  17288. getThumbKnobWidth: function getThumbKnobWidth(thumb) {
  17289. return _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.THUMB_KNOB).getBoundingClientRect().width;
  17290. },
  17291. getThumbBoundingClientRect: function getThumbBoundingClientRect(thumb) {
  17292. return _this.getThumbEl(thumb).getBoundingClientRect();
  17293. },
  17294. getBoundingClientRect: function getBoundingClientRect() {
  17295. return _this.root.getBoundingClientRect();
  17296. },
  17297. isRTL: function isRTL() {
  17298. return getComputedStyle(_this.root).direction === 'rtl';
  17299. },
  17300. setThumbStyleProperty: function setThumbStyleProperty(propertyName, value, thumb) {
  17301. _this.getThumbEl(thumb).style.setProperty(propertyName, value);
  17302. },
  17303. removeThumbStyleProperty: function removeThumbStyleProperty(propertyName, thumb) {
  17304. _this.getThumbEl(thumb).style.removeProperty(propertyName);
  17305. },
  17306. setTrackActiveStyleProperty: function setTrackActiveStyleProperty(propertyName, value) {
  17307. _this.trackActive.style.setProperty(propertyName, value);
  17308. },
  17309. removeTrackActiveStyleProperty: function removeTrackActiveStyleProperty(propertyName) {
  17310. _this.trackActive.style.removeProperty(propertyName);
  17311. },
  17312. setValueIndicatorText: function setValueIndicatorText(value, thumb) {
  17313. var valueIndicatorEl = _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.VALUE_INDICATOR_TEXT);
  17314. valueIndicatorEl.textContent = String(value);
  17315. },
  17316. getValueToAriaValueTextFn: function getValueToAriaValueTextFn() {
  17317. return _this.valueToAriaValueTextFn;
  17318. },
  17319. updateTickMarks: function updateTickMarks(tickMarks) {
  17320. var tickMarksContainer = _this.root.querySelector("." + constants_1.cssClasses.TICK_MARKS_CONTAINER);
  17321. if (!tickMarksContainer) {
  17322. tickMarksContainer = document.createElement('div');
  17323. tickMarksContainer.classList.add(constants_1.cssClasses.TICK_MARKS_CONTAINER);
  17324. var track = _this.root.querySelector("." + constants_1.cssClasses.TRACK);
  17325. track.appendChild(tickMarksContainer);
  17326. }
  17327. if (tickMarks.length !== tickMarksContainer.children.length) {
  17328. tickMarksContainer.innerHTML = '';
  17329. _this.addTickMarks(tickMarksContainer, tickMarks);
  17330. } else {
  17331. _this.updateTickMarks(tickMarksContainer, tickMarks);
  17332. }
  17333. },
  17334. setPointerCapture: function setPointerCapture(pointerId) {
  17335. _this.root.setPointerCapture(pointerId);
  17336. },
  17337. emitChangeEvent: function emitChangeEvent(value, thumb) {
  17338. _this.emit(constants_1.events.CHANGE, { value: value, thumb: thumb });
  17339. },
  17340. emitInputEvent: function emitInputEvent(value, thumb) {
  17341. _this.emit(constants_1.events.INPUT, { value: value, thumb: thumb });
  17342. },
  17343. emitDragStartEvent: function emitDragStartEvent(_, thumb) {
  17344. // Emitting event is not yet implemented. See issue:
  17345. // https://github.com/material-components/material-components-web/issues/6448
  17346. _this.getRipple(thumb).activate();
  17347. },
  17348. emitDragEndEvent: function emitDragEndEvent(_, thumb) {
  17349. // Emitting event is not yet implemented. See issue:
  17350. // https://github.com/material-components/material-components-web/issues/6448
  17351. _this.getRipple(thumb).deactivate();
  17352. },
  17353. registerEventHandler: function registerEventHandler(evtType, handler) {
  17354. _this.listen(evtType, handler);
  17355. },
  17356. deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
  17357. _this.unlisten(evtType, handler);
  17358. },
  17359. registerThumbEventHandler: function registerThumbEventHandler(thumb, evtType, handler) {
  17360. _this.getThumbEl(thumb).addEventListener(evtType, handler);
  17361. },
  17362. deregisterThumbEventHandler: function deregisterThumbEventHandler(thumb, evtType, handler) {
  17363. _this.getThumbEl(thumb).removeEventListener(evtType, handler);
  17364. },
  17365. registerInputEventHandler: function registerInputEventHandler(thumb, evtType, handler) {
  17366. _this.getInput(thumb).addEventListener(evtType, handler);
  17367. },
  17368. deregisterInputEventHandler: function deregisterInputEventHandler(thumb, evtType, handler) {
  17369. _this.getInput(thumb).removeEventListener(evtType, handler);
  17370. },
  17371. registerBodyEventHandler: function registerBodyEventHandler(evtType, handler) {
  17372. document.body.addEventListener(evtType, handler);
  17373. },
  17374. deregisterBodyEventHandler: function deregisterBodyEventHandler(evtType, handler) {
  17375. document.body.removeEventListener(evtType, handler);
  17376. },
  17377. registerWindowEventHandler: function registerWindowEventHandler(evtType, handler) {
  17378. window.addEventListener(evtType, handler);
  17379. },
  17380. deregisterWindowEventHandler: function deregisterWindowEventHandler(evtType, handler) {
  17381. window.removeEventListener(evtType, handler);
  17382. }
  17383. };
  17384. return new foundation_2.MDCSliderFoundation(adapter);
  17385. };
  17386. /**
  17387. * Initializes component, with the following options:
  17388. * - `skipInitialUIUpdate`: Whether to skip updating the UI when initially
  17389. * syncing with the DOM. This should be enabled when the slider position
  17390. * is set before component initialization.
  17391. */
  17392. MDCSlider.prototype.initialize = function (_a) {
  17393. var skipInitialUIUpdate = (_a === void 0 ? {} : _a).skipInitialUIUpdate;
  17394. this.inputs = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.INPUT));
  17395. this.thumbs = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.THUMB));
  17396. this.trackActive = this.root.querySelector("." + constants_1.cssClasses.TRACK_ACTIVE);
  17397. this.ripples = this.createRipples();
  17398. if (skipInitialUIUpdate) {
  17399. this.skipInitialUIUpdate = true;
  17400. }
  17401. };
  17402. MDCSlider.prototype.initialSyncWithDOM = function () {
  17403. this.foundation.layout({ skipUpdateUI: this.skipInitialUIUpdate });
  17404. };
  17405. /** Redraws UI based on DOM (e.g. element dimensions, RTL). */
  17406. MDCSlider.prototype.layout = function () {
  17407. this.foundation.layout();
  17408. };
  17409. MDCSlider.prototype.getValueStart = function () {
  17410. return this.foundation.getValueStart();
  17411. };
  17412. MDCSlider.prototype.setValueStart = function (valueStart) {
  17413. this.foundation.setValueStart(valueStart);
  17414. };
  17415. MDCSlider.prototype.getValue = function () {
  17416. return this.foundation.getValue();
  17417. };
  17418. MDCSlider.prototype.setValue = function (value) {
  17419. this.foundation.setValue(value);
  17420. };
  17421. /** @return Slider disabled state. */
  17422. MDCSlider.prototype.getDisabled = function () {
  17423. return this.foundation.getDisabled();
  17424. };
  17425. /** Sets slider disabled state. */
  17426. MDCSlider.prototype.setDisabled = function (disabled) {
  17427. this.foundation.setDisabled(disabled);
  17428. };
  17429. /**
  17430. * Sets a function that maps the slider value to the value of the
  17431. * `aria-valuetext` attribute on the thumb element.
  17432. */
  17433. MDCSlider.prototype.setValueToAriaValueTextFn = function (mapFn) {
  17434. this.valueToAriaValueTextFn = mapFn;
  17435. };
  17436. MDCSlider.prototype.getThumbEl = function (thumb) {
  17437. return thumb === types_1.Thumb.END ? this.thumbs[this.thumbs.length - 1] : this.thumbs[0];
  17438. };
  17439. MDCSlider.prototype.getInput = function (thumb) {
  17440. return thumb === types_1.Thumb.END ? this.inputs[this.inputs.length - 1] : this.inputs[0];
  17441. };
  17442. MDCSlider.prototype.getRipple = function (thumb) {
  17443. return thumb === types_1.Thumb.END ? this.ripples[this.ripples.length - 1] : this.ripples[0];
  17444. };
  17445. /** Adds tick mark elements to the given container. */
  17446. MDCSlider.prototype.addTickMarks = function (tickMarkContainer, tickMarks) {
  17447. var fragment = document.createDocumentFragment();
  17448. for (var i = 0; i < tickMarks.length; i++) {
  17449. var div = document.createElement('div');
  17450. var tickMarkClass = tickMarks[i] === types_1.TickMark.ACTIVE ? constants_1.cssClasses.TICK_MARK_ACTIVE : constants_1.cssClasses.TICK_MARK_INACTIVE;
  17451. div.classList.add(tickMarkClass);
  17452. fragment.appendChild(div);
  17453. }
  17454. tickMarkContainer.appendChild(fragment);
  17455. };
  17456. /** Updates tick mark elements' classes in the given container. */
  17457. MDCSlider.prototype.updateTickMarks = function (tickMarkContainer, tickMarks) {
  17458. var tickMarkEls = Array.from(tickMarkContainer.children);
  17459. for (var i = 0; i < tickMarkEls.length; i++) {
  17460. if (tickMarks[i] === types_1.TickMark.ACTIVE) {
  17461. tickMarkEls[i].classList.add(constants_1.cssClasses.TICK_MARK_ACTIVE);
  17462. tickMarkEls[i].classList.remove(constants_1.cssClasses.TICK_MARK_INACTIVE);
  17463. } else {
  17464. tickMarkEls[i].classList.add(constants_1.cssClasses.TICK_MARK_INACTIVE);
  17465. tickMarkEls[i].classList.remove(constants_1.cssClasses.TICK_MARK_ACTIVE);
  17466. }
  17467. }
  17468. };
  17469. /** Initializes thumb ripples. */
  17470. MDCSlider.prototype.createRipples = function () {
  17471. var ripples = [];
  17472. var rippleSurfaces = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.THUMB));
  17473. var _loop_1 = function _loop_1(i) {
  17474. var rippleSurface = rippleSurfaces[i];
  17475. // Use the corresponding input as the focus source for the ripple (i.e.
  17476. // when the input is focused, the ripple is in the focused state).
  17477. var input = this_1.inputs[i];
  17478. var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this_1)), { addClass: function addClass(className) {
  17479. rippleSurface.classList.add(className);
  17480. }, computeBoundingRect: function computeBoundingRect() {
  17481. return rippleSurface.getBoundingClientRect();
  17482. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  17483. input.removeEventListener(evtType, handler);
  17484. }, isSurfaceActive: function isSurfaceActive() {
  17485. return ponyfill_1.matches(input, ':active');
  17486. }, isUnbounded: function isUnbounded() {
  17487. return true;
  17488. }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  17489. input.addEventListener(evtType, handler, events_1.applyPassive());
  17490. }, removeClass: function removeClass(className) {
  17491. rippleSurface.classList.remove(className);
  17492. }, updateCssVariable: function updateCssVariable(varName, value) {
  17493. rippleSurface.style.setProperty(varName, value);
  17494. } });
  17495. var ripple = new component_2.MDCRipple(rippleSurface, new foundation_1.MDCRippleFoundation(adapter));
  17496. ripple.unbounded = true;
  17497. ripples.push(ripple);
  17498. };
  17499. var this_1 = this;
  17500. for (var i = 0; i < rippleSurfaces.length; i++) {
  17501. _loop_1(i);
  17502. }
  17503. return ripples;
  17504. };
  17505. return MDCSlider;
  17506. }(component_1.MDCComponent);
  17507. exports.MDCSlider = MDCSlider;
  17508. /***/ }),
  17509. /***/ "./packages/mdc-slider/constants.ts":
  17510. /*!******************************************!*\
  17511. !*** ./packages/mdc-slider/constants.ts ***!
  17512. \******************************************/
  17513. /*! no static exports found */
  17514. /***/ (function(module, exports, __webpack_require__) {
  17515. "use strict";
  17516. /**
  17517. * @license
  17518. * Copyright 2020 Google Inc.
  17519. *
  17520. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17521. * of this software and associated documentation files (the "Software"), to deal
  17522. * in the Software without restriction, including without limitation the rights
  17523. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17524. * copies of the Software, and to permit persons to whom the Software is
  17525. * furnished to do so, subject to the following conditions:
  17526. *
  17527. * The above copyright notice and this permission notice shall be included in
  17528. * all copies or substantial portions of the Software.
  17529. *
  17530. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17531. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17532. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17533. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17534. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17535. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17536. * THE SOFTWARE.
  17537. */
  17538. Object.defineProperty(exports, "__esModule", { value: true });
  17539. /** Slider element classes. */
  17540. exports.cssClasses = {
  17541. DISABLED: 'mdc-slider--disabled',
  17542. DISCRETE: 'mdc-slider--discrete',
  17543. INPUT: 'mdc-slider__input',
  17544. RANGE: 'mdc-slider--range',
  17545. THUMB: 'mdc-slider__thumb',
  17546. THUMB_KNOB: 'mdc-slider__thumb-knob',
  17547. // Class added to the top thumb (for overlapping thumbs in range slider).
  17548. THUMB_TOP: 'mdc-slider__thumb--top',
  17549. THUMB_WITH_INDICATOR: 'mdc-slider__thumb--with-indicator',
  17550. TICK_MARKS: 'mdc-slider--tick-marks',
  17551. TICK_MARKS_CONTAINER: 'mdc-slider__tick-marks',
  17552. TICK_MARK_ACTIVE: 'mdc-slider__tick-mark--active',
  17553. TICK_MARK_INACTIVE: 'mdc-slider__tick-mark--inactive',
  17554. TRACK: 'mdc-slider__track',
  17555. // The active track fill element that will be scaled as the value changes.
  17556. TRACK_ACTIVE: 'mdc-slider__track--active_fill',
  17557. VALUE_INDICATOR_TEXT: 'mdc-slider__value-indicator-text'
  17558. };
  17559. /** Slider numbers. */
  17560. exports.numbers = {
  17561. // Default step size.
  17562. STEP_SIZE: 1,
  17563. // Minimum absolute difference between clientX of move event / down event
  17564. // for which to update thumb, in the case of overlapping thumbs.
  17565. // This is needed to reduce chances of choosing the thumb based on
  17566. // pointer jitter.
  17567. THUMB_UPDATE_MIN_PX: 5
  17568. };
  17569. /** Slider attributes. */
  17570. exports.attributes = {
  17571. ARIA_DISABLED: 'aria-disabled',
  17572. ARIA_VALUEMAX: 'aria-valuemax',
  17573. ARIA_VALUEMIN: 'aria-valuemin',
  17574. ARIA_VALUENOW: 'aria-valuenow',
  17575. ARIA_VALUETEXT: 'aria-valuetext',
  17576. INPUT_DISABLED: 'disabled',
  17577. INPUT_MIN: 'min',
  17578. INPUT_MAX: 'max',
  17579. INPUT_VALUE: 'value',
  17580. INPUT_STEP: 'step'
  17581. };
  17582. /** Slider events. */
  17583. exports.events = {
  17584. CHANGE: 'MDCSlider:change',
  17585. INPUT: 'MDCSlider:input'
  17586. };
  17587. /***/ }),
  17588. /***/ "./packages/mdc-slider/foundation.ts":
  17589. /*!*******************************************!*\
  17590. !*** ./packages/mdc-slider/foundation.ts ***!
  17591. \*******************************************/
  17592. /*! no static exports found */
  17593. /***/ (function(module, exports, __webpack_require__) {
  17594. "use strict";
  17595. /**
  17596. * @license
  17597. * Copyright 2020 Google Inc.
  17598. *
  17599. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17600. * of this software and associated documentation files (the "Software"), to deal
  17601. * in the Software without restriction, including without limitation the rights
  17602. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17603. * copies of the Software, and to permit persons to whom the Software is
  17604. * furnished to do so, subject to the following conditions:
  17605. *
  17606. * The above copyright notice and this permission notice shall be included in
  17607. * all copies or substantial portions of the Software.
  17608. *
  17609. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17610. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17611. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17612. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17613. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17614. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17615. * THE SOFTWARE.
  17616. */
  17617. var __extends = this && this.__extends || function () {
  17618. var _extendStatics = function extendStatics(d, b) {
  17619. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  17620. d.__proto__ = b;
  17621. } || function (d, b) {
  17622. for (var p in b) {
  17623. if (b.hasOwnProperty(p)) d[p] = b[p];
  17624. }
  17625. };
  17626. return _extendStatics(d, b);
  17627. };
  17628. return function (d, b) {
  17629. _extendStatics(d, b);
  17630. function __() {
  17631. this.constructor = d;
  17632. }
  17633. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17634. };
  17635. }();
  17636. var __assign = this && this.__assign || function () {
  17637. __assign = Object.assign || function (t) {
  17638. for (var s, i = 1, n = arguments.length; i < n; i++) {
  17639. s = arguments[i];
  17640. for (var p in s) {
  17641. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  17642. }
  17643. }
  17644. return t;
  17645. };
  17646. return __assign.apply(this, arguments);
  17647. };
  17648. Object.defineProperty(exports, "__esModule", { value: true });
  17649. var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
  17650. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  17651. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
  17652. var types_1 = __webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts");
  17653. // Accessing `window` without a `typeof` check will throw on Node environments.
  17654. var HAS_WINDOW = typeof window !== 'undefined';
  17655. /**
  17656. * Foundation class for slider. Responsibilities include:
  17657. * - Updating slider values (internal state and DOM updates) based on client
  17658. * 'x' position.
  17659. * - Updating DOM after slider property updates (e.g. min, max).
  17660. */
  17661. var MDCSliderFoundation = /** @class */function (_super) {
  17662. __extends(MDCSliderFoundation, _super);
  17663. function MDCSliderFoundation(adapter) {
  17664. var _this = _super.call(this, __assign(__assign({}, MDCSliderFoundation.defaultAdapter), adapter)) || this;
  17665. // Whether the initial styles (to position the thumb, before component
  17666. // initialization) have been removed.
  17667. _this.initialStylesRemoved = false;
  17668. _this.isDisabled = false;
  17669. _this.isDiscrete = false;
  17670. _this.step = constants_1.numbers.STEP_SIZE;
  17671. _this.hasTickMarks = false;
  17672. // The following properties are only set for range sliders.
  17673. _this.isRange = false;
  17674. // Tracks the thumb being moved across a slider pointer interaction (down,
  17675. // move event).
  17676. _this.thumb = null;
  17677. // `clientX` from the most recent down event. Used in subsequent move
  17678. // events to determine which thumb to move (in the case of
  17679. // overlapping thumbs).
  17680. _this.downEventClientX = null;
  17681. // Width of the start thumb knob.
  17682. _this.startThumbKnobWidth = 0;
  17683. // Width of the end thumb knob.
  17684. _this.endThumbKnobWidth = 0;
  17685. return _this;
  17686. }
  17687. Object.defineProperty(MDCSliderFoundation, "defaultAdapter", {
  17688. get: function get() {
  17689. // tslint:disable:object-literal-sort-keys Methods should be in the same
  17690. // order as the adapter interface.
  17691. return {
  17692. hasClass: function hasClass() {
  17693. return false;
  17694. },
  17695. addClass: function addClass() {
  17696. return undefined;
  17697. },
  17698. removeClass: function removeClass() {
  17699. return undefined;
  17700. },
  17701. addThumbClass: function addThumbClass() {
  17702. return undefined;
  17703. },
  17704. removeThumbClass: function removeThumbClass() {
  17705. return undefined;
  17706. },
  17707. getAttribute: function getAttribute() {
  17708. return null;
  17709. },
  17710. getInputValue: function getInputValue() {
  17711. return '';
  17712. },
  17713. setInputValue: function setInputValue() {
  17714. return undefined;
  17715. },
  17716. getInputAttribute: function getInputAttribute() {
  17717. return null;
  17718. },
  17719. setInputAttribute: function setInputAttribute() {
  17720. return null;
  17721. },
  17722. removeInputAttribute: function removeInputAttribute() {
  17723. return null;
  17724. },
  17725. focusInput: function focusInput() {
  17726. return undefined;
  17727. },
  17728. isInputFocused: function isInputFocused() {
  17729. return false;
  17730. },
  17731. getThumbKnobWidth: function getThumbKnobWidth() {
  17732. return 0;
  17733. },
  17734. getThumbBoundingClientRect: function getThumbBoundingClientRect() {
  17735. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  17736. },
  17737. getBoundingClientRect: function getBoundingClientRect() {
  17738. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  17739. },
  17740. isRTL: function isRTL() {
  17741. return false;
  17742. },
  17743. setThumbStyleProperty: function setThumbStyleProperty() {
  17744. return undefined;
  17745. },
  17746. removeThumbStyleProperty: function removeThumbStyleProperty() {
  17747. return undefined;
  17748. },
  17749. setTrackActiveStyleProperty: function setTrackActiveStyleProperty() {
  17750. return undefined;
  17751. },
  17752. removeTrackActiveStyleProperty: function removeTrackActiveStyleProperty() {
  17753. return undefined;
  17754. },
  17755. setValueIndicatorText: function setValueIndicatorText() {
  17756. return undefined;
  17757. },
  17758. getValueToAriaValueTextFn: function getValueToAriaValueTextFn() {
  17759. return null;
  17760. },
  17761. updateTickMarks: function updateTickMarks() {
  17762. return undefined;
  17763. },
  17764. setPointerCapture: function setPointerCapture() {
  17765. return undefined;
  17766. },
  17767. emitChangeEvent: function emitChangeEvent() {
  17768. return undefined;
  17769. },
  17770. emitInputEvent: function emitInputEvent() {
  17771. return undefined;
  17772. },
  17773. emitDragStartEvent: function emitDragStartEvent() {
  17774. return undefined;
  17775. },
  17776. emitDragEndEvent: function emitDragEndEvent() {
  17777. return undefined;
  17778. },
  17779. registerEventHandler: function registerEventHandler() {
  17780. return undefined;
  17781. },
  17782. deregisterEventHandler: function deregisterEventHandler() {
  17783. return undefined;
  17784. },
  17785. registerThumbEventHandler: function registerThumbEventHandler() {
  17786. return undefined;
  17787. },
  17788. deregisterThumbEventHandler: function deregisterThumbEventHandler() {
  17789. return undefined;
  17790. },
  17791. registerInputEventHandler: function registerInputEventHandler() {
  17792. return undefined;
  17793. },
  17794. deregisterInputEventHandler: function deregisterInputEventHandler() {
  17795. return undefined;
  17796. },
  17797. registerBodyEventHandler: function registerBodyEventHandler() {
  17798. return undefined;
  17799. },
  17800. deregisterBodyEventHandler: function deregisterBodyEventHandler() {
  17801. return undefined;
  17802. },
  17803. registerWindowEventHandler: function registerWindowEventHandler() {
  17804. return undefined;
  17805. },
  17806. deregisterWindowEventHandler: function deregisterWindowEventHandler() {
  17807. return undefined;
  17808. }
  17809. };
  17810. // tslint:enable:object-literal-sort-keys
  17811. },
  17812. enumerable: true,
  17813. configurable: true
  17814. });
  17815. MDCSliderFoundation.prototype.init = function () {
  17816. var _this = this;
  17817. this.isDisabled = this.adapter.hasClass(constants_1.cssClasses.DISABLED);
  17818. this.isDiscrete = this.adapter.hasClass(constants_1.cssClasses.DISCRETE);
  17819. this.hasTickMarks = this.adapter.hasClass(constants_1.cssClasses.TICK_MARKS);
  17820. this.isRange = this.adapter.hasClass(constants_1.cssClasses.RANGE);
  17821. var min = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_MIN, this.isRange ? types_1.Thumb.START : types_1.Thumb.END), constants_1.attributes.INPUT_MIN);
  17822. var max = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_MAX, types_1.Thumb.END), constants_1.attributes.INPUT_MAX);
  17823. var value = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_VALUE, types_1.Thumb.END), constants_1.attributes.INPUT_VALUE);
  17824. var valueStart = this.isRange ? this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_VALUE, types_1.Thumb.START), constants_1.attributes.INPUT_VALUE) : min;
  17825. this.validateProperties({ min: min, max: max, value: value, valueStart: valueStart });
  17826. this.min = min;
  17827. this.max = max;
  17828. this.value = value;
  17829. this.valueStart = valueStart;
  17830. this.valueBeforeDownEvent = value;
  17831. this.valueStartBeforeDownEvent = valueStart;
  17832. var stepAttr = this.adapter.getInputAttribute(constants_1.attributes.INPUT_STEP, types_1.Thumb.END);
  17833. if (stepAttr) {
  17834. this.step = this.convertAttributeValueToNumber(stepAttr, constants_1.attributes.INPUT_STEP);
  17835. }
  17836. if (this.step <= 0) {
  17837. throw new Error("MDCSliderFoundation: step must be a positive number. " + ("Current step: " + this.step));
  17838. }
  17839. this.mousedownOrTouchstartListener = this.handleMousedownOrTouchstart.bind(this);
  17840. this.moveListener = this.handleMove.bind(this);
  17841. this.pointerdownListener = this.handlePointerdown.bind(this);
  17842. this.pointerupListener = this.handlePointerup.bind(this);
  17843. this.thumbMouseenterListener = this.handleThumbMouseenter.bind(this);
  17844. this.thumbMouseleaveListener = this.handleThumbMouseleave.bind(this);
  17845. this.inputStartChangeListener = function () {
  17846. _this.handleInputChange(types_1.Thumb.START);
  17847. };
  17848. this.inputEndChangeListener = function () {
  17849. _this.handleInputChange(types_1.Thumb.END);
  17850. };
  17851. this.inputStartFocusListener = function () {
  17852. _this.handleInputFocus(types_1.Thumb.START);
  17853. };
  17854. this.inputEndFocusListener = function () {
  17855. _this.handleInputFocus(types_1.Thumb.END);
  17856. };
  17857. this.inputStartBlurListener = function () {
  17858. _this.handleInputBlur(types_1.Thumb.START);
  17859. };
  17860. this.inputEndBlurListener = function () {
  17861. _this.handleInputBlur(types_1.Thumb.END);
  17862. };
  17863. this.resizeListener = this.handleResize.bind(this);
  17864. this.registerEventHandlers();
  17865. };
  17866. MDCSliderFoundation.prototype.destroy = function () {
  17867. this.deregisterEventHandlers();
  17868. };
  17869. MDCSliderFoundation.prototype.getMin = function () {
  17870. return this.min;
  17871. };
  17872. MDCSliderFoundation.prototype.getMax = function () {
  17873. return this.max;
  17874. };
  17875. /**
  17876. * - For single point sliders, returns the thumb value.
  17877. * - For range (two-thumb) sliders, returns the end thumb's value.
  17878. */
  17879. MDCSliderFoundation.prototype.getValue = function () {
  17880. return this.value;
  17881. };
  17882. /**
  17883. * - For single point sliders, sets the thumb value.
  17884. * - For range (two-thumb) sliders, sets the end thumb's value.
  17885. */
  17886. MDCSliderFoundation.prototype.setValue = function (value) {
  17887. if (this.isRange && value < this.valueStart) {
  17888. throw new Error("end thumb value (" + value + ") must be >= start thumb " + ("value (" + this.valueStart + ")"));
  17889. }
  17890. this.updateValue(value, types_1.Thumb.END);
  17891. };
  17892. /**
  17893. * Only applicable for range sliders.
  17894. * @return The start thumb's value.
  17895. */
  17896. MDCSliderFoundation.prototype.getValueStart = function () {
  17897. if (!this.isRange) {
  17898. throw new Error('`valueStart` is only applicable for range sliders.');
  17899. }
  17900. return this.valueStart;
  17901. };
  17902. /**
  17903. * Only applicable for range sliders. Sets the start thumb's value.
  17904. */
  17905. MDCSliderFoundation.prototype.setValueStart = function (valueStart) {
  17906. if (!this.isRange) {
  17907. throw new Error('`valueStart` is only applicable for range sliders.');
  17908. }
  17909. if (this.isRange && valueStart > this.value) {
  17910. throw new Error("start thumb value (" + valueStart + ") must be <= end thumb " + ("value (" + this.value + ")"));
  17911. }
  17912. this.updateValue(valueStart, types_1.Thumb.START);
  17913. };
  17914. MDCSliderFoundation.prototype.getStep = function () {
  17915. return this.step;
  17916. };
  17917. MDCSliderFoundation.prototype.getDisabled = function () {
  17918. return this.isDisabled;
  17919. };
  17920. /**
  17921. * Sets disabled state, including updating styles and thumb tabindex.
  17922. */
  17923. MDCSliderFoundation.prototype.setDisabled = function (disabled) {
  17924. this.isDisabled = disabled;
  17925. if (disabled) {
  17926. this.adapter.addClass(constants_1.cssClasses.DISABLED);
  17927. if (this.isRange) {
  17928. this.adapter.setInputAttribute(constants_1.attributes.INPUT_DISABLED, '', types_1.Thumb.START);
  17929. }
  17930. this.adapter.setInputAttribute(constants_1.attributes.INPUT_DISABLED, '', types_1.Thumb.END);
  17931. } else {
  17932. this.adapter.removeClass(constants_1.cssClasses.DISABLED);
  17933. if (this.isRange) {
  17934. this.adapter.removeInputAttribute(constants_1.attributes.INPUT_DISABLED, types_1.Thumb.START);
  17935. }
  17936. this.adapter.removeInputAttribute(constants_1.attributes.INPUT_DISABLED, types_1.Thumb.END);
  17937. }
  17938. };
  17939. /** @return Whether the slider is a range slider. */
  17940. MDCSliderFoundation.prototype.getIsRange = function () {
  17941. return this.isRange;
  17942. };
  17943. /**
  17944. * - Syncs slider boundingClientRect with the current DOM.
  17945. * - Updates UI based on internal state.
  17946. */
  17947. MDCSliderFoundation.prototype.layout = function (_a) {
  17948. var skipUpdateUI = (_a === void 0 ? {} : _a).skipUpdateUI;
  17949. this.rect = this.adapter.getBoundingClientRect();
  17950. if (this.isRange) {
  17951. this.startThumbKnobWidth = this.adapter.getThumbKnobWidth(types_1.Thumb.START);
  17952. this.endThumbKnobWidth = this.adapter.getThumbKnobWidth(types_1.Thumb.END);
  17953. }
  17954. if (!skipUpdateUI) {
  17955. this.updateUI();
  17956. }
  17957. };
  17958. /** Handles resize events on the window. */
  17959. MDCSliderFoundation.prototype.handleResize = function () {
  17960. this.layout();
  17961. };
  17962. /**
  17963. * Handles pointer down events on the slider root element.
  17964. */
  17965. MDCSliderFoundation.prototype.handleDown = function (event) {
  17966. if (this.isDisabled) return;
  17967. this.valueStartBeforeDownEvent = this.valueStart;
  17968. this.valueBeforeDownEvent = this.value;
  17969. var clientX = event.clientX != null ? event.clientX : event.targetTouches[0].clientX;
  17970. this.downEventClientX = clientX;
  17971. var value = this.mapClientXOnSliderScale(clientX);
  17972. this.thumb = this.getThumbFromDownEvent(clientX, value);
  17973. if (this.thumb === null) return;
  17974. this.handleDragStart(event, value, this.thumb);
  17975. // Presses within the range do not invoke slider updates.
  17976. var newValueInCurrentRange = this.isRange && value >= this.valueStart && value <= this.value;
  17977. if (newValueInCurrentRange) return;
  17978. this.updateValue(value, this.thumb, { emitInputEvent: true });
  17979. };
  17980. /**
  17981. * Handles pointer move events on the slider root element.
  17982. */
  17983. MDCSliderFoundation.prototype.handleMove = function (event) {
  17984. if (this.isDisabled) return;
  17985. // Prevent scrolling.
  17986. event.preventDefault();
  17987. var clientX = event.clientX != null ? event.clientX : event.targetTouches[0].clientX;
  17988. var dragAlreadyStarted = this.thumb != null;
  17989. this.thumb = this.getThumbFromMoveEvent(clientX);
  17990. if (this.thumb === null) return;
  17991. var value = this.mapClientXOnSliderScale(clientX);
  17992. if (!dragAlreadyStarted) {
  17993. this.handleDragStart(event, value, this.thumb);
  17994. this.adapter.emitDragStartEvent(value, this.thumb);
  17995. }
  17996. this.updateValue(value, this.thumb, { emitInputEvent: true });
  17997. };
  17998. /**
  17999. * Handles pointer up events on the slider root element.
  18000. */
  18001. MDCSliderFoundation.prototype.handleUp = function () {
  18002. if (this.isDisabled || this.thumb === null) return;
  18003. var oldValue = this.thumb === types_1.Thumb.START ? this.valueStartBeforeDownEvent : this.valueBeforeDownEvent;
  18004. var newValue = this.thumb === types_1.Thumb.START ? this.valueStart : this.value;
  18005. if (oldValue !== newValue) {
  18006. this.adapter.emitChangeEvent(newValue, this.thumb);
  18007. }
  18008. this.adapter.emitDragEndEvent(newValue, this.thumb);
  18009. this.thumb = null;
  18010. };
  18011. /**
  18012. * For range, discrete slider, shows the value indicator on both thumbs.
  18013. */
  18014. MDCSliderFoundation.prototype.handleThumbMouseenter = function () {
  18015. if (!this.isDiscrete || !this.isRange) return;
  18016. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.START);
  18017. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.END);
  18018. };
  18019. /**
  18020. * For range, discrete slider, hides the value indicator on both thumbs.
  18021. */
  18022. MDCSliderFoundation.prototype.handleThumbMouseleave = function () {
  18023. if (!this.isDiscrete || !this.isRange) return;
  18024. if (this.adapter.isInputFocused(types_1.Thumb.START) || this.adapter.isInputFocused(types_1.Thumb.END)) {
  18025. // Leave value indicator shown if either input is focused.
  18026. return;
  18027. }
  18028. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.START);
  18029. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.END);
  18030. };
  18031. MDCSliderFoundation.prototype.handleMousedownOrTouchstart = function (event) {
  18032. var _this = this;
  18033. var moveEventType = event.type === 'mousedown' ? 'mousemove' : 'touchmove';
  18034. // After a down event on the slider root, listen for move events on
  18035. // body (so the slider value is updated for events outside of the
  18036. // slider root).
  18037. this.adapter.registerBodyEventHandler(moveEventType, this.moveListener);
  18038. var upHandler = function upHandler() {
  18039. _this.handleUp();
  18040. // Once the drag is finished (up event on body), remove the move
  18041. // handler.
  18042. _this.adapter.deregisterBodyEventHandler(moveEventType, _this.moveListener);
  18043. // Also stop listening for subsequent up events.
  18044. _this.adapter.deregisterEventHandler('mouseup', upHandler);
  18045. _this.adapter.deregisterEventHandler('touchend', upHandler);
  18046. };
  18047. this.adapter.registerBodyEventHandler('mouseup', upHandler);
  18048. this.adapter.registerBodyEventHandler('touchend', upHandler);
  18049. this.handleDown(event);
  18050. };
  18051. MDCSliderFoundation.prototype.handlePointerdown = function (event) {
  18052. this.adapter.setPointerCapture(event.pointerId);
  18053. this.adapter.registerEventHandler('pointermove', this.moveListener);
  18054. this.handleDown(event);
  18055. };
  18056. /**
  18057. * Handles input `change` event by setting internal slider value to match
  18058. * input's new value.
  18059. */
  18060. MDCSliderFoundation.prototype.handleInputChange = function (thumb) {
  18061. var value = Number(this.adapter.getInputValue(thumb));
  18062. if (thumb === types_1.Thumb.START) {
  18063. this.setValueStart(value);
  18064. } else {
  18065. this.setValue(value);
  18066. }
  18067. this.adapter.emitChangeEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
  18068. };
  18069. /** Shows value indicator on thumb(s). */
  18070. MDCSliderFoundation.prototype.handleInputFocus = function (thumb) {
  18071. if (!this.isDiscrete) return;
  18072. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, thumb);
  18073. if (this.isRange) {
  18074. var otherThumb = thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START;
  18075. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, otherThumb);
  18076. }
  18077. };
  18078. /** Removes value indicator from thumb(s). */
  18079. MDCSliderFoundation.prototype.handleInputBlur = function (thumb) {
  18080. if (!this.isDiscrete) return;
  18081. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, thumb);
  18082. if (this.isRange) {
  18083. var otherThumb = thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START;
  18084. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, otherThumb);
  18085. }
  18086. };
  18087. /**
  18088. * Emits custom dragStart event, along with focusing the underlying input.
  18089. */
  18090. MDCSliderFoundation.prototype.handleDragStart = function (event, value, thumb) {
  18091. this.adapter.focusInput(thumb);
  18092. // Prevent the input (that we just focused) from losing focus.
  18093. event.preventDefault();
  18094. this.adapter.emitDragStartEvent(value, thumb);
  18095. };
  18096. /**
  18097. * @return The thumb to be moved based on initial down event.
  18098. */
  18099. MDCSliderFoundation.prototype.getThumbFromDownEvent = function (clientX, value) {
  18100. // For single point slider, thumb to be moved is always the END (only)
  18101. // thumb.
  18102. if (!this.isRange) return types_1.Thumb.END;
  18103. // Check if event press point is in the bounds of any thumb.
  18104. var thumbStartRect = this.adapter.getThumbBoundingClientRect(types_1.Thumb.START);
  18105. var thumbEndRect = this.adapter.getThumbBoundingClientRect(types_1.Thumb.END);
  18106. var inThumbStartBounds = clientX >= thumbStartRect.left && clientX <= thumbStartRect.right;
  18107. var inThumbEndBounds = clientX >= thumbEndRect.left && clientX <= thumbEndRect.right;
  18108. if (inThumbStartBounds && inThumbEndBounds) {
  18109. // Thumbs overlapping. Thumb to be moved cannot be determined yet.
  18110. return null;
  18111. }
  18112. // If press is in bounds for either thumb on down event, that's the thumb
  18113. // to be moved.
  18114. if (inThumbStartBounds) {
  18115. return types_1.Thumb.START;
  18116. }
  18117. if (inThumbEndBounds) {
  18118. return types_1.Thumb.END;
  18119. }
  18120. // Otherwise, if press occurred outside of the range, return either start
  18121. // or end thumb based on which the press is closer to.
  18122. if (value < this.valueStart) {
  18123. return types_1.Thumb.START;
  18124. }
  18125. if (value > this.value) {
  18126. return types_1.Thumb.END;
  18127. }
  18128. return null;
  18129. };
  18130. /**
  18131. * @return The thumb to be moved based on move event (based on drag
  18132. * direction from original down event). Only applicable if thumbs
  18133. * were overlapping in the down event.
  18134. */
  18135. MDCSliderFoundation.prototype.getThumbFromMoveEvent = function (clientX) {
  18136. // Thumb has already been chosen.
  18137. if (this.thumb !== null) return this.thumb;
  18138. if (this.downEventClientX === null) {
  18139. throw new Error('`downEventClientX` is null after move event.');
  18140. }
  18141. var moveDistanceUnderThreshold = Math.abs(this.downEventClientX - clientX) < constants_1.numbers.THUMB_UPDATE_MIN_PX;
  18142. if (moveDistanceUnderThreshold) return this.thumb;
  18143. var draggedThumbToLeft = clientX < this.downEventClientX;
  18144. if (draggedThumbToLeft) {
  18145. return this.adapter.isRTL() ? types_1.Thumb.END : types_1.Thumb.START;
  18146. } else {
  18147. return this.adapter.isRTL() ? types_1.Thumb.START : types_1.Thumb.END;
  18148. }
  18149. };
  18150. /**
  18151. * Updates UI based on internal state.
  18152. * @param thumb Thumb whose value is being updated. If undefined, UI is
  18153. * updated for both thumbs based on current internal state.
  18154. */
  18155. MDCSliderFoundation.prototype.updateUI = function (thumb) {
  18156. this.updateThumbAndInputAttributes(thumb);
  18157. this.updateThumbAndTrackUI(thumb);
  18158. this.updateValueIndicatorUI(thumb);
  18159. this.updateTickMarksUI();
  18160. };
  18161. /**
  18162. * Updates thumb and input attributes based on current value.
  18163. * @param thumb Thumb whose aria attributes to update.
  18164. */
  18165. MDCSliderFoundation.prototype.updateThumbAndInputAttributes = function (thumb) {
  18166. if (!thumb) return;
  18167. var value = this.isRange && thumb === types_1.Thumb.START ? this.valueStart : this.value;
  18168. var valueStr = String(value);
  18169. this.adapter.setInputAttribute(constants_1.attributes.INPUT_VALUE, valueStr, thumb);
  18170. if (this.isRange && thumb === types_1.Thumb.START) {
  18171. this.adapter.setInputAttribute(constants_1.attributes.INPUT_MIN, valueStr, types_1.Thumb.END);
  18172. } else if (this.isRange && thumb === types_1.Thumb.END) {
  18173. this.adapter.setInputAttribute(constants_1.attributes.INPUT_MAX, valueStr, types_1.Thumb.START);
  18174. }
  18175. // Sync attribute with property.
  18176. if (this.adapter.getInputValue(thumb) !== valueStr) {
  18177. this.adapter.setInputValue(valueStr, thumb);
  18178. }
  18179. var valueToAriaValueTextFn = this.adapter.getValueToAriaValueTextFn();
  18180. if (valueToAriaValueTextFn) {
  18181. this.adapter.setInputAttribute(constants_1.attributes.ARIA_VALUETEXT, valueToAriaValueTextFn(value), thumb);
  18182. }
  18183. };
  18184. /**
  18185. * Updates value indicator UI based on current value.
  18186. * @param thumb Thumb whose value indicator to update. If undefined, all
  18187. * thumbs' value indicators are updated.
  18188. */
  18189. MDCSliderFoundation.prototype.updateValueIndicatorUI = function (thumb) {
  18190. if (!this.isDiscrete) return;
  18191. var value = this.isRange && thumb === types_1.Thumb.START ? this.valueStart : this.value;
  18192. this.adapter.setValueIndicatorText(value, thumb === types_1.Thumb.START ? types_1.Thumb.START : types_1.Thumb.END);
  18193. if (!thumb && this.isRange) {
  18194. this.adapter.setValueIndicatorText(this.valueStart, types_1.Thumb.START);
  18195. }
  18196. };
  18197. /**
  18198. * Updates tick marks UI within slider, based on current min, max, and step.
  18199. */
  18200. MDCSliderFoundation.prototype.updateTickMarksUI = function () {
  18201. if (!this.isDiscrete || !this.hasTickMarks) return;
  18202. var numTickMarksInactiveStart = (this.valueStart - this.min) / this.step;
  18203. var numTickMarksActive = (this.value - this.valueStart) / this.step + 1;
  18204. var numTickMarksInactiveEnd = (this.max - this.value) / this.step;
  18205. var tickMarksInactiveStart = Array.from({ length: numTickMarksInactiveStart }).fill(types_1.TickMark.INACTIVE);
  18206. var tickMarksActive = Array.from({ length: numTickMarksActive }).fill(types_1.TickMark.ACTIVE);
  18207. var tickMarksInactiveEnd = Array.from({ length: numTickMarksInactiveEnd }).fill(types_1.TickMark.INACTIVE);
  18208. this.adapter.updateTickMarks(tickMarksInactiveStart.concat(tickMarksActive).concat(tickMarksInactiveEnd));
  18209. };
  18210. /** Maps clientX to a value on the slider scale. */
  18211. MDCSliderFoundation.prototype.mapClientXOnSliderScale = function (clientX) {
  18212. var xPos = clientX - this.rect.left;
  18213. var pctComplete = xPos / this.rect.width;
  18214. if (this.adapter.isRTL()) {
  18215. pctComplete = 1 - pctComplete;
  18216. }
  18217. // Fit the percentage complete between the range [min,max]
  18218. // by remapping from [0, 1] to [min, min+(max-min)].
  18219. var value = this.min + pctComplete * (this.max - this.min);
  18220. if (value === this.max || value === this.min) {
  18221. return value;
  18222. }
  18223. return this.quantize(value);
  18224. };
  18225. /**
  18226. * Updates slider value (internal state and UI) based on the given value.
  18227. */
  18228. MDCSliderFoundation.prototype.updateValue = function (value, thumb, _a) {
  18229. var _b = _a === void 0 ? {} : _a,
  18230. emitInputEvent = _b.emitInputEvent,
  18231. emitChangeEvent = _b.emitChangeEvent;
  18232. value = this.clampValue(value, thumb);
  18233. if (this.isRange && thumb === types_1.Thumb.START) {
  18234. // Exit early if current value is the same as the new value.
  18235. if (this.valueStart === value) return;
  18236. this.valueStart = value;
  18237. } else {
  18238. // Exit early if current value is the same as the new value.
  18239. if (this.value === value) return;
  18240. this.value = value;
  18241. }
  18242. this.updateUI(thumb);
  18243. if (emitInputEvent) {
  18244. this.adapter.emitInputEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
  18245. }
  18246. if (emitChangeEvent) {
  18247. this.adapter.emitChangeEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
  18248. }
  18249. };
  18250. /** Calculates the quantized value based on step value. */
  18251. MDCSliderFoundation.prototype.quantize = function (value) {
  18252. var numSteps = Math.round(value / this.step);
  18253. return numSteps * this.step;
  18254. };
  18255. /**
  18256. * Clamps the given value for the given thumb based on slider properties:
  18257. * - Restricts value within [min, max].
  18258. * - If range slider, clamp start value <= end value, and
  18259. * end value >= start value.
  18260. */
  18261. MDCSliderFoundation.prototype.clampValue = function (value, thumb) {
  18262. // Clamp value to [min, max] range.
  18263. value = Math.min(Math.max(value, this.min), this.max);
  18264. var thumbStartMovedPastThumbEnd = this.isRange && thumb === types_1.Thumb.START && value > this.value;
  18265. if (thumbStartMovedPastThumbEnd) {
  18266. return this.value;
  18267. }
  18268. var thumbEndMovedPastThumbStart = this.isRange && thumb === types_1.Thumb.END && value < this.valueStart;
  18269. if (thumbEndMovedPastThumbStart) {
  18270. return this.valueStart;
  18271. }
  18272. return value;
  18273. };
  18274. /**
  18275. * Updates the active track and thumb style properties to reflect current
  18276. * value.
  18277. */
  18278. MDCSliderFoundation.prototype.updateThumbAndTrackUI = function (thumb) {
  18279. var _this = this;
  18280. var _a = this,
  18281. max = _a.max,
  18282. min = _a.min;
  18283. var pctComplete = (this.value - this.valueStart) / (max - min);
  18284. var rangePx = pctComplete * this.rect.width;
  18285. var isRtl = this.adapter.isRTL();
  18286. var transformProp = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
  18287. if (this.isRange) {
  18288. var thumbLeftPos_1 = this.adapter.isRTL() ? (max - this.value) / (max - min) * this.rect.width : (this.valueStart - min) / (max - min) * this.rect.width;
  18289. var thumbRightPos_1 = thumbLeftPos_1 + rangePx;
  18290. requestAnimationFrame(function () {
  18291. // Set active track styles, accounting for animation direction by
  18292. // setting `transform-origin`.
  18293. var trackAnimatesFromRight = !isRtl && thumb === types_1.Thumb.START || isRtl && thumb !== types_1.Thumb.START;
  18294. if (trackAnimatesFromRight) {
  18295. _this.adapter.setTrackActiveStyleProperty('transform-origin', 'right');
  18296. _this.adapter.setTrackActiveStyleProperty('left', 'unset');
  18297. _this.adapter.setTrackActiveStyleProperty('right', _this.rect.width - thumbRightPos_1 + "px");
  18298. } else {
  18299. _this.adapter.setTrackActiveStyleProperty('transform-origin', 'left');
  18300. _this.adapter.setTrackActiveStyleProperty('right', 'unset');
  18301. _this.adapter.setTrackActiveStyleProperty('left', thumbLeftPos_1 + "px");
  18302. }
  18303. _this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
  18304. // Set thumb styles.
  18305. var thumbStartPos = isRtl ? thumbRightPos_1 : thumbLeftPos_1;
  18306. var thumbEndPos = _this.adapter.isRTL() ? thumbLeftPos_1 : thumbRightPos_1;
  18307. if (thumb === types_1.Thumb.START || !thumb || !_this.initialStylesRemoved) {
  18308. _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", types_1.Thumb.START);
  18309. }
  18310. if (thumb === types_1.Thumb.END || !thumb || !_this.initialStylesRemoved) {
  18311. _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbEndPos + "px)", types_1.Thumb.END);
  18312. }
  18313. _this.removeInitialStyles(isRtl);
  18314. _this.updateOverlappingThumbsUI(thumbStartPos, thumbEndPos, thumb);
  18315. });
  18316. } else {
  18317. requestAnimationFrame(function () {
  18318. var thumbStartPos = isRtl ? _this.rect.width - rangePx : rangePx;
  18319. _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", types_1.Thumb.END);
  18320. _this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
  18321. _this.removeInitialStyles(isRtl);
  18322. });
  18323. }
  18324. };
  18325. /**
  18326. * Removes initial inline styles if not already removed. `left:<...>%`
  18327. * inline styles can be added to position the thumb correctly before JS
  18328. * initialization. However, they need to be removed before the JS starts
  18329. * positioning the thumb. This is because the JS uses
  18330. * `transform:translateX(<...>)px` (for performance reasons) to position
  18331. * the thumb (which is not possible for initial styles since we need the
  18332. * bounding rect measurements).
  18333. */
  18334. MDCSliderFoundation.prototype.removeInitialStyles = function (isRtl) {
  18335. if (this.initialStylesRemoved) return;
  18336. // Remove thumb position properties that were added for initial render.
  18337. var position = isRtl ? 'right' : 'left';
  18338. this.adapter.removeThumbStyleProperty(position, types_1.Thumb.END);
  18339. if (this.isRange) {
  18340. this.adapter.removeThumbStyleProperty(position, types_1.Thumb.START);
  18341. }
  18342. this.initialStylesRemoved = true;
  18343. this.resetTrackAndThumbAnimation();
  18344. };
  18345. /**
  18346. * Resets track/thumb animation to prevent animation when adding
  18347. * `transform` styles to thumb initially.
  18348. */
  18349. MDCSliderFoundation.prototype.resetTrackAndThumbAnimation = function () {
  18350. var _this = this;
  18351. if (!this.isDiscrete) return;
  18352. // Set transition properties to default (no animation), so that the
  18353. // newly added `transform` styles do not animate thumb/track from
  18354. // their default positions.
  18355. var transitionProp = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transition') : 'transition';
  18356. var transitionDefault = 'all 0s ease 0s';
  18357. this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, types_1.Thumb.END);
  18358. if (this.isRange) {
  18359. this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, types_1.Thumb.START);
  18360. }
  18361. this.adapter.setTrackActiveStyleProperty(transitionProp, transitionDefault);
  18362. // In the next frame, remove the transition inline styles we just
  18363. // added, such that any animations added in the CSS can now take effect.
  18364. requestAnimationFrame(function () {
  18365. _this.adapter.removeThumbStyleProperty(transitionProp, types_1.Thumb.END);
  18366. _this.adapter.removeTrackActiveStyleProperty(transitionProp);
  18367. if (_this.isRange) {
  18368. _this.adapter.removeThumbStyleProperty(transitionProp, types_1.Thumb.START);
  18369. }
  18370. });
  18371. };
  18372. /**
  18373. * Adds THUMB_TOP class to active thumb if thumb knobs overlap; otherwise
  18374. * removes THUMB_TOP class from both thumbs.
  18375. * @param thumb Thumb that is active (being moved).
  18376. */
  18377. MDCSliderFoundation.prototype.updateOverlappingThumbsUI = function (thumbStartPos, thumbEndPos, thumb) {
  18378. var thumbsOverlap = false;
  18379. if (this.adapter.isRTL()) {
  18380. var startThumbLeftEdge = thumbStartPos - this.startThumbKnobWidth / 2;
  18381. var endThumbRightEdge = thumbEndPos + this.endThumbKnobWidth / 2;
  18382. thumbsOverlap = endThumbRightEdge >= startThumbLeftEdge;
  18383. } else {
  18384. var startThumbRightEdge = thumbStartPos + this.startThumbKnobWidth / 2;
  18385. var endThumbLeftEdge = thumbEndPos - this.endThumbKnobWidth / 2;
  18386. thumbsOverlap = startThumbRightEdge >= endThumbLeftEdge;
  18387. }
  18388. if (thumbsOverlap) {
  18389. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_TOP,
  18390. // If no thumb was dragged (in the case of initial layout), end
  18391. // thumb is on top by default.
  18392. thumb || types_1.Thumb.END);
  18393. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START);
  18394. } else {
  18395. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, types_1.Thumb.START);
  18396. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, types_1.Thumb.END);
  18397. }
  18398. };
  18399. /**
  18400. * Converts attribute value to a number, e.g. '100' => 100. Throws errors
  18401. * for invalid values.
  18402. * @param attributeValue Attribute value, e.g. 100.
  18403. * @param attributeName Attribute name, e.g. `aria-valuemax`.
  18404. */
  18405. MDCSliderFoundation.prototype.convertAttributeValueToNumber = function (attributeValue, attributeName) {
  18406. if (attributeValue === null) {
  18407. throw new Error("MDCSliderFoundation: `" + attributeName + "` must be non-null.");
  18408. }
  18409. var value = Number(attributeValue);
  18410. if (isNaN(value)) {
  18411. throw new Error("MDCSliderFoundation: `" + attributeName + "` value is " + ("`" + attributeValue + "`, but must be a number."));
  18412. }
  18413. return value;
  18414. };
  18415. /** Checks that the given properties are valid slider values. */
  18416. MDCSliderFoundation.prototype.validateProperties = function (_a) {
  18417. var min = _a.min,
  18418. max = _a.max,
  18419. value = _a.value,
  18420. valueStart = _a.valueStart;
  18421. if (min >= max) {
  18422. throw new Error("MDCSliderFoundation: min must be strictly less than max. " + ("Current: [min: " + min + ", max: " + max + "]"));
  18423. }
  18424. if (this.isRange) {
  18425. if (value < min || value > max || valueStart < min || valueStart > max) {
  18426. throw new Error("MDCSliderFoundation: values must be in [min, max] range. " + ("Current values: [start value: " + valueStart + ", end value: " + value + "]"));
  18427. }
  18428. if (valueStart > value) {
  18429. throw new Error("MDCSliderFoundation: start value must be <= end value. " + ("Current values: [start value: " + valueStart + ", end value: " + value + "]"));
  18430. }
  18431. } else {
  18432. // Single point slider.
  18433. if (value < min || value > max) {
  18434. throw new Error("MDCSliderFoundation: value must be in [min, max] range. " + ("Current value: " + value));
  18435. }
  18436. }
  18437. };
  18438. MDCSliderFoundation.prototype.registerEventHandlers = function () {
  18439. this.adapter.registerWindowEventHandler('resize', this.resizeListener);
  18440. if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
  18441. // If supported, use pointer events API with #setPointerCapture.
  18442. this.adapter.registerEventHandler('pointerdown', this.pointerdownListener);
  18443. this.adapter.registerEventHandler('pointerup', this.pointerupListener);
  18444. } else {
  18445. // Otherwise, fall back to mousedown/touchstart events.
  18446. this.adapter.registerEventHandler('mousedown', this.mousedownOrTouchstartListener);
  18447. this.adapter.registerEventHandler('touchstart', this.mousedownOrTouchstartListener);
  18448. }
  18449. if (this.isRange) {
  18450. this.adapter.registerThumbEventHandler(types_1.Thumb.START, 'mouseenter', this.thumbMouseenterListener);
  18451. this.adapter.registerThumbEventHandler(types_1.Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
  18452. this.adapter.registerInputEventHandler(types_1.Thumb.START, 'change', this.inputStartChangeListener);
  18453. this.adapter.registerInputEventHandler(types_1.Thumb.START, 'focus', this.inputStartFocusListener);
  18454. this.adapter.registerInputEventHandler(types_1.Thumb.START, 'blur', this.inputStartBlurListener);
  18455. }
  18456. this.adapter.registerThumbEventHandler(types_1.Thumb.END, 'mouseenter', this.thumbMouseenterListener);
  18457. this.adapter.registerThumbEventHandler(types_1.Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
  18458. this.adapter.registerInputEventHandler(types_1.Thumb.END, 'change', this.inputEndChangeListener);
  18459. this.adapter.registerInputEventHandler(types_1.Thumb.END, 'focus', this.inputEndFocusListener);
  18460. this.adapter.registerInputEventHandler(types_1.Thumb.END, 'blur', this.inputEndBlurListener);
  18461. };
  18462. MDCSliderFoundation.prototype.deregisterEventHandlers = function () {
  18463. this.adapter.deregisterWindowEventHandler('resize', this.resizeListener);
  18464. if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
  18465. this.adapter.deregisterEventHandler('pointerdown', this.pointerdownListener);
  18466. this.adapter.deregisterEventHandler('pointerup', this.pointerupListener);
  18467. } else {
  18468. this.adapter.deregisterEventHandler('mousedown', this.mousedownOrTouchstartListener);
  18469. this.adapter.deregisterEventHandler('touchstart', this.mousedownOrTouchstartListener);
  18470. }
  18471. if (this.isRange) {
  18472. this.adapter.deregisterThumbEventHandler(types_1.Thumb.START, 'mouseenter', this.thumbMouseenterListener);
  18473. this.adapter.deregisterThumbEventHandler(types_1.Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
  18474. this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'change', this.inputStartChangeListener);
  18475. this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'focus', this.inputStartFocusListener);
  18476. this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'blur', this.inputStartBlurListener);
  18477. }
  18478. this.adapter.deregisterThumbEventHandler(types_1.Thumb.END, 'mouseenter', this.thumbMouseenterListener);
  18479. this.adapter.deregisterThumbEventHandler(types_1.Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
  18480. this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'change', this.inputEndChangeListener);
  18481. this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'focus', this.inputEndFocusListener);
  18482. this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'blur', this.inputEndBlurListener);
  18483. };
  18484. MDCSliderFoundation.prototype.handlePointerup = function () {
  18485. this.handleUp();
  18486. this.adapter.deregisterEventHandler('pointermove', this.moveListener);
  18487. };
  18488. MDCSliderFoundation.SUPPORTS_POINTER_EVENTS = HAS_WINDOW && Boolean(window.PointerEvent) &&
  18489. // #setPointerCapture is buggy on iOS, so we can't use pointer events
  18490. // until the following bug is fixed:
  18491. // https://bugs.webkit.org/show_bug.cgi?id=220196
  18492. !isIOS();
  18493. return MDCSliderFoundation;
  18494. }(foundation_1.MDCFoundation);
  18495. exports.MDCSliderFoundation = MDCSliderFoundation;
  18496. function isIOS() {
  18497. // Source:
  18498. // https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
  18499. return ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform)
  18500. // iPad on iOS 13 detection
  18501. || navigator.userAgent.includes('Mac') && 'ontouchend' in document;
  18502. }
  18503. /***/ }),
  18504. /***/ "./packages/mdc-slider/index.ts":
  18505. /*!**************************************!*\
  18506. !*** ./packages/mdc-slider/index.ts ***!
  18507. \**************************************/
  18508. /*! no static exports found */
  18509. /***/ (function(module, exports, __webpack_require__) {
  18510. "use strict";
  18511. /**
  18512. * @license
  18513. * Copyright 2020 Google Inc.
  18514. *
  18515. * Permission is hereby granted, free of charge, to any person obtaining a copy
  18516. * of this software and associated documentation files (the "Software"), to deal
  18517. * in the Software without restriction, including without limitation the rights
  18518. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18519. * copies of the Software, and to permit persons to whom the Software is
  18520. * furnished to do so, subject to the following conditions:
  18521. *
  18522. * The above copyright notice and this permission notice shall be included in
  18523. * all copies or substantial portions of the Software.
  18524. *
  18525. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18526. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18527. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18528. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18529. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18530. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18531. * THE SOFTWARE.
  18532. */
  18533. function __export(m) {
  18534. for (var p in m) {
  18535. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  18536. }
  18537. }
  18538. Object.defineProperty(exports, "__esModule", { value: true });
  18539. __export(__webpack_require__(/*! ./component */ "./packages/mdc-slider/component.ts"));
  18540. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts"));
  18541. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts"));
  18542. __export(__webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts"));
  18543. /***/ }),
  18544. /***/ "./packages/mdc-slider/types.ts":
  18545. /*!**************************************!*\
  18546. !*** ./packages/mdc-slider/types.ts ***!
  18547. \**************************************/
  18548. /*! no static exports found */
  18549. /***/ (function(module, exports, __webpack_require__) {
  18550. "use strict";
  18551. /**
  18552. * @license
  18553. * Copyright 2020 Google Inc.
  18554. *
  18555. * Permission is hereby granted, free of charge, to any person obtaining a copy
  18556. * of this software and associated documentation files (the "Software"), to deal
  18557. * in the Software without restriction, including without limitation the rights
  18558. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18559. * copies of the Software, and to permit persons to whom the Software is
  18560. * furnished to do so, subject to the following conditions:
  18561. *
  18562. * The above copyright notice and this permission notice shall be included in
  18563. * all copies or substantial portions of the Software.
  18564. *
  18565. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18566. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18567. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18568. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18569. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18570. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18571. * THE SOFTWARE.
  18572. */
  18573. Object.defineProperty(exports, "__esModule", { value: true });
  18574. /** Tick mark enum, for discrete sliders. */
  18575. var TickMark;
  18576. (function (TickMark) {
  18577. TickMark[TickMark["ACTIVE"] = 0] = "ACTIVE";
  18578. TickMark[TickMark["INACTIVE"] = 1] = "INACTIVE";
  18579. })(TickMark = exports.TickMark || (exports.TickMark = {}));
  18580. /**
  18581. * Thumb types: range slider has two thumbs (START, END) whereas single point
  18582. * slider only has one thumb (END).
  18583. */
  18584. var Thumb;
  18585. (function (Thumb) {
  18586. // Thumb at start of slider (e.g. in LTR mode, left thumb on range slider).
  18587. Thumb[Thumb["START"] = 1] = "START";
  18588. // Thumb at end of slider (e.g. in LTR mode, right thumb on range slider,
  18589. // or only thumb on single point slider).
  18590. Thumb[Thumb["END"] = 2] = "END";
  18591. })(Thumb = exports.Thumb || (exports.Thumb = {}));
  18592. /***/ }),
  18593. /***/ "./packages/mdc-snackbar/component.ts":
  18594. /*!********************************************!*\
  18595. !*** ./packages/mdc-snackbar/component.ts ***!
  18596. \********************************************/
  18597. /*! no static exports found */
  18598. /***/ (function(module, exports, __webpack_require__) {
  18599. "use strict";
  18600. /**
  18601. * @license
  18602. * Copyright 2018 Google Inc.
  18603. *
  18604. * Permission is hereby granted, free of charge, to any person obtaining a copy
  18605. * of this software and associated documentation files (the "Software"), to deal
  18606. * in the Software without restriction, including without limitation the rights
  18607. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18608. * copies of the Software, and to permit persons to whom the Software is
  18609. * furnished to do so, subject to the following conditions:
  18610. *
  18611. * The above copyright notice and this permission notice shall be included in
  18612. * all copies or substantial portions of the Software.
  18613. *
  18614. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18615. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18616. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18617. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18618. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18619. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18620. * THE SOFTWARE.
  18621. */
  18622. var __extends = this && this.__extends || function () {
  18623. var _extendStatics = function extendStatics(d, b) {
  18624. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  18625. d.__proto__ = b;
  18626. } || function (d, b) {
  18627. for (var p in b) {
  18628. if (b.hasOwnProperty(p)) d[p] = b[p];
  18629. }
  18630. };
  18631. return _extendStatics(d, b);
  18632. };
  18633. return function (d, b) {
  18634. _extendStatics(d, b);
  18635. function __() {
  18636. this.constructor = d;
  18637. }
  18638. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  18639. };
  18640. }();
  18641. var __importStar = this && this.__importStar || function (mod) {
  18642. if (mod && mod.__esModule) return mod;
  18643. var result = {};
  18644. if (mod != null) for (var k in mod) {
  18645. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  18646. }result["default"] = mod;
  18647. return result;
  18648. };
  18649. Object.defineProperty(exports, "__esModule", { value: true });
  18650. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  18651. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  18652. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
  18653. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts");
  18654. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
  18655. var SURFACE_SELECTOR = constants_1.strings.SURFACE_SELECTOR,
  18656. LABEL_SELECTOR = constants_1.strings.LABEL_SELECTOR,
  18657. ACTION_SELECTOR = constants_1.strings.ACTION_SELECTOR,
  18658. DISMISS_SELECTOR = constants_1.strings.DISMISS_SELECTOR,
  18659. OPENING_EVENT = constants_1.strings.OPENING_EVENT,
  18660. OPENED_EVENT = constants_1.strings.OPENED_EVENT,
  18661. CLOSING_EVENT = constants_1.strings.CLOSING_EVENT,
  18662. CLOSED_EVENT = constants_1.strings.CLOSED_EVENT;
  18663. var MDCSnackbar = /** @class */function (_super) {
  18664. __extends(MDCSnackbar, _super);
  18665. function MDCSnackbar() {
  18666. return _super !== null && _super.apply(this, arguments) || this;
  18667. }
  18668. MDCSnackbar.attachTo = function (root) {
  18669. return new MDCSnackbar(root);
  18670. };
  18671. MDCSnackbar.prototype.initialize = function (announcerFactory) {
  18672. if (announcerFactory === void 0) {
  18673. announcerFactory = function announcerFactory() {
  18674. return util.announce;
  18675. };
  18676. }
  18677. this.announce_ = announcerFactory();
  18678. };
  18679. MDCSnackbar.prototype.initialSyncWithDOM = function () {
  18680. var _this = this;
  18681. this.surfaceEl_ = this.root.querySelector(SURFACE_SELECTOR);
  18682. this.labelEl_ = this.root.querySelector(LABEL_SELECTOR);
  18683. this.actionEl_ = this.root.querySelector(ACTION_SELECTOR);
  18684. this.handleKeyDown_ = function (evt) {
  18685. return _this.foundation.handleKeyDown(evt);
  18686. };
  18687. this.handleSurfaceClick_ = function (evt) {
  18688. var target = evt.target;
  18689. if (_this.isActionButton_(target)) {
  18690. _this.foundation.handleActionButtonClick(evt);
  18691. } else if (_this.isActionIcon_(target)) {
  18692. _this.foundation.handleActionIconClick(evt);
  18693. }
  18694. };
  18695. this.registerKeyDownHandler_(this.handleKeyDown_);
  18696. this.registerSurfaceClickHandler_(this.handleSurfaceClick_);
  18697. };
  18698. MDCSnackbar.prototype.destroy = function () {
  18699. _super.prototype.destroy.call(this);
  18700. this.deregisterKeyDownHandler_(this.handleKeyDown_);
  18701. this.deregisterSurfaceClickHandler_(this.handleSurfaceClick_);
  18702. };
  18703. MDCSnackbar.prototype.open = function () {
  18704. this.foundation.open();
  18705. };
  18706. /**
  18707. * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
  18708. * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
  18709. * client-specific values may also be used if desired.
  18710. */
  18711. MDCSnackbar.prototype.close = function (reason) {
  18712. if (reason === void 0) {
  18713. reason = '';
  18714. }
  18715. this.foundation.close(reason);
  18716. };
  18717. MDCSnackbar.prototype.getDefaultFoundation = function () {
  18718. var _this = this;
  18719. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  18720. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  18721. var adapter = {
  18722. addClass: function addClass(className) {
  18723. return _this.root.classList.add(className);
  18724. },
  18725. announce: function announce() {
  18726. return _this.announce_(_this.labelEl_);
  18727. },
  18728. notifyClosed: function notifyClosed(reason) {
  18729. return _this.emit(CLOSED_EVENT, reason ? { reason: reason } : {});
  18730. },
  18731. notifyClosing: function notifyClosing(reason) {
  18732. return _this.emit(CLOSING_EVENT, reason ? { reason: reason } : {});
  18733. },
  18734. notifyOpened: function notifyOpened() {
  18735. return _this.emit(OPENED_EVENT, {});
  18736. },
  18737. notifyOpening: function notifyOpening() {
  18738. return _this.emit(OPENING_EVENT, {});
  18739. },
  18740. removeClass: function removeClass(className) {
  18741. return _this.root.classList.remove(className);
  18742. }
  18743. };
  18744. return new foundation_1.MDCSnackbarFoundation(adapter);
  18745. };
  18746. Object.defineProperty(MDCSnackbar.prototype, "timeoutMs", {
  18747. get: function get() {
  18748. return this.foundation.getTimeoutMs();
  18749. },
  18750. set: function set(timeoutMs) {
  18751. this.foundation.setTimeoutMs(timeoutMs);
  18752. },
  18753. enumerable: true,
  18754. configurable: true
  18755. });
  18756. Object.defineProperty(MDCSnackbar.prototype, "closeOnEscape", {
  18757. get: function get() {
  18758. return this.foundation.getCloseOnEscape();
  18759. },
  18760. set: function set(closeOnEscape) {
  18761. this.foundation.setCloseOnEscape(closeOnEscape);
  18762. },
  18763. enumerable: true,
  18764. configurable: true
  18765. });
  18766. Object.defineProperty(MDCSnackbar.prototype, "isOpen", {
  18767. get: function get() {
  18768. return this.foundation.isOpen();
  18769. },
  18770. enumerable: true,
  18771. configurable: true
  18772. });
  18773. Object.defineProperty(MDCSnackbar.prototype, "labelText", {
  18774. get: function get() {
  18775. // This property only returns null if the node is a document, DOCTYPE, or notation.
  18776. // On Element nodes, it always returns a string.
  18777. return this.labelEl_.textContent;
  18778. },
  18779. set: function set(labelText) {
  18780. this.labelEl_.textContent = labelText;
  18781. },
  18782. enumerable: true,
  18783. configurable: true
  18784. });
  18785. Object.defineProperty(MDCSnackbar.prototype, "actionButtonText", {
  18786. get: function get() {
  18787. return this.actionEl_.textContent;
  18788. },
  18789. set: function set(actionButtonText) {
  18790. this.actionEl_.textContent = actionButtonText;
  18791. },
  18792. enumerable: true,
  18793. configurable: true
  18794. });
  18795. MDCSnackbar.prototype.registerKeyDownHandler_ = function (handler) {
  18796. this.listen('keydown', handler);
  18797. };
  18798. MDCSnackbar.prototype.deregisterKeyDownHandler_ = function (handler) {
  18799. this.unlisten('keydown', handler);
  18800. };
  18801. MDCSnackbar.prototype.registerSurfaceClickHandler_ = function (handler) {
  18802. this.surfaceEl_.addEventListener('click', handler);
  18803. };
  18804. MDCSnackbar.prototype.deregisterSurfaceClickHandler_ = function (handler) {
  18805. this.surfaceEl_.removeEventListener('click', handler);
  18806. };
  18807. MDCSnackbar.prototype.isActionButton_ = function (target) {
  18808. return Boolean(ponyfill_1.closest(target, ACTION_SELECTOR));
  18809. };
  18810. MDCSnackbar.prototype.isActionIcon_ = function (target) {
  18811. return Boolean(ponyfill_1.closest(target, DISMISS_SELECTOR));
  18812. };
  18813. return MDCSnackbar;
  18814. }(component_1.MDCComponent);
  18815. exports.MDCSnackbar = MDCSnackbar;
  18816. /***/ }),
  18817. /***/ "./packages/mdc-snackbar/constants.ts":
  18818. /*!********************************************!*\
  18819. !*** ./packages/mdc-snackbar/constants.ts ***!
  18820. \********************************************/
  18821. /*! no static exports found */
  18822. /***/ (function(module, exports, __webpack_require__) {
  18823. "use strict";
  18824. /**
  18825. * @license
  18826. * Copyright 2018 Google Inc.
  18827. *
  18828. * Permission is hereby granted, free of charge, to any person obtaining a copy
  18829. * of this software and associated documentation files (the "Software"), to deal
  18830. * in the Software without restriction, including without limitation the rights
  18831. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18832. * copies of the Software, and to permit persons to whom the Software is
  18833. * furnished to do so, subject to the following conditions:
  18834. *
  18835. * The above copyright notice and this permission notice shall be included in
  18836. * all copies or substantial portions of the Software.
  18837. *
  18838. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18839. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18840. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18841. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18842. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18843. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18844. * THE SOFTWARE.
  18845. */
  18846. Object.defineProperty(exports, "__esModule", { value: true });
  18847. var cssClasses = {
  18848. CLOSING: 'mdc-snackbar--closing',
  18849. OPEN: 'mdc-snackbar--open',
  18850. OPENING: 'mdc-snackbar--opening'
  18851. };
  18852. exports.cssClasses = cssClasses;
  18853. var strings = {
  18854. ACTION_SELECTOR: '.mdc-snackbar__action',
  18855. ARIA_LIVE_LABEL_TEXT_ATTR: 'data-mdc-snackbar-label-text',
  18856. CLOSED_EVENT: 'MDCSnackbar:closed',
  18857. CLOSING_EVENT: 'MDCSnackbar:closing',
  18858. DISMISS_SELECTOR: '.mdc-snackbar__dismiss',
  18859. LABEL_SELECTOR: '.mdc-snackbar__label',
  18860. OPENED_EVENT: 'MDCSnackbar:opened',
  18861. OPENING_EVENT: 'MDCSnackbar:opening',
  18862. REASON_ACTION: 'action',
  18863. REASON_DISMISS: 'dismiss',
  18864. SURFACE_SELECTOR: '.mdc-snackbar__surface'
  18865. };
  18866. exports.strings = strings;
  18867. var numbers = {
  18868. DEFAULT_AUTO_DISMISS_TIMEOUT_MS: 5000,
  18869. INDETERMINATE: -1,
  18870. MAX_AUTO_DISMISS_TIMEOUT_MS: 10000,
  18871. MIN_AUTO_DISMISS_TIMEOUT_MS: 4000,
  18872. // These variables need to be kept in sync with the values in _variables.scss.
  18873. SNACKBAR_ANIMATION_CLOSE_TIME_MS: 75,
  18874. SNACKBAR_ANIMATION_OPEN_TIME_MS: 150,
  18875. /**
  18876. * Number of milliseconds to wait between temporarily clearing the label text
  18877. * in the DOM and subsequently restoring it. This is necessary to force IE 11
  18878. * to pick up the `aria-live` content change and announce it to the user.
  18879. */
  18880. ARIA_LIVE_DELAY_MS: 1000
  18881. };
  18882. exports.numbers = numbers;
  18883. /***/ }),
  18884. /***/ "./packages/mdc-snackbar/foundation.ts":
  18885. /*!*********************************************!*\
  18886. !*** ./packages/mdc-snackbar/foundation.ts ***!
  18887. \*********************************************/
  18888. /*! no static exports found */
  18889. /***/ (function(module, exports, __webpack_require__) {
  18890. "use strict";
  18891. /**
  18892. * @license
  18893. * Copyright 2018 Google Inc.
  18894. *
  18895. * Permission is hereby granted, free of charge, to any person obtaining a copy
  18896. * of this software and associated documentation files (the "Software"), to deal
  18897. * in the Software without restriction, including without limitation the rights
  18898. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18899. * copies of the Software, and to permit persons to whom the Software is
  18900. * furnished to do so, subject to the following conditions:
  18901. *
  18902. * The above copyright notice and this permission notice shall be included in
  18903. * all copies or substantial portions of the Software.
  18904. *
  18905. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18906. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18907. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18908. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18909. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18910. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18911. * THE SOFTWARE.
  18912. */
  18913. var __extends = this && this.__extends || function () {
  18914. var _extendStatics = function extendStatics(d, b) {
  18915. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  18916. d.__proto__ = b;
  18917. } || function (d, b) {
  18918. for (var p in b) {
  18919. if (b.hasOwnProperty(p)) d[p] = b[p];
  18920. }
  18921. };
  18922. return _extendStatics(d, b);
  18923. };
  18924. return function (d, b) {
  18925. _extendStatics(d, b);
  18926. function __() {
  18927. this.constructor = d;
  18928. }
  18929. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  18930. };
  18931. }();
  18932. var __assign = this && this.__assign || function () {
  18933. __assign = Object.assign || function (t) {
  18934. for (var s, i = 1, n = arguments.length; i < n; i++) {
  18935. s = arguments[i];
  18936. for (var p in s) {
  18937. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  18938. }
  18939. }
  18940. return t;
  18941. };
  18942. return __assign.apply(this, arguments);
  18943. };
  18944. Object.defineProperty(exports, "__esModule", { value: true });
  18945. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  18946. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
  18947. var OPENING = constants_1.cssClasses.OPENING,
  18948. OPEN = constants_1.cssClasses.OPEN,
  18949. CLOSING = constants_1.cssClasses.CLOSING;
  18950. var REASON_ACTION = constants_1.strings.REASON_ACTION,
  18951. REASON_DISMISS = constants_1.strings.REASON_DISMISS;
  18952. var MDCSnackbarFoundation = /** @class */function (_super) {
  18953. __extends(MDCSnackbarFoundation, _super);
  18954. function MDCSnackbarFoundation(adapter) {
  18955. var _this = _super.call(this, __assign(__assign({}, MDCSnackbarFoundation.defaultAdapter), adapter)) || this;
  18956. _this.isOpen_ = false;
  18957. _this.animationFrame_ = 0;
  18958. _this.animationTimer_ = 0;
  18959. _this.autoDismissTimer_ = 0;
  18960. _this.autoDismissTimeoutMs_ = constants_1.numbers.DEFAULT_AUTO_DISMISS_TIMEOUT_MS;
  18961. _this.closeOnEscape_ = true;
  18962. return _this;
  18963. }
  18964. Object.defineProperty(MDCSnackbarFoundation, "cssClasses", {
  18965. get: function get() {
  18966. return constants_1.cssClasses;
  18967. },
  18968. enumerable: true,
  18969. configurable: true
  18970. });
  18971. Object.defineProperty(MDCSnackbarFoundation, "strings", {
  18972. get: function get() {
  18973. return constants_1.strings;
  18974. },
  18975. enumerable: true,
  18976. configurable: true
  18977. });
  18978. Object.defineProperty(MDCSnackbarFoundation, "numbers", {
  18979. get: function get() {
  18980. return constants_1.numbers;
  18981. },
  18982. enumerable: true,
  18983. configurable: true
  18984. });
  18985. Object.defineProperty(MDCSnackbarFoundation, "defaultAdapter", {
  18986. get: function get() {
  18987. return {
  18988. addClass: function addClass() {
  18989. return undefined;
  18990. },
  18991. announce: function announce() {
  18992. return undefined;
  18993. },
  18994. notifyClosed: function notifyClosed() {
  18995. return undefined;
  18996. },
  18997. notifyClosing: function notifyClosing() {
  18998. return undefined;
  18999. },
  19000. notifyOpened: function notifyOpened() {
  19001. return undefined;
  19002. },
  19003. notifyOpening: function notifyOpening() {
  19004. return undefined;
  19005. },
  19006. removeClass: function removeClass() {
  19007. return undefined;
  19008. }
  19009. };
  19010. },
  19011. enumerable: true,
  19012. configurable: true
  19013. });
  19014. MDCSnackbarFoundation.prototype.destroy = function () {
  19015. this.clearAutoDismissTimer_();
  19016. cancelAnimationFrame(this.animationFrame_);
  19017. this.animationFrame_ = 0;
  19018. clearTimeout(this.animationTimer_);
  19019. this.animationTimer_ = 0;
  19020. this.adapter.removeClass(OPENING);
  19021. this.adapter.removeClass(OPEN);
  19022. this.adapter.removeClass(CLOSING);
  19023. };
  19024. MDCSnackbarFoundation.prototype.open = function () {
  19025. var _this = this;
  19026. this.clearAutoDismissTimer_();
  19027. this.isOpen_ = true;
  19028. this.adapter.notifyOpening();
  19029. this.adapter.removeClass(CLOSING);
  19030. this.adapter.addClass(OPENING);
  19031. this.adapter.announce();
  19032. // Wait a frame once display is no longer "none", to establish basis for animation
  19033. this.runNextAnimationFrame_(function () {
  19034. _this.adapter.addClass(OPEN);
  19035. _this.animationTimer_ = setTimeout(function () {
  19036. var timeoutMs = _this.getTimeoutMs();
  19037. _this.handleAnimationTimerEnd_();
  19038. _this.adapter.notifyOpened();
  19039. if (timeoutMs !== constants_1.numbers.INDETERMINATE) {
  19040. _this.autoDismissTimer_ = setTimeout(function () {
  19041. _this.close(REASON_DISMISS);
  19042. }, timeoutMs);
  19043. }
  19044. }, constants_1.numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS);
  19045. });
  19046. };
  19047. /**
  19048. * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
  19049. * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
  19050. * client-specific values may also be used if desired.
  19051. */
  19052. MDCSnackbarFoundation.prototype.close = function (reason) {
  19053. var _this = this;
  19054. if (reason === void 0) {
  19055. reason = '';
  19056. }
  19057. if (!this.isOpen_) {
  19058. // Avoid redundant close calls (and events), e.g. repeated interactions as the snackbar is animating closed
  19059. return;
  19060. }
  19061. cancelAnimationFrame(this.animationFrame_);
  19062. this.animationFrame_ = 0;
  19063. this.clearAutoDismissTimer_();
  19064. this.isOpen_ = false;
  19065. this.adapter.notifyClosing(reason);
  19066. this.adapter.addClass(constants_1.cssClasses.CLOSING);
  19067. this.adapter.removeClass(constants_1.cssClasses.OPEN);
  19068. this.adapter.removeClass(constants_1.cssClasses.OPENING);
  19069. clearTimeout(this.animationTimer_);
  19070. this.animationTimer_ = setTimeout(function () {
  19071. _this.handleAnimationTimerEnd_();
  19072. _this.adapter.notifyClosed(reason);
  19073. }, constants_1.numbers.SNACKBAR_ANIMATION_CLOSE_TIME_MS);
  19074. };
  19075. MDCSnackbarFoundation.prototype.isOpen = function () {
  19076. return this.isOpen_;
  19077. };
  19078. MDCSnackbarFoundation.prototype.getTimeoutMs = function () {
  19079. return this.autoDismissTimeoutMs_;
  19080. };
  19081. MDCSnackbarFoundation.prototype.setTimeoutMs = function (timeoutMs) {
  19082. // Use shorter variable names to make the code more readable
  19083. var minValue = constants_1.numbers.MIN_AUTO_DISMISS_TIMEOUT_MS;
  19084. var maxValue = constants_1.numbers.MAX_AUTO_DISMISS_TIMEOUT_MS;
  19085. var indeterminateValue = constants_1.numbers.INDETERMINATE;
  19086. if (timeoutMs === constants_1.numbers.INDETERMINATE || timeoutMs <= maxValue && timeoutMs >= minValue) {
  19087. this.autoDismissTimeoutMs_ = timeoutMs;
  19088. } else {
  19089. throw new Error("\n timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + "\n (or " + indeterminateValue + " to disable), but got '" + timeoutMs + "'");
  19090. }
  19091. };
  19092. MDCSnackbarFoundation.prototype.getCloseOnEscape = function () {
  19093. return this.closeOnEscape_;
  19094. };
  19095. MDCSnackbarFoundation.prototype.setCloseOnEscape = function (closeOnEscape) {
  19096. this.closeOnEscape_ = closeOnEscape;
  19097. };
  19098. MDCSnackbarFoundation.prototype.handleKeyDown = function (evt) {
  19099. var isEscapeKey = evt.key === 'Escape' || evt.keyCode === 27;
  19100. if (isEscapeKey && this.getCloseOnEscape()) {
  19101. this.close(REASON_DISMISS);
  19102. }
  19103. };
  19104. MDCSnackbarFoundation.prototype.handleActionButtonClick = function (_evt) {
  19105. this.close(REASON_ACTION);
  19106. };
  19107. MDCSnackbarFoundation.prototype.handleActionIconClick = function (_evt) {
  19108. this.close(REASON_DISMISS);
  19109. };
  19110. MDCSnackbarFoundation.prototype.clearAutoDismissTimer_ = function () {
  19111. clearTimeout(this.autoDismissTimer_);
  19112. this.autoDismissTimer_ = 0;
  19113. };
  19114. MDCSnackbarFoundation.prototype.handleAnimationTimerEnd_ = function () {
  19115. this.animationTimer_ = 0;
  19116. this.adapter.removeClass(constants_1.cssClasses.OPENING);
  19117. this.adapter.removeClass(constants_1.cssClasses.CLOSING);
  19118. };
  19119. /**
  19120. * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
  19121. */
  19122. MDCSnackbarFoundation.prototype.runNextAnimationFrame_ = function (callback) {
  19123. var _this = this;
  19124. cancelAnimationFrame(this.animationFrame_);
  19125. this.animationFrame_ = requestAnimationFrame(function () {
  19126. _this.animationFrame_ = 0;
  19127. clearTimeout(_this.animationTimer_);
  19128. _this.animationTimer_ = setTimeout(callback, 0);
  19129. });
  19130. };
  19131. return MDCSnackbarFoundation;
  19132. }(foundation_1.MDCFoundation);
  19133. exports.MDCSnackbarFoundation = MDCSnackbarFoundation;
  19134. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  19135. exports.default = MDCSnackbarFoundation;
  19136. /***/ }),
  19137. /***/ "./packages/mdc-snackbar/index.ts":
  19138. /*!****************************************!*\
  19139. !*** ./packages/mdc-snackbar/index.ts ***!
  19140. \****************************************/
  19141. /*! no static exports found */
  19142. /***/ (function(module, exports, __webpack_require__) {
  19143. "use strict";
  19144. /**
  19145. * @license
  19146. * Copyright 2019 Google Inc.
  19147. *
  19148. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19149. * of this software and associated documentation files (the "Software"), to deal
  19150. * in the Software without restriction, including without limitation the rights
  19151. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19152. * copies of the Software, and to permit persons to whom the Software is
  19153. * furnished to do so, subject to the following conditions:
  19154. *
  19155. * The above copyright notice and this permission notice shall be included in
  19156. * all copies or substantial portions of the Software.
  19157. *
  19158. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19159. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19160. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19161. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19162. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19163. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19164. * THE SOFTWARE.
  19165. */
  19166. function __export(m) {
  19167. for (var p in m) {
  19168. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  19169. }
  19170. }
  19171. var __importStar = this && this.__importStar || function (mod) {
  19172. if (mod && mod.__esModule) return mod;
  19173. var result = {};
  19174. if (mod != null) for (var k in mod) {
  19175. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  19176. }result["default"] = mod;
  19177. return result;
  19178. };
  19179. Object.defineProperty(exports, "__esModule", { value: true });
  19180. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
  19181. exports.util = util;
  19182. __export(__webpack_require__(/*! ./component */ "./packages/mdc-snackbar/component.ts"));
  19183. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts"));
  19184. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts"));
  19185. /***/ }),
  19186. /***/ "./packages/mdc-snackbar/util.ts":
  19187. /*!***************************************!*\
  19188. !*** ./packages/mdc-snackbar/util.ts ***!
  19189. \***************************************/
  19190. /*! no static exports found */
  19191. /***/ (function(module, exports, __webpack_require__) {
  19192. "use strict";
  19193. /**
  19194. * @license
  19195. * Copyright 2018 Google Inc.
  19196. *
  19197. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19198. * of this software and associated documentation files (the "Software"), to deal
  19199. * in the Software without restriction, including without limitation the rights
  19200. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19201. * copies of the Software, and to permit persons to whom the Software is
  19202. * furnished to do so, subject to the following conditions:
  19203. *
  19204. * The above copyright notice and this permission notice shall be included in
  19205. * all copies or substantial portions of the Software.
  19206. *
  19207. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19208. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19209. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19210. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19211. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19212. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19213. * THE SOFTWARE.
  19214. */
  19215. Object.defineProperty(exports, "__esModule", { value: true });
  19216. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
  19217. var ARIA_LIVE_DELAY_MS = constants_1.numbers.ARIA_LIVE_DELAY_MS;
  19218. var ARIA_LIVE_LABEL_TEXT_ATTR = constants_1.strings.ARIA_LIVE_LABEL_TEXT_ATTR;
  19219. function announce(ariaEl, labelEl) {
  19220. if (labelEl === void 0) {
  19221. labelEl = ariaEl;
  19222. }
  19223. var priority = ariaEl.getAttribute('aria-live');
  19224. // Trim text to ignore `&nbsp;` (see below).
  19225. // textContent is only null if the node is a document, DOCTYPE, or notation.
  19226. var labelText = labelEl.textContent.trim();
  19227. if (!labelText || !priority) {
  19228. return;
  19229. }
  19230. // Temporarily disable `aria-live` to prevent JAWS+Firefox from announcing the message twice.
  19231. ariaEl.setAttribute('aria-live', 'off');
  19232. // Temporarily clear `textContent` to force a DOM mutation event that will be detected by screen readers.
  19233. // `aria-live` elements are only announced when the element's `textContent` *changes*, so snackbars
  19234. // sent to the browser in the initial HTML response won't be read unless we clear the element's `textContent` first.
  19235. // Similarly, displaying the same snackbar message twice in a row doesn't trigger a DOM mutation event,
  19236. // so screen readers won't announce the second message unless we first clear `textContent`.
  19237. //
  19238. // We have to clear the label text two different ways to make it work in all browsers and screen readers:
  19239. //
  19240. // 1. `textContent = ''` is required for IE11 + JAWS
  19241. // 2. `innerHTML = '&nbsp;'` is required for Chrome + JAWS and NVDA
  19242. //
  19243. // All other browser/screen reader combinations support both methods.
  19244. //
  19245. // The wrapper `<span>` visually hides the space character so that it doesn't cause jank when added/removed.
  19246. // N.B.: Setting `position: absolute`, `opacity: 0`, or `height: 0` prevents Chrome from detecting the DOM change.
  19247. //
  19248. // This technique has been tested in:
  19249. //
  19250. // * JAWS 2019:
  19251. // - Chrome 70
  19252. // - Firefox 60 (ESR)
  19253. // - IE 11
  19254. // * NVDA 2018:
  19255. // - Chrome 70
  19256. // - Firefox 60 (ESR)
  19257. // - IE 11
  19258. // * ChromeVox 53
  19259. labelEl.textContent = '';
  19260. labelEl.innerHTML = '<span style="display: inline-block; width: 0; height: 1px;">&nbsp;</span>';
  19261. // Prevent visual jank by temporarily displaying the label text in the ::before pseudo-element.
  19262. // CSS generated content is normally announced by screen readers
  19263. // (except in IE 11; see https://tink.uk/accessibility-support-for-css-generated-content/);
  19264. // however, `aria-live` is turned off, so this DOM update will be ignored by screen readers.
  19265. labelEl.setAttribute(ARIA_LIVE_LABEL_TEXT_ATTR, labelText);
  19266. setTimeout(function () {
  19267. // Allow screen readers to announce changes to the DOM again.
  19268. ariaEl.setAttribute('aria-live', priority);
  19269. // Remove the message from the ::before pseudo-element.
  19270. labelEl.removeAttribute(ARIA_LIVE_LABEL_TEXT_ATTR);
  19271. // Restore the original label text, which will be announced by screen readers.
  19272. labelEl.textContent = labelText;
  19273. }, ARIA_LIVE_DELAY_MS);
  19274. }
  19275. exports.announce = announce;
  19276. /***/ }),
  19277. /***/ "./packages/mdc-switch/component.ts":
  19278. /*!******************************************!*\
  19279. !*** ./packages/mdc-switch/component.ts ***!
  19280. \******************************************/
  19281. /*! no static exports found */
  19282. /***/ (function(module, exports, __webpack_require__) {
  19283. "use strict";
  19284. /**
  19285. * @license
  19286. * Copyright 2018 Google Inc.
  19287. *
  19288. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19289. * of this software and associated documentation files (the "Software"), to deal
  19290. * in the Software without restriction, including without limitation the rights
  19291. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19292. * copies of the Software, and to permit persons to whom the Software is
  19293. * furnished to do so, subject to the following conditions:
  19294. *
  19295. * The above copyright notice and this permission notice shall be included in
  19296. * all copies or substantial portions of the Software.
  19297. *
  19298. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19299. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19300. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19301. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19302. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19303. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19304. * THE SOFTWARE.
  19305. */
  19306. var __extends = this && this.__extends || function () {
  19307. var _extendStatics = function extendStatics(d, b) {
  19308. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  19309. d.__proto__ = b;
  19310. } || function (d, b) {
  19311. for (var p in b) {
  19312. if (b.hasOwnProperty(p)) d[p] = b[p];
  19313. }
  19314. };
  19315. return _extendStatics(d, b);
  19316. };
  19317. return function (d, b) {
  19318. _extendStatics(d, b);
  19319. function __() {
  19320. this.constructor = d;
  19321. }
  19322. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19323. };
  19324. }();
  19325. var __assign = this && this.__assign || function () {
  19326. __assign = Object.assign || function (t) {
  19327. for (var s, i = 1, n = arguments.length; i < n; i++) {
  19328. s = arguments[i];
  19329. for (var p in s) {
  19330. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  19331. }
  19332. }
  19333. return t;
  19334. };
  19335. return __assign.apply(this, arguments);
  19336. };
  19337. var __read = this && this.__read || function (o, n) {
  19338. var m = typeof Symbol === "function" && o[Symbol.iterator];
  19339. if (!m) return o;
  19340. var i = m.call(o),
  19341. r,
  19342. ar = [],
  19343. e;
  19344. try {
  19345. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  19346. ar.push(r.value);
  19347. }
  19348. } catch (error) {
  19349. e = { error: error };
  19350. } finally {
  19351. try {
  19352. if (r && !r.done && (m = i["return"])) m.call(i);
  19353. } finally {
  19354. if (e) throw e.error;
  19355. }
  19356. }
  19357. return ar;
  19358. };
  19359. var __spread = this && this.__spread || function () {
  19360. for (var ar = [], i = 0; i < arguments.length; i++) {
  19361. ar = ar.concat(__read(arguments[i]));
  19362. }return ar;
  19363. };
  19364. Object.defineProperty(exports, "__esModule", { value: true });
  19365. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  19366. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  19367. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  19368. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  19369. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  19370. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-switch/foundation.ts");
  19371. var MDCSwitch = /** @class */function (_super) {
  19372. __extends(MDCSwitch, _super);
  19373. function MDCSwitch() {
  19374. var _this = _super !== null && _super.apply(this, arguments) || this;
  19375. _this.ripple_ = _this.createRipple_();
  19376. return _this;
  19377. }
  19378. MDCSwitch.attachTo = function (root) {
  19379. return new MDCSwitch(root);
  19380. };
  19381. MDCSwitch.prototype.destroy = function () {
  19382. _super.prototype.destroy.call(this);
  19383. this.ripple_.destroy();
  19384. this.nativeControl_.removeEventListener('change', this.changeHandler_);
  19385. };
  19386. MDCSwitch.prototype.initialSyncWithDOM = function () {
  19387. var _this = this;
  19388. this.changeHandler_ = function () {
  19389. var _a;
  19390. var args = [];
  19391. for (var _i = 0; _i < arguments.length; _i++) {
  19392. args[_i] = arguments[_i];
  19393. }
  19394. return (_a = _this.foundation).handleChange.apply(_a, __spread(args));
  19395. };
  19396. this.nativeControl_.addEventListener('change', this.changeHandler_);
  19397. // Sometimes the checked state of the input element is saved in the history.
  19398. // The switch styling should match the checked state of the input element.
  19399. // Do an initial sync between the native control and the foundation.
  19400. this.checked = this.checked;
  19401. };
  19402. MDCSwitch.prototype.getDefaultFoundation = function () {
  19403. var _this = this;
  19404. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  19405. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  19406. var adapter = {
  19407. addClass: function addClass(className) {
  19408. return _this.root.classList.add(className);
  19409. },
  19410. removeClass: function removeClass(className) {
  19411. return _this.root.classList.remove(className);
  19412. },
  19413. setNativeControlChecked: function setNativeControlChecked(checked) {
  19414. return _this.nativeControl_.checked = checked;
  19415. },
  19416. setNativeControlDisabled: function setNativeControlDisabled(disabled) {
  19417. return _this.nativeControl_.disabled = disabled;
  19418. },
  19419. setNativeControlAttr: function setNativeControlAttr(attr, value) {
  19420. return _this.nativeControl_.setAttribute(attr, value);
  19421. }
  19422. };
  19423. return new foundation_2.MDCSwitchFoundation(adapter);
  19424. };
  19425. Object.defineProperty(MDCSwitch.prototype, "ripple", {
  19426. get: function get() {
  19427. return this.ripple_;
  19428. },
  19429. enumerable: true,
  19430. configurable: true
  19431. });
  19432. Object.defineProperty(MDCSwitch.prototype, "checked", {
  19433. get: function get() {
  19434. return this.nativeControl_.checked;
  19435. },
  19436. set: function set(checked) {
  19437. this.foundation.setChecked(checked);
  19438. },
  19439. enumerable: true,
  19440. configurable: true
  19441. });
  19442. Object.defineProperty(MDCSwitch.prototype, "disabled", {
  19443. get: function get() {
  19444. return this.nativeControl_.disabled;
  19445. },
  19446. set: function set(disabled) {
  19447. this.foundation.setDisabled(disabled);
  19448. },
  19449. enumerable: true,
  19450. configurable: true
  19451. });
  19452. MDCSwitch.prototype.createRipple_ = function () {
  19453. var _this = this;
  19454. var RIPPLE_SURFACE_SELECTOR = foundation_2.MDCSwitchFoundation.strings.RIPPLE_SURFACE_SELECTOR;
  19455. var rippleSurface = this.root.querySelector(RIPPLE_SURFACE_SELECTOR);
  19456. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  19457. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  19458. var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { addClass: function addClass(className) {
  19459. return rippleSurface.classList.add(className);
  19460. }, computeBoundingRect: function computeBoundingRect() {
  19461. return rippleSurface.getBoundingClientRect();
  19462. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  19463. _this.nativeControl_.removeEventListener(evtType, handler, events_1.applyPassive());
  19464. }, isSurfaceActive: function isSurfaceActive() {
  19465. return ponyfill_1.matches(_this.nativeControl_, ':active');
  19466. }, isUnbounded: function isUnbounded() {
  19467. return true;
  19468. }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  19469. _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
  19470. }, removeClass: function removeClass(className) {
  19471. rippleSurface.classList.remove(className);
  19472. }, updateCssVariable: function updateCssVariable(varName, value) {
  19473. rippleSurface.style.setProperty(varName, value);
  19474. } });
  19475. return new component_2.MDCRipple(this.root, new foundation_1.MDCRippleFoundation(adapter));
  19476. };
  19477. Object.defineProperty(MDCSwitch.prototype, "nativeControl_", {
  19478. get: function get() {
  19479. var NATIVE_CONTROL_SELECTOR = foundation_2.MDCSwitchFoundation.strings.NATIVE_CONTROL_SELECTOR;
  19480. return this.root.querySelector(NATIVE_CONTROL_SELECTOR);
  19481. },
  19482. enumerable: true,
  19483. configurable: true
  19484. });
  19485. return MDCSwitch;
  19486. }(component_1.MDCComponent);
  19487. exports.MDCSwitch = MDCSwitch;
  19488. /***/ }),
  19489. /***/ "./packages/mdc-switch/constants.ts":
  19490. /*!******************************************!*\
  19491. !*** ./packages/mdc-switch/constants.ts ***!
  19492. \******************************************/
  19493. /*! no static exports found */
  19494. /***/ (function(module, exports, __webpack_require__) {
  19495. "use strict";
  19496. /**
  19497. * @license
  19498. * Copyright 2018 Google Inc.
  19499. *
  19500. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19501. * of this software and associated documentation files (the "Software"), to deal
  19502. * in the Software without restriction, including without limitation the rights
  19503. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19504. * copies of the Software, and to permit persons to whom the Software is
  19505. * furnished to do so, subject to the following conditions:
  19506. *
  19507. * The above copyright notice and this permission notice shall be included in
  19508. * all copies or substantial portions of the Software.
  19509. *
  19510. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19511. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19512. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19513. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19514. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19515. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19516. * THE SOFTWARE.
  19517. */
  19518. Object.defineProperty(exports, "__esModule", { value: true });
  19519. /** CSS classes used by the switch. */
  19520. var cssClasses = {
  19521. /** Class used for a switch that is in the "checked" (on) position. */
  19522. CHECKED: 'mdc-switch--checked',
  19523. /** Class used for a switch that is disabled. */
  19524. DISABLED: 'mdc-switch--disabled'
  19525. };
  19526. exports.cssClasses = cssClasses;
  19527. /** String constants used by the switch. */
  19528. var strings = {
  19529. /** Aria attribute for checked or unchecked state of switch */
  19530. ARIA_CHECKED_ATTR: 'aria-checked',
  19531. /** A CSS selector used to locate the native HTML control for the switch. */
  19532. NATIVE_CONTROL_SELECTOR: '.mdc-switch__native-control',
  19533. /** A CSS selector used to locate the ripple surface element for the switch. */
  19534. RIPPLE_SURFACE_SELECTOR: '.mdc-switch__thumb-underlay'
  19535. };
  19536. exports.strings = strings;
  19537. /***/ }),
  19538. /***/ "./packages/mdc-switch/foundation.ts":
  19539. /*!*******************************************!*\
  19540. !*** ./packages/mdc-switch/foundation.ts ***!
  19541. \*******************************************/
  19542. /*! no static exports found */
  19543. /***/ (function(module, exports, __webpack_require__) {
  19544. "use strict";
  19545. /**
  19546. * @license
  19547. * Copyright 2018 Google Inc.
  19548. *
  19549. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19550. * of this software and associated documentation files (the "Software"), to deal
  19551. * in the Software without restriction, including without limitation the rights
  19552. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19553. * copies of the Software, and to permit persons to whom the Software is
  19554. * furnished to do so, subject to the following conditions:
  19555. *
  19556. * The above copyright notice and this permission notice shall be included in
  19557. * all copies or substantial portions of the Software.
  19558. *
  19559. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19560. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19561. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19562. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19563. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19564. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19565. * THE SOFTWARE.
  19566. */
  19567. var __extends = this && this.__extends || function () {
  19568. var _extendStatics = function extendStatics(d, b) {
  19569. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  19570. d.__proto__ = b;
  19571. } || function (d, b) {
  19572. for (var p in b) {
  19573. if (b.hasOwnProperty(p)) d[p] = b[p];
  19574. }
  19575. };
  19576. return _extendStatics(d, b);
  19577. };
  19578. return function (d, b) {
  19579. _extendStatics(d, b);
  19580. function __() {
  19581. this.constructor = d;
  19582. }
  19583. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19584. };
  19585. }();
  19586. var __assign = this && this.__assign || function () {
  19587. __assign = Object.assign || function (t) {
  19588. for (var s, i = 1, n = arguments.length; i < n; i++) {
  19589. s = arguments[i];
  19590. for (var p in s) {
  19591. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  19592. }
  19593. }
  19594. return t;
  19595. };
  19596. return __assign.apply(this, arguments);
  19597. };
  19598. Object.defineProperty(exports, "__esModule", { value: true });
  19599. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  19600. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts");
  19601. var MDCSwitchFoundation = /** @class */function (_super) {
  19602. __extends(MDCSwitchFoundation, _super);
  19603. function MDCSwitchFoundation(adapter) {
  19604. return _super.call(this, __assign(__assign({}, MDCSwitchFoundation.defaultAdapter), adapter)) || this;
  19605. }
  19606. Object.defineProperty(MDCSwitchFoundation, "strings", {
  19607. /** The string constants used by the switch. */
  19608. get: function get() {
  19609. return constants_1.strings;
  19610. },
  19611. enumerable: true,
  19612. configurable: true
  19613. });
  19614. Object.defineProperty(MDCSwitchFoundation, "cssClasses", {
  19615. /** The CSS classes used by the switch. */
  19616. get: function get() {
  19617. return constants_1.cssClasses;
  19618. },
  19619. enumerable: true,
  19620. configurable: true
  19621. });
  19622. Object.defineProperty(MDCSwitchFoundation, "defaultAdapter", {
  19623. /** The default Adapter for the switch. */
  19624. get: function get() {
  19625. return {
  19626. addClass: function addClass() {
  19627. return undefined;
  19628. },
  19629. removeClass: function removeClass() {
  19630. return undefined;
  19631. },
  19632. setNativeControlChecked: function setNativeControlChecked() {
  19633. return undefined;
  19634. },
  19635. setNativeControlDisabled: function setNativeControlDisabled() {
  19636. return undefined;
  19637. },
  19638. setNativeControlAttr: function setNativeControlAttr() {
  19639. return undefined;
  19640. }
  19641. };
  19642. },
  19643. enumerable: true,
  19644. configurable: true
  19645. });
  19646. /** Sets the checked state of the switch. */
  19647. MDCSwitchFoundation.prototype.setChecked = function (checked) {
  19648. this.adapter.setNativeControlChecked(checked);
  19649. this.updateAriaChecked_(checked);
  19650. this.updateCheckedStyling_(checked);
  19651. };
  19652. /** Sets the disabled state of the switch. */
  19653. MDCSwitchFoundation.prototype.setDisabled = function (disabled) {
  19654. this.adapter.setNativeControlDisabled(disabled);
  19655. if (disabled) {
  19656. this.adapter.addClass(constants_1.cssClasses.DISABLED);
  19657. } else {
  19658. this.adapter.removeClass(constants_1.cssClasses.DISABLED);
  19659. }
  19660. };
  19661. /** Handles the change event for the switch native control. */
  19662. MDCSwitchFoundation.prototype.handleChange = function (evt) {
  19663. var nativeControl = evt.target;
  19664. this.updateAriaChecked_(nativeControl.checked);
  19665. this.updateCheckedStyling_(nativeControl.checked);
  19666. };
  19667. /** Updates the styling of the switch based on its checked state. */
  19668. MDCSwitchFoundation.prototype.updateCheckedStyling_ = function (checked) {
  19669. if (checked) {
  19670. this.adapter.addClass(constants_1.cssClasses.CHECKED);
  19671. } else {
  19672. this.adapter.removeClass(constants_1.cssClasses.CHECKED);
  19673. }
  19674. };
  19675. MDCSwitchFoundation.prototype.updateAriaChecked_ = function (checked) {
  19676. this.adapter.setNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR, "" + !!checked);
  19677. };
  19678. return MDCSwitchFoundation;
  19679. }(foundation_1.MDCFoundation);
  19680. exports.MDCSwitchFoundation = MDCSwitchFoundation;
  19681. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  19682. exports.default = MDCSwitchFoundation;
  19683. /***/ }),
  19684. /***/ "./packages/mdc-switch/index.ts":
  19685. /*!**************************************!*\
  19686. !*** ./packages/mdc-switch/index.ts ***!
  19687. \**************************************/
  19688. /*! no static exports found */
  19689. /***/ (function(module, exports, __webpack_require__) {
  19690. "use strict";
  19691. /**
  19692. * @license
  19693. * Copyright 2019 Google Inc.
  19694. *
  19695. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19696. * of this software and associated documentation files (the "Software"), to deal
  19697. * in the Software without restriction, including without limitation the rights
  19698. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19699. * copies of the Software, and to permit persons to whom the Software is
  19700. * furnished to do so, subject to the following conditions:
  19701. *
  19702. * The above copyright notice and this permission notice shall be included in
  19703. * all copies or substantial portions of the Software.
  19704. *
  19705. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19706. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19707. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19708. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19709. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19710. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19711. * THE SOFTWARE.
  19712. */
  19713. function __export(m) {
  19714. for (var p in m) {
  19715. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  19716. }
  19717. }
  19718. Object.defineProperty(exports, "__esModule", { value: true });
  19719. __export(__webpack_require__(/*! ./component */ "./packages/mdc-switch/component.ts"));
  19720. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts"));
  19721. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-switch/foundation.ts"));
  19722. /***/ }),
  19723. /***/ "./packages/mdc-tab-bar/component.ts":
  19724. /*!*******************************************!*\
  19725. !*** ./packages/mdc-tab-bar/component.ts ***!
  19726. \*******************************************/
  19727. /*! no static exports found */
  19728. /***/ (function(module, exports, __webpack_require__) {
  19729. "use strict";
  19730. /**
  19731. * @license
  19732. * Copyright 2018 Google Inc.
  19733. *
  19734. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19735. * of this software and associated documentation files (the "Software"), to deal
  19736. * in the Software without restriction, including without limitation the rights
  19737. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19738. * copies of the Software, and to permit persons to whom the Software is
  19739. * furnished to do so, subject to the following conditions:
  19740. *
  19741. * The above copyright notice and this permission notice shall be included in
  19742. * all copies or substantial portions of the Software.
  19743. *
  19744. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19745. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19746. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19747. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19748. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19749. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19750. * THE SOFTWARE.
  19751. */
  19752. var __extends = this && this.__extends || function () {
  19753. var _extendStatics = function extendStatics(d, b) {
  19754. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  19755. d.__proto__ = b;
  19756. } || function (d, b) {
  19757. for (var p in b) {
  19758. if (b.hasOwnProperty(p)) d[p] = b[p];
  19759. }
  19760. };
  19761. return _extendStatics(d, b);
  19762. };
  19763. return function (d, b) {
  19764. _extendStatics(d, b);
  19765. function __() {
  19766. this.constructor = d;
  19767. }
  19768. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19769. };
  19770. }();
  19771. Object.defineProperty(exports, "__esModule", { value: true });
  19772. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  19773. var component_2 = __webpack_require__(/*! @material/tab-scroller/component */ "./packages/mdc-tab-scroller/component.ts");
  19774. var component_3 = __webpack_require__(/*! @material/tab/component */ "./packages/mdc-tab/component.ts");
  19775. var foundation_1 = __webpack_require__(/*! @material/tab/foundation */ "./packages/mdc-tab/foundation.ts");
  19776. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-bar/foundation.ts");
  19777. var strings = foundation_2.MDCTabBarFoundation.strings;
  19778. var tabIdCounter = 0;
  19779. var MDCTabBar = /** @class */function (_super) {
  19780. __extends(MDCTabBar, _super);
  19781. function MDCTabBar() {
  19782. return _super !== null && _super.apply(this, arguments) || this;
  19783. }
  19784. MDCTabBar.attachTo = function (root) {
  19785. return new MDCTabBar(root);
  19786. };
  19787. Object.defineProperty(MDCTabBar.prototype, "focusOnActivate", {
  19788. set: function set(focusOnActivate) {
  19789. this.tabList_.forEach(function (tab) {
  19790. return tab.focusOnActivate = focusOnActivate;
  19791. });
  19792. },
  19793. enumerable: true,
  19794. configurable: true
  19795. });
  19796. Object.defineProperty(MDCTabBar.prototype, "useAutomaticActivation", {
  19797. set: function set(useAutomaticActivation) {
  19798. this.foundation.setUseAutomaticActivation(useAutomaticActivation);
  19799. },
  19800. enumerable: true,
  19801. configurable: true
  19802. });
  19803. MDCTabBar.prototype.initialize = function (tabFactory, tabScrollerFactory) {
  19804. if (tabFactory === void 0) {
  19805. tabFactory = function tabFactory(el) {
  19806. return new component_3.MDCTab(el);
  19807. };
  19808. }
  19809. if (tabScrollerFactory === void 0) {
  19810. tabScrollerFactory = function tabScrollerFactory(el) {
  19811. return new component_2.MDCTabScroller(el);
  19812. };
  19813. }
  19814. this.tabList_ = this.instantiateTabs_(tabFactory);
  19815. this.tabScroller_ = this.instantiateTabScroller_(tabScrollerFactory);
  19816. };
  19817. MDCTabBar.prototype.initialSyncWithDOM = function () {
  19818. var _this = this;
  19819. this.handleTabInteraction_ = function (evt) {
  19820. return _this.foundation.handleTabInteraction(evt);
  19821. };
  19822. this.handleKeyDown_ = function (evt) {
  19823. return _this.foundation.handleKeyDown(evt);
  19824. };
  19825. this.listen(foundation_1.MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_);
  19826. this.listen('keydown', this.handleKeyDown_);
  19827. for (var i = 0; i < this.tabList_.length; i++) {
  19828. if (this.tabList_[i].active) {
  19829. this.scrollIntoView(i);
  19830. break;
  19831. }
  19832. }
  19833. };
  19834. MDCTabBar.prototype.destroy = function () {
  19835. _super.prototype.destroy.call(this);
  19836. this.unlisten(foundation_1.MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_);
  19837. this.unlisten('keydown', this.handleKeyDown_);
  19838. this.tabList_.forEach(function (tab) {
  19839. return tab.destroy();
  19840. });
  19841. if (this.tabScroller_) {
  19842. this.tabScroller_.destroy();
  19843. }
  19844. };
  19845. MDCTabBar.prototype.getDefaultFoundation = function () {
  19846. var _this = this;
  19847. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  19848. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  19849. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  19850. var adapter = {
  19851. scrollTo: function scrollTo(scrollX) {
  19852. return _this.tabScroller_.scrollTo(scrollX);
  19853. },
  19854. incrementScroll: function incrementScroll(scrollXIncrement) {
  19855. return _this.tabScroller_.incrementScroll(scrollXIncrement);
  19856. },
  19857. getScrollPosition: function getScrollPosition() {
  19858. return _this.tabScroller_.getScrollPosition();
  19859. },
  19860. getScrollContentWidth: function getScrollContentWidth() {
  19861. return _this.tabScroller_.getScrollContentWidth();
  19862. },
  19863. getOffsetWidth: function getOffsetWidth() {
  19864. return _this.root.offsetWidth;
  19865. },
  19866. isRTL: function isRTL() {
  19867. return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
  19868. },
  19869. setActiveTab: function setActiveTab(index) {
  19870. return _this.foundation.activateTab(index);
  19871. },
  19872. activateTabAtIndex: function activateTabAtIndex(index, clientRect) {
  19873. return _this.tabList_[index].activate(clientRect);
  19874. },
  19875. deactivateTabAtIndex: function deactivateTabAtIndex(index) {
  19876. return _this.tabList_[index].deactivate();
  19877. },
  19878. focusTabAtIndex: function focusTabAtIndex(index) {
  19879. return _this.tabList_[index].focus();
  19880. },
  19881. getTabIndicatorClientRectAtIndex: function getTabIndicatorClientRectAtIndex(index) {
  19882. return _this.tabList_[index].computeIndicatorClientRect();
  19883. },
  19884. getTabDimensionsAtIndex: function getTabDimensionsAtIndex(index) {
  19885. return _this.tabList_[index].computeDimensions();
  19886. },
  19887. getPreviousActiveTabIndex: function getPreviousActiveTabIndex() {
  19888. for (var i = 0; i < _this.tabList_.length; i++) {
  19889. if (_this.tabList_[i].active) {
  19890. return i;
  19891. }
  19892. }
  19893. return -1;
  19894. },
  19895. getFocusedTabIndex: function getFocusedTabIndex() {
  19896. var tabElements = _this.getTabElements_();
  19897. var activeElement = document.activeElement;
  19898. return tabElements.indexOf(activeElement);
  19899. },
  19900. getIndexOfTabById: function getIndexOfTabById(id) {
  19901. for (var i = 0; i < _this.tabList_.length; i++) {
  19902. if (_this.tabList_[i].id === id) {
  19903. return i;
  19904. }
  19905. }
  19906. return -1;
  19907. },
  19908. getTabListLength: function getTabListLength() {
  19909. return _this.tabList_.length;
  19910. },
  19911. notifyTabActivated: function notifyTabActivated(index) {
  19912. return _this.emit(strings.TAB_ACTIVATED_EVENT, { index: index }, true);
  19913. }
  19914. };
  19915. // tslint:enable:object-literal-sort-keys
  19916. return new foundation_2.MDCTabBarFoundation(adapter);
  19917. };
  19918. /**
  19919. * Activates the tab at the given index
  19920. * @param index The index of the tab
  19921. */
  19922. MDCTabBar.prototype.activateTab = function (index) {
  19923. this.foundation.activateTab(index);
  19924. };
  19925. /**
  19926. * Scrolls the tab at the given index into view
  19927. * @param index THe index of the tab
  19928. */
  19929. MDCTabBar.prototype.scrollIntoView = function (index) {
  19930. this.foundation.scrollIntoView(index);
  19931. };
  19932. /**
  19933. * Returns all the tab elements in a nice clean array
  19934. */
  19935. MDCTabBar.prototype.getTabElements_ = function () {
  19936. return [].slice.call(this.root.querySelectorAll(strings.TAB_SELECTOR));
  19937. };
  19938. /**
  19939. * Instantiates tab components on all child tab elements
  19940. */
  19941. MDCTabBar.prototype.instantiateTabs_ = function (tabFactory) {
  19942. return this.getTabElements_().map(function (el) {
  19943. el.id = el.id || "mdc-tab-" + ++tabIdCounter;
  19944. return tabFactory(el);
  19945. });
  19946. };
  19947. /**
  19948. * Instantiates tab scroller component on the child tab scroller element
  19949. */
  19950. MDCTabBar.prototype.instantiateTabScroller_ = function (tabScrollerFactory) {
  19951. var tabScrollerElement = this.root.querySelector(strings.TAB_SCROLLER_SELECTOR);
  19952. if (tabScrollerElement) {
  19953. return tabScrollerFactory(tabScrollerElement);
  19954. }
  19955. return null;
  19956. };
  19957. return MDCTabBar;
  19958. }(component_1.MDCComponent);
  19959. exports.MDCTabBar = MDCTabBar;
  19960. /***/ }),
  19961. /***/ "./packages/mdc-tab-bar/constants.ts":
  19962. /*!*******************************************!*\
  19963. !*** ./packages/mdc-tab-bar/constants.ts ***!
  19964. \*******************************************/
  19965. /*! no static exports found */
  19966. /***/ (function(module, exports, __webpack_require__) {
  19967. "use strict";
  19968. /**
  19969. * @license
  19970. * Copyright 2018 Google Inc.
  19971. *
  19972. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19973. * of this software and associated documentation files (the "Software"), to deal
  19974. * in the Software without restriction, including without limitation the rights
  19975. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19976. * copies of the Software, and to permit persons to whom the Software is
  19977. * furnished to do so, subject to the following conditions:
  19978. *
  19979. * The above copyright notice and this permission notice shall be included in
  19980. * all copies or substantial portions of the Software.
  19981. *
  19982. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19983. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19984. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19985. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19986. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19987. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19988. * THE SOFTWARE.
  19989. */
  19990. Object.defineProperty(exports, "__esModule", { value: true });
  19991. var strings = {
  19992. ARROW_LEFT_KEY: 'ArrowLeft',
  19993. ARROW_RIGHT_KEY: 'ArrowRight',
  19994. END_KEY: 'End',
  19995. ENTER_KEY: 'Enter',
  19996. HOME_KEY: 'Home',
  19997. SPACE_KEY: 'Space',
  19998. TAB_ACTIVATED_EVENT: 'MDCTabBar:activated',
  19999. TAB_SCROLLER_SELECTOR: '.mdc-tab-scroller',
  20000. TAB_SELECTOR: '.mdc-tab'
  20001. };
  20002. exports.strings = strings;
  20003. var numbers = {
  20004. ARROW_LEFT_KEYCODE: 37,
  20005. ARROW_RIGHT_KEYCODE: 39,
  20006. END_KEYCODE: 35,
  20007. ENTER_KEYCODE: 13,
  20008. EXTRA_SCROLL_AMOUNT: 20,
  20009. HOME_KEYCODE: 36,
  20010. SPACE_KEYCODE: 32
  20011. };
  20012. exports.numbers = numbers;
  20013. /***/ }),
  20014. /***/ "./packages/mdc-tab-bar/foundation.ts":
  20015. /*!********************************************!*\
  20016. !*** ./packages/mdc-tab-bar/foundation.ts ***!
  20017. \********************************************/
  20018. /*! no static exports found */
  20019. /***/ (function(module, exports, __webpack_require__) {
  20020. "use strict";
  20021. /**
  20022. * @license
  20023. * Copyright 2018 Google Inc.
  20024. *
  20025. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20026. * of this software and associated documentation files (the "Software"), to deal
  20027. * in the Software without restriction, including without limitation the rights
  20028. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20029. * copies of the Software, and to permit persons to whom the Software is
  20030. * furnished to do so, subject to the following conditions:
  20031. *
  20032. * The above copyright notice and this permission notice shall be included in
  20033. * all copies or substantial portions of the Software.
  20034. *
  20035. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20036. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20037. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20038. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20039. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20040. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20041. * THE SOFTWARE.
  20042. */
  20043. var __extends = this && this.__extends || function () {
  20044. var _extendStatics = function extendStatics(d, b) {
  20045. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20046. d.__proto__ = b;
  20047. } || function (d, b) {
  20048. for (var p in b) {
  20049. if (b.hasOwnProperty(p)) d[p] = b[p];
  20050. }
  20051. };
  20052. return _extendStatics(d, b);
  20053. };
  20054. return function (d, b) {
  20055. _extendStatics(d, b);
  20056. function __() {
  20057. this.constructor = d;
  20058. }
  20059. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20060. };
  20061. }();
  20062. var __assign = this && this.__assign || function () {
  20063. __assign = Object.assign || function (t) {
  20064. for (var s, i = 1, n = arguments.length; i < n; i++) {
  20065. s = arguments[i];
  20066. for (var p in s) {
  20067. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  20068. }
  20069. }
  20070. return t;
  20071. };
  20072. return __assign.apply(this, arguments);
  20073. };
  20074. Object.defineProperty(exports, "__esModule", { value: true });
  20075. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  20076. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-bar/constants.ts");
  20077. var ACCEPTABLE_KEYS = new Set();
  20078. // IE11 has no support for new Set with iterable so we need to initialize this by hand
  20079. ACCEPTABLE_KEYS.add(constants_1.strings.ARROW_LEFT_KEY);
  20080. ACCEPTABLE_KEYS.add(constants_1.strings.ARROW_RIGHT_KEY);
  20081. ACCEPTABLE_KEYS.add(constants_1.strings.END_KEY);
  20082. ACCEPTABLE_KEYS.add(constants_1.strings.HOME_KEY);
  20083. ACCEPTABLE_KEYS.add(constants_1.strings.ENTER_KEY);
  20084. ACCEPTABLE_KEYS.add(constants_1.strings.SPACE_KEY);
  20085. var KEYCODE_MAP = new Map();
  20086. // IE11 has no support for new Map with iterable so we need to initialize this by hand
  20087. KEYCODE_MAP.set(constants_1.numbers.ARROW_LEFT_KEYCODE, constants_1.strings.ARROW_LEFT_KEY);
  20088. KEYCODE_MAP.set(constants_1.numbers.ARROW_RIGHT_KEYCODE, constants_1.strings.ARROW_RIGHT_KEY);
  20089. KEYCODE_MAP.set(constants_1.numbers.END_KEYCODE, constants_1.strings.END_KEY);
  20090. KEYCODE_MAP.set(constants_1.numbers.HOME_KEYCODE, constants_1.strings.HOME_KEY);
  20091. KEYCODE_MAP.set(constants_1.numbers.ENTER_KEYCODE, constants_1.strings.ENTER_KEY);
  20092. KEYCODE_MAP.set(constants_1.numbers.SPACE_KEYCODE, constants_1.strings.SPACE_KEY);
  20093. var MDCTabBarFoundation = /** @class */function (_super) {
  20094. __extends(MDCTabBarFoundation, _super);
  20095. function MDCTabBarFoundation(adapter) {
  20096. var _this = _super.call(this, __assign(__assign({}, MDCTabBarFoundation.defaultAdapter), adapter)) || this;
  20097. _this.useAutomaticActivation_ = false;
  20098. return _this;
  20099. }
  20100. Object.defineProperty(MDCTabBarFoundation, "strings", {
  20101. get: function get() {
  20102. return constants_1.strings;
  20103. },
  20104. enumerable: true,
  20105. configurable: true
  20106. });
  20107. Object.defineProperty(MDCTabBarFoundation, "numbers", {
  20108. get: function get() {
  20109. return constants_1.numbers;
  20110. },
  20111. enumerable: true,
  20112. configurable: true
  20113. });
  20114. Object.defineProperty(MDCTabBarFoundation, "defaultAdapter", {
  20115. get: function get() {
  20116. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  20117. return {
  20118. scrollTo: function scrollTo() {
  20119. return undefined;
  20120. },
  20121. incrementScroll: function incrementScroll() {
  20122. return undefined;
  20123. },
  20124. getScrollPosition: function getScrollPosition() {
  20125. return 0;
  20126. },
  20127. getScrollContentWidth: function getScrollContentWidth() {
  20128. return 0;
  20129. },
  20130. getOffsetWidth: function getOffsetWidth() {
  20131. return 0;
  20132. },
  20133. isRTL: function isRTL() {
  20134. return false;
  20135. },
  20136. setActiveTab: function setActiveTab() {
  20137. return undefined;
  20138. },
  20139. activateTabAtIndex: function activateTabAtIndex() {
  20140. return undefined;
  20141. },
  20142. deactivateTabAtIndex: function deactivateTabAtIndex() {
  20143. return undefined;
  20144. },
  20145. focusTabAtIndex: function focusTabAtIndex() {
  20146. return undefined;
  20147. },
  20148. getTabIndicatorClientRectAtIndex: function getTabIndicatorClientRectAtIndex() {
  20149. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  20150. },
  20151. getTabDimensionsAtIndex: function getTabDimensionsAtIndex() {
  20152. return { rootLeft: 0, rootRight: 0, contentLeft: 0, contentRight: 0 };
  20153. },
  20154. getPreviousActiveTabIndex: function getPreviousActiveTabIndex() {
  20155. return -1;
  20156. },
  20157. getFocusedTabIndex: function getFocusedTabIndex() {
  20158. return -1;
  20159. },
  20160. getIndexOfTabById: function getIndexOfTabById() {
  20161. return -1;
  20162. },
  20163. getTabListLength: function getTabListLength() {
  20164. return 0;
  20165. },
  20166. notifyTabActivated: function notifyTabActivated() {
  20167. return undefined;
  20168. }
  20169. };
  20170. // tslint:enable:object-literal-sort-keys
  20171. },
  20172. enumerable: true,
  20173. configurable: true
  20174. });
  20175. /**
  20176. * Switches between automatic and manual activation modes.
  20177. * See https://www.w3.org/TR/wai-aria-practices/#tabpanel for examples.
  20178. */
  20179. MDCTabBarFoundation.prototype.setUseAutomaticActivation = function (useAutomaticActivation) {
  20180. this.useAutomaticActivation_ = useAutomaticActivation;
  20181. };
  20182. MDCTabBarFoundation.prototype.activateTab = function (index) {
  20183. var previousActiveIndex = this.adapter.getPreviousActiveTabIndex();
  20184. if (!this.indexIsInRange_(index) || index === previousActiveIndex) {
  20185. return;
  20186. }
  20187. var previousClientRect;
  20188. if (previousActiveIndex !== -1) {
  20189. this.adapter.deactivateTabAtIndex(previousActiveIndex);
  20190. previousClientRect = this.adapter.getTabIndicatorClientRectAtIndex(previousActiveIndex);
  20191. }
  20192. this.adapter.activateTabAtIndex(index, previousClientRect);
  20193. this.scrollIntoView(index);
  20194. this.adapter.notifyTabActivated(index);
  20195. };
  20196. MDCTabBarFoundation.prototype.handleKeyDown = function (evt) {
  20197. // Get the key from the event
  20198. var key = this.getKeyFromEvent_(evt);
  20199. // Early exit if the event key isn't one of the keyboard navigation keys
  20200. if (key === undefined) {
  20201. return;
  20202. }
  20203. // Prevent default behavior for movement keys, but not for activation keys, since :active is used to apply ripple
  20204. if (!this.isActivationKey_(key)) {
  20205. evt.preventDefault();
  20206. }
  20207. if (this.useAutomaticActivation_) {
  20208. if (this.isActivationKey_(key)) {
  20209. return;
  20210. }
  20211. var index = this.determineTargetFromKey_(this.adapter.getPreviousActiveTabIndex(), key);
  20212. this.adapter.setActiveTab(index);
  20213. this.scrollIntoView(index);
  20214. } else {
  20215. var focusedTabIndex = this.adapter.getFocusedTabIndex();
  20216. if (this.isActivationKey_(key)) {
  20217. this.adapter.setActiveTab(focusedTabIndex);
  20218. } else {
  20219. var index = this.determineTargetFromKey_(focusedTabIndex, key);
  20220. this.adapter.focusTabAtIndex(index);
  20221. this.scrollIntoView(index);
  20222. }
  20223. }
  20224. };
  20225. /**
  20226. * Handles the MDCTab:interacted event
  20227. */
  20228. MDCTabBarFoundation.prototype.handleTabInteraction = function (evt) {
  20229. this.adapter.setActiveTab(this.adapter.getIndexOfTabById(evt.detail.tabId));
  20230. };
  20231. /**
  20232. * Scrolls the tab at the given index into view
  20233. * @param index The tab index to make visible
  20234. */
  20235. MDCTabBarFoundation.prototype.scrollIntoView = function (index) {
  20236. // Early exit if the index is out of range
  20237. if (!this.indexIsInRange_(index)) {
  20238. return;
  20239. }
  20240. // Always scroll to 0 if scrolling to the 0th index
  20241. if (index === 0) {
  20242. return this.adapter.scrollTo(0);
  20243. }
  20244. // Always scroll to the max value if scrolling to the Nth index
  20245. // MDCTabScroller.scrollTo() will never scroll past the max possible value
  20246. if (index === this.adapter.getTabListLength() - 1) {
  20247. return this.adapter.scrollTo(this.adapter.getScrollContentWidth());
  20248. }
  20249. if (this.isRTL_()) {
  20250. return this.scrollIntoViewRTL_(index);
  20251. }
  20252. this.scrollIntoView_(index);
  20253. };
  20254. /**
  20255. * Private method for determining the index of the destination tab based on what key was pressed
  20256. * @param origin The original index from which to determine the destination
  20257. * @param key The name of the key
  20258. */
  20259. MDCTabBarFoundation.prototype.determineTargetFromKey_ = function (origin, key) {
  20260. var isRTL = this.isRTL_();
  20261. var maxIndex = this.adapter.getTabListLength() - 1;
  20262. var shouldGoToEnd = key === constants_1.strings.END_KEY;
  20263. var shouldDecrement = key === constants_1.strings.ARROW_LEFT_KEY && !isRTL || key === constants_1.strings.ARROW_RIGHT_KEY && isRTL;
  20264. var shouldIncrement = key === constants_1.strings.ARROW_RIGHT_KEY && !isRTL || key === constants_1.strings.ARROW_LEFT_KEY && isRTL;
  20265. var index = origin;
  20266. if (shouldGoToEnd) {
  20267. index = maxIndex;
  20268. } else if (shouldDecrement) {
  20269. index -= 1;
  20270. } else if (shouldIncrement) {
  20271. index += 1;
  20272. } else {
  20273. index = 0;
  20274. }
  20275. if (index < 0) {
  20276. index = maxIndex;
  20277. } else if (index > maxIndex) {
  20278. index = 0;
  20279. }
  20280. return index;
  20281. };
  20282. /**
  20283. * Calculates the scroll increment that will make the tab at the given index visible
  20284. * @param index The index of the tab
  20285. * @param nextIndex The index of the next tab
  20286. * @param scrollPosition The current scroll position
  20287. * @param barWidth The width of the Tab Bar
  20288. */
  20289. MDCTabBarFoundation.prototype.calculateScrollIncrement_ = function (index, nextIndex, scrollPosition, barWidth) {
  20290. var nextTabDimensions = this.adapter.getTabDimensionsAtIndex(nextIndex);
  20291. var relativeContentLeft = nextTabDimensions.contentLeft - scrollPosition - barWidth;
  20292. var relativeContentRight = nextTabDimensions.contentRight - scrollPosition;
  20293. var leftIncrement = relativeContentRight - constants_1.numbers.EXTRA_SCROLL_AMOUNT;
  20294. var rightIncrement = relativeContentLeft + constants_1.numbers.EXTRA_SCROLL_AMOUNT;
  20295. if (nextIndex < index) {
  20296. return Math.min(leftIncrement, 0);
  20297. }
  20298. return Math.max(rightIncrement, 0);
  20299. };
  20300. /**
  20301. * Calculates the scroll increment that will make the tab at the given index visible in RTL
  20302. * @param index The index of the tab
  20303. * @param nextIndex The index of the next tab
  20304. * @param scrollPosition The current scroll position
  20305. * @param barWidth The width of the Tab Bar
  20306. * @param scrollContentWidth The width of the scroll content
  20307. */
  20308. MDCTabBarFoundation.prototype.calculateScrollIncrementRTL_ = function (index, nextIndex, scrollPosition, barWidth, scrollContentWidth) {
  20309. var nextTabDimensions = this.adapter.getTabDimensionsAtIndex(nextIndex);
  20310. var relativeContentLeft = scrollContentWidth - nextTabDimensions.contentLeft - scrollPosition;
  20311. var relativeContentRight = scrollContentWidth - nextTabDimensions.contentRight - scrollPosition - barWidth;
  20312. var leftIncrement = relativeContentRight + constants_1.numbers.EXTRA_SCROLL_AMOUNT;
  20313. var rightIncrement = relativeContentLeft - constants_1.numbers.EXTRA_SCROLL_AMOUNT;
  20314. if (nextIndex > index) {
  20315. return Math.max(leftIncrement, 0);
  20316. }
  20317. return Math.min(rightIncrement, 0);
  20318. };
  20319. /**
  20320. * Determines the index of the adjacent tab closest to either edge of the Tab Bar
  20321. * @param index The index of the tab
  20322. * @param tabDimensions The dimensions of the tab
  20323. * @param scrollPosition The current scroll position
  20324. * @param barWidth The width of the tab bar
  20325. */
  20326. MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdge_ = function (index, tabDimensions, scrollPosition, barWidth) {
  20327. /**
  20328. * Tabs are laid out in the Tab Scroller like this:
  20329. *
  20330. * Scroll Position
  20331. * +---+
  20332. * | | Bar Width
  20333. * | +-----------------------------------+
  20334. * | | |
  20335. * | V V
  20336. * | +-----------------------------------+
  20337. * V | Tab Scroller |
  20338. * +------------+--------------+-------------------+
  20339. * | Tab | Tab | Tab |
  20340. * +------------+--------------+-------------------+
  20341. * | |
  20342. * +-----------------------------------+
  20343. *
  20344. * To determine the next adjacent index, we look at the Tab root left and
  20345. * Tab root right, both relative to the scroll position. If the Tab root
  20346. * left is less than 0, then we know it's out of view to the left. If the
  20347. * Tab root right minus the bar width is greater than 0, we know the Tab is
  20348. * out of view to the right. From there, we either increment or decrement
  20349. * the index.
  20350. */
  20351. var relativeRootLeft = tabDimensions.rootLeft - scrollPosition;
  20352. var relativeRootRight = tabDimensions.rootRight - scrollPosition - barWidth;
  20353. var relativeRootDelta = relativeRootLeft + relativeRootRight;
  20354. var leftEdgeIsCloser = relativeRootLeft < 0 || relativeRootDelta < 0;
  20355. var rightEdgeIsCloser = relativeRootRight > 0 || relativeRootDelta > 0;
  20356. if (leftEdgeIsCloser) {
  20357. return index - 1;
  20358. }
  20359. if (rightEdgeIsCloser) {
  20360. return index + 1;
  20361. }
  20362. return -1;
  20363. };
  20364. /**
  20365. * Determines the index of the adjacent tab closest to either edge of the Tab Bar in RTL
  20366. * @param index The index of the tab
  20367. * @param tabDimensions The dimensions of the tab
  20368. * @param scrollPosition The current scroll position
  20369. * @param barWidth The width of the tab bar
  20370. * @param scrollContentWidth The width of the scroller content
  20371. */
  20372. MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdgeRTL_ = function (index, tabDimensions, scrollPosition, barWidth, scrollContentWidth) {
  20373. var rootLeft = scrollContentWidth - tabDimensions.rootLeft - barWidth - scrollPosition;
  20374. var rootRight = scrollContentWidth - tabDimensions.rootRight - scrollPosition;
  20375. var rootDelta = rootLeft + rootRight;
  20376. var leftEdgeIsCloser = rootLeft > 0 || rootDelta > 0;
  20377. var rightEdgeIsCloser = rootRight < 0 || rootDelta < 0;
  20378. if (leftEdgeIsCloser) {
  20379. return index + 1;
  20380. }
  20381. if (rightEdgeIsCloser) {
  20382. return index - 1;
  20383. }
  20384. return -1;
  20385. };
  20386. /**
  20387. * Returns the key associated with a keydown event
  20388. * @param evt The keydown event
  20389. */
  20390. MDCTabBarFoundation.prototype.getKeyFromEvent_ = function (evt) {
  20391. if (ACCEPTABLE_KEYS.has(evt.key)) {
  20392. return evt.key;
  20393. }
  20394. return KEYCODE_MAP.get(evt.keyCode);
  20395. };
  20396. MDCTabBarFoundation.prototype.isActivationKey_ = function (key) {
  20397. return key === constants_1.strings.SPACE_KEY || key === constants_1.strings.ENTER_KEY;
  20398. };
  20399. /**
  20400. * Returns whether a given index is inclusively between the ends
  20401. * @param index The index to test
  20402. */
  20403. MDCTabBarFoundation.prototype.indexIsInRange_ = function (index) {
  20404. return index >= 0 && index < this.adapter.getTabListLength();
  20405. };
  20406. /**
  20407. * Returns the view's RTL property
  20408. */
  20409. MDCTabBarFoundation.prototype.isRTL_ = function () {
  20410. return this.adapter.isRTL();
  20411. };
  20412. /**
  20413. * Scrolls the tab at the given index into view for left-to-right user agents.
  20414. * @param index The index of the tab to scroll into view
  20415. */
  20416. MDCTabBarFoundation.prototype.scrollIntoView_ = function (index) {
  20417. var scrollPosition = this.adapter.getScrollPosition();
  20418. var barWidth = this.adapter.getOffsetWidth();
  20419. var tabDimensions = this.adapter.getTabDimensionsAtIndex(index);
  20420. var nextIndex = this.findAdjacentTabIndexClosestToEdge_(index, tabDimensions, scrollPosition, barWidth);
  20421. if (!this.indexIsInRange_(nextIndex)) {
  20422. return;
  20423. }
  20424. var scrollIncrement = this.calculateScrollIncrement_(index, nextIndex, scrollPosition, barWidth);
  20425. this.adapter.incrementScroll(scrollIncrement);
  20426. };
  20427. /**
  20428. * Scrolls the tab at the given index into view in RTL
  20429. * @param index The tab index to make visible
  20430. */
  20431. MDCTabBarFoundation.prototype.scrollIntoViewRTL_ = function (index) {
  20432. var scrollPosition = this.adapter.getScrollPosition();
  20433. var barWidth = this.adapter.getOffsetWidth();
  20434. var tabDimensions = this.adapter.getTabDimensionsAtIndex(index);
  20435. var scrollWidth = this.adapter.getScrollContentWidth();
  20436. var nextIndex = this.findAdjacentTabIndexClosestToEdgeRTL_(index, tabDimensions, scrollPosition, barWidth, scrollWidth);
  20437. if (!this.indexIsInRange_(nextIndex)) {
  20438. return;
  20439. }
  20440. var scrollIncrement = this.calculateScrollIncrementRTL_(index, nextIndex, scrollPosition, barWidth, scrollWidth);
  20441. this.adapter.incrementScroll(scrollIncrement);
  20442. };
  20443. return MDCTabBarFoundation;
  20444. }(foundation_1.MDCFoundation);
  20445. exports.MDCTabBarFoundation = MDCTabBarFoundation;
  20446. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  20447. exports.default = MDCTabBarFoundation;
  20448. /***/ }),
  20449. /***/ "./packages/mdc-tab-bar/index.ts":
  20450. /*!***************************************!*\
  20451. !*** ./packages/mdc-tab-bar/index.ts ***!
  20452. \***************************************/
  20453. /*! no static exports found */
  20454. /***/ (function(module, exports, __webpack_require__) {
  20455. "use strict";
  20456. /**
  20457. * @license
  20458. * Copyright 2019 Google Inc.
  20459. *
  20460. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20461. * of this software and associated documentation files (the "Software"), to deal
  20462. * in the Software without restriction, including without limitation the rights
  20463. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20464. * copies of the Software, and to permit persons to whom the Software is
  20465. * furnished to do so, subject to the following conditions:
  20466. *
  20467. * The above copyright notice and this permission notice shall be included in
  20468. * all copies or substantial portions of the Software.
  20469. *
  20470. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20471. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20472. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20473. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20474. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20475. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20476. * THE SOFTWARE.
  20477. */
  20478. function __export(m) {
  20479. for (var p in m) {
  20480. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  20481. }
  20482. }
  20483. Object.defineProperty(exports, "__esModule", { value: true });
  20484. __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab-bar/component.ts"));
  20485. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-bar/constants.ts"));
  20486. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-bar/foundation.ts"));
  20487. /***/ }),
  20488. /***/ "./packages/mdc-tab-indicator/component.ts":
  20489. /*!*************************************************!*\
  20490. !*** ./packages/mdc-tab-indicator/component.ts ***!
  20491. \*************************************************/
  20492. /*! no static exports found */
  20493. /***/ (function(module, exports, __webpack_require__) {
  20494. "use strict";
  20495. /**
  20496. * @license
  20497. * Copyright 2018 Google Inc.
  20498. *
  20499. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20500. * of this software and associated documentation files (the "Software"), to deal
  20501. * in the Software without restriction, including without limitation the rights
  20502. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20503. * copies of the Software, and to permit persons to whom the Software is
  20504. * furnished to do so, subject to the following conditions:
  20505. *
  20506. * The above copyright notice and this permission notice shall be included in
  20507. * all copies or substantial portions of the Software.
  20508. *
  20509. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20510. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20511. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20512. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20513. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20514. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20515. * THE SOFTWARE.
  20516. */
  20517. var __extends = this && this.__extends || function () {
  20518. var _extendStatics = function extendStatics(d, b) {
  20519. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20520. d.__proto__ = b;
  20521. } || function (d, b) {
  20522. for (var p in b) {
  20523. if (b.hasOwnProperty(p)) d[p] = b[p];
  20524. }
  20525. };
  20526. return _extendStatics(d, b);
  20527. };
  20528. return function (d, b) {
  20529. _extendStatics(d, b);
  20530. function __() {
  20531. this.constructor = d;
  20532. }
  20533. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20534. };
  20535. }();
  20536. Object.defineProperty(exports, "__esModule", { value: true });
  20537. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  20538. var fading_foundation_1 = __webpack_require__(/*! ./fading-foundation */ "./packages/mdc-tab-indicator/fading-foundation.ts");
  20539. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
  20540. var sliding_foundation_1 = __webpack_require__(/*! ./sliding-foundation */ "./packages/mdc-tab-indicator/sliding-foundation.ts");
  20541. var MDCTabIndicator = /** @class */function (_super) {
  20542. __extends(MDCTabIndicator, _super);
  20543. function MDCTabIndicator() {
  20544. return _super !== null && _super.apply(this, arguments) || this;
  20545. }
  20546. MDCTabIndicator.attachTo = function (root) {
  20547. return new MDCTabIndicator(root);
  20548. };
  20549. MDCTabIndicator.prototype.initialize = function () {
  20550. this.content_ = this.root.querySelector(foundation_1.MDCTabIndicatorFoundation.strings.CONTENT_SELECTOR);
  20551. };
  20552. MDCTabIndicator.prototype.computeContentClientRect = function () {
  20553. return this.foundation.computeContentClientRect();
  20554. };
  20555. MDCTabIndicator.prototype.getDefaultFoundation = function () {
  20556. var _this = this;
  20557. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  20558. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  20559. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  20560. var adapter = {
  20561. addClass: function addClass(className) {
  20562. return _this.root.classList.add(className);
  20563. },
  20564. removeClass: function removeClass(className) {
  20565. return _this.root.classList.remove(className);
  20566. },
  20567. computeContentClientRect: function computeContentClientRect() {
  20568. return _this.content_.getBoundingClientRect();
  20569. },
  20570. setContentStyleProperty: function setContentStyleProperty(prop, value) {
  20571. return _this.content_.style.setProperty(prop, value);
  20572. }
  20573. };
  20574. // tslint:enable:object-literal-sort-keys
  20575. if (this.root.classList.contains(foundation_1.MDCTabIndicatorFoundation.cssClasses.FADE)) {
  20576. return new fading_foundation_1.MDCFadingTabIndicatorFoundation(adapter);
  20577. }
  20578. // Default to the sliding indicator
  20579. return new sliding_foundation_1.MDCSlidingTabIndicatorFoundation(adapter);
  20580. };
  20581. MDCTabIndicator.prototype.activate = function (previousIndicatorClientRect) {
  20582. this.foundation.activate(previousIndicatorClientRect);
  20583. };
  20584. MDCTabIndicator.prototype.deactivate = function () {
  20585. this.foundation.deactivate();
  20586. };
  20587. return MDCTabIndicator;
  20588. }(component_1.MDCComponent);
  20589. exports.MDCTabIndicator = MDCTabIndicator;
  20590. /***/ }),
  20591. /***/ "./packages/mdc-tab-indicator/constants.ts":
  20592. /*!*************************************************!*\
  20593. !*** ./packages/mdc-tab-indicator/constants.ts ***!
  20594. \*************************************************/
  20595. /*! no static exports found */
  20596. /***/ (function(module, exports, __webpack_require__) {
  20597. "use strict";
  20598. /**
  20599. * @license
  20600. * Copyright 2018 Google Inc.
  20601. *
  20602. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20603. * of this software and associated documentation files (the "Software"), to deal
  20604. * in the Software without restriction, including without limitation the rights
  20605. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20606. * copies of the Software, and to permit persons to whom the Software is
  20607. * furnished to do so, subject to the following conditions:
  20608. *
  20609. * The above copyright notice and this permission notice shall be included in
  20610. * all copies or substantial portions of the Software.
  20611. *
  20612. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20613. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20614. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20615. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20616. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20617. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20618. * THE SOFTWARE.
  20619. */
  20620. Object.defineProperty(exports, "__esModule", { value: true });
  20621. var cssClasses = {
  20622. ACTIVE: 'mdc-tab-indicator--active',
  20623. FADE: 'mdc-tab-indicator--fade',
  20624. NO_TRANSITION: 'mdc-tab-indicator--no-transition'
  20625. };
  20626. exports.cssClasses = cssClasses;
  20627. var strings = {
  20628. CONTENT_SELECTOR: '.mdc-tab-indicator__content'
  20629. };
  20630. exports.strings = strings;
  20631. /***/ }),
  20632. /***/ "./packages/mdc-tab-indicator/fading-foundation.ts":
  20633. /*!*********************************************************!*\
  20634. !*** ./packages/mdc-tab-indicator/fading-foundation.ts ***!
  20635. \*********************************************************/
  20636. /*! no static exports found */
  20637. /***/ (function(module, exports, __webpack_require__) {
  20638. "use strict";
  20639. /**
  20640. * @license
  20641. * Copyright 2018 Google Inc.
  20642. *
  20643. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20644. * of this software and associated documentation files (the "Software"), to deal
  20645. * in the Software without restriction, including without limitation the rights
  20646. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20647. * copies of the Software, and to permit persons to whom the Software is
  20648. * furnished to do so, subject to the following conditions:
  20649. *
  20650. * The above copyright notice and this permission notice shall be included in
  20651. * all copies or substantial portions of the Software.
  20652. *
  20653. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20654. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20655. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20656. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20657. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20658. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20659. * THE SOFTWARE.
  20660. */
  20661. var __extends = this && this.__extends || function () {
  20662. var _extendStatics = function extendStatics(d, b) {
  20663. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20664. d.__proto__ = b;
  20665. } || function (d, b) {
  20666. for (var p in b) {
  20667. if (b.hasOwnProperty(p)) d[p] = b[p];
  20668. }
  20669. };
  20670. return _extendStatics(d, b);
  20671. };
  20672. return function (d, b) {
  20673. _extendStatics(d, b);
  20674. function __() {
  20675. this.constructor = d;
  20676. }
  20677. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20678. };
  20679. }();
  20680. Object.defineProperty(exports, "__esModule", { value: true });
  20681. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
  20682. /* istanbul ignore next: subclass is not a branch statement */
  20683. var MDCFadingTabIndicatorFoundation = /** @class */function (_super) {
  20684. __extends(MDCFadingTabIndicatorFoundation, _super);
  20685. function MDCFadingTabIndicatorFoundation() {
  20686. return _super !== null && _super.apply(this, arguments) || this;
  20687. }
  20688. MDCFadingTabIndicatorFoundation.prototype.activate = function () {
  20689. this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
  20690. };
  20691. MDCFadingTabIndicatorFoundation.prototype.deactivate = function () {
  20692. this.adapter.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
  20693. };
  20694. return MDCFadingTabIndicatorFoundation;
  20695. }(foundation_1.MDCTabIndicatorFoundation);
  20696. exports.MDCFadingTabIndicatorFoundation = MDCFadingTabIndicatorFoundation;
  20697. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  20698. exports.default = MDCFadingTabIndicatorFoundation;
  20699. /***/ }),
  20700. /***/ "./packages/mdc-tab-indicator/foundation.ts":
  20701. /*!**************************************************!*\
  20702. !*** ./packages/mdc-tab-indicator/foundation.ts ***!
  20703. \**************************************************/
  20704. /*! no static exports found */
  20705. /***/ (function(module, exports, __webpack_require__) {
  20706. "use strict";
  20707. /**
  20708. * @license
  20709. * Copyright 2018 Google Inc.
  20710. *
  20711. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20712. * of this software and associated documentation files (the "Software"), to deal
  20713. * in the Software without restriction, including without limitation the rights
  20714. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20715. * copies of the Software, and to permit persons to whom the Software is
  20716. * furnished to do so, subject to the following conditions:
  20717. *
  20718. * The above copyright notice and this permission notice shall be included in
  20719. * all copies or substantial portions of the Software.
  20720. *
  20721. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20722. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20723. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20724. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20725. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20726. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20727. * THE SOFTWARE.
  20728. */
  20729. var __extends = this && this.__extends || function () {
  20730. var _extendStatics = function extendStatics(d, b) {
  20731. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20732. d.__proto__ = b;
  20733. } || function (d, b) {
  20734. for (var p in b) {
  20735. if (b.hasOwnProperty(p)) d[p] = b[p];
  20736. }
  20737. };
  20738. return _extendStatics(d, b);
  20739. };
  20740. return function (d, b) {
  20741. _extendStatics(d, b);
  20742. function __() {
  20743. this.constructor = d;
  20744. }
  20745. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20746. };
  20747. }();
  20748. var __assign = this && this.__assign || function () {
  20749. __assign = Object.assign || function (t) {
  20750. for (var s, i = 1, n = arguments.length; i < n; i++) {
  20751. s = arguments[i];
  20752. for (var p in s) {
  20753. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  20754. }
  20755. }
  20756. return t;
  20757. };
  20758. return __assign.apply(this, arguments);
  20759. };
  20760. Object.defineProperty(exports, "__esModule", { value: true });
  20761. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  20762. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-indicator/constants.ts");
  20763. var MDCTabIndicatorFoundation = /** @class */function (_super) {
  20764. __extends(MDCTabIndicatorFoundation, _super);
  20765. function MDCTabIndicatorFoundation(adapter) {
  20766. return _super.call(this, __assign(__assign({}, MDCTabIndicatorFoundation.defaultAdapter), adapter)) || this;
  20767. }
  20768. Object.defineProperty(MDCTabIndicatorFoundation, "cssClasses", {
  20769. get: function get() {
  20770. return constants_1.cssClasses;
  20771. },
  20772. enumerable: true,
  20773. configurable: true
  20774. });
  20775. Object.defineProperty(MDCTabIndicatorFoundation, "strings", {
  20776. get: function get() {
  20777. return constants_1.strings;
  20778. },
  20779. enumerable: true,
  20780. configurable: true
  20781. });
  20782. Object.defineProperty(MDCTabIndicatorFoundation, "defaultAdapter", {
  20783. get: function get() {
  20784. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  20785. return {
  20786. addClass: function addClass() {
  20787. return undefined;
  20788. },
  20789. removeClass: function removeClass() {
  20790. return undefined;
  20791. },
  20792. computeContentClientRect: function computeContentClientRect() {
  20793. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  20794. },
  20795. setContentStyleProperty: function setContentStyleProperty() {
  20796. return undefined;
  20797. }
  20798. };
  20799. // tslint:enable:object-literal-sort-keys
  20800. },
  20801. enumerable: true,
  20802. configurable: true
  20803. });
  20804. MDCTabIndicatorFoundation.prototype.computeContentClientRect = function () {
  20805. return this.adapter.computeContentClientRect();
  20806. };
  20807. return MDCTabIndicatorFoundation;
  20808. }(foundation_1.MDCFoundation);
  20809. exports.MDCTabIndicatorFoundation = MDCTabIndicatorFoundation;
  20810. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  20811. exports.default = MDCTabIndicatorFoundation;
  20812. /***/ }),
  20813. /***/ "./packages/mdc-tab-indicator/index.ts":
  20814. /*!*********************************************!*\
  20815. !*** ./packages/mdc-tab-indicator/index.ts ***!
  20816. \*********************************************/
  20817. /*! no static exports found */
  20818. /***/ (function(module, exports, __webpack_require__) {
  20819. "use strict";
  20820. /**
  20821. * @license
  20822. * Copyright 2019 Google Inc.
  20823. *
  20824. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20825. * of this software and associated documentation files (the "Software"), to deal
  20826. * in the Software without restriction, including without limitation the rights
  20827. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20828. * copies of the Software, and to permit persons to whom the Software is
  20829. * furnished to do so, subject to the following conditions:
  20830. *
  20831. * The above copyright notice and this permission notice shall be included in
  20832. * all copies or substantial portions of the Software.
  20833. *
  20834. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20835. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20836. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20837. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20838. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20839. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20840. * THE SOFTWARE.
  20841. */
  20842. function __export(m) {
  20843. for (var p in m) {
  20844. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  20845. }
  20846. }
  20847. Object.defineProperty(exports, "__esModule", { value: true });
  20848. __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab-indicator/component.ts"));
  20849. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-indicator/constants.ts"));
  20850. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts"));
  20851. __export(__webpack_require__(/*! ./fading-foundation */ "./packages/mdc-tab-indicator/fading-foundation.ts"));
  20852. __export(__webpack_require__(/*! ./sliding-foundation */ "./packages/mdc-tab-indicator/sliding-foundation.ts"));
  20853. /***/ }),
  20854. /***/ "./packages/mdc-tab-indicator/sliding-foundation.ts":
  20855. /*!**********************************************************!*\
  20856. !*** ./packages/mdc-tab-indicator/sliding-foundation.ts ***!
  20857. \**********************************************************/
  20858. /*! no static exports found */
  20859. /***/ (function(module, exports, __webpack_require__) {
  20860. "use strict";
  20861. /**
  20862. * @license
  20863. * Copyright 2018 Google Inc.
  20864. *
  20865. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20866. * of this software and associated documentation files (the "Software"), to deal
  20867. * in the Software without restriction, including without limitation the rights
  20868. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20869. * copies of the Software, and to permit persons to whom the Software is
  20870. * furnished to do so, subject to the following conditions:
  20871. *
  20872. * The above copyright notice and this permission notice shall be included in
  20873. * all copies or substantial portions of the Software.
  20874. *
  20875. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20876. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20877. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20878. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20879. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20880. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20881. * THE SOFTWARE.
  20882. */
  20883. var __extends = this && this.__extends || function () {
  20884. var _extendStatics = function extendStatics(d, b) {
  20885. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20886. d.__proto__ = b;
  20887. } || function (d, b) {
  20888. for (var p in b) {
  20889. if (b.hasOwnProperty(p)) d[p] = b[p];
  20890. }
  20891. };
  20892. return _extendStatics(d, b);
  20893. };
  20894. return function (d, b) {
  20895. _extendStatics(d, b);
  20896. function __() {
  20897. this.constructor = d;
  20898. }
  20899. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20900. };
  20901. }();
  20902. Object.defineProperty(exports, "__esModule", { value: true });
  20903. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
  20904. /* istanbul ignore next: subclass is not a branch statement */
  20905. var MDCSlidingTabIndicatorFoundation = /** @class */function (_super) {
  20906. __extends(MDCSlidingTabIndicatorFoundation, _super);
  20907. function MDCSlidingTabIndicatorFoundation() {
  20908. return _super !== null && _super.apply(this, arguments) || this;
  20909. }
  20910. MDCSlidingTabIndicatorFoundation.prototype.activate = function (previousIndicatorClientRect) {
  20911. // Early exit if no indicator is present to handle cases where an indicator
  20912. // may be activated without a prior indicator state
  20913. if (!previousIndicatorClientRect) {
  20914. this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
  20915. return;
  20916. }
  20917. // This animation uses the FLIP approach. You can read more about it at the link below:
  20918. // https://aerotwist.com/blog/flip-your-animations/
  20919. // Calculate the dimensions based on the dimensions of the previous indicator
  20920. var currentClientRect = this.computeContentClientRect();
  20921. var widthDelta = previousIndicatorClientRect.width / currentClientRect.width;
  20922. var xPosition = previousIndicatorClientRect.left - currentClientRect.left;
  20923. this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION);
  20924. this.adapter.setContentStyleProperty('transform', "translateX(" + xPosition + "px) scaleX(" + widthDelta + ")");
  20925. // Force repaint before updating classes and transform to ensure the transform properly takes effect
  20926. this.computeContentClientRect();
  20927. this.adapter.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION);
  20928. this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
  20929. this.adapter.setContentStyleProperty('transform', '');
  20930. };
  20931. MDCSlidingTabIndicatorFoundation.prototype.deactivate = function () {
  20932. this.adapter.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
  20933. };
  20934. return MDCSlidingTabIndicatorFoundation;
  20935. }(foundation_1.MDCTabIndicatorFoundation);
  20936. exports.MDCSlidingTabIndicatorFoundation = MDCSlidingTabIndicatorFoundation;
  20937. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  20938. exports.default = MDCSlidingTabIndicatorFoundation;
  20939. /***/ }),
  20940. /***/ "./packages/mdc-tab-scroller/component.ts":
  20941. /*!************************************************!*\
  20942. !*** ./packages/mdc-tab-scroller/component.ts ***!
  20943. \************************************************/
  20944. /*! no static exports found */
  20945. /***/ (function(module, exports, __webpack_require__) {
  20946. "use strict";
  20947. /**
  20948. * @license
  20949. * Copyright 2018 Google Inc.
  20950. *
  20951. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20952. * of this software and associated documentation files (the "Software"), to deal
  20953. * in the Software without restriction, including without limitation the rights
  20954. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20955. * copies of the Software, and to permit persons to whom the Software is
  20956. * furnished to do so, subject to the following conditions:
  20957. *
  20958. * The above copyright notice and this permission notice shall be included in
  20959. * all copies or substantial portions of the Software.
  20960. *
  20961. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20962. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20963. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20964. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20965. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20966. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20967. * THE SOFTWARE.
  20968. */
  20969. var __extends = this && this.__extends || function () {
  20970. var _extendStatics = function extendStatics(d, b) {
  20971. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20972. d.__proto__ = b;
  20973. } || function (d, b) {
  20974. for (var p in b) {
  20975. if (b.hasOwnProperty(p)) d[p] = b[p];
  20976. }
  20977. };
  20978. return _extendStatics(d, b);
  20979. };
  20980. return function (d, b) {
  20981. _extendStatics(d, b);
  20982. function __() {
  20983. this.constructor = d;
  20984. }
  20985. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20986. };
  20987. }();
  20988. var __importStar = this && this.__importStar || function (mod) {
  20989. if (mod && mod.__esModule) return mod;
  20990. var result = {};
  20991. if (mod != null) for (var k in mod) {
  20992. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  20993. }result["default"] = mod;
  20994. return result;
  20995. };
  20996. Object.defineProperty(exports, "__esModule", { value: true });
  20997. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  20998. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  20999. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  21000. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-scroller/foundation.ts");
  21001. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-tab-scroller/util.ts"));
  21002. var MDCTabScroller = /** @class */function (_super) {
  21003. __extends(MDCTabScroller, _super);
  21004. function MDCTabScroller() {
  21005. return _super !== null && _super.apply(this, arguments) || this;
  21006. }
  21007. MDCTabScroller.attachTo = function (root) {
  21008. return new MDCTabScroller(root);
  21009. };
  21010. MDCTabScroller.prototype.initialize = function () {
  21011. this.area_ = this.root.querySelector(foundation_1.MDCTabScrollerFoundation.strings.AREA_SELECTOR);
  21012. this.content_ = this.root.querySelector(foundation_1.MDCTabScrollerFoundation.strings.CONTENT_SELECTOR);
  21013. };
  21014. MDCTabScroller.prototype.initialSyncWithDOM = function () {
  21015. var _this = this;
  21016. this.handleInteraction_ = function () {
  21017. return _this.foundation.handleInteraction();
  21018. };
  21019. this.handleTransitionEnd_ = function (evt) {
  21020. return _this.foundation.handleTransitionEnd(evt);
  21021. };
  21022. this.area_.addEventListener('wheel', this.handleInteraction_, events_1.applyPassive());
  21023. this.area_.addEventListener('touchstart', this.handleInteraction_, events_1.applyPassive());
  21024. this.area_.addEventListener('pointerdown', this.handleInteraction_, events_1.applyPassive());
  21025. this.area_.addEventListener('mousedown', this.handleInteraction_, events_1.applyPassive());
  21026. this.area_.addEventListener('keydown', this.handleInteraction_, events_1.applyPassive());
  21027. this.content_.addEventListener('transitionend', this.handleTransitionEnd_);
  21028. };
  21029. MDCTabScroller.prototype.destroy = function () {
  21030. _super.prototype.destroy.call(this);
  21031. this.area_.removeEventListener('wheel', this.handleInteraction_, events_1.applyPassive());
  21032. this.area_.removeEventListener('touchstart', this.handleInteraction_, events_1.applyPassive());
  21033. this.area_.removeEventListener('pointerdown', this.handleInteraction_, events_1.applyPassive());
  21034. this.area_.removeEventListener('mousedown', this.handleInteraction_, events_1.applyPassive());
  21035. this.area_.removeEventListener('keydown', this.handleInteraction_, events_1.applyPassive());
  21036. this.content_.removeEventListener('transitionend', this.handleTransitionEnd_);
  21037. };
  21038. MDCTabScroller.prototype.getDefaultFoundation = function () {
  21039. var _this = this;
  21040. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  21041. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  21042. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  21043. var adapter = {
  21044. eventTargetMatchesSelector: function eventTargetMatchesSelector(evtTarget, selector) {
  21045. return ponyfill_1.matches(evtTarget, selector);
  21046. },
  21047. addClass: function addClass(className) {
  21048. return _this.root.classList.add(className);
  21049. },
  21050. removeClass: function removeClass(className) {
  21051. return _this.root.classList.remove(className);
  21052. },
  21053. addScrollAreaClass: function addScrollAreaClass(className) {
  21054. return _this.area_.classList.add(className);
  21055. },
  21056. setScrollAreaStyleProperty: function setScrollAreaStyleProperty(prop, value) {
  21057. return _this.area_.style.setProperty(prop, value);
  21058. },
  21059. setScrollContentStyleProperty: function setScrollContentStyleProperty(prop, value) {
  21060. return _this.content_.style.setProperty(prop, value);
  21061. },
  21062. getScrollContentStyleValue: function getScrollContentStyleValue(propName) {
  21063. return window.getComputedStyle(_this.content_).getPropertyValue(propName);
  21064. },
  21065. setScrollAreaScrollLeft: function setScrollAreaScrollLeft(scrollX) {
  21066. return _this.area_.scrollLeft = scrollX;
  21067. },
  21068. getScrollAreaScrollLeft: function getScrollAreaScrollLeft() {
  21069. return _this.area_.scrollLeft;
  21070. },
  21071. getScrollContentOffsetWidth: function getScrollContentOffsetWidth() {
  21072. return _this.content_.offsetWidth;
  21073. },
  21074. getScrollAreaOffsetWidth: function getScrollAreaOffsetWidth() {
  21075. return _this.area_.offsetWidth;
  21076. },
  21077. computeScrollAreaClientRect: function computeScrollAreaClientRect() {
  21078. return _this.area_.getBoundingClientRect();
  21079. },
  21080. computeScrollContentClientRect: function computeScrollContentClientRect() {
  21081. return _this.content_.getBoundingClientRect();
  21082. },
  21083. computeHorizontalScrollbarHeight: function computeHorizontalScrollbarHeight() {
  21084. return util.computeHorizontalScrollbarHeight(document);
  21085. }
  21086. };
  21087. // tslint:enable:object-literal-sort-keys
  21088. return new foundation_1.MDCTabScrollerFoundation(adapter);
  21089. };
  21090. /**
  21091. * Returns the current visual scroll position
  21092. */
  21093. MDCTabScroller.prototype.getScrollPosition = function () {
  21094. return this.foundation.getScrollPosition();
  21095. };
  21096. /**
  21097. * Returns the width of the scroll content
  21098. */
  21099. MDCTabScroller.prototype.getScrollContentWidth = function () {
  21100. return this.content_.offsetWidth;
  21101. };
  21102. /**
  21103. * Increments the scroll value by the given amount
  21104. * @param scrollXIncrement The pixel value by which to increment the scroll value
  21105. */
  21106. MDCTabScroller.prototype.incrementScroll = function (scrollXIncrement) {
  21107. this.foundation.incrementScroll(scrollXIncrement);
  21108. };
  21109. /**
  21110. * Scrolls to the given pixel position
  21111. * @param scrollX The pixel value to scroll to
  21112. */
  21113. MDCTabScroller.prototype.scrollTo = function (scrollX) {
  21114. this.foundation.scrollTo(scrollX);
  21115. };
  21116. return MDCTabScroller;
  21117. }(component_1.MDCComponent);
  21118. exports.MDCTabScroller = MDCTabScroller;
  21119. /***/ }),
  21120. /***/ "./packages/mdc-tab-scroller/constants.ts":
  21121. /*!************************************************!*\
  21122. !*** ./packages/mdc-tab-scroller/constants.ts ***!
  21123. \************************************************/
  21124. /*! no static exports found */
  21125. /***/ (function(module, exports, __webpack_require__) {
  21126. "use strict";
  21127. /**
  21128. * @license
  21129. * Copyright 2018 Google Inc.
  21130. *
  21131. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21132. * of this software and associated documentation files (the "Software"), to deal
  21133. * in the Software without restriction, including without limitation the rights
  21134. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21135. * copies of the Software, and to permit persons to whom the Software is
  21136. * furnished to do so, subject to the following conditions:
  21137. *
  21138. * The above copyright notice and this permission notice shall be included in
  21139. * all copies or substantial portions of the Software.
  21140. *
  21141. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21142. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21143. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21144. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21145. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21146. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21147. * THE SOFTWARE.
  21148. */
  21149. Object.defineProperty(exports, "__esModule", { value: true });
  21150. var cssClasses = {
  21151. ANIMATING: 'mdc-tab-scroller--animating',
  21152. SCROLL_AREA_SCROLL: 'mdc-tab-scroller__scroll-area--scroll',
  21153. SCROLL_TEST: 'mdc-tab-scroller__test'
  21154. };
  21155. exports.cssClasses = cssClasses;
  21156. var strings = {
  21157. AREA_SELECTOR: '.mdc-tab-scroller__scroll-area',
  21158. CONTENT_SELECTOR: '.mdc-tab-scroller__scroll-content'
  21159. };
  21160. exports.strings = strings;
  21161. /***/ }),
  21162. /***/ "./packages/mdc-tab-scroller/foundation.ts":
  21163. /*!*************************************************!*\
  21164. !*** ./packages/mdc-tab-scroller/foundation.ts ***!
  21165. \*************************************************/
  21166. /*! no static exports found */
  21167. /***/ (function(module, exports, __webpack_require__) {
  21168. "use strict";
  21169. /**
  21170. * @license
  21171. * Copyright 2018 Google Inc.
  21172. *
  21173. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21174. * of this software and associated documentation files (the "Software"), to deal
  21175. * in the Software without restriction, including without limitation the rights
  21176. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21177. * copies of the Software, and to permit persons to whom the Software is
  21178. * furnished to do so, subject to the following conditions:
  21179. *
  21180. * The above copyright notice and this permission notice shall be included in
  21181. * all copies or substantial portions of the Software.
  21182. *
  21183. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21184. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21185. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21186. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21187. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21188. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21189. * THE SOFTWARE.
  21190. */
  21191. var __extends = this && this.__extends || function () {
  21192. var _extendStatics = function extendStatics(d, b) {
  21193. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  21194. d.__proto__ = b;
  21195. } || function (d, b) {
  21196. for (var p in b) {
  21197. if (b.hasOwnProperty(p)) d[p] = b[p];
  21198. }
  21199. };
  21200. return _extendStatics(d, b);
  21201. };
  21202. return function (d, b) {
  21203. _extendStatics(d, b);
  21204. function __() {
  21205. this.constructor = d;
  21206. }
  21207. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21208. };
  21209. }();
  21210. var __assign = this && this.__assign || function () {
  21211. __assign = Object.assign || function (t) {
  21212. for (var s, i = 1, n = arguments.length; i < n; i++) {
  21213. s = arguments[i];
  21214. for (var p in s) {
  21215. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  21216. }
  21217. }
  21218. return t;
  21219. };
  21220. return __assign.apply(this, arguments);
  21221. };
  21222. var __read = this && this.__read || function (o, n) {
  21223. var m = typeof Symbol === "function" && o[Symbol.iterator];
  21224. if (!m) return o;
  21225. var i = m.call(o),
  21226. r,
  21227. ar = [],
  21228. e;
  21229. try {
  21230. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  21231. ar.push(r.value);
  21232. }
  21233. } catch (error) {
  21234. e = { error: error };
  21235. } finally {
  21236. try {
  21237. if (r && !r.done && (m = i["return"])) m.call(i);
  21238. } finally {
  21239. if (e) throw e.error;
  21240. }
  21241. }
  21242. return ar;
  21243. };
  21244. Object.defineProperty(exports, "__esModule", { value: true });
  21245. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  21246. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts");
  21247. var rtl_default_scroller_1 = __webpack_require__(/*! ./rtl-default-scroller */ "./packages/mdc-tab-scroller/rtl-default-scroller.ts");
  21248. var rtl_negative_scroller_1 = __webpack_require__(/*! ./rtl-negative-scroller */ "./packages/mdc-tab-scroller/rtl-negative-scroller.ts");
  21249. var rtl_reverse_scroller_1 = __webpack_require__(/*! ./rtl-reverse-scroller */ "./packages/mdc-tab-scroller/rtl-reverse-scroller.ts");
  21250. var MDCTabScrollerFoundation = /** @class */function (_super) {
  21251. __extends(MDCTabScrollerFoundation, _super);
  21252. function MDCTabScrollerFoundation(adapter) {
  21253. var _this = _super.call(this, __assign(__assign({}, MDCTabScrollerFoundation.defaultAdapter), adapter)) || this;
  21254. /**
  21255. * Controls whether we should handle the transitionend and interaction events during the animation.
  21256. */
  21257. _this.isAnimating_ = false;
  21258. return _this;
  21259. }
  21260. Object.defineProperty(MDCTabScrollerFoundation, "cssClasses", {
  21261. get: function get() {
  21262. return constants_1.cssClasses;
  21263. },
  21264. enumerable: true,
  21265. configurable: true
  21266. });
  21267. Object.defineProperty(MDCTabScrollerFoundation, "strings", {
  21268. get: function get() {
  21269. return constants_1.strings;
  21270. },
  21271. enumerable: true,
  21272. configurable: true
  21273. });
  21274. Object.defineProperty(MDCTabScrollerFoundation, "defaultAdapter", {
  21275. get: function get() {
  21276. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  21277. return {
  21278. eventTargetMatchesSelector: function eventTargetMatchesSelector() {
  21279. return false;
  21280. },
  21281. addClass: function addClass() {
  21282. return undefined;
  21283. },
  21284. removeClass: function removeClass() {
  21285. return undefined;
  21286. },
  21287. addScrollAreaClass: function addScrollAreaClass() {
  21288. return undefined;
  21289. },
  21290. setScrollAreaStyleProperty: function setScrollAreaStyleProperty() {
  21291. return undefined;
  21292. },
  21293. setScrollContentStyleProperty: function setScrollContentStyleProperty() {
  21294. return undefined;
  21295. },
  21296. getScrollContentStyleValue: function getScrollContentStyleValue() {
  21297. return '';
  21298. },
  21299. setScrollAreaScrollLeft: function setScrollAreaScrollLeft() {
  21300. return undefined;
  21301. },
  21302. getScrollAreaScrollLeft: function getScrollAreaScrollLeft() {
  21303. return 0;
  21304. },
  21305. getScrollContentOffsetWidth: function getScrollContentOffsetWidth() {
  21306. return 0;
  21307. },
  21308. getScrollAreaOffsetWidth: function getScrollAreaOffsetWidth() {
  21309. return 0;
  21310. },
  21311. computeScrollAreaClientRect: function computeScrollAreaClientRect() {
  21312. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  21313. },
  21314. computeScrollContentClientRect: function computeScrollContentClientRect() {
  21315. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  21316. },
  21317. computeHorizontalScrollbarHeight: function computeHorizontalScrollbarHeight() {
  21318. return 0;
  21319. }
  21320. };
  21321. // tslint:enable:object-literal-sort-keys
  21322. },
  21323. enumerable: true,
  21324. configurable: true
  21325. });
  21326. MDCTabScrollerFoundation.prototype.init = function () {
  21327. // Compute horizontal scrollbar height on scroller with overflow initially hidden, then update overflow to scroll
  21328. // and immediately adjust bottom margin to avoid the scrollbar initially appearing before JS runs.
  21329. var horizontalScrollbarHeight = this.adapter.computeHorizontalScrollbarHeight();
  21330. this.adapter.setScrollAreaStyleProperty('margin-bottom', -horizontalScrollbarHeight + 'px');
  21331. this.adapter.addScrollAreaClass(MDCTabScrollerFoundation.cssClasses.SCROLL_AREA_SCROLL);
  21332. };
  21333. /**
  21334. * Computes the current visual scroll position
  21335. */
  21336. MDCTabScrollerFoundation.prototype.getScrollPosition = function () {
  21337. if (this.isRTL_()) {
  21338. return this.computeCurrentScrollPositionRTL_();
  21339. }
  21340. var currentTranslateX = this.calculateCurrentTranslateX_();
  21341. var scrollLeft = this.adapter.getScrollAreaScrollLeft();
  21342. return scrollLeft - currentTranslateX;
  21343. };
  21344. /**
  21345. * Handles interaction events that occur during transition
  21346. */
  21347. MDCTabScrollerFoundation.prototype.handleInteraction = function () {
  21348. // Early exit if we aren't animating
  21349. if (!this.isAnimating_) {
  21350. return;
  21351. }
  21352. // Prevent other event listeners from handling this event
  21353. this.stopScrollAnimation_();
  21354. };
  21355. /**
  21356. * Handles the transitionend event
  21357. */
  21358. MDCTabScrollerFoundation.prototype.handleTransitionEnd = function (evt) {
  21359. // Early exit if we aren't animating or the event was triggered by a different element.
  21360. var evtTarget = evt.target;
  21361. if (!this.isAnimating_ || !this.adapter.eventTargetMatchesSelector(evtTarget, MDCTabScrollerFoundation.strings.CONTENT_SELECTOR)) {
  21362. return;
  21363. }
  21364. this.isAnimating_ = false;
  21365. this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
  21366. };
  21367. /**
  21368. * Increment the scroll value by the scrollXIncrement using animation.
  21369. * @param scrollXIncrement The value by which to increment the scroll position
  21370. */
  21371. MDCTabScrollerFoundation.prototype.incrementScroll = function (scrollXIncrement) {
  21372. // Early exit for non-operational increment values
  21373. if (scrollXIncrement === 0) {
  21374. return;
  21375. }
  21376. this.animate_(this.getIncrementScrollOperation_(scrollXIncrement));
  21377. };
  21378. /**
  21379. * Increment the scroll value by the scrollXIncrement without animation.
  21380. * @param scrollXIncrement The value by which to increment the scroll position
  21381. */
  21382. MDCTabScrollerFoundation.prototype.incrementScrollImmediate = function (scrollXIncrement) {
  21383. // Early exit for non-operational increment values
  21384. if (scrollXIncrement === 0) {
  21385. return;
  21386. }
  21387. var operation = this.getIncrementScrollOperation_(scrollXIncrement);
  21388. if (operation.scrollDelta === 0) {
  21389. return;
  21390. }
  21391. this.stopScrollAnimation_();
  21392. this.adapter.setScrollAreaScrollLeft(operation.finalScrollPosition);
  21393. };
  21394. /**
  21395. * Scrolls to the given scrollX value
  21396. */
  21397. MDCTabScrollerFoundation.prototype.scrollTo = function (scrollX) {
  21398. if (this.isRTL_()) {
  21399. return this.scrollToRTL_(scrollX);
  21400. }
  21401. this.scrollTo_(scrollX);
  21402. };
  21403. /**
  21404. * @return Browser-specific {@link MDCTabScrollerRTL} instance.
  21405. */
  21406. MDCTabScrollerFoundation.prototype.getRTLScroller = function () {
  21407. if (!this.rtlScrollerInstance_) {
  21408. this.rtlScrollerInstance_ = this.rtlScrollerFactory_();
  21409. }
  21410. return this.rtlScrollerInstance_;
  21411. };
  21412. /**
  21413. * @return translateX value from a CSS matrix transform function string.
  21414. */
  21415. MDCTabScrollerFoundation.prototype.calculateCurrentTranslateX_ = function () {
  21416. var transformValue = this.adapter.getScrollContentStyleValue('transform');
  21417. // Early exit if no transform is present
  21418. if (transformValue === 'none') {
  21419. return 0;
  21420. }
  21421. // The transform value comes back as a matrix transformation in the form
  21422. // of `matrix(a, b, c, d, tx, ty)`. We only care about tx (translateX) so
  21423. // we're going to grab all the parenthesized values, strip out tx, and
  21424. // parse it.
  21425. var match = /\((.+?)\)/.exec(transformValue);
  21426. if (!match) {
  21427. return 0;
  21428. }
  21429. var matrixParams = match[1];
  21430. // tslint:disable-next-line:ban-ts-ignore "Unused vars" should be a linter warning, not a compiler error.
  21431. // @ts-ignore These unused variables should retain their semantic names for clarity.
  21432. var _a = __read(matrixParams.split(','), 6),
  21433. a = _a[0],
  21434. b = _a[1],
  21435. c = _a[2],
  21436. d = _a[3],
  21437. tx = _a[4],
  21438. ty = _a[5];
  21439. return parseFloat(tx); // tslint:disable-line:ban
  21440. };
  21441. /**
  21442. * Calculates a safe scroll value that is > 0 and < the max scroll value
  21443. * @param scrollX The distance to scroll
  21444. */
  21445. MDCTabScrollerFoundation.prototype.clampScrollValue_ = function (scrollX) {
  21446. var edges = this.calculateScrollEdges_();
  21447. return Math.min(Math.max(edges.left, scrollX), edges.right);
  21448. };
  21449. MDCTabScrollerFoundation.prototype.computeCurrentScrollPositionRTL_ = function () {
  21450. var translateX = this.calculateCurrentTranslateX_();
  21451. return this.getRTLScroller().getScrollPositionRTL(translateX);
  21452. };
  21453. MDCTabScrollerFoundation.prototype.calculateScrollEdges_ = function () {
  21454. var contentWidth = this.adapter.getScrollContentOffsetWidth();
  21455. var rootWidth = this.adapter.getScrollAreaOffsetWidth();
  21456. return {
  21457. left: 0,
  21458. right: contentWidth - rootWidth
  21459. };
  21460. };
  21461. /**
  21462. * Internal scroll method
  21463. * @param scrollX The new scroll position
  21464. */
  21465. MDCTabScrollerFoundation.prototype.scrollTo_ = function (scrollX) {
  21466. var currentScrollX = this.getScrollPosition();
  21467. var safeScrollX = this.clampScrollValue_(scrollX);
  21468. var scrollDelta = safeScrollX - currentScrollX;
  21469. this.animate_({
  21470. finalScrollPosition: safeScrollX,
  21471. scrollDelta: scrollDelta
  21472. });
  21473. };
  21474. /**
  21475. * Internal RTL scroll method
  21476. * @param scrollX The new scroll position
  21477. */
  21478. MDCTabScrollerFoundation.prototype.scrollToRTL_ = function (scrollX) {
  21479. var animation = this.getRTLScroller().scrollToRTL(scrollX);
  21480. this.animate_(animation);
  21481. };
  21482. /**
  21483. * Internal method to compute the increment scroll operation values.
  21484. * @param scrollX The desired scroll position increment
  21485. * @return MDCTabScrollerAnimation with the sanitized values for performing the scroll operation.
  21486. */
  21487. MDCTabScrollerFoundation.prototype.getIncrementScrollOperation_ = function (scrollX) {
  21488. if (this.isRTL_()) {
  21489. return this.getRTLScroller().incrementScrollRTL(scrollX);
  21490. }
  21491. var currentScrollX = this.getScrollPosition();
  21492. var targetScrollX = scrollX + currentScrollX;
  21493. var safeScrollX = this.clampScrollValue_(targetScrollX);
  21494. var scrollDelta = safeScrollX - currentScrollX;
  21495. return {
  21496. finalScrollPosition: safeScrollX,
  21497. scrollDelta: scrollDelta
  21498. };
  21499. };
  21500. /**
  21501. * Animates the tab scrolling
  21502. * @param animation The animation to apply
  21503. */
  21504. MDCTabScrollerFoundation.prototype.animate_ = function (animation) {
  21505. var _this = this;
  21506. // Early exit if translateX is 0, which means there's no animation to perform
  21507. if (animation.scrollDelta === 0) {
  21508. return;
  21509. }
  21510. this.stopScrollAnimation_();
  21511. // This animation uses the FLIP approach.
  21512. // Read more here: https://aerotwist.com/blog/flip-your-animations/
  21513. this.adapter.setScrollAreaScrollLeft(animation.finalScrollPosition);
  21514. this.adapter.setScrollContentStyleProperty('transform', "translateX(" + animation.scrollDelta + "px)");
  21515. // Force repaint
  21516. this.adapter.computeScrollAreaClientRect();
  21517. requestAnimationFrame(function () {
  21518. _this.adapter.addClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
  21519. _this.adapter.setScrollContentStyleProperty('transform', 'none');
  21520. });
  21521. this.isAnimating_ = true;
  21522. };
  21523. /**
  21524. * Stops scroll animation
  21525. */
  21526. MDCTabScrollerFoundation.prototype.stopScrollAnimation_ = function () {
  21527. this.isAnimating_ = false;
  21528. var currentScrollPosition = this.getAnimatingScrollPosition_();
  21529. this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
  21530. this.adapter.setScrollContentStyleProperty('transform', 'translateX(0px)');
  21531. this.adapter.setScrollAreaScrollLeft(currentScrollPosition);
  21532. };
  21533. /**
  21534. * Gets the current scroll position during animation
  21535. */
  21536. MDCTabScrollerFoundation.prototype.getAnimatingScrollPosition_ = function () {
  21537. var currentTranslateX = this.calculateCurrentTranslateX_();
  21538. var scrollLeft = this.adapter.getScrollAreaScrollLeft();
  21539. if (this.isRTL_()) {
  21540. return this.getRTLScroller().getAnimatingScrollPosition(scrollLeft, currentTranslateX);
  21541. }
  21542. return scrollLeft - currentTranslateX;
  21543. };
  21544. /**
  21545. * Determines the RTL Scroller to use
  21546. */
  21547. MDCTabScrollerFoundation.prototype.rtlScrollerFactory_ = function () {
  21548. // Browsers have three different implementations of scrollLeft in RTL mode,
  21549. // dependent on the browser. The behavior is based off the max LTR
  21550. // scrollLeft value and 0.
  21551. //
  21552. // * Default scrolling in RTL *
  21553. // - Left-most value: 0
  21554. // - Right-most value: Max LTR scrollLeft value
  21555. //
  21556. // * Negative scrolling in RTL *
  21557. // - Left-most value: Negated max LTR scrollLeft value
  21558. // - Right-most value: 0
  21559. //
  21560. // * Reverse scrolling in RTL *
  21561. // - Left-most value: Max LTR scrollLeft value
  21562. // - Right-most value: 0
  21563. //
  21564. // We use those principles below to determine which RTL scrollLeft
  21565. // behavior is implemented in the current browser.
  21566. var initialScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21567. this.adapter.setScrollAreaScrollLeft(initialScrollLeft - 1);
  21568. var newScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21569. // If the newScrollLeft value is negative,then we know that the browser has
  21570. // implemented negative RTL scrolling, since all other implementations have
  21571. // only positive values.
  21572. if (newScrollLeft < 0) {
  21573. // Undo the scrollLeft test check
  21574. this.adapter.setScrollAreaScrollLeft(initialScrollLeft);
  21575. return new rtl_negative_scroller_1.MDCTabScrollerRTLNegative(this.adapter);
  21576. }
  21577. var rootClientRect = this.adapter.computeScrollAreaClientRect();
  21578. var contentClientRect = this.adapter.computeScrollContentClientRect();
  21579. var rightEdgeDelta = Math.round(contentClientRect.right - rootClientRect.right);
  21580. // Undo the scrollLeft test check
  21581. this.adapter.setScrollAreaScrollLeft(initialScrollLeft);
  21582. // By calculating the clientRect of the root element and the clientRect of
  21583. // the content element, we can determine how much the scroll value changed
  21584. // when we performed the scrollLeft subtraction above.
  21585. if (rightEdgeDelta === newScrollLeft) {
  21586. return new rtl_reverse_scroller_1.MDCTabScrollerRTLReverse(this.adapter);
  21587. }
  21588. return new rtl_default_scroller_1.MDCTabScrollerRTLDefault(this.adapter);
  21589. };
  21590. MDCTabScrollerFoundation.prototype.isRTL_ = function () {
  21591. return this.adapter.getScrollContentStyleValue('direction') === 'rtl';
  21592. };
  21593. return MDCTabScrollerFoundation;
  21594. }(foundation_1.MDCFoundation);
  21595. exports.MDCTabScrollerFoundation = MDCTabScrollerFoundation;
  21596. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  21597. exports.default = MDCTabScrollerFoundation;
  21598. /***/ }),
  21599. /***/ "./packages/mdc-tab-scroller/index.ts":
  21600. /*!********************************************!*\
  21601. !*** ./packages/mdc-tab-scroller/index.ts ***!
  21602. \********************************************/
  21603. /*! no static exports found */
  21604. /***/ (function(module, exports, __webpack_require__) {
  21605. "use strict";
  21606. /**
  21607. * @license
  21608. * Copyright 2019 Google Inc.
  21609. *
  21610. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21611. * of this software and associated documentation files (the "Software"), to deal
  21612. * in the Software without restriction, including without limitation the rights
  21613. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21614. * copies of the Software, and to permit persons to whom the Software is
  21615. * furnished to do so, subject to the following conditions:
  21616. *
  21617. * The above copyright notice and this permission notice shall be included in
  21618. * all copies or substantial portions of the Software.
  21619. *
  21620. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21621. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21622. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21623. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21624. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21625. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21626. * THE SOFTWARE.
  21627. */
  21628. function __export(m) {
  21629. for (var p in m) {
  21630. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  21631. }
  21632. }
  21633. var __importStar = this && this.__importStar || function (mod) {
  21634. if (mod && mod.__esModule) return mod;
  21635. var result = {};
  21636. if (mod != null) for (var k in mod) {
  21637. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  21638. }result["default"] = mod;
  21639. return result;
  21640. };
  21641. Object.defineProperty(exports, "__esModule", { value: true });
  21642. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-tab-scroller/util.ts"));
  21643. exports.util = util;
  21644. __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab-scroller/component.ts"));
  21645. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts"));
  21646. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-scroller/foundation.ts"));
  21647. /***/ }),
  21648. /***/ "./packages/mdc-tab-scroller/rtl-default-scroller.ts":
  21649. /*!***********************************************************!*\
  21650. !*** ./packages/mdc-tab-scroller/rtl-default-scroller.ts ***!
  21651. \***********************************************************/
  21652. /*! no static exports found */
  21653. /***/ (function(module, exports, __webpack_require__) {
  21654. "use strict";
  21655. /**
  21656. * @license
  21657. * Copyright 2018 Google Inc.
  21658. *
  21659. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21660. * of this software and associated documentation files (the "Software"), to deal
  21661. * in the Software without restriction, including without limitation the rights
  21662. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21663. * copies of the Software, and to permit persons to whom the Software is
  21664. * furnished to do so, subject to the following conditions:
  21665. *
  21666. * The above copyright notice and this permission notice shall be included in
  21667. * all copies or substantial portions of the Software.
  21668. *
  21669. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21670. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21671. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21672. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21673. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21674. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21675. * THE SOFTWARE.
  21676. */
  21677. var __extends = this && this.__extends || function () {
  21678. var _extendStatics = function extendStatics(d, b) {
  21679. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  21680. d.__proto__ = b;
  21681. } || function (d, b) {
  21682. for (var p in b) {
  21683. if (b.hasOwnProperty(p)) d[p] = b[p];
  21684. }
  21685. };
  21686. return _extendStatics(d, b);
  21687. };
  21688. return function (d, b) {
  21689. _extendStatics(d, b);
  21690. function __() {
  21691. this.constructor = d;
  21692. }
  21693. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21694. };
  21695. }();
  21696. Object.defineProperty(exports, "__esModule", { value: true });
  21697. var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
  21698. var MDCTabScrollerRTLDefault = /** @class */function (_super) {
  21699. __extends(MDCTabScrollerRTLDefault, _super);
  21700. function MDCTabScrollerRTLDefault() {
  21701. return _super !== null && _super.apply(this, arguments) || this;
  21702. }
  21703. MDCTabScrollerRTLDefault.prototype.getScrollPositionRTL = function () {
  21704. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21705. var right = this.calculateScrollEdges_().right;
  21706. // Scroll values on most browsers are ints instead of floats so we round
  21707. return Math.round(right - currentScrollLeft);
  21708. };
  21709. MDCTabScrollerRTLDefault.prototype.scrollToRTL = function (scrollX) {
  21710. var edges = this.calculateScrollEdges_();
  21711. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21712. var clampedScrollLeft = this.clampScrollValue_(edges.right - scrollX);
  21713. return {
  21714. finalScrollPosition: clampedScrollLeft,
  21715. scrollDelta: clampedScrollLeft - currentScrollLeft
  21716. };
  21717. };
  21718. MDCTabScrollerRTLDefault.prototype.incrementScrollRTL = function (scrollX) {
  21719. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21720. var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft - scrollX);
  21721. return {
  21722. finalScrollPosition: clampedScrollLeft,
  21723. scrollDelta: clampedScrollLeft - currentScrollLeft
  21724. };
  21725. };
  21726. MDCTabScrollerRTLDefault.prototype.getAnimatingScrollPosition = function (scrollX) {
  21727. return scrollX;
  21728. };
  21729. MDCTabScrollerRTLDefault.prototype.calculateScrollEdges_ = function () {
  21730. var contentWidth = this.adapter.getScrollContentOffsetWidth();
  21731. var rootWidth = this.adapter.getScrollAreaOffsetWidth();
  21732. return {
  21733. left: 0,
  21734. right: contentWidth - rootWidth
  21735. };
  21736. };
  21737. MDCTabScrollerRTLDefault.prototype.clampScrollValue_ = function (scrollX) {
  21738. var edges = this.calculateScrollEdges_();
  21739. return Math.min(Math.max(edges.left, scrollX), edges.right);
  21740. };
  21741. return MDCTabScrollerRTLDefault;
  21742. }(rtl_scroller_1.MDCTabScrollerRTL);
  21743. exports.MDCTabScrollerRTLDefault = MDCTabScrollerRTLDefault;
  21744. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  21745. exports.default = MDCTabScrollerRTLDefault;
  21746. /***/ }),
  21747. /***/ "./packages/mdc-tab-scroller/rtl-negative-scroller.ts":
  21748. /*!************************************************************!*\
  21749. !*** ./packages/mdc-tab-scroller/rtl-negative-scroller.ts ***!
  21750. \************************************************************/
  21751. /*! no static exports found */
  21752. /***/ (function(module, exports, __webpack_require__) {
  21753. "use strict";
  21754. /**
  21755. * @license
  21756. * Copyright 2018 Google Inc.
  21757. *
  21758. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21759. * of this software and associated documentation files (the "Software"), to deal
  21760. * in the Software without restriction, including without limitation the rights
  21761. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21762. * copies of the Software, and to permit persons to whom the Software is
  21763. * furnished to do so, subject to the following conditions:
  21764. *
  21765. * The above copyright notice and this permission notice shall be included in
  21766. * all copies or substantial portions of the Software.
  21767. *
  21768. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21769. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21770. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21771. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21772. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21773. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21774. * THE SOFTWARE.
  21775. */
  21776. var __extends = this && this.__extends || function () {
  21777. var _extendStatics = function extendStatics(d, b) {
  21778. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  21779. d.__proto__ = b;
  21780. } || function (d, b) {
  21781. for (var p in b) {
  21782. if (b.hasOwnProperty(p)) d[p] = b[p];
  21783. }
  21784. };
  21785. return _extendStatics(d, b);
  21786. };
  21787. return function (d, b) {
  21788. _extendStatics(d, b);
  21789. function __() {
  21790. this.constructor = d;
  21791. }
  21792. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21793. };
  21794. }();
  21795. Object.defineProperty(exports, "__esModule", { value: true });
  21796. var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
  21797. var MDCTabScrollerRTLNegative = /** @class */function (_super) {
  21798. __extends(MDCTabScrollerRTLNegative, _super);
  21799. function MDCTabScrollerRTLNegative() {
  21800. return _super !== null && _super.apply(this, arguments) || this;
  21801. }
  21802. MDCTabScrollerRTLNegative.prototype.getScrollPositionRTL = function (translateX) {
  21803. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21804. return Math.round(translateX - currentScrollLeft);
  21805. };
  21806. MDCTabScrollerRTLNegative.prototype.scrollToRTL = function (scrollX) {
  21807. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21808. var clampedScrollLeft = this.clampScrollValue_(-scrollX);
  21809. return {
  21810. finalScrollPosition: clampedScrollLeft,
  21811. scrollDelta: clampedScrollLeft - currentScrollLeft
  21812. };
  21813. };
  21814. MDCTabScrollerRTLNegative.prototype.incrementScrollRTL = function (scrollX) {
  21815. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21816. var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft - scrollX);
  21817. return {
  21818. finalScrollPosition: clampedScrollLeft,
  21819. scrollDelta: clampedScrollLeft - currentScrollLeft
  21820. };
  21821. };
  21822. MDCTabScrollerRTLNegative.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
  21823. return scrollX - translateX;
  21824. };
  21825. MDCTabScrollerRTLNegative.prototype.calculateScrollEdges_ = function () {
  21826. var contentWidth = this.adapter.getScrollContentOffsetWidth();
  21827. var rootWidth = this.adapter.getScrollAreaOffsetWidth();
  21828. return {
  21829. left: rootWidth - contentWidth,
  21830. right: 0
  21831. };
  21832. };
  21833. MDCTabScrollerRTLNegative.prototype.clampScrollValue_ = function (scrollX) {
  21834. var edges = this.calculateScrollEdges_();
  21835. return Math.max(Math.min(edges.right, scrollX), edges.left);
  21836. };
  21837. return MDCTabScrollerRTLNegative;
  21838. }(rtl_scroller_1.MDCTabScrollerRTL);
  21839. exports.MDCTabScrollerRTLNegative = MDCTabScrollerRTLNegative;
  21840. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  21841. exports.default = MDCTabScrollerRTLNegative;
  21842. /***/ }),
  21843. /***/ "./packages/mdc-tab-scroller/rtl-reverse-scroller.ts":
  21844. /*!***********************************************************!*\
  21845. !*** ./packages/mdc-tab-scroller/rtl-reverse-scroller.ts ***!
  21846. \***********************************************************/
  21847. /*! no static exports found */
  21848. /***/ (function(module, exports, __webpack_require__) {
  21849. "use strict";
  21850. /**
  21851. * @license
  21852. * Copyright 2018 Google Inc.
  21853. *
  21854. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21855. * of this software and associated documentation files (the "Software"), to deal
  21856. * in the Software without restriction, including without limitation the rights
  21857. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21858. * copies of the Software, and to permit persons to whom the Software is
  21859. * furnished to do so, subject to the following conditions:
  21860. *
  21861. * The above copyright notice and this permission notice shall be included in
  21862. * all copies or substantial portions of the Software.
  21863. *
  21864. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21865. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21866. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21867. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21868. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21869. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21870. * THE SOFTWARE.
  21871. */
  21872. var __extends = this && this.__extends || function () {
  21873. var _extendStatics = function extendStatics(d, b) {
  21874. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  21875. d.__proto__ = b;
  21876. } || function (d, b) {
  21877. for (var p in b) {
  21878. if (b.hasOwnProperty(p)) d[p] = b[p];
  21879. }
  21880. };
  21881. return _extendStatics(d, b);
  21882. };
  21883. return function (d, b) {
  21884. _extendStatics(d, b);
  21885. function __() {
  21886. this.constructor = d;
  21887. }
  21888. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21889. };
  21890. }();
  21891. Object.defineProperty(exports, "__esModule", { value: true });
  21892. var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
  21893. var MDCTabScrollerRTLReverse = /** @class */function (_super) {
  21894. __extends(MDCTabScrollerRTLReverse, _super);
  21895. function MDCTabScrollerRTLReverse() {
  21896. return _super !== null && _super.apply(this, arguments) || this;
  21897. }
  21898. MDCTabScrollerRTLReverse.prototype.getScrollPositionRTL = function (translateX) {
  21899. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21900. // Scroll values on most browsers are ints instead of floats so we round
  21901. return Math.round(currentScrollLeft - translateX);
  21902. };
  21903. MDCTabScrollerRTLReverse.prototype.scrollToRTL = function (scrollX) {
  21904. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21905. var clampedScrollLeft = this.clampScrollValue_(scrollX);
  21906. return {
  21907. finalScrollPosition: clampedScrollLeft,
  21908. scrollDelta: currentScrollLeft - clampedScrollLeft
  21909. };
  21910. };
  21911. MDCTabScrollerRTLReverse.prototype.incrementScrollRTL = function (scrollX) {
  21912. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21913. var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft + scrollX);
  21914. return {
  21915. finalScrollPosition: clampedScrollLeft,
  21916. scrollDelta: currentScrollLeft - clampedScrollLeft
  21917. };
  21918. };
  21919. MDCTabScrollerRTLReverse.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
  21920. return scrollX + translateX;
  21921. };
  21922. MDCTabScrollerRTLReverse.prototype.calculateScrollEdges_ = function () {
  21923. var contentWidth = this.adapter.getScrollContentOffsetWidth();
  21924. var rootWidth = this.adapter.getScrollAreaOffsetWidth();
  21925. return {
  21926. left: contentWidth - rootWidth,
  21927. right: 0
  21928. };
  21929. };
  21930. MDCTabScrollerRTLReverse.prototype.clampScrollValue_ = function (scrollX) {
  21931. var edges = this.calculateScrollEdges_();
  21932. return Math.min(Math.max(edges.right, scrollX), edges.left);
  21933. };
  21934. return MDCTabScrollerRTLReverse;
  21935. }(rtl_scroller_1.MDCTabScrollerRTL);
  21936. exports.MDCTabScrollerRTLReverse = MDCTabScrollerRTLReverse;
  21937. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  21938. exports.default = MDCTabScrollerRTLReverse;
  21939. /***/ }),
  21940. /***/ "./packages/mdc-tab-scroller/rtl-scroller.ts":
  21941. /*!***************************************************!*\
  21942. !*** ./packages/mdc-tab-scroller/rtl-scroller.ts ***!
  21943. \***************************************************/
  21944. /*! no static exports found */
  21945. /***/ (function(module, exports, __webpack_require__) {
  21946. "use strict";
  21947. /**
  21948. * @license
  21949. * Copyright 2018 Google Inc.
  21950. *
  21951. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21952. * of this software and associated documentation files (the "Software"), to deal
  21953. * in the Software without restriction, including without limitation the rights
  21954. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21955. * copies of the Software, and to permit persons to whom the Software is
  21956. * furnished to do so, subject to the following conditions:
  21957. *
  21958. * The above copyright notice and this permission notice shall be included in
  21959. * all copies or substantial portions of the Software.
  21960. *
  21961. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21962. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21963. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21964. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21965. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21966. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21967. * THE SOFTWARE.
  21968. */
  21969. Object.defineProperty(exports, "__esModule", { value: true });
  21970. var MDCTabScrollerRTL = /** @class */function () {
  21971. function MDCTabScrollerRTL(adapter) {
  21972. this.adapter = adapter;
  21973. }
  21974. return MDCTabScrollerRTL;
  21975. }();
  21976. exports.MDCTabScrollerRTL = MDCTabScrollerRTL;
  21977. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  21978. exports.default = MDCTabScrollerRTL;
  21979. /***/ }),
  21980. /***/ "./packages/mdc-tab-scroller/util.ts":
  21981. /*!*******************************************!*\
  21982. !*** ./packages/mdc-tab-scroller/util.ts ***!
  21983. \*******************************************/
  21984. /*! no static exports found */
  21985. /***/ (function(module, exports, __webpack_require__) {
  21986. "use strict";
  21987. /**
  21988. * @license
  21989. * Copyright 2018 Google Inc.
  21990. *
  21991. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21992. * of this software and associated documentation files (the "Software"), to deal
  21993. * in the Software without restriction, including without limitation the rights
  21994. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21995. * copies of the Software, and to permit persons to whom the Software is
  21996. * furnished to do so, subject to the following conditions:
  21997. *
  21998. * The above copyright notice and this permission notice shall be included in
  21999. * all copies or substantial portions of the Software.
  22000. *
  22001. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22002. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22003. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22004. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22005. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22006. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22007. * THE SOFTWARE.
  22008. */
  22009. Object.defineProperty(exports, "__esModule", { value: true });
  22010. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts");
  22011. /**
  22012. * Stores result from computeHorizontalScrollbarHeight to avoid redundant processing.
  22013. */
  22014. var horizontalScrollbarHeight_;
  22015. /**
  22016. * Computes the height of browser-rendered horizontal scrollbars using a self-created test element.
  22017. * May return 0 (e.g. on OS X browsers under default configuration).
  22018. */
  22019. function computeHorizontalScrollbarHeight(documentObj, shouldCacheResult) {
  22020. if (shouldCacheResult === void 0) {
  22021. shouldCacheResult = true;
  22022. }
  22023. if (shouldCacheResult && typeof horizontalScrollbarHeight_ !== 'undefined') {
  22024. return horizontalScrollbarHeight_;
  22025. }
  22026. var el = documentObj.createElement('div');
  22027. el.classList.add(constants_1.cssClasses.SCROLL_TEST);
  22028. documentObj.body.appendChild(el);
  22029. var horizontalScrollbarHeight = el.offsetHeight - el.clientHeight;
  22030. documentObj.body.removeChild(el);
  22031. if (shouldCacheResult) {
  22032. horizontalScrollbarHeight_ = horizontalScrollbarHeight;
  22033. }
  22034. return horizontalScrollbarHeight;
  22035. }
  22036. exports.computeHorizontalScrollbarHeight = computeHorizontalScrollbarHeight;
  22037. /***/ }),
  22038. /***/ "./packages/mdc-tab/component.ts":
  22039. /*!***************************************!*\
  22040. !*** ./packages/mdc-tab/component.ts ***!
  22041. \***************************************/
  22042. /*! no static exports found */
  22043. /***/ (function(module, exports, __webpack_require__) {
  22044. "use strict";
  22045. /**
  22046. * @license
  22047. * Copyright 2018 Google Inc.
  22048. *
  22049. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22050. * of this software and associated documentation files (the "Software"), to deal
  22051. * in the Software without restriction, including without limitation the rights
  22052. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22053. * copies of the Software, and to permit persons to whom the Software is
  22054. * furnished to do so, subject to the following conditions:
  22055. *
  22056. * The above copyright notice and this permission notice shall be included in
  22057. * all copies or substantial portions of the Software.
  22058. *
  22059. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22060. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22061. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22062. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22063. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22064. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22065. * THE SOFTWARE.
  22066. */
  22067. var __extends = this && this.__extends || function () {
  22068. var _extendStatics = function extendStatics(d, b) {
  22069. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  22070. d.__proto__ = b;
  22071. } || function (d, b) {
  22072. for (var p in b) {
  22073. if (b.hasOwnProperty(p)) d[p] = b[p];
  22074. }
  22075. };
  22076. return _extendStatics(d, b);
  22077. };
  22078. return function (d, b) {
  22079. _extendStatics(d, b);
  22080. function __() {
  22081. this.constructor = d;
  22082. }
  22083. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22084. };
  22085. }();
  22086. var __assign = this && this.__assign || function () {
  22087. __assign = Object.assign || function (t) {
  22088. for (var s, i = 1, n = arguments.length; i < n; i++) {
  22089. s = arguments[i];
  22090. for (var p in s) {
  22091. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  22092. }
  22093. }
  22094. return t;
  22095. };
  22096. return __assign.apply(this, arguments);
  22097. };
  22098. Object.defineProperty(exports, "__esModule", { value: true });
  22099. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  22100. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  22101. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  22102. var component_3 = __webpack_require__(/*! @material/tab-indicator/component */ "./packages/mdc-tab-indicator/component.ts");
  22103. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab/foundation.ts");
  22104. var MDCTab = /** @class */function (_super) {
  22105. __extends(MDCTab, _super);
  22106. function MDCTab() {
  22107. return _super !== null && _super.apply(this, arguments) || this;
  22108. }
  22109. MDCTab.attachTo = function (root) {
  22110. return new MDCTab(root);
  22111. };
  22112. MDCTab.prototype.initialize = function (rippleFactory, tabIndicatorFactory) {
  22113. if (rippleFactory === void 0) {
  22114. rippleFactory = function rippleFactory(el, foundation) {
  22115. return new component_2.MDCRipple(el, foundation);
  22116. };
  22117. }
  22118. if (tabIndicatorFactory === void 0) {
  22119. tabIndicatorFactory = function tabIndicatorFactory(el) {
  22120. return new component_3.MDCTabIndicator(el);
  22121. };
  22122. }
  22123. this.id = this.root.id;
  22124. var rippleSurface = this.root.querySelector(foundation_2.MDCTabFoundation.strings.RIPPLE_SELECTOR);
  22125. var rippleAdapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { addClass: function addClass(className) {
  22126. return rippleSurface.classList.add(className);
  22127. }, removeClass: function removeClass(className) {
  22128. return rippleSurface.classList.remove(className);
  22129. }, updateCssVariable: function updateCssVariable(varName, value) {
  22130. return rippleSurface.style.setProperty(varName, value);
  22131. } });
  22132. var rippleFoundation = new foundation_1.MDCRippleFoundation(rippleAdapter);
  22133. this.ripple_ = rippleFactory(this.root, rippleFoundation);
  22134. var tabIndicatorElement = this.root.querySelector(foundation_2.MDCTabFoundation.strings.TAB_INDICATOR_SELECTOR);
  22135. this.tabIndicator_ = tabIndicatorFactory(tabIndicatorElement);
  22136. this.content_ = this.root.querySelector(foundation_2.MDCTabFoundation.strings.CONTENT_SELECTOR);
  22137. };
  22138. MDCTab.prototype.initialSyncWithDOM = function () {
  22139. var _this = this;
  22140. this.handleClick_ = function () {
  22141. return _this.foundation.handleClick();
  22142. };
  22143. this.listen('click', this.handleClick_);
  22144. };
  22145. MDCTab.prototype.destroy = function () {
  22146. this.unlisten('click', this.handleClick_);
  22147. this.ripple_.destroy();
  22148. _super.prototype.destroy.call(this);
  22149. };
  22150. MDCTab.prototype.getDefaultFoundation = function () {
  22151. var _this = this;
  22152. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  22153. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  22154. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  22155. var adapter = {
  22156. setAttr: function setAttr(attr, value) {
  22157. return _this.root.setAttribute(attr, value);
  22158. },
  22159. addClass: function addClass(className) {
  22160. return _this.root.classList.add(className);
  22161. },
  22162. removeClass: function removeClass(className) {
  22163. return _this.root.classList.remove(className);
  22164. },
  22165. hasClass: function hasClass(className) {
  22166. return _this.root.classList.contains(className);
  22167. },
  22168. activateIndicator: function activateIndicator(previousIndicatorClientRect) {
  22169. return _this.tabIndicator_.activate(previousIndicatorClientRect);
  22170. },
  22171. deactivateIndicator: function deactivateIndicator() {
  22172. return _this.tabIndicator_.deactivate();
  22173. },
  22174. notifyInteracted: function notifyInteracted() {
  22175. return _this.emit(foundation_2.MDCTabFoundation.strings.INTERACTED_EVENT, { tabId: _this.id }, true /* bubble */);
  22176. },
  22177. getOffsetLeft: function getOffsetLeft() {
  22178. return _this.root.offsetLeft;
  22179. },
  22180. getOffsetWidth: function getOffsetWidth() {
  22181. return _this.root.offsetWidth;
  22182. },
  22183. getContentOffsetLeft: function getContentOffsetLeft() {
  22184. return _this.content_.offsetLeft;
  22185. },
  22186. getContentOffsetWidth: function getContentOffsetWidth() {
  22187. return _this.content_.offsetWidth;
  22188. },
  22189. focus: function focus() {
  22190. return _this.root.focus();
  22191. }
  22192. };
  22193. // tslint:enable:object-literal-sort-keys
  22194. return new foundation_2.MDCTabFoundation(adapter);
  22195. };
  22196. Object.defineProperty(MDCTab.prototype, "active", {
  22197. /**
  22198. * Getter for the active state of the tab
  22199. */
  22200. get: function get() {
  22201. return this.foundation.isActive();
  22202. },
  22203. enumerable: true,
  22204. configurable: true
  22205. });
  22206. Object.defineProperty(MDCTab.prototype, "focusOnActivate", {
  22207. set: function set(focusOnActivate) {
  22208. this.foundation.setFocusOnActivate(focusOnActivate);
  22209. },
  22210. enumerable: true,
  22211. configurable: true
  22212. });
  22213. /**
  22214. * Activates the tab
  22215. */
  22216. MDCTab.prototype.activate = function (computeIndicatorClientRect) {
  22217. this.foundation.activate(computeIndicatorClientRect);
  22218. };
  22219. /**
  22220. * Deactivates the tab
  22221. */
  22222. MDCTab.prototype.deactivate = function () {
  22223. this.foundation.deactivate();
  22224. };
  22225. /**
  22226. * Returns the indicator's client rect
  22227. */
  22228. MDCTab.prototype.computeIndicatorClientRect = function () {
  22229. return this.tabIndicator_.computeContentClientRect();
  22230. };
  22231. MDCTab.prototype.computeDimensions = function () {
  22232. return this.foundation.computeDimensions();
  22233. };
  22234. /**
  22235. * Focuses the tab
  22236. */
  22237. MDCTab.prototype.focus = function () {
  22238. this.root.focus();
  22239. };
  22240. return MDCTab;
  22241. }(component_1.MDCComponent);
  22242. exports.MDCTab = MDCTab;
  22243. /***/ }),
  22244. /***/ "./packages/mdc-tab/constants.ts":
  22245. /*!***************************************!*\
  22246. !*** ./packages/mdc-tab/constants.ts ***!
  22247. \***************************************/
  22248. /*! no static exports found */
  22249. /***/ (function(module, exports, __webpack_require__) {
  22250. "use strict";
  22251. /**
  22252. * @license
  22253. * Copyright 2018 Google Inc.
  22254. *
  22255. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22256. * of this software and associated documentation files (the "Software"), to deal
  22257. * in the Software without restriction, including without limitation the rights
  22258. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22259. * copies of the Software, and to permit persons to whom the Software is
  22260. * furnished to do so, subject to the following conditions:
  22261. *
  22262. * The above copyright notice and this permission notice shall be included in
  22263. * all copies or substantial portions of the Software.
  22264. *
  22265. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22266. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22267. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22268. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22269. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22270. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22271. * THE SOFTWARE.
  22272. */
  22273. Object.defineProperty(exports, "__esModule", { value: true });
  22274. var cssClasses = {
  22275. ACTIVE: 'mdc-tab--active'
  22276. };
  22277. exports.cssClasses = cssClasses;
  22278. var strings = {
  22279. ARIA_SELECTED: 'aria-selected',
  22280. CONTENT_SELECTOR: '.mdc-tab__content',
  22281. INTERACTED_EVENT: 'MDCTab:interacted',
  22282. RIPPLE_SELECTOR: '.mdc-tab__ripple',
  22283. TABINDEX: 'tabIndex',
  22284. TAB_INDICATOR_SELECTOR: '.mdc-tab-indicator'
  22285. };
  22286. exports.strings = strings;
  22287. /***/ }),
  22288. /***/ "./packages/mdc-tab/foundation.ts":
  22289. /*!****************************************!*\
  22290. !*** ./packages/mdc-tab/foundation.ts ***!
  22291. \****************************************/
  22292. /*! no static exports found */
  22293. /***/ (function(module, exports, __webpack_require__) {
  22294. "use strict";
  22295. /**
  22296. * @license
  22297. * Copyright 2018 Google Inc.
  22298. *
  22299. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22300. * of this software and associated documentation files (the "Software"), to deal
  22301. * in the Software without restriction, including without limitation the rights
  22302. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22303. * copies of the Software, and to permit persons to whom the Software is
  22304. * furnished to do so, subject to the following conditions:
  22305. *
  22306. * The above copyright notice and this permission notice shall be included in
  22307. * all copies or substantial portions of the Software.
  22308. *
  22309. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22310. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22311. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22312. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22313. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22314. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22315. * THE SOFTWARE.
  22316. */
  22317. var __extends = this && this.__extends || function () {
  22318. var _extendStatics = function extendStatics(d, b) {
  22319. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  22320. d.__proto__ = b;
  22321. } || function (d, b) {
  22322. for (var p in b) {
  22323. if (b.hasOwnProperty(p)) d[p] = b[p];
  22324. }
  22325. };
  22326. return _extendStatics(d, b);
  22327. };
  22328. return function (d, b) {
  22329. _extendStatics(d, b);
  22330. function __() {
  22331. this.constructor = d;
  22332. }
  22333. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22334. };
  22335. }();
  22336. var __assign = this && this.__assign || function () {
  22337. __assign = Object.assign || function (t) {
  22338. for (var s, i = 1, n = arguments.length; i < n; i++) {
  22339. s = arguments[i];
  22340. for (var p in s) {
  22341. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  22342. }
  22343. }
  22344. return t;
  22345. };
  22346. return __assign.apply(this, arguments);
  22347. };
  22348. Object.defineProperty(exports, "__esModule", { value: true });
  22349. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  22350. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab/constants.ts");
  22351. var MDCTabFoundation = /** @class */function (_super) {
  22352. __extends(MDCTabFoundation, _super);
  22353. function MDCTabFoundation(adapter) {
  22354. var _this = _super.call(this, __assign(__assign({}, MDCTabFoundation.defaultAdapter), adapter)) || this;
  22355. _this.focusOnActivate_ = true;
  22356. return _this;
  22357. }
  22358. Object.defineProperty(MDCTabFoundation, "cssClasses", {
  22359. get: function get() {
  22360. return constants_1.cssClasses;
  22361. },
  22362. enumerable: true,
  22363. configurable: true
  22364. });
  22365. Object.defineProperty(MDCTabFoundation, "strings", {
  22366. get: function get() {
  22367. return constants_1.strings;
  22368. },
  22369. enumerable: true,
  22370. configurable: true
  22371. });
  22372. Object.defineProperty(MDCTabFoundation, "defaultAdapter", {
  22373. get: function get() {
  22374. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  22375. return {
  22376. addClass: function addClass() {
  22377. return undefined;
  22378. },
  22379. removeClass: function removeClass() {
  22380. return undefined;
  22381. },
  22382. hasClass: function hasClass() {
  22383. return false;
  22384. },
  22385. setAttr: function setAttr() {
  22386. return undefined;
  22387. },
  22388. activateIndicator: function activateIndicator() {
  22389. return undefined;
  22390. },
  22391. deactivateIndicator: function deactivateIndicator() {
  22392. return undefined;
  22393. },
  22394. notifyInteracted: function notifyInteracted() {
  22395. return undefined;
  22396. },
  22397. getOffsetLeft: function getOffsetLeft() {
  22398. return 0;
  22399. },
  22400. getOffsetWidth: function getOffsetWidth() {
  22401. return 0;
  22402. },
  22403. getContentOffsetLeft: function getContentOffsetLeft() {
  22404. return 0;
  22405. },
  22406. getContentOffsetWidth: function getContentOffsetWidth() {
  22407. return 0;
  22408. },
  22409. focus: function focus() {
  22410. return undefined;
  22411. }
  22412. };
  22413. // tslint:enable:object-literal-sort-keys
  22414. },
  22415. enumerable: true,
  22416. configurable: true
  22417. });
  22418. MDCTabFoundation.prototype.handleClick = function () {
  22419. // It's up to the parent component to keep track of the active Tab and
  22420. // ensure we don't activate a Tab that's already active.
  22421. this.adapter.notifyInteracted();
  22422. };
  22423. MDCTabFoundation.prototype.isActive = function () {
  22424. return this.adapter.hasClass(constants_1.cssClasses.ACTIVE);
  22425. };
  22426. /**
  22427. * Sets whether the tab should focus itself when activated
  22428. */
  22429. MDCTabFoundation.prototype.setFocusOnActivate = function (focusOnActivate) {
  22430. this.focusOnActivate_ = focusOnActivate;
  22431. };
  22432. /**
  22433. * Activates the Tab
  22434. */
  22435. MDCTabFoundation.prototype.activate = function (previousIndicatorClientRect) {
  22436. this.adapter.addClass(constants_1.cssClasses.ACTIVE);
  22437. this.adapter.setAttr(constants_1.strings.ARIA_SELECTED, 'true');
  22438. this.adapter.setAttr(constants_1.strings.TABINDEX, '0');
  22439. this.adapter.activateIndicator(previousIndicatorClientRect);
  22440. if (this.focusOnActivate_) {
  22441. this.adapter.focus();
  22442. }
  22443. };
  22444. /**
  22445. * Deactivates the Tab
  22446. */
  22447. MDCTabFoundation.prototype.deactivate = function () {
  22448. // Early exit
  22449. if (!this.isActive()) {
  22450. return;
  22451. }
  22452. this.adapter.removeClass(constants_1.cssClasses.ACTIVE);
  22453. this.adapter.setAttr(constants_1.strings.ARIA_SELECTED, 'false');
  22454. this.adapter.setAttr(constants_1.strings.TABINDEX, '-1');
  22455. this.adapter.deactivateIndicator();
  22456. };
  22457. /**
  22458. * Returns the dimensions of the Tab
  22459. */
  22460. MDCTabFoundation.prototype.computeDimensions = function () {
  22461. var rootWidth = this.adapter.getOffsetWidth();
  22462. var rootLeft = this.adapter.getOffsetLeft();
  22463. var contentWidth = this.adapter.getContentOffsetWidth();
  22464. var contentLeft = this.adapter.getContentOffsetLeft();
  22465. return {
  22466. contentLeft: rootLeft + contentLeft,
  22467. contentRight: rootLeft + contentLeft + contentWidth,
  22468. rootLeft: rootLeft,
  22469. rootRight: rootLeft + rootWidth
  22470. };
  22471. };
  22472. return MDCTabFoundation;
  22473. }(foundation_1.MDCFoundation);
  22474. exports.MDCTabFoundation = MDCTabFoundation;
  22475. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  22476. exports.default = MDCTabFoundation;
  22477. /***/ }),
  22478. /***/ "./packages/mdc-tab/index.ts":
  22479. /*!***********************************!*\
  22480. !*** ./packages/mdc-tab/index.ts ***!
  22481. \***********************************/
  22482. /*! no static exports found */
  22483. /***/ (function(module, exports, __webpack_require__) {
  22484. "use strict";
  22485. /**
  22486. * @license
  22487. * Copyright 2019 Google Inc.
  22488. *
  22489. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22490. * of this software and associated documentation files (the "Software"), to deal
  22491. * in the Software without restriction, including without limitation the rights
  22492. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22493. * copies of the Software, and to permit persons to whom the Software is
  22494. * furnished to do so, subject to the following conditions:
  22495. *
  22496. * The above copyright notice and this permission notice shall be included in
  22497. * all copies or substantial portions of the Software.
  22498. *
  22499. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22500. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22501. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22502. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22503. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22504. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22505. * THE SOFTWARE.
  22506. */
  22507. function __export(m) {
  22508. for (var p in m) {
  22509. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  22510. }
  22511. }
  22512. Object.defineProperty(exports, "__esModule", { value: true });
  22513. __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab/component.ts"));
  22514. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab/constants.ts"));
  22515. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab/foundation.ts"));
  22516. /***/ }),
  22517. /***/ "./packages/mdc-textfield/character-counter/component.ts":
  22518. /*!***************************************************************!*\
  22519. !*** ./packages/mdc-textfield/character-counter/component.ts ***!
  22520. \***************************************************************/
  22521. /*! no static exports found */
  22522. /***/ (function(module, exports, __webpack_require__) {
  22523. "use strict";
  22524. /**
  22525. * @license
  22526. * Copyright 2019 Google Inc.
  22527. *
  22528. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22529. * of this software and associated documentation files (the "Software"), to deal
  22530. * in the Software without restriction, including without limitation the rights
  22531. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22532. * copies of the Software, and to permit persons to whom the Software is
  22533. * furnished to do so, subject to the following conditions:
  22534. *
  22535. * The above copyright notice and this permission notice shall be included in
  22536. * all copies or substantial portions of the Software.
  22537. *
  22538. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22539. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22540. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22541. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22542. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22543. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22544. * THE SOFTWARE.
  22545. */
  22546. var __extends = this && this.__extends || function () {
  22547. var _extendStatics = function extendStatics(d, b) {
  22548. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  22549. d.__proto__ = b;
  22550. } || function (d, b) {
  22551. for (var p in b) {
  22552. if (b.hasOwnProperty(p)) d[p] = b[p];
  22553. }
  22554. };
  22555. return _extendStatics(d, b);
  22556. };
  22557. return function (d, b) {
  22558. _extendStatics(d, b);
  22559. function __() {
  22560. this.constructor = d;
  22561. }
  22562. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22563. };
  22564. }();
  22565. Object.defineProperty(exports, "__esModule", { value: true });
  22566. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  22567. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/character-counter/foundation.ts");
  22568. var MDCTextFieldCharacterCounter = /** @class */function (_super) {
  22569. __extends(MDCTextFieldCharacterCounter, _super);
  22570. function MDCTextFieldCharacterCounter() {
  22571. return _super !== null && _super.apply(this, arguments) || this;
  22572. }
  22573. MDCTextFieldCharacterCounter.attachTo = function (root) {
  22574. return new MDCTextFieldCharacterCounter(root);
  22575. };
  22576. Object.defineProperty(MDCTextFieldCharacterCounter.prototype, "foundationForTextField", {
  22577. // Provided for access by MDCTextField component
  22578. get: function get() {
  22579. return this.foundation;
  22580. },
  22581. enumerable: true,
  22582. configurable: true
  22583. });
  22584. MDCTextFieldCharacterCounter.prototype.getDefaultFoundation = function () {
  22585. var _this = this;
  22586. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  22587. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  22588. var adapter = {
  22589. setContent: function setContent(content) {
  22590. _this.root.textContent = content;
  22591. }
  22592. };
  22593. return new foundation_1.MDCTextFieldCharacterCounterFoundation(adapter);
  22594. };
  22595. return MDCTextFieldCharacterCounter;
  22596. }(component_1.MDCComponent);
  22597. exports.MDCTextFieldCharacterCounter = MDCTextFieldCharacterCounter;
  22598. /***/ }),
  22599. /***/ "./packages/mdc-textfield/character-counter/constants.ts":
  22600. /*!***************************************************************!*\
  22601. !*** ./packages/mdc-textfield/character-counter/constants.ts ***!
  22602. \***************************************************************/
  22603. /*! no static exports found */
  22604. /***/ (function(module, exports, __webpack_require__) {
  22605. "use strict";
  22606. /**
  22607. * @license
  22608. * Copyright 2019 Google Inc.
  22609. *
  22610. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22611. * of this software and associated documentation files (the "Software"), to deal
  22612. * in the Software without restriction, including without limitation the rights
  22613. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22614. * copies of the Software, and to permit persons to whom the Software is
  22615. * furnished to do so, subject to the following conditions:
  22616. *
  22617. * The above copyright notice and this permission notice shall be included in
  22618. * all copies or substantial portions of the Software.
  22619. *
  22620. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22621. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22622. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22623. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22624. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22625. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22626. * THE SOFTWARE.
  22627. */
  22628. Object.defineProperty(exports, "__esModule", { value: true });
  22629. var cssClasses = {
  22630. ROOT: 'mdc-text-field-character-counter'
  22631. };
  22632. exports.cssClasses = cssClasses;
  22633. var strings = {
  22634. ROOT_SELECTOR: "." + cssClasses.ROOT
  22635. };
  22636. exports.strings = strings;
  22637. /***/ }),
  22638. /***/ "./packages/mdc-textfield/character-counter/foundation.ts":
  22639. /*!****************************************************************!*\
  22640. !*** ./packages/mdc-textfield/character-counter/foundation.ts ***!
  22641. \****************************************************************/
  22642. /*! no static exports found */
  22643. /***/ (function(module, exports, __webpack_require__) {
  22644. "use strict";
  22645. /**
  22646. * @license
  22647. * Copyright 2019 Google Inc.
  22648. *
  22649. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22650. * of this software and associated documentation files (the "Software"), to deal
  22651. * in the Software without restriction, including without limitation the rights
  22652. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22653. * copies of the Software, and to permit persons to whom the Software is
  22654. * furnished to do so, subject to the following conditions:
  22655. *
  22656. * The above copyright notice and this permission notice shall be included in
  22657. * all copies or substantial portions of the Software.
  22658. *
  22659. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22660. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22661. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22662. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22663. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22664. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22665. * THE SOFTWARE.
  22666. */
  22667. var __extends = this && this.__extends || function () {
  22668. var _extendStatics = function extendStatics(d, b) {
  22669. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  22670. d.__proto__ = b;
  22671. } || function (d, b) {
  22672. for (var p in b) {
  22673. if (b.hasOwnProperty(p)) d[p] = b[p];
  22674. }
  22675. };
  22676. return _extendStatics(d, b);
  22677. };
  22678. return function (d, b) {
  22679. _extendStatics(d, b);
  22680. function __() {
  22681. this.constructor = d;
  22682. }
  22683. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22684. };
  22685. }();
  22686. var __assign = this && this.__assign || function () {
  22687. __assign = Object.assign || function (t) {
  22688. for (var s, i = 1, n = arguments.length; i < n; i++) {
  22689. s = arguments[i];
  22690. for (var p in s) {
  22691. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  22692. }
  22693. }
  22694. return t;
  22695. };
  22696. return __assign.apply(this, arguments);
  22697. };
  22698. Object.defineProperty(exports, "__esModule", { value: true });
  22699. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  22700. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/character-counter/constants.ts");
  22701. var MDCTextFieldCharacterCounterFoundation = /** @class */function (_super) {
  22702. __extends(MDCTextFieldCharacterCounterFoundation, _super);
  22703. function MDCTextFieldCharacterCounterFoundation(adapter) {
  22704. return _super.call(this, __assign(__assign({}, MDCTextFieldCharacterCounterFoundation.defaultAdapter), adapter)) || this;
  22705. }
  22706. Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "cssClasses", {
  22707. get: function get() {
  22708. return constants_1.cssClasses;
  22709. },
  22710. enumerable: true,
  22711. configurable: true
  22712. });
  22713. Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "strings", {
  22714. get: function get() {
  22715. return constants_1.strings;
  22716. },
  22717. enumerable: true,
  22718. configurable: true
  22719. });
  22720. Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "defaultAdapter", {
  22721. /**
  22722. * See {@link MDCTextFieldCharacterCounterAdapter} for typing information on parameters and return types.
  22723. */
  22724. get: function get() {
  22725. return {
  22726. setContent: function setContent() {
  22727. return undefined;
  22728. }
  22729. };
  22730. },
  22731. enumerable: true,
  22732. configurable: true
  22733. });
  22734. MDCTextFieldCharacterCounterFoundation.prototype.setCounterValue = function (currentLength, maxLength) {
  22735. currentLength = Math.min(currentLength, maxLength);
  22736. this.adapter.setContent(currentLength + " / " + maxLength);
  22737. };
  22738. return MDCTextFieldCharacterCounterFoundation;
  22739. }(foundation_1.MDCFoundation);
  22740. exports.MDCTextFieldCharacterCounterFoundation = MDCTextFieldCharacterCounterFoundation;
  22741. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  22742. exports.default = MDCTextFieldCharacterCounterFoundation;
  22743. /***/ }),
  22744. /***/ "./packages/mdc-textfield/character-counter/index.ts":
  22745. /*!***********************************************************!*\
  22746. !*** ./packages/mdc-textfield/character-counter/index.ts ***!
  22747. \***********************************************************/
  22748. /*! no static exports found */
  22749. /***/ (function(module, exports, __webpack_require__) {
  22750. "use strict";
  22751. /**
  22752. * @license
  22753. * Copyright 2019 Google Inc.
  22754. *
  22755. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22756. * of this software and associated documentation files (the "Software"), to deal
  22757. * in the Software without restriction, including without limitation the rights
  22758. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22759. * copies of the Software, and to permit persons to whom the Software is
  22760. * furnished to do so, subject to the following conditions:
  22761. *
  22762. * The above copyright notice and this permission notice shall be included in
  22763. * all copies or substantial portions of the Software.
  22764. *
  22765. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22766. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22767. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22768. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22769. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22770. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22771. * THE SOFTWARE.
  22772. */
  22773. function __export(m) {
  22774. for (var p in m) {
  22775. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  22776. }
  22777. }
  22778. Object.defineProperty(exports, "__esModule", { value: true });
  22779. __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/character-counter/component.ts"));
  22780. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/character-counter/foundation.ts"));
  22781. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/character-counter/constants.ts");
  22782. exports.characterCountCssClasses = constants_1.cssClasses;
  22783. exports.characterCountStrings = constants_1.strings;
  22784. /***/ }),
  22785. /***/ "./packages/mdc-textfield/component.ts":
  22786. /*!*********************************************!*\
  22787. !*** ./packages/mdc-textfield/component.ts ***!
  22788. \*********************************************/
  22789. /*! no static exports found */
  22790. /***/ (function(module, exports, __webpack_require__) {
  22791. "use strict";
  22792. /**
  22793. * @license
  22794. * Copyright 2016 Google Inc.
  22795. *
  22796. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22797. * of this software and associated documentation files (the "Software"), to deal
  22798. * in the Software without restriction, including without limitation the rights
  22799. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22800. * copies of the Software, and to permit persons to whom the Software is
  22801. * furnished to do so, subject to the following conditions:
  22802. *
  22803. * The above copyright notice and this permission notice shall be included in
  22804. * all copies or substantial portions of the Software.
  22805. *
  22806. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22807. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22808. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22809. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22810. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22811. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22812. * THE SOFTWARE.
  22813. */
  22814. var __extends = this && this.__extends || function () {
  22815. var _extendStatics = function extendStatics(d, b) {
  22816. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  22817. d.__proto__ = b;
  22818. } || function (d, b) {
  22819. for (var p in b) {
  22820. if (b.hasOwnProperty(p)) d[p] = b[p];
  22821. }
  22822. };
  22823. return _extendStatics(d, b);
  22824. };
  22825. return function (d, b) {
  22826. _extendStatics(d, b);
  22827. function __() {
  22828. this.constructor = d;
  22829. }
  22830. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22831. };
  22832. }();
  22833. var __assign = this && this.__assign || function () {
  22834. __assign = Object.assign || function (t) {
  22835. for (var s, i = 1, n = arguments.length; i < n; i++) {
  22836. s = arguments[i];
  22837. for (var p in s) {
  22838. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  22839. }
  22840. }
  22841. return t;
  22842. };
  22843. return __assign.apply(this, arguments);
  22844. };
  22845. var __importStar = this && this.__importStar || function (mod) {
  22846. if (mod && mod.__esModule) return mod;
  22847. var result = {};
  22848. if (mod != null) for (var k in mod) {
  22849. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  22850. }result["default"] = mod;
  22851. return result;
  22852. };
  22853. Object.defineProperty(exports, "__esModule", { value: true });
  22854. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  22855. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  22856. var ponyfill = __importStar(__webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts"));
  22857. var component_2 = __webpack_require__(/*! @material/floating-label/component */ "./packages/mdc-floating-label/component.ts");
  22858. var component_3 = __webpack_require__(/*! @material/line-ripple/component */ "./packages/mdc-line-ripple/component.ts");
  22859. var component_4 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
  22860. var component_5 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  22861. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  22862. var component_6 = __webpack_require__(/*! ./character-counter/component */ "./packages/mdc-textfield/character-counter/component.ts");
  22863. var foundation_2 = __webpack_require__(/*! ./character-counter/foundation */ "./packages/mdc-textfield/character-counter/foundation.ts");
  22864. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts");
  22865. var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/foundation.ts");
  22866. var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-textfield/helper-text/component.ts");
  22867. var foundation_4 = __webpack_require__(/*! ./helper-text/foundation */ "./packages/mdc-textfield/helper-text/foundation.ts");
  22868. var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-textfield/icon/component.ts");
  22869. var MDCTextField = /** @class */function (_super) {
  22870. __extends(MDCTextField, _super);
  22871. function MDCTextField() {
  22872. return _super !== null && _super.apply(this, arguments) || this;
  22873. }
  22874. MDCTextField.attachTo = function (root) {
  22875. return new MDCTextField(root);
  22876. };
  22877. MDCTextField.prototype.initialize = function (rippleFactory, lineRippleFactory, helperTextFactory, characterCounterFactory, iconFactory, labelFactory, outlineFactory) {
  22878. if (rippleFactory === void 0) {
  22879. rippleFactory = function rippleFactory(el, foundation) {
  22880. return new component_5.MDCRipple(el, foundation);
  22881. };
  22882. }
  22883. if (lineRippleFactory === void 0) {
  22884. lineRippleFactory = function lineRippleFactory(el) {
  22885. return new component_3.MDCLineRipple(el);
  22886. };
  22887. }
  22888. if (helperTextFactory === void 0) {
  22889. helperTextFactory = function helperTextFactory(el) {
  22890. return new component_7.MDCTextFieldHelperText(el);
  22891. };
  22892. }
  22893. if (characterCounterFactory === void 0) {
  22894. characterCounterFactory = function characterCounterFactory(el) {
  22895. return new component_6.MDCTextFieldCharacterCounter(el);
  22896. };
  22897. }
  22898. if (iconFactory === void 0) {
  22899. iconFactory = function iconFactory(el) {
  22900. return new component_8.MDCTextFieldIcon(el);
  22901. };
  22902. }
  22903. if (labelFactory === void 0) {
  22904. labelFactory = function labelFactory(el) {
  22905. return new component_2.MDCFloatingLabel(el);
  22906. };
  22907. }
  22908. if (outlineFactory === void 0) {
  22909. outlineFactory = function outlineFactory(el) {
  22910. return new component_4.MDCNotchedOutline(el);
  22911. };
  22912. }
  22913. this.input_ = this.root.querySelector(constants_1.strings.INPUT_SELECTOR);
  22914. var labelElement = this.root.querySelector(constants_1.strings.LABEL_SELECTOR);
  22915. this.label_ = labelElement ? labelFactory(labelElement) : null;
  22916. var lineRippleElement = this.root.querySelector(constants_1.strings.LINE_RIPPLE_SELECTOR);
  22917. this.lineRipple_ = lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
  22918. var outlineElement = this.root.querySelector(constants_1.strings.OUTLINE_SELECTOR);
  22919. this.outline_ = outlineElement ? outlineFactory(outlineElement) : null;
  22920. // Helper text
  22921. var helperTextStrings = foundation_4.MDCTextFieldHelperTextFoundation.strings;
  22922. var nextElementSibling = this.root.nextElementSibling;
  22923. var hasHelperLine = nextElementSibling && nextElementSibling.classList.contains(constants_1.cssClasses.HELPER_LINE);
  22924. var helperTextEl = hasHelperLine && nextElementSibling && nextElementSibling.querySelector(helperTextStrings.ROOT_SELECTOR);
  22925. this.helperText_ = helperTextEl ? helperTextFactory(helperTextEl) : null;
  22926. // Character counter
  22927. var characterCounterStrings = foundation_2.MDCTextFieldCharacterCounterFoundation.strings;
  22928. var characterCounterEl = this.root.querySelector(characterCounterStrings.ROOT_SELECTOR);
  22929. // If character counter is not found in root element search in sibling element.
  22930. if (!characterCounterEl && hasHelperLine && nextElementSibling) {
  22931. characterCounterEl = nextElementSibling.querySelector(characterCounterStrings.ROOT_SELECTOR);
  22932. }
  22933. this.characterCounter_ = characterCounterEl ? characterCounterFactory(characterCounterEl) : null;
  22934. // Leading icon
  22935. var leadingIconEl = this.root.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
  22936. this.leadingIcon_ = leadingIconEl ? iconFactory(leadingIconEl) : null;
  22937. // Trailing icon
  22938. var trailingIconEl = this.root.querySelector(constants_1.strings.TRAILING_ICON_SELECTOR);
  22939. this.trailingIcon_ = trailingIconEl ? iconFactory(trailingIconEl) : null;
  22940. // Prefix and Suffix
  22941. this.prefix_ = this.root.querySelector(constants_1.strings.PREFIX_SELECTOR);
  22942. this.suffix_ = this.root.querySelector(constants_1.strings.SUFFIX_SELECTOR);
  22943. this.ripple = this.createRipple_(rippleFactory);
  22944. };
  22945. MDCTextField.prototype.destroy = function () {
  22946. if (this.ripple) {
  22947. this.ripple.destroy();
  22948. }
  22949. if (this.lineRipple_) {
  22950. this.lineRipple_.destroy();
  22951. }
  22952. if (this.helperText_) {
  22953. this.helperText_.destroy();
  22954. }
  22955. if (this.characterCounter_) {
  22956. this.characterCounter_.destroy();
  22957. }
  22958. if (this.leadingIcon_) {
  22959. this.leadingIcon_.destroy();
  22960. }
  22961. if (this.trailingIcon_) {
  22962. this.trailingIcon_.destroy();
  22963. }
  22964. if (this.label_) {
  22965. this.label_.destroy();
  22966. }
  22967. if (this.outline_) {
  22968. this.outline_.destroy();
  22969. }
  22970. _super.prototype.destroy.call(this);
  22971. };
  22972. /**
  22973. * Initializes the Text Field's internal state based on the environment's
  22974. * state.
  22975. */
  22976. MDCTextField.prototype.initialSyncWithDOM = function () {
  22977. this.disabled = this.input_.disabled;
  22978. };
  22979. Object.defineProperty(MDCTextField.prototype, "value", {
  22980. get: function get() {
  22981. return this.foundation.getValue();
  22982. },
  22983. /**
  22984. * @param value The value to set on the input.
  22985. */
  22986. set: function set(value) {
  22987. this.foundation.setValue(value);
  22988. },
  22989. enumerable: true,
  22990. configurable: true
  22991. });
  22992. Object.defineProperty(MDCTextField.prototype, "disabled", {
  22993. get: function get() {
  22994. return this.foundation.isDisabled();
  22995. },
  22996. /**
  22997. * @param disabled Sets the Text Field disabled or enabled.
  22998. */
  22999. set: function set(disabled) {
  23000. this.foundation.setDisabled(disabled);
  23001. },
  23002. enumerable: true,
  23003. configurable: true
  23004. });
  23005. Object.defineProperty(MDCTextField.prototype, "valid", {
  23006. get: function get() {
  23007. return this.foundation.isValid();
  23008. },
  23009. /**
  23010. * @param valid Sets the Text Field valid or invalid.
  23011. */
  23012. set: function set(valid) {
  23013. this.foundation.setValid(valid);
  23014. },
  23015. enumerable: true,
  23016. configurable: true
  23017. });
  23018. Object.defineProperty(MDCTextField.prototype, "required", {
  23019. get: function get() {
  23020. return this.input_.required;
  23021. },
  23022. /**
  23023. * @param required Sets the Text Field to required.
  23024. */
  23025. set: function set(required) {
  23026. this.input_.required = required;
  23027. },
  23028. enumerable: true,
  23029. configurable: true
  23030. });
  23031. Object.defineProperty(MDCTextField.prototype, "pattern", {
  23032. get: function get() {
  23033. return this.input_.pattern;
  23034. },
  23035. /**
  23036. * @param pattern Sets the input element's validation pattern.
  23037. */
  23038. set: function set(pattern) {
  23039. this.input_.pattern = pattern;
  23040. },
  23041. enumerable: true,
  23042. configurable: true
  23043. });
  23044. Object.defineProperty(MDCTextField.prototype, "minLength", {
  23045. get: function get() {
  23046. return this.input_.minLength;
  23047. },
  23048. /**
  23049. * @param minLength Sets the input element's minLength.
  23050. */
  23051. set: function set(minLength) {
  23052. this.input_.minLength = minLength;
  23053. },
  23054. enumerable: true,
  23055. configurable: true
  23056. });
  23057. Object.defineProperty(MDCTextField.prototype, "maxLength", {
  23058. get: function get() {
  23059. return this.input_.maxLength;
  23060. },
  23061. /**
  23062. * @param maxLength Sets the input element's maxLength.
  23063. */
  23064. set: function set(maxLength) {
  23065. // Chrome throws exception if maxLength is set to a value less than zero
  23066. if (maxLength < 0) {
  23067. this.input_.removeAttribute('maxLength');
  23068. } else {
  23069. this.input_.maxLength = maxLength;
  23070. }
  23071. },
  23072. enumerable: true,
  23073. configurable: true
  23074. });
  23075. Object.defineProperty(MDCTextField.prototype, "min", {
  23076. get: function get() {
  23077. return this.input_.min;
  23078. },
  23079. /**
  23080. * @param min Sets the input element's min.
  23081. */
  23082. set: function set(min) {
  23083. this.input_.min = min;
  23084. },
  23085. enumerable: true,
  23086. configurable: true
  23087. });
  23088. Object.defineProperty(MDCTextField.prototype, "max", {
  23089. get: function get() {
  23090. return this.input_.max;
  23091. },
  23092. /**
  23093. * @param max Sets the input element's max.
  23094. */
  23095. set: function set(max) {
  23096. this.input_.max = max;
  23097. },
  23098. enumerable: true,
  23099. configurable: true
  23100. });
  23101. Object.defineProperty(MDCTextField.prototype, "step", {
  23102. get: function get() {
  23103. return this.input_.step;
  23104. },
  23105. /**
  23106. * @param step Sets the input element's step.
  23107. */
  23108. set: function set(step) {
  23109. this.input_.step = step;
  23110. },
  23111. enumerable: true,
  23112. configurable: true
  23113. });
  23114. Object.defineProperty(MDCTextField.prototype, "helperTextContent", {
  23115. /**
  23116. * Sets the helper text element content.
  23117. */
  23118. set: function set(content) {
  23119. this.foundation.setHelperTextContent(content);
  23120. },
  23121. enumerable: true,
  23122. configurable: true
  23123. });
  23124. Object.defineProperty(MDCTextField.prototype, "leadingIconAriaLabel", {
  23125. /**
  23126. * Sets the aria label of the leading icon.
  23127. */
  23128. set: function set(label) {
  23129. this.foundation.setLeadingIconAriaLabel(label);
  23130. },
  23131. enumerable: true,
  23132. configurable: true
  23133. });
  23134. Object.defineProperty(MDCTextField.prototype, "leadingIconContent", {
  23135. /**
  23136. * Sets the text content of the leading icon.
  23137. */
  23138. set: function set(content) {
  23139. this.foundation.setLeadingIconContent(content);
  23140. },
  23141. enumerable: true,
  23142. configurable: true
  23143. });
  23144. Object.defineProperty(MDCTextField.prototype, "trailingIconAriaLabel", {
  23145. /**
  23146. * Sets the aria label of the trailing icon.
  23147. */
  23148. set: function set(label) {
  23149. this.foundation.setTrailingIconAriaLabel(label);
  23150. },
  23151. enumerable: true,
  23152. configurable: true
  23153. });
  23154. Object.defineProperty(MDCTextField.prototype, "trailingIconContent", {
  23155. /**
  23156. * Sets the text content of the trailing icon.
  23157. */
  23158. set: function set(content) {
  23159. this.foundation.setTrailingIconContent(content);
  23160. },
  23161. enumerable: true,
  23162. configurable: true
  23163. });
  23164. Object.defineProperty(MDCTextField.prototype, "useNativeValidation", {
  23165. /**
  23166. * Enables or disables the use of native validation. Use this for custom validation.
  23167. * @param useNativeValidation Set this to false to ignore native input validation.
  23168. */
  23169. set: function set(useNativeValidation) {
  23170. this.foundation.setUseNativeValidation(useNativeValidation);
  23171. },
  23172. enumerable: true,
  23173. configurable: true
  23174. });
  23175. Object.defineProperty(MDCTextField.prototype, "prefixText", {
  23176. /**
  23177. * Gets the text content of the prefix, or null if it does not exist.
  23178. */
  23179. get: function get() {
  23180. return this.prefix_ ? this.prefix_.textContent : null;
  23181. },
  23182. /**
  23183. * Sets the text content of the prefix, if it exists.
  23184. */
  23185. set: function set(prefixText) {
  23186. if (this.prefix_) {
  23187. this.prefix_.textContent = prefixText;
  23188. }
  23189. },
  23190. enumerable: true,
  23191. configurable: true
  23192. });
  23193. Object.defineProperty(MDCTextField.prototype, "suffixText", {
  23194. /**
  23195. * Gets the text content of the suffix, or null if it does not exist.
  23196. */
  23197. get: function get() {
  23198. return this.suffix_ ? this.suffix_.textContent : null;
  23199. },
  23200. /**
  23201. * Sets the text content of the suffix, if it exists.
  23202. */
  23203. set: function set(suffixText) {
  23204. if (this.suffix_) {
  23205. this.suffix_.textContent = suffixText;
  23206. }
  23207. },
  23208. enumerable: true,
  23209. configurable: true
  23210. });
  23211. /**
  23212. * Focuses the input element.
  23213. */
  23214. MDCTextField.prototype.focus = function () {
  23215. this.input_.focus();
  23216. };
  23217. /**
  23218. * Recomputes the outline SVG path for the outline element.
  23219. */
  23220. MDCTextField.prototype.layout = function () {
  23221. var openNotch = this.foundation.shouldFloat;
  23222. this.foundation.notchOutline(openNotch);
  23223. };
  23224. MDCTextField.prototype.getDefaultFoundation = function () {
  23225. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  23226. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  23227. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  23228. var adapter = __assign(__assign(__assign(__assign(__assign({}, this.getRootAdapterMethods_()), this.getInputAdapterMethods_()), this.getLabelAdapterMethods_()), this.getLineRippleAdapterMethods_()), this.getOutlineAdapterMethods_());
  23229. // tslint:enable:object-literal-sort-keys
  23230. return new foundation_3.MDCTextFieldFoundation(adapter, this.getFoundationMap_());
  23231. };
  23232. MDCTextField.prototype.getRootAdapterMethods_ = function () {
  23233. var _this = this;
  23234. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  23235. return {
  23236. addClass: function addClass(className) {
  23237. return _this.root.classList.add(className);
  23238. },
  23239. removeClass: function removeClass(className) {
  23240. return _this.root.classList.remove(className);
  23241. },
  23242. hasClass: function hasClass(className) {
  23243. return _this.root.classList.contains(className);
  23244. },
  23245. registerTextFieldInteractionHandler: function registerTextFieldInteractionHandler(evtType, handler) {
  23246. _this.listen(evtType, handler);
  23247. },
  23248. deregisterTextFieldInteractionHandler: function deregisterTextFieldInteractionHandler(evtType, handler) {
  23249. _this.unlisten(evtType, handler);
  23250. },
  23251. registerValidationAttributeChangeHandler: function registerValidationAttributeChangeHandler(handler) {
  23252. var getAttributesList = function getAttributesList(mutationsList) {
  23253. return mutationsList.map(function (mutation) {
  23254. return mutation.attributeName;
  23255. }).filter(function (attributeName) {
  23256. return attributeName;
  23257. });
  23258. };
  23259. var observer = new MutationObserver(function (mutationsList) {
  23260. return handler(getAttributesList(mutationsList));
  23261. });
  23262. var config = { attributes: true };
  23263. observer.observe(_this.input_, config);
  23264. return observer;
  23265. },
  23266. deregisterValidationAttributeChangeHandler: function deregisterValidationAttributeChangeHandler(observer) {
  23267. observer.disconnect();
  23268. }
  23269. };
  23270. // tslint:enable:object-literal-sort-keys
  23271. };
  23272. MDCTextField.prototype.getInputAdapterMethods_ = function () {
  23273. var _this = this;
  23274. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  23275. return {
  23276. getNativeInput: function getNativeInput() {
  23277. return _this.input_;
  23278. },
  23279. setInputAttr: function setInputAttr(attr, value) {
  23280. _this.input_.setAttribute(attr, value);
  23281. },
  23282. removeInputAttr: function removeInputAttr(attr) {
  23283. _this.input_.removeAttribute(attr);
  23284. },
  23285. isFocused: function isFocused() {
  23286. return document.activeElement === _this.input_;
  23287. },
  23288. registerInputInteractionHandler: function registerInputInteractionHandler(evtType, handler) {
  23289. _this.input_.addEventListener(evtType, handler, events_1.applyPassive());
  23290. },
  23291. deregisterInputInteractionHandler: function deregisterInputInteractionHandler(evtType, handler) {
  23292. _this.input_.removeEventListener(evtType, handler, events_1.applyPassive());
  23293. }
  23294. };
  23295. // tslint:enable:object-literal-sort-keys
  23296. };
  23297. MDCTextField.prototype.getLabelAdapterMethods_ = function () {
  23298. var _this = this;
  23299. return {
  23300. floatLabel: function floatLabel(shouldFloat) {
  23301. return _this.label_ && _this.label_.float(shouldFloat);
  23302. },
  23303. getLabelWidth: function getLabelWidth() {
  23304. return _this.label_ ? _this.label_.getWidth() : 0;
  23305. },
  23306. hasLabel: function hasLabel() {
  23307. return Boolean(_this.label_);
  23308. },
  23309. shakeLabel: function shakeLabel(shouldShake) {
  23310. return _this.label_ && _this.label_.shake(shouldShake);
  23311. },
  23312. setLabelRequired: function setLabelRequired(isRequired) {
  23313. return _this.label_ && _this.label_.setRequired(isRequired);
  23314. }
  23315. };
  23316. };
  23317. MDCTextField.prototype.getLineRippleAdapterMethods_ = function () {
  23318. var _this = this;
  23319. return {
  23320. activateLineRipple: function activateLineRipple() {
  23321. if (_this.lineRipple_) {
  23322. _this.lineRipple_.activate();
  23323. }
  23324. },
  23325. deactivateLineRipple: function deactivateLineRipple() {
  23326. if (_this.lineRipple_) {
  23327. _this.lineRipple_.deactivate();
  23328. }
  23329. },
  23330. setLineRippleTransformOrigin: function setLineRippleTransformOrigin(normalizedX) {
  23331. if (_this.lineRipple_) {
  23332. _this.lineRipple_.setRippleCenter(normalizedX);
  23333. }
  23334. }
  23335. };
  23336. };
  23337. MDCTextField.prototype.getOutlineAdapterMethods_ = function () {
  23338. var _this = this;
  23339. return {
  23340. closeOutline: function closeOutline() {
  23341. return _this.outline_ && _this.outline_.closeNotch();
  23342. },
  23343. hasOutline: function hasOutline() {
  23344. return Boolean(_this.outline_);
  23345. },
  23346. notchOutline: function notchOutline(labelWidth) {
  23347. return _this.outline_ && _this.outline_.notch(labelWidth);
  23348. }
  23349. };
  23350. };
  23351. /**
  23352. * @return A map of all subcomponents to subfoundations.
  23353. */
  23354. MDCTextField.prototype.getFoundationMap_ = function () {
  23355. return {
  23356. characterCounter: this.characterCounter_ ? this.characterCounter_.foundationForTextField : undefined,
  23357. helperText: this.helperText_ ? this.helperText_.foundationForTextField : undefined,
  23358. leadingIcon: this.leadingIcon_ ? this.leadingIcon_.foundationForTextField : undefined,
  23359. trailingIcon: this.trailingIcon_ ? this.trailingIcon_.foundationForTextField : undefined
  23360. };
  23361. };
  23362. MDCTextField.prototype.createRipple_ = function (rippleFactory) {
  23363. var _this = this;
  23364. var isTextArea = this.root.classList.contains(constants_1.cssClasses.TEXTAREA);
  23365. var isOutlined = this.root.classList.contains(constants_1.cssClasses.OUTLINED);
  23366. if (isTextArea || isOutlined) {
  23367. return null;
  23368. }
  23369. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  23370. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  23371. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  23372. var adapter = __assign(__assign({}, component_5.MDCRipple.createAdapter(this)), { isSurfaceActive: function isSurfaceActive() {
  23373. return ponyfill.matches(_this.input_, ':active');
  23374. }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  23375. return _this.input_.addEventListener(evtType, handler, events_1.applyPassive());
  23376. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  23377. return _this.input_.removeEventListener(evtType, handler, events_1.applyPassive());
  23378. } });
  23379. // tslint:enable:object-literal-sort-keys
  23380. return rippleFactory(this.root, new foundation_1.MDCRippleFoundation(adapter));
  23381. };
  23382. return MDCTextField;
  23383. }(component_1.MDCComponent);
  23384. exports.MDCTextField = MDCTextField;
  23385. /***/ }),
  23386. /***/ "./packages/mdc-textfield/constants.ts":
  23387. /*!*********************************************!*\
  23388. !*** ./packages/mdc-textfield/constants.ts ***!
  23389. \*********************************************/
  23390. /*! no static exports found */
  23391. /***/ (function(module, exports, __webpack_require__) {
  23392. "use strict";
  23393. /**
  23394. * @license
  23395. * Copyright 2016 Google Inc.
  23396. *
  23397. * Permission is hereby granted, free of charge, to any person obtaining a copy
  23398. * of this software and associated documentation files (the "Software"), to deal
  23399. * in the Software without restriction, including without limitation the rights
  23400. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  23401. * copies of the Software, and to permit persons to whom the Software is
  23402. * furnished to do so, subject to the following conditions:
  23403. *
  23404. * The above copyright notice and this permission notice shall be included in
  23405. * all copies or substantial portions of the Software.
  23406. *
  23407. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23408. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23409. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  23410. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23411. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23412. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23413. * THE SOFTWARE.
  23414. */
  23415. Object.defineProperty(exports, "__esModule", { value: true });
  23416. var strings = {
  23417. ARIA_CONTROLS: 'aria-controls',
  23418. ARIA_DESCRIBEDBY: 'aria-describedby',
  23419. INPUT_SELECTOR: '.mdc-text-field__input',
  23420. LABEL_SELECTOR: '.mdc-floating-label',
  23421. LEADING_ICON_SELECTOR: '.mdc-text-field__icon--leading',
  23422. LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
  23423. OUTLINE_SELECTOR: '.mdc-notched-outline',
  23424. PREFIX_SELECTOR: '.mdc-text-field__affix--prefix',
  23425. SUFFIX_SELECTOR: '.mdc-text-field__affix--suffix',
  23426. TRAILING_ICON_SELECTOR: '.mdc-text-field__icon--trailing'
  23427. };
  23428. exports.strings = strings;
  23429. var cssClasses = {
  23430. DISABLED: 'mdc-text-field--disabled',
  23431. FOCUSED: 'mdc-text-field--focused',
  23432. HELPER_LINE: 'mdc-text-field-helper-line',
  23433. INVALID: 'mdc-text-field--invalid',
  23434. LABEL_FLOATING: 'mdc-text-field--label-floating',
  23435. NO_LABEL: 'mdc-text-field--no-label',
  23436. OUTLINED: 'mdc-text-field--outlined',
  23437. ROOT: 'mdc-text-field',
  23438. TEXTAREA: 'mdc-text-field--textarea',
  23439. WITH_LEADING_ICON: 'mdc-text-field--with-leading-icon',
  23440. WITH_TRAILING_ICON: 'mdc-text-field--with-trailing-icon'
  23441. };
  23442. exports.cssClasses = cssClasses;
  23443. var numbers = {
  23444. LABEL_SCALE: 0.75
  23445. };
  23446. exports.numbers = numbers;
  23447. /**
  23448. * Whitelist based off of https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation
  23449. * under the "Validation-related attributes" section.
  23450. */
  23451. var VALIDATION_ATTR_WHITELIST = ['pattern', 'min', 'max', 'required', 'step', 'minlength', 'maxlength'];
  23452. exports.VALIDATION_ATTR_WHITELIST = VALIDATION_ATTR_WHITELIST;
  23453. /**
  23454. * Label should always float for these types as they show some UI even if value is empty.
  23455. */
  23456. var ALWAYS_FLOAT_TYPES = ['color', 'date', 'datetime-local', 'month', 'range', 'time', 'week'];
  23457. exports.ALWAYS_FLOAT_TYPES = ALWAYS_FLOAT_TYPES;
  23458. /***/ }),
  23459. /***/ "./packages/mdc-textfield/foundation.ts":
  23460. /*!**********************************************!*\
  23461. !*** ./packages/mdc-textfield/foundation.ts ***!
  23462. \**********************************************/
  23463. /*! no static exports found */
  23464. /***/ (function(module, exports, __webpack_require__) {
  23465. "use strict";
  23466. /**
  23467. * @license
  23468. * Copyright 2016 Google Inc.
  23469. *
  23470. * Permission is hereby granted, free of charge, to any person obtaining a copy
  23471. * of this software and associated documentation files (the "Software"), to deal
  23472. * in the Software without restriction, including without limitation the rights
  23473. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  23474. * copies of the Software, and to permit persons to whom the Software is
  23475. * furnished to do so, subject to the following conditions:
  23476. *
  23477. * The above copyright notice and this permission notice shall be included in
  23478. * all copies or substantial portions of the Software.
  23479. *
  23480. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23481. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23482. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  23483. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23484. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23485. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23486. * THE SOFTWARE.
  23487. */
  23488. var __extends = this && this.__extends || function () {
  23489. var _extendStatics = function extendStatics(d, b) {
  23490. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  23491. d.__proto__ = b;
  23492. } || function (d, b) {
  23493. for (var p in b) {
  23494. if (b.hasOwnProperty(p)) d[p] = b[p];
  23495. }
  23496. };
  23497. return _extendStatics(d, b);
  23498. };
  23499. return function (d, b) {
  23500. _extendStatics(d, b);
  23501. function __() {
  23502. this.constructor = d;
  23503. }
  23504. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23505. };
  23506. }();
  23507. var __assign = this && this.__assign || function () {
  23508. __assign = Object.assign || function (t) {
  23509. for (var s, i = 1, n = arguments.length; i < n; i++) {
  23510. s = arguments[i];
  23511. for (var p in s) {
  23512. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  23513. }
  23514. }
  23515. return t;
  23516. };
  23517. return __assign.apply(this, arguments);
  23518. };
  23519. Object.defineProperty(exports, "__esModule", { value: true });
  23520. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  23521. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts");
  23522. var POINTERDOWN_EVENTS = ['mousedown', 'touchstart'];
  23523. var INTERACTION_EVENTS = ['click', 'keydown'];
  23524. var MDCTextFieldFoundation = /** @class */function (_super) {
  23525. __extends(MDCTextFieldFoundation, _super);
  23526. /**
  23527. * @param adapter
  23528. * @param foundationMap Map from subcomponent names to their subfoundations.
  23529. */
  23530. function MDCTextFieldFoundation(adapter, foundationMap) {
  23531. if (foundationMap === void 0) {
  23532. foundationMap = {};
  23533. }
  23534. var _this = _super.call(this, __assign(__assign({}, MDCTextFieldFoundation.defaultAdapter), adapter)) || this;
  23535. _this.isFocused_ = false;
  23536. _this.receivedUserInput_ = false;
  23537. _this.isValid_ = true;
  23538. _this.useNativeValidation_ = true;
  23539. _this.validateOnValueChange_ = true;
  23540. _this.helperText_ = foundationMap.helperText;
  23541. _this.characterCounter_ = foundationMap.characterCounter;
  23542. _this.leadingIcon_ = foundationMap.leadingIcon;
  23543. _this.trailingIcon_ = foundationMap.trailingIcon;
  23544. _this.inputFocusHandler_ = function () {
  23545. return _this.activateFocus();
  23546. };
  23547. _this.inputBlurHandler_ = function () {
  23548. return _this.deactivateFocus();
  23549. };
  23550. _this.inputInputHandler_ = function () {
  23551. return _this.handleInput();
  23552. };
  23553. _this.setPointerXOffset_ = function (evt) {
  23554. return _this.setTransformOrigin(evt);
  23555. };
  23556. _this.textFieldInteractionHandler_ = function () {
  23557. return _this.handleTextFieldInteraction();
  23558. };
  23559. _this.validationAttributeChangeHandler_ = function (attributesList) {
  23560. return _this.handleValidationAttributeChange(attributesList);
  23561. };
  23562. return _this;
  23563. }
  23564. Object.defineProperty(MDCTextFieldFoundation, "cssClasses", {
  23565. get: function get() {
  23566. return constants_1.cssClasses;
  23567. },
  23568. enumerable: true,
  23569. configurable: true
  23570. });
  23571. Object.defineProperty(MDCTextFieldFoundation, "strings", {
  23572. get: function get() {
  23573. return constants_1.strings;
  23574. },
  23575. enumerable: true,
  23576. configurable: true
  23577. });
  23578. Object.defineProperty(MDCTextFieldFoundation, "numbers", {
  23579. get: function get() {
  23580. return constants_1.numbers;
  23581. },
  23582. enumerable: true,
  23583. configurable: true
  23584. });
  23585. Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldAlwaysFloat_", {
  23586. get: function get() {
  23587. var type = this.getNativeInput_().type;
  23588. return constants_1.ALWAYS_FLOAT_TYPES.indexOf(type) >= 0;
  23589. },
  23590. enumerable: true,
  23591. configurable: true
  23592. });
  23593. Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldFloat", {
  23594. get: function get() {
  23595. return this.shouldAlwaysFloat_ || this.isFocused_ || !!this.getValue() || this.isBadInput_();
  23596. },
  23597. enumerable: true,
  23598. configurable: true
  23599. });
  23600. Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldShake", {
  23601. get: function get() {
  23602. return !this.isFocused_ && !this.isValid() && !!this.getValue();
  23603. },
  23604. enumerable: true,
  23605. configurable: true
  23606. });
  23607. Object.defineProperty(MDCTextFieldFoundation, "defaultAdapter", {
  23608. /**
  23609. * See {@link MDCTextFieldAdapter} for typing information on parameters and
  23610. * return types.
  23611. */
  23612. get: function get() {
  23613. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  23614. return {
  23615. addClass: function addClass() {
  23616. return undefined;
  23617. },
  23618. removeClass: function removeClass() {
  23619. return undefined;
  23620. },
  23621. hasClass: function hasClass() {
  23622. return true;
  23623. },
  23624. setInputAttr: function setInputAttr() {
  23625. return undefined;
  23626. },
  23627. removeInputAttr: function removeInputAttr() {
  23628. return undefined;
  23629. },
  23630. registerTextFieldInteractionHandler: function registerTextFieldInteractionHandler() {
  23631. return undefined;
  23632. },
  23633. deregisterTextFieldInteractionHandler: function deregisterTextFieldInteractionHandler() {
  23634. return undefined;
  23635. },
  23636. registerInputInteractionHandler: function registerInputInteractionHandler() {
  23637. return undefined;
  23638. },
  23639. deregisterInputInteractionHandler: function deregisterInputInteractionHandler() {
  23640. return undefined;
  23641. },
  23642. registerValidationAttributeChangeHandler: function registerValidationAttributeChangeHandler() {
  23643. return new MutationObserver(function () {
  23644. return undefined;
  23645. });
  23646. },
  23647. deregisterValidationAttributeChangeHandler: function deregisterValidationAttributeChangeHandler() {
  23648. return undefined;
  23649. },
  23650. getNativeInput: function getNativeInput() {
  23651. return null;
  23652. },
  23653. isFocused: function isFocused() {
  23654. return false;
  23655. },
  23656. activateLineRipple: function activateLineRipple() {
  23657. return undefined;
  23658. },
  23659. deactivateLineRipple: function deactivateLineRipple() {
  23660. return undefined;
  23661. },
  23662. setLineRippleTransformOrigin: function setLineRippleTransformOrigin() {
  23663. return undefined;
  23664. },
  23665. shakeLabel: function shakeLabel() {
  23666. return undefined;
  23667. },
  23668. floatLabel: function floatLabel() {
  23669. return undefined;
  23670. },
  23671. setLabelRequired: function setLabelRequired() {
  23672. return undefined;
  23673. },
  23674. hasLabel: function hasLabel() {
  23675. return false;
  23676. },
  23677. getLabelWidth: function getLabelWidth() {
  23678. return 0;
  23679. },
  23680. hasOutline: function hasOutline() {
  23681. return false;
  23682. },
  23683. notchOutline: function notchOutline() {
  23684. return undefined;
  23685. },
  23686. closeOutline: function closeOutline() {
  23687. return undefined;
  23688. }
  23689. };
  23690. // tslint:enable:object-literal-sort-keys
  23691. },
  23692. enumerable: true,
  23693. configurable: true
  23694. });
  23695. MDCTextFieldFoundation.prototype.init = function () {
  23696. var _this = this;
  23697. if (this.adapter.hasLabel() && this.getNativeInput_().required) {
  23698. this.adapter.setLabelRequired(true);
  23699. }
  23700. if (this.adapter.isFocused()) {
  23701. this.inputFocusHandler_();
  23702. } else if (this.adapter.hasLabel() && this.shouldFloat) {
  23703. this.notchOutline(true);
  23704. this.adapter.floatLabel(true);
  23705. this.styleFloating_(true);
  23706. }
  23707. this.adapter.registerInputInteractionHandler('focus', this.inputFocusHandler_);
  23708. this.adapter.registerInputInteractionHandler('blur', this.inputBlurHandler_);
  23709. this.adapter.registerInputInteractionHandler('input', this.inputInputHandler_);
  23710. POINTERDOWN_EVENTS.forEach(function (evtType) {
  23711. _this.adapter.registerInputInteractionHandler(evtType, _this.setPointerXOffset_);
  23712. });
  23713. INTERACTION_EVENTS.forEach(function (evtType) {
  23714. _this.adapter.registerTextFieldInteractionHandler(evtType, _this.textFieldInteractionHandler_);
  23715. });
  23716. this.validationObserver_ = this.adapter.registerValidationAttributeChangeHandler(this.validationAttributeChangeHandler_);
  23717. this.setCharacterCounter_(this.getValue().length);
  23718. };
  23719. MDCTextFieldFoundation.prototype.destroy = function () {
  23720. var _this = this;
  23721. this.adapter.deregisterInputInteractionHandler('focus', this.inputFocusHandler_);
  23722. this.adapter.deregisterInputInteractionHandler('blur', this.inputBlurHandler_);
  23723. this.adapter.deregisterInputInteractionHandler('input', this.inputInputHandler_);
  23724. POINTERDOWN_EVENTS.forEach(function (evtType) {
  23725. _this.adapter.deregisterInputInteractionHandler(evtType, _this.setPointerXOffset_);
  23726. });
  23727. INTERACTION_EVENTS.forEach(function (evtType) {
  23728. _this.adapter.deregisterTextFieldInteractionHandler(evtType, _this.textFieldInteractionHandler_);
  23729. });
  23730. this.adapter.deregisterValidationAttributeChangeHandler(this.validationObserver_);
  23731. };
  23732. /**
  23733. * Handles user interactions with the Text Field.
  23734. */
  23735. MDCTextFieldFoundation.prototype.handleTextFieldInteraction = function () {
  23736. var nativeInput = this.adapter.getNativeInput();
  23737. if (nativeInput && nativeInput.disabled) {
  23738. return;
  23739. }
  23740. this.receivedUserInput_ = true;
  23741. };
  23742. /**
  23743. * Handles validation attribute changes
  23744. */
  23745. MDCTextFieldFoundation.prototype.handleValidationAttributeChange = function (attributesList) {
  23746. var _this = this;
  23747. attributesList.some(function (attributeName) {
  23748. if (constants_1.VALIDATION_ATTR_WHITELIST.indexOf(attributeName) > -1) {
  23749. _this.styleValidity_(true);
  23750. _this.adapter.setLabelRequired(_this.getNativeInput_().required);
  23751. return true;
  23752. }
  23753. return false;
  23754. });
  23755. if (attributesList.indexOf('maxlength') > -1) {
  23756. this.setCharacterCounter_(this.getValue().length);
  23757. }
  23758. };
  23759. /**
  23760. * Opens/closes the notched outline.
  23761. */
  23762. MDCTextFieldFoundation.prototype.notchOutline = function (openNotch) {
  23763. if (!this.adapter.hasOutline() || !this.adapter.hasLabel()) {
  23764. return;
  23765. }
  23766. if (openNotch) {
  23767. var labelWidth = this.adapter.getLabelWidth() * constants_1.numbers.LABEL_SCALE;
  23768. this.adapter.notchOutline(labelWidth);
  23769. } else {
  23770. this.adapter.closeOutline();
  23771. }
  23772. };
  23773. /**
  23774. * Activates the text field focus state.
  23775. */
  23776. MDCTextFieldFoundation.prototype.activateFocus = function () {
  23777. this.isFocused_ = true;
  23778. this.styleFocused_(this.isFocused_);
  23779. this.adapter.activateLineRipple();
  23780. if (this.adapter.hasLabel()) {
  23781. this.notchOutline(this.shouldFloat);
  23782. this.adapter.floatLabel(this.shouldFloat);
  23783. this.styleFloating_(this.shouldFloat);
  23784. this.adapter.shakeLabel(this.shouldShake);
  23785. }
  23786. if (this.helperText_ && (this.helperText_.isPersistent() || !this.helperText_.isValidation() || !this.isValid_)) {
  23787. this.helperText_.showToScreenReader();
  23788. }
  23789. };
  23790. /**
  23791. * Sets the line ripple's transform origin, so that the line ripple activate
  23792. * animation will animate out from the user's click location.
  23793. */
  23794. MDCTextFieldFoundation.prototype.setTransformOrigin = function (evt) {
  23795. if (this.isDisabled() || this.adapter.hasOutline()) {
  23796. return;
  23797. }
  23798. var touches = evt.touches;
  23799. var targetEvent = touches ? touches[0] : evt;
  23800. var targetClientRect = targetEvent.target.getBoundingClientRect();
  23801. var normalizedX = targetEvent.clientX - targetClientRect.left;
  23802. this.adapter.setLineRippleTransformOrigin(normalizedX);
  23803. };
  23804. /**
  23805. * Handles input change of text input and text area.
  23806. */
  23807. MDCTextFieldFoundation.prototype.handleInput = function () {
  23808. this.autoCompleteFocus();
  23809. this.setCharacterCounter_(this.getValue().length);
  23810. };
  23811. /**
  23812. * Activates the Text Field's focus state in cases when the input value
  23813. * changes without user input (e.g. programmatically).
  23814. */
  23815. MDCTextFieldFoundation.prototype.autoCompleteFocus = function () {
  23816. if (!this.receivedUserInput_) {
  23817. this.activateFocus();
  23818. }
  23819. };
  23820. /**
  23821. * Deactivates the Text Field's focus state.
  23822. */
  23823. MDCTextFieldFoundation.prototype.deactivateFocus = function () {
  23824. this.isFocused_ = false;
  23825. this.adapter.deactivateLineRipple();
  23826. var isValid = this.isValid();
  23827. this.styleValidity_(isValid);
  23828. this.styleFocused_(this.isFocused_);
  23829. if (this.adapter.hasLabel()) {
  23830. this.notchOutline(this.shouldFloat);
  23831. this.adapter.floatLabel(this.shouldFloat);
  23832. this.styleFloating_(this.shouldFloat);
  23833. this.adapter.shakeLabel(this.shouldShake);
  23834. }
  23835. if (!this.shouldFloat) {
  23836. this.receivedUserInput_ = false;
  23837. }
  23838. };
  23839. MDCTextFieldFoundation.prototype.getValue = function () {
  23840. return this.getNativeInput_().value;
  23841. };
  23842. /**
  23843. * @param value The value to set on the input Element.
  23844. */
  23845. MDCTextFieldFoundation.prototype.setValue = function (value) {
  23846. // Prevent Safari from moving the caret to the end of the input when the
  23847. // value has not changed.
  23848. if (this.getValue() !== value) {
  23849. this.getNativeInput_().value = value;
  23850. }
  23851. this.setCharacterCounter_(value.length);
  23852. if (this.validateOnValueChange_) {
  23853. var isValid = this.isValid();
  23854. this.styleValidity_(isValid);
  23855. }
  23856. if (this.adapter.hasLabel()) {
  23857. this.notchOutline(this.shouldFloat);
  23858. this.adapter.floatLabel(this.shouldFloat);
  23859. this.styleFloating_(this.shouldFloat);
  23860. if (this.validateOnValueChange_) {
  23861. this.adapter.shakeLabel(this.shouldShake);
  23862. }
  23863. }
  23864. };
  23865. /**
  23866. * @return The custom validity state, if set; otherwise, the result of a
  23867. * native validity check.
  23868. */
  23869. MDCTextFieldFoundation.prototype.isValid = function () {
  23870. return this.useNativeValidation_ ? this.isNativeInputValid_() : this.isValid_;
  23871. };
  23872. /**
  23873. * @param isValid Sets the custom validity state of the Text Field.
  23874. */
  23875. MDCTextFieldFoundation.prototype.setValid = function (isValid) {
  23876. this.isValid_ = isValid;
  23877. this.styleValidity_(isValid);
  23878. var shouldShake = !isValid && !this.isFocused_ && !!this.getValue();
  23879. if (this.adapter.hasLabel()) {
  23880. this.adapter.shakeLabel(shouldShake);
  23881. }
  23882. };
  23883. /**
  23884. * @param shouldValidate Whether or not validity should be updated on
  23885. * value change.
  23886. */
  23887. MDCTextFieldFoundation.prototype.setValidateOnValueChange = function (shouldValidate) {
  23888. this.validateOnValueChange_ = shouldValidate;
  23889. };
  23890. /**
  23891. * @return Whether or not validity should be updated on value change. `true`
  23892. * by default.
  23893. */
  23894. MDCTextFieldFoundation.prototype.getValidateOnValueChange = function () {
  23895. return this.validateOnValueChange_;
  23896. };
  23897. /**
  23898. * Enables or disables the use of native validation. Use this for custom
  23899. * validation.
  23900. * @param useNativeValidation Set this to false to ignore native input
  23901. * validation.
  23902. */
  23903. MDCTextFieldFoundation.prototype.setUseNativeValidation = function (useNativeValidation) {
  23904. this.useNativeValidation_ = useNativeValidation;
  23905. };
  23906. MDCTextFieldFoundation.prototype.isDisabled = function () {
  23907. return this.getNativeInput_().disabled;
  23908. };
  23909. /**
  23910. * @param disabled Sets the text-field disabled or enabled.
  23911. */
  23912. MDCTextFieldFoundation.prototype.setDisabled = function (disabled) {
  23913. this.getNativeInput_().disabled = disabled;
  23914. this.styleDisabled_(disabled);
  23915. };
  23916. /**
  23917. * @param content Sets the content of the helper text.
  23918. */
  23919. MDCTextFieldFoundation.prototype.setHelperTextContent = function (content) {
  23920. if (this.helperText_) {
  23921. this.helperText_.setContent(content);
  23922. }
  23923. };
  23924. /**
  23925. * Sets the aria label of the leading icon.
  23926. */
  23927. MDCTextFieldFoundation.prototype.setLeadingIconAriaLabel = function (label) {
  23928. if (this.leadingIcon_) {
  23929. this.leadingIcon_.setAriaLabel(label);
  23930. }
  23931. };
  23932. /**
  23933. * Sets the text content of the leading icon.
  23934. */
  23935. MDCTextFieldFoundation.prototype.setLeadingIconContent = function (content) {
  23936. if (this.leadingIcon_) {
  23937. this.leadingIcon_.setContent(content);
  23938. }
  23939. };
  23940. /**
  23941. * Sets the aria label of the trailing icon.
  23942. */
  23943. MDCTextFieldFoundation.prototype.setTrailingIconAriaLabel = function (label) {
  23944. if (this.trailingIcon_) {
  23945. this.trailingIcon_.setAriaLabel(label);
  23946. }
  23947. };
  23948. /**
  23949. * Sets the text content of the trailing icon.
  23950. */
  23951. MDCTextFieldFoundation.prototype.setTrailingIconContent = function (content) {
  23952. if (this.trailingIcon_) {
  23953. this.trailingIcon_.setContent(content);
  23954. }
  23955. };
  23956. /**
  23957. * Sets character counter values that shows characters used and the total
  23958. * character limit.
  23959. */
  23960. MDCTextFieldFoundation.prototype.setCharacterCounter_ = function (currentLength) {
  23961. if (!this.characterCounter_) {
  23962. return;
  23963. }
  23964. var maxLength = this.getNativeInput_().maxLength;
  23965. if (maxLength === -1) {
  23966. throw new Error('MDCTextFieldFoundation: Expected maxlength html property on text input or textarea.');
  23967. }
  23968. this.characterCounter_.setCounterValue(currentLength, maxLength);
  23969. };
  23970. /**
  23971. * @return True if the Text Field input fails in converting the user-supplied
  23972. * value.
  23973. */
  23974. MDCTextFieldFoundation.prototype.isBadInput_ = function () {
  23975. // The badInput property is not supported in IE 11 💩.
  23976. return this.getNativeInput_().validity.badInput || false;
  23977. };
  23978. /**
  23979. * @return The result of native validity checking (ValidityState.valid).
  23980. */
  23981. MDCTextFieldFoundation.prototype.isNativeInputValid_ = function () {
  23982. return this.getNativeInput_().validity.valid;
  23983. };
  23984. /**
  23985. * Styles the component based on the validity state.
  23986. */
  23987. MDCTextFieldFoundation.prototype.styleValidity_ = function (isValid) {
  23988. var INVALID = MDCTextFieldFoundation.cssClasses.INVALID;
  23989. if (isValid) {
  23990. this.adapter.removeClass(INVALID);
  23991. } else {
  23992. this.adapter.addClass(INVALID);
  23993. }
  23994. if (this.helperText_) {
  23995. this.helperText_.setValidity(isValid);
  23996. // We dynamically set or unset aria-describedby for validation helper text
  23997. // only, based on whether the field is valid
  23998. var helperTextValidation = this.helperText_.isValidation();
  23999. if (!helperTextValidation) {
  24000. return;
  24001. }
  24002. var helperTextVisible = this.helperText_.isVisible();
  24003. var helperTextId = this.helperText_.getId();
  24004. if (helperTextVisible && helperTextId) {
  24005. this.adapter.setInputAttr(constants_1.strings.ARIA_DESCRIBEDBY, helperTextId);
  24006. } else {
  24007. this.adapter.removeInputAttr(constants_1.strings.ARIA_DESCRIBEDBY);
  24008. }
  24009. }
  24010. };
  24011. /**
  24012. * Styles the component based on the focused state.
  24013. */
  24014. MDCTextFieldFoundation.prototype.styleFocused_ = function (isFocused) {
  24015. var FOCUSED = MDCTextFieldFoundation.cssClasses.FOCUSED;
  24016. if (isFocused) {
  24017. this.adapter.addClass(FOCUSED);
  24018. } else {
  24019. this.adapter.removeClass(FOCUSED);
  24020. }
  24021. };
  24022. /**
  24023. * Styles the component based on the disabled state.
  24024. */
  24025. MDCTextFieldFoundation.prototype.styleDisabled_ = function (isDisabled) {
  24026. var _a = MDCTextFieldFoundation.cssClasses,
  24027. DISABLED = _a.DISABLED,
  24028. INVALID = _a.INVALID;
  24029. if (isDisabled) {
  24030. this.adapter.addClass(DISABLED);
  24031. this.adapter.removeClass(INVALID);
  24032. } else {
  24033. this.adapter.removeClass(DISABLED);
  24034. }
  24035. if (this.leadingIcon_) {
  24036. this.leadingIcon_.setDisabled(isDisabled);
  24037. }
  24038. if (this.trailingIcon_) {
  24039. this.trailingIcon_.setDisabled(isDisabled);
  24040. }
  24041. };
  24042. /**
  24043. * Styles the component based on the label floating state.
  24044. */
  24045. MDCTextFieldFoundation.prototype.styleFloating_ = function (isFloating) {
  24046. var LABEL_FLOATING = MDCTextFieldFoundation.cssClasses.LABEL_FLOATING;
  24047. if (isFloating) {
  24048. this.adapter.addClass(LABEL_FLOATING);
  24049. } else {
  24050. this.adapter.removeClass(LABEL_FLOATING);
  24051. }
  24052. };
  24053. /**
  24054. * @return The native text input element from the host environment, or an
  24055. * object with the same shape for unit tests.
  24056. */
  24057. MDCTextFieldFoundation.prototype.getNativeInput_ = function () {
  24058. // this.adapter may be undefined in foundation unit tests. This happens when
  24059. // testdouble is creating a mock object and invokes the
  24060. // shouldShake/shouldFloat getters (which in turn call getValue(), which
  24061. // calls this method) before init() has been called from the MDCTextField
  24062. // constructor. To work around that issue, we return a dummy object.
  24063. var nativeInput = this.adapter ? this.adapter.getNativeInput() : null;
  24064. return nativeInput || {
  24065. disabled: false,
  24066. maxLength: -1,
  24067. required: false,
  24068. type: 'input',
  24069. validity: {
  24070. badInput: false,
  24071. valid: true
  24072. },
  24073. value: ''
  24074. };
  24075. };
  24076. return MDCTextFieldFoundation;
  24077. }(foundation_1.MDCFoundation);
  24078. exports.MDCTextFieldFoundation = MDCTextFieldFoundation;
  24079. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  24080. exports.default = MDCTextFieldFoundation;
  24081. /***/ }),
  24082. /***/ "./packages/mdc-textfield/helper-text/component.ts":
  24083. /*!*********************************************************!*\
  24084. !*** ./packages/mdc-textfield/helper-text/component.ts ***!
  24085. \*********************************************************/
  24086. /*! no static exports found */
  24087. /***/ (function(module, exports, __webpack_require__) {
  24088. "use strict";
  24089. /**
  24090. * @license
  24091. * Copyright 2017 Google Inc.
  24092. *
  24093. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24094. * of this software and associated documentation files (the "Software"), to deal
  24095. * in the Software without restriction, including without limitation the rights
  24096. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24097. * copies of the Software, and to permit persons to whom the Software is
  24098. * furnished to do so, subject to the following conditions:
  24099. *
  24100. * The above copyright notice and this permission notice shall be included in
  24101. * all copies or substantial portions of the Software.
  24102. *
  24103. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24104. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24105. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24106. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24107. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24108. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24109. * THE SOFTWARE.
  24110. */
  24111. var __extends = this && this.__extends || function () {
  24112. var _extendStatics = function extendStatics(d, b) {
  24113. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  24114. d.__proto__ = b;
  24115. } || function (d, b) {
  24116. for (var p in b) {
  24117. if (b.hasOwnProperty(p)) d[p] = b[p];
  24118. }
  24119. };
  24120. return _extendStatics(d, b);
  24121. };
  24122. return function (d, b) {
  24123. _extendStatics(d, b);
  24124. function __() {
  24125. this.constructor = d;
  24126. }
  24127. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24128. };
  24129. }();
  24130. Object.defineProperty(exports, "__esModule", { value: true });
  24131. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  24132. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/helper-text/foundation.ts");
  24133. var MDCTextFieldHelperText = /** @class */function (_super) {
  24134. __extends(MDCTextFieldHelperText, _super);
  24135. function MDCTextFieldHelperText() {
  24136. return _super !== null && _super.apply(this, arguments) || this;
  24137. }
  24138. MDCTextFieldHelperText.attachTo = function (root) {
  24139. return new MDCTextFieldHelperText(root);
  24140. };
  24141. Object.defineProperty(MDCTextFieldHelperText.prototype, "foundationForTextField", {
  24142. // Provided for access by MDCTextField component
  24143. get: function get() {
  24144. return this.foundation;
  24145. },
  24146. enumerable: true,
  24147. configurable: true
  24148. });
  24149. MDCTextFieldHelperText.prototype.getDefaultFoundation = function () {
  24150. var _this = this;
  24151. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  24152. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  24153. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  24154. var adapter = {
  24155. addClass: function addClass(className) {
  24156. return _this.root.classList.add(className);
  24157. },
  24158. removeClass: function removeClass(className) {
  24159. return _this.root.classList.remove(className);
  24160. },
  24161. hasClass: function hasClass(className) {
  24162. return _this.root.classList.contains(className);
  24163. },
  24164. getAttr: function getAttr(attr) {
  24165. return _this.root.getAttribute(attr);
  24166. },
  24167. setAttr: function setAttr(attr, value) {
  24168. return _this.root.setAttribute(attr, value);
  24169. },
  24170. removeAttr: function removeAttr(attr) {
  24171. return _this.root.removeAttribute(attr);
  24172. },
  24173. setContent: function setContent(content) {
  24174. _this.root.textContent = content;
  24175. }
  24176. };
  24177. // tslint:enable:object-literal-sort-keys
  24178. return new foundation_1.MDCTextFieldHelperTextFoundation(adapter);
  24179. };
  24180. return MDCTextFieldHelperText;
  24181. }(component_1.MDCComponent);
  24182. exports.MDCTextFieldHelperText = MDCTextFieldHelperText;
  24183. /***/ }),
  24184. /***/ "./packages/mdc-textfield/helper-text/constants.ts":
  24185. /*!*********************************************************!*\
  24186. !*** ./packages/mdc-textfield/helper-text/constants.ts ***!
  24187. \*********************************************************/
  24188. /*! no static exports found */
  24189. /***/ (function(module, exports, __webpack_require__) {
  24190. "use strict";
  24191. /**
  24192. * @license
  24193. * Copyright 2016 Google Inc.
  24194. *
  24195. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24196. * of this software and associated documentation files (the "Software"), to deal
  24197. * in the Software without restriction, including without limitation the rights
  24198. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24199. * copies of the Software, and to permit persons to whom the Software is
  24200. * furnished to do so, subject to the following conditions:
  24201. *
  24202. * The above copyright notice and this permission notice shall be included in
  24203. * all copies or substantial portions of the Software.
  24204. *
  24205. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24206. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24207. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24208. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24209. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24210. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24211. * THE SOFTWARE.
  24212. */
  24213. Object.defineProperty(exports, "__esModule", { value: true });
  24214. var cssClasses = {
  24215. HELPER_TEXT_PERSISTENT: 'mdc-text-field-helper-text--persistent',
  24216. HELPER_TEXT_VALIDATION_MSG: 'mdc-text-field-helper-text--validation-msg',
  24217. ROOT: 'mdc-text-field-helper-text'
  24218. };
  24219. exports.cssClasses = cssClasses;
  24220. var strings = {
  24221. ARIA_HIDDEN: 'aria-hidden',
  24222. ROLE: 'role',
  24223. ROOT_SELECTOR: "." + cssClasses.ROOT
  24224. };
  24225. exports.strings = strings;
  24226. /***/ }),
  24227. /***/ "./packages/mdc-textfield/helper-text/foundation.ts":
  24228. /*!**********************************************************!*\
  24229. !*** ./packages/mdc-textfield/helper-text/foundation.ts ***!
  24230. \**********************************************************/
  24231. /*! no static exports found */
  24232. /***/ (function(module, exports, __webpack_require__) {
  24233. "use strict";
  24234. /**
  24235. * @license
  24236. * Copyright 2017 Google Inc.
  24237. *
  24238. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24239. * of this software and associated documentation files (the "Software"), to deal
  24240. * in the Software without restriction, including without limitation the rights
  24241. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24242. * copies of the Software, and to permit persons to whom the Software is
  24243. * furnished to do so, subject to the following conditions:
  24244. *
  24245. * The above copyright notice and this permission notice shall be included in
  24246. * all copies or substantial portions of the Software.
  24247. *
  24248. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24249. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24250. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24251. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24252. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24253. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24254. * THE SOFTWARE.
  24255. */
  24256. var __extends = this && this.__extends || function () {
  24257. var _extendStatics = function extendStatics(d, b) {
  24258. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  24259. d.__proto__ = b;
  24260. } || function (d, b) {
  24261. for (var p in b) {
  24262. if (b.hasOwnProperty(p)) d[p] = b[p];
  24263. }
  24264. };
  24265. return _extendStatics(d, b);
  24266. };
  24267. return function (d, b) {
  24268. _extendStatics(d, b);
  24269. function __() {
  24270. this.constructor = d;
  24271. }
  24272. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24273. };
  24274. }();
  24275. var __assign = this && this.__assign || function () {
  24276. __assign = Object.assign || function (t) {
  24277. for (var s, i = 1, n = arguments.length; i < n; i++) {
  24278. s = arguments[i];
  24279. for (var p in s) {
  24280. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  24281. }
  24282. }
  24283. return t;
  24284. };
  24285. return __assign.apply(this, arguments);
  24286. };
  24287. Object.defineProperty(exports, "__esModule", { value: true });
  24288. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  24289. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/helper-text/constants.ts");
  24290. var MDCTextFieldHelperTextFoundation = /** @class */function (_super) {
  24291. __extends(MDCTextFieldHelperTextFoundation, _super);
  24292. function MDCTextFieldHelperTextFoundation(adapter) {
  24293. return _super.call(this, __assign(__assign({}, MDCTextFieldHelperTextFoundation.defaultAdapter), adapter)) || this;
  24294. }
  24295. Object.defineProperty(MDCTextFieldHelperTextFoundation, "cssClasses", {
  24296. get: function get() {
  24297. return constants_1.cssClasses;
  24298. },
  24299. enumerable: true,
  24300. configurable: true
  24301. });
  24302. Object.defineProperty(MDCTextFieldHelperTextFoundation, "strings", {
  24303. get: function get() {
  24304. return constants_1.strings;
  24305. },
  24306. enumerable: true,
  24307. configurable: true
  24308. });
  24309. Object.defineProperty(MDCTextFieldHelperTextFoundation, "defaultAdapter", {
  24310. /**
  24311. * See {@link MDCTextFieldHelperTextAdapter} for typing information on parameters and return types.
  24312. */
  24313. get: function get() {
  24314. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  24315. return {
  24316. addClass: function addClass() {
  24317. return undefined;
  24318. },
  24319. removeClass: function removeClass() {
  24320. return undefined;
  24321. },
  24322. hasClass: function hasClass() {
  24323. return false;
  24324. },
  24325. getAttr: function getAttr() {
  24326. return null;
  24327. },
  24328. setAttr: function setAttr() {
  24329. return undefined;
  24330. },
  24331. removeAttr: function removeAttr() {
  24332. return undefined;
  24333. },
  24334. setContent: function setContent() {
  24335. return undefined;
  24336. }
  24337. };
  24338. // tslint:enable:object-literal-sort-keys
  24339. },
  24340. enumerable: true,
  24341. configurable: true
  24342. });
  24343. MDCTextFieldHelperTextFoundation.prototype.getId = function () {
  24344. return this.adapter.getAttr('id');
  24345. };
  24346. MDCTextFieldHelperTextFoundation.prototype.isVisible = function () {
  24347. return this.adapter.getAttr(constants_1.strings.ARIA_HIDDEN) !== 'true';
  24348. };
  24349. /**
  24350. * Sets the content of the helper text field.
  24351. */
  24352. MDCTextFieldHelperTextFoundation.prototype.setContent = function (content) {
  24353. this.adapter.setContent(content);
  24354. };
  24355. MDCTextFieldHelperTextFoundation.prototype.isPersistent = function () {
  24356. return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
  24357. };
  24358. /**
  24359. * @param isPersistent Sets the persistency of the helper text.
  24360. */
  24361. MDCTextFieldHelperTextFoundation.prototype.setPersistent = function (isPersistent) {
  24362. if (isPersistent) {
  24363. this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
  24364. } else {
  24365. this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
  24366. }
  24367. };
  24368. /**
  24369. * @return whether the helper text acts as an error validation message.
  24370. */
  24371. MDCTextFieldHelperTextFoundation.prototype.isValidation = function () {
  24372. return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  24373. };
  24374. /**
  24375. * @param isValidation True to make the helper text act as an error validation message.
  24376. */
  24377. MDCTextFieldHelperTextFoundation.prototype.setValidation = function (isValidation) {
  24378. if (isValidation) {
  24379. this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  24380. } else {
  24381. this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  24382. }
  24383. };
  24384. /**
  24385. * Makes the helper text visible to the screen reader.
  24386. */
  24387. MDCTextFieldHelperTextFoundation.prototype.showToScreenReader = function () {
  24388. this.adapter.removeAttr(constants_1.strings.ARIA_HIDDEN);
  24389. };
  24390. /**
  24391. * Sets the validity of the helper text based on the input validity.
  24392. */
  24393. MDCTextFieldHelperTextFoundation.prototype.setValidity = function (inputIsValid) {
  24394. var helperTextIsPersistent = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
  24395. var helperTextIsValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  24396. var validationMsgNeedsDisplay = helperTextIsValidationMsg && !inputIsValid;
  24397. if (validationMsgNeedsDisplay) {
  24398. this.showToScreenReader();
  24399. this.adapter.setAttr(constants_1.strings.ROLE, 'alert');
  24400. } else {
  24401. this.adapter.removeAttr(constants_1.strings.ROLE);
  24402. }
  24403. if (!helperTextIsPersistent && !validationMsgNeedsDisplay) {
  24404. this.hide_();
  24405. }
  24406. };
  24407. /**
  24408. * Hides the help text from screen readers.
  24409. */
  24410. MDCTextFieldHelperTextFoundation.prototype.hide_ = function () {
  24411. this.adapter.setAttr(constants_1.strings.ARIA_HIDDEN, 'true');
  24412. };
  24413. return MDCTextFieldHelperTextFoundation;
  24414. }(foundation_1.MDCFoundation);
  24415. exports.MDCTextFieldHelperTextFoundation = MDCTextFieldHelperTextFoundation;
  24416. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  24417. exports.default = MDCTextFieldHelperTextFoundation;
  24418. /***/ }),
  24419. /***/ "./packages/mdc-textfield/helper-text/index.ts":
  24420. /*!*****************************************************!*\
  24421. !*** ./packages/mdc-textfield/helper-text/index.ts ***!
  24422. \*****************************************************/
  24423. /*! no static exports found */
  24424. /***/ (function(module, exports, __webpack_require__) {
  24425. "use strict";
  24426. /**
  24427. * @license
  24428. * Copyright 2019 Google Inc.
  24429. *
  24430. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24431. * of this software and associated documentation files (the "Software"), to deal
  24432. * in the Software without restriction, including without limitation the rights
  24433. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24434. * copies of the Software, and to permit persons to whom the Software is
  24435. * furnished to do so, subject to the following conditions:
  24436. *
  24437. * The above copyright notice and this permission notice shall be included in
  24438. * all copies or substantial portions of the Software.
  24439. *
  24440. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24441. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24442. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24443. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24444. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24445. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24446. * THE SOFTWARE.
  24447. */
  24448. function __export(m) {
  24449. for (var p in m) {
  24450. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  24451. }
  24452. }
  24453. Object.defineProperty(exports, "__esModule", { value: true });
  24454. __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/helper-text/component.ts"));
  24455. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/helper-text/foundation.ts"));
  24456. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/helper-text/constants.ts");
  24457. exports.helperTextCssClasses = constants_1.cssClasses;
  24458. exports.helperTextStrings = constants_1.strings;
  24459. /***/ }),
  24460. /***/ "./packages/mdc-textfield/icon/component.ts":
  24461. /*!**************************************************!*\
  24462. !*** ./packages/mdc-textfield/icon/component.ts ***!
  24463. \**************************************************/
  24464. /*! no static exports found */
  24465. /***/ (function(module, exports, __webpack_require__) {
  24466. "use strict";
  24467. /**
  24468. * @license
  24469. * Copyright 2017 Google Inc.
  24470. *
  24471. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24472. * of this software and associated documentation files (the "Software"), to deal
  24473. * in the Software without restriction, including without limitation the rights
  24474. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24475. * copies of the Software, and to permit persons to whom the Software is
  24476. * furnished to do so, subject to the following conditions:
  24477. *
  24478. * The above copyright notice and this permission notice shall be included in
  24479. * all copies or substantial portions of the Software.
  24480. *
  24481. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24482. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24483. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24484. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24485. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24486. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24487. * THE SOFTWARE.
  24488. */
  24489. var __extends = this && this.__extends || function () {
  24490. var _extendStatics = function extendStatics(d, b) {
  24491. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  24492. d.__proto__ = b;
  24493. } || function (d, b) {
  24494. for (var p in b) {
  24495. if (b.hasOwnProperty(p)) d[p] = b[p];
  24496. }
  24497. };
  24498. return _extendStatics(d, b);
  24499. };
  24500. return function (d, b) {
  24501. _extendStatics(d, b);
  24502. function __() {
  24503. this.constructor = d;
  24504. }
  24505. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24506. };
  24507. }();
  24508. Object.defineProperty(exports, "__esModule", { value: true });
  24509. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  24510. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/icon/foundation.ts");
  24511. var MDCTextFieldIcon = /** @class */function (_super) {
  24512. __extends(MDCTextFieldIcon, _super);
  24513. function MDCTextFieldIcon() {
  24514. return _super !== null && _super.apply(this, arguments) || this;
  24515. }
  24516. MDCTextFieldIcon.attachTo = function (root) {
  24517. return new MDCTextFieldIcon(root);
  24518. };
  24519. Object.defineProperty(MDCTextFieldIcon.prototype, "foundationForTextField", {
  24520. // Provided for access by MDCTextField component
  24521. get: function get() {
  24522. return this.foundation;
  24523. },
  24524. enumerable: true,
  24525. configurable: true
  24526. });
  24527. MDCTextFieldIcon.prototype.getDefaultFoundation = function () {
  24528. var _this = this;
  24529. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  24530. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  24531. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  24532. var adapter = {
  24533. getAttr: function getAttr(attr) {
  24534. return _this.root.getAttribute(attr);
  24535. },
  24536. setAttr: function setAttr(attr, value) {
  24537. return _this.root.setAttribute(attr, value);
  24538. },
  24539. removeAttr: function removeAttr(attr) {
  24540. return _this.root.removeAttribute(attr);
  24541. },
  24542. setContent: function setContent(content) {
  24543. _this.root.textContent = content;
  24544. },
  24545. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  24546. return _this.listen(evtType, handler);
  24547. },
  24548. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  24549. return _this.unlisten(evtType, handler);
  24550. },
  24551. notifyIconAction: function notifyIconAction() {
  24552. return _this.emit(foundation_1.MDCTextFieldIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */);
  24553. }
  24554. };
  24555. // tslint:enable:object-literal-sort-keys
  24556. return new foundation_1.MDCTextFieldIconFoundation(adapter);
  24557. };
  24558. return MDCTextFieldIcon;
  24559. }(component_1.MDCComponent);
  24560. exports.MDCTextFieldIcon = MDCTextFieldIcon;
  24561. /***/ }),
  24562. /***/ "./packages/mdc-textfield/icon/constants.ts":
  24563. /*!**************************************************!*\
  24564. !*** ./packages/mdc-textfield/icon/constants.ts ***!
  24565. \**************************************************/
  24566. /*! no static exports found */
  24567. /***/ (function(module, exports, __webpack_require__) {
  24568. "use strict";
  24569. /**
  24570. * @license
  24571. * Copyright 2016 Google Inc.
  24572. *
  24573. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24574. * of this software and associated documentation files (the "Software"), to deal
  24575. * in the Software without restriction, including without limitation the rights
  24576. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24577. * copies of the Software, and to permit persons to whom the Software is
  24578. * furnished to do so, subject to the following conditions:
  24579. *
  24580. * The above copyright notice and this permission notice shall be included in
  24581. * all copies or substantial portions of the Software.
  24582. *
  24583. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24584. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24585. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24586. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24587. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24588. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24589. * THE SOFTWARE.
  24590. */
  24591. Object.defineProperty(exports, "__esModule", { value: true });
  24592. var strings = {
  24593. ICON_EVENT: 'MDCTextField:icon',
  24594. ICON_ROLE: 'button'
  24595. };
  24596. exports.strings = strings;
  24597. var cssClasses = {
  24598. ROOT: 'mdc-text-field__icon'
  24599. };
  24600. exports.cssClasses = cssClasses;
  24601. /***/ }),
  24602. /***/ "./packages/mdc-textfield/icon/foundation.ts":
  24603. /*!***************************************************!*\
  24604. !*** ./packages/mdc-textfield/icon/foundation.ts ***!
  24605. \***************************************************/
  24606. /*! no static exports found */
  24607. /***/ (function(module, exports, __webpack_require__) {
  24608. "use strict";
  24609. /**
  24610. * @license
  24611. * Copyright 2017 Google Inc.
  24612. *
  24613. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24614. * of this software and associated documentation files (the "Software"), to deal
  24615. * in the Software without restriction, including without limitation the rights
  24616. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24617. * copies of the Software, and to permit persons to whom the Software is
  24618. * furnished to do so, subject to the following conditions:
  24619. *
  24620. * The above copyright notice and this permission notice shall be included in
  24621. * all copies or substantial portions of the Software.
  24622. *
  24623. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24624. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24625. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24626. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24627. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24628. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24629. * THE SOFTWARE.
  24630. */
  24631. var __extends = this && this.__extends || function () {
  24632. var _extendStatics = function extendStatics(d, b) {
  24633. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  24634. d.__proto__ = b;
  24635. } || function (d, b) {
  24636. for (var p in b) {
  24637. if (b.hasOwnProperty(p)) d[p] = b[p];
  24638. }
  24639. };
  24640. return _extendStatics(d, b);
  24641. };
  24642. return function (d, b) {
  24643. _extendStatics(d, b);
  24644. function __() {
  24645. this.constructor = d;
  24646. }
  24647. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24648. };
  24649. }();
  24650. var __assign = this && this.__assign || function () {
  24651. __assign = Object.assign || function (t) {
  24652. for (var s, i = 1, n = arguments.length; i < n; i++) {
  24653. s = arguments[i];
  24654. for (var p in s) {
  24655. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  24656. }
  24657. }
  24658. return t;
  24659. };
  24660. return __assign.apply(this, arguments);
  24661. };
  24662. Object.defineProperty(exports, "__esModule", { value: true });
  24663. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  24664. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/icon/constants.ts");
  24665. var INTERACTION_EVENTS = ['click', 'keydown'];
  24666. var MDCTextFieldIconFoundation = /** @class */function (_super) {
  24667. __extends(MDCTextFieldIconFoundation, _super);
  24668. function MDCTextFieldIconFoundation(adapter) {
  24669. var _this = _super.call(this, __assign(__assign({}, MDCTextFieldIconFoundation.defaultAdapter), adapter)) || this;
  24670. _this.savedTabIndex_ = null;
  24671. _this.interactionHandler_ = function (evt) {
  24672. return _this.handleInteraction(evt);
  24673. };
  24674. return _this;
  24675. }
  24676. Object.defineProperty(MDCTextFieldIconFoundation, "strings", {
  24677. get: function get() {
  24678. return constants_1.strings;
  24679. },
  24680. enumerable: true,
  24681. configurable: true
  24682. });
  24683. Object.defineProperty(MDCTextFieldIconFoundation, "cssClasses", {
  24684. get: function get() {
  24685. return constants_1.cssClasses;
  24686. },
  24687. enumerable: true,
  24688. configurable: true
  24689. });
  24690. Object.defineProperty(MDCTextFieldIconFoundation, "defaultAdapter", {
  24691. /**
  24692. * See {@link MDCTextFieldIconAdapter} for typing information on parameters and return types.
  24693. */
  24694. get: function get() {
  24695. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  24696. return {
  24697. getAttr: function getAttr() {
  24698. return null;
  24699. },
  24700. setAttr: function setAttr() {
  24701. return undefined;
  24702. },
  24703. removeAttr: function removeAttr() {
  24704. return undefined;
  24705. },
  24706. setContent: function setContent() {
  24707. return undefined;
  24708. },
  24709. registerInteractionHandler: function registerInteractionHandler() {
  24710. return undefined;
  24711. },
  24712. deregisterInteractionHandler: function deregisterInteractionHandler() {
  24713. return undefined;
  24714. },
  24715. notifyIconAction: function notifyIconAction() {
  24716. return undefined;
  24717. }
  24718. };
  24719. // tslint:enable:object-literal-sort-keys
  24720. },
  24721. enumerable: true,
  24722. configurable: true
  24723. });
  24724. MDCTextFieldIconFoundation.prototype.init = function () {
  24725. var _this = this;
  24726. this.savedTabIndex_ = this.adapter.getAttr('tabindex');
  24727. INTERACTION_EVENTS.forEach(function (evtType) {
  24728. _this.adapter.registerInteractionHandler(evtType, _this.interactionHandler_);
  24729. });
  24730. };
  24731. MDCTextFieldIconFoundation.prototype.destroy = function () {
  24732. var _this = this;
  24733. INTERACTION_EVENTS.forEach(function (evtType) {
  24734. _this.adapter.deregisterInteractionHandler(evtType, _this.interactionHandler_);
  24735. });
  24736. };
  24737. MDCTextFieldIconFoundation.prototype.setDisabled = function (disabled) {
  24738. if (!this.savedTabIndex_) {
  24739. return;
  24740. }
  24741. if (disabled) {
  24742. this.adapter.setAttr('tabindex', '-1');
  24743. this.adapter.removeAttr('role');
  24744. } else {
  24745. this.adapter.setAttr('tabindex', this.savedTabIndex_);
  24746. this.adapter.setAttr('role', constants_1.strings.ICON_ROLE);
  24747. }
  24748. };
  24749. MDCTextFieldIconFoundation.prototype.setAriaLabel = function (label) {
  24750. this.adapter.setAttr('aria-label', label);
  24751. };
  24752. MDCTextFieldIconFoundation.prototype.setContent = function (content) {
  24753. this.adapter.setContent(content);
  24754. };
  24755. MDCTextFieldIconFoundation.prototype.handleInteraction = function (evt) {
  24756. var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
  24757. if (evt.type === 'click' || isEnterKey) {
  24758. evt.preventDefault(); // stop click from causing host label to focus
  24759. // input
  24760. this.adapter.notifyIconAction();
  24761. }
  24762. };
  24763. return MDCTextFieldIconFoundation;
  24764. }(foundation_1.MDCFoundation);
  24765. exports.MDCTextFieldIconFoundation = MDCTextFieldIconFoundation;
  24766. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  24767. exports.default = MDCTextFieldIconFoundation;
  24768. /***/ }),
  24769. /***/ "./packages/mdc-textfield/icon/index.ts":
  24770. /*!**********************************************!*\
  24771. !*** ./packages/mdc-textfield/icon/index.ts ***!
  24772. \**********************************************/
  24773. /*! no static exports found */
  24774. /***/ (function(module, exports, __webpack_require__) {
  24775. "use strict";
  24776. /**
  24777. * @license
  24778. * Copyright 2019 Google Inc.
  24779. *
  24780. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24781. * of this software and associated documentation files (the "Software"), to deal
  24782. * in the Software without restriction, including without limitation the rights
  24783. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24784. * copies of the Software, and to permit persons to whom the Software is
  24785. * furnished to do so, subject to the following conditions:
  24786. *
  24787. * The above copyright notice and this permission notice shall be included in
  24788. * all copies or substantial portions of the Software.
  24789. *
  24790. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24791. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24792. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24793. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24794. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24795. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24796. * THE SOFTWARE.
  24797. */
  24798. function __export(m) {
  24799. for (var p in m) {
  24800. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  24801. }
  24802. }
  24803. Object.defineProperty(exports, "__esModule", { value: true });
  24804. __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/icon/component.ts"));
  24805. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/icon/foundation.ts"));
  24806. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/icon/constants.ts");
  24807. exports.iconCssClasses = constants_1.cssClasses;
  24808. exports.iconStrings = constants_1.strings;
  24809. /***/ }),
  24810. /***/ "./packages/mdc-textfield/index.ts":
  24811. /*!*****************************************!*\
  24812. !*** ./packages/mdc-textfield/index.ts ***!
  24813. \*****************************************/
  24814. /*! no static exports found */
  24815. /***/ (function(module, exports, __webpack_require__) {
  24816. "use strict";
  24817. /**
  24818. * @license
  24819. * Copyright 2019 Google Inc.
  24820. *
  24821. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24822. * of this software and associated documentation files (the "Software"), to deal
  24823. * in the Software without restriction, including without limitation the rights
  24824. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24825. * copies of the Software, and to permit persons to whom the Software is
  24826. * furnished to do so, subject to the following conditions:
  24827. *
  24828. * The above copyright notice and this permission notice shall be included in
  24829. * all copies or substantial portions of the Software.
  24830. *
  24831. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24832. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24833. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24834. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24835. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24836. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24837. * THE SOFTWARE.
  24838. */
  24839. function __export(m) {
  24840. for (var p in m) {
  24841. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  24842. }
  24843. }
  24844. Object.defineProperty(exports, "__esModule", { value: true });
  24845. __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/component.ts"));
  24846. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts"));
  24847. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/foundation.ts"));
  24848. __export(__webpack_require__(/*! ./character-counter/index */ "./packages/mdc-textfield/character-counter/index.ts"));
  24849. __export(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-textfield/helper-text/index.ts"));
  24850. __export(__webpack_require__(/*! ./icon/index */ "./packages/mdc-textfield/icon/index.ts"));
  24851. /***/ }),
  24852. /***/ "./packages/mdc-tooltip/component.ts":
  24853. /*!*******************************************!*\
  24854. !*** ./packages/mdc-tooltip/component.ts ***!
  24855. \*******************************************/
  24856. /*! no static exports found */
  24857. /***/ (function(module, exports, __webpack_require__) {
  24858. "use strict";
  24859. /**
  24860. * @license
  24861. * Copyright 2020 Google Inc.
  24862. *
  24863. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24864. * of this software and associated documentation files (the "Software"), to deal
  24865. * in the Software without restriction, including without limitation the rights
  24866. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24867. * copies of the Software, and to permit persons to whom the Software is
  24868. * furnished to do so, subject to the following conditions:
  24869. *
  24870. * The above copyright notice and this permission notice shall be included in
  24871. * all copies or substantial portions of the Software.
  24872. *
  24873. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24874. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24875. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24876. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24877. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24878. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24879. * THE SOFTWARE.
  24880. */
  24881. var __extends = this && this.__extends || function () {
  24882. var _extendStatics = function extendStatics(d, b) {
  24883. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  24884. d.__proto__ = b;
  24885. } || function (d, b) {
  24886. for (var p in b) {
  24887. if (b.hasOwnProperty(p)) d[p] = b[p];
  24888. }
  24889. };
  24890. return _extendStatics(d, b);
  24891. };
  24892. return function (d, b) {
  24893. _extendStatics(d, b);
  24894. function __() {
  24895. this.constructor = d;
  24896. }
  24897. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24898. };
  24899. }();
  24900. Object.defineProperty(exports, "__esModule", { value: true });
  24901. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  24902. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts");
  24903. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tooltip/foundation.ts");
  24904. var MDCTooltip = /** @class */function (_super) {
  24905. __extends(MDCTooltip, _super);
  24906. function MDCTooltip() {
  24907. return _super !== null && _super.apply(this, arguments) || this;
  24908. }
  24909. MDCTooltip.attachTo = function (root) {
  24910. return new MDCTooltip(root);
  24911. };
  24912. MDCTooltip.prototype.initialize = function () {
  24913. var tooltipId = this.root.getAttribute('id');
  24914. if (!tooltipId) {
  24915. throw new Error('MDCTooltip: Tooltip component must have an id.');
  24916. }
  24917. var anchorElem = document.querySelector("[aria-describedby=\"" + tooltipId + "\"]") || document.querySelector("[data-tooltip-id=\"" + tooltipId + "\"]");
  24918. if (!anchorElem) {
  24919. throw new Error('MDCTooltip: Tooltip component requires an anchor element annotated with [aria-describedby] or [data-tooltip-id] anchor element.');
  24920. }
  24921. this.anchorElem = anchorElem;
  24922. };
  24923. MDCTooltip.prototype.initialSyncWithDOM = function () {
  24924. var _this = this;
  24925. this.isTooltipRich = this.foundation.isRich();
  24926. this.isTooltipPersistent = this.foundation.isPersistent();
  24927. this.handleMouseEnter = function () {
  24928. _this.foundation.handleAnchorMouseEnter();
  24929. };
  24930. this.handleFocus = function (evt) {
  24931. _this.foundation.handleAnchorFocus(evt);
  24932. };
  24933. this.handleMouseLeave = function () {
  24934. _this.foundation.handleAnchorMouseLeave();
  24935. };
  24936. this.handleBlur = function (evt) {
  24937. _this.foundation.handleAnchorBlur(evt);
  24938. };
  24939. this.handleTransitionEnd = function () {
  24940. _this.foundation.handleTransitionEnd();
  24941. };
  24942. this.handleClick = function () {
  24943. _this.foundation.handleAnchorClick();
  24944. };
  24945. this.anchorElem.addEventListener('blur', this.handleBlur);
  24946. if (this.isTooltipRich && this.isTooltipPersistent) {
  24947. this.anchorElem.addEventListener('click', this.handleClick);
  24948. } else {
  24949. this.anchorElem.addEventListener('mouseenter', this.handleMouseEnter);
  24950. // TODO(b/157075286): Listening for a 'focus' event is too broad.
  24951. this.anchorElem.addEventListener('focus', this.handleFocus);
  24952. this.anchorElem.addEventListener('mouseleave', this.handleMouseLeave);
  24953. }
  24954. this.listen('transitionend', this.handleTransitionEnd);
  24955. };
  24956. MDCTooltip.prototype.destroy = function () {
  24957. if (this.anchorElem) {
  24958. this.anchorElem.removeEventListener('blur', this.handleBlur);
  24959. if (this.isTooltipRich && this.isTooltipPersistent) {
  24960. this.anchorElem.removeEventListener('click', this.handleClick);
  24961. } else {
  24962. this.anchorElem.removeEventListener('mouseenter', this.handleMouseEnter);
  24963. this.anchorElem.removeEventListener('focus', this.handleFocus);
  24964. this.anchorElem.removeEventListener('mouseleave', this.handleMouseLeave);
  24965. }
  24966. }
  24967. this.unlisten('transitionend', this.handleTransitionEnd);
  24968. _super.prototype.destroy.call(this);
  24969. };
  24970. MDCTooltip.prototype.setTooltipPosition = function (position) {
  24971. this.foundation.setTooltipPosition(position);
  24972. };
  24973. MDCTooltip.prototype.setAnchorBoundaryType = function (type) {
  24974. this.foundation.setAnchorBoundaryType(type);
  24975. };
  24976. MDCTooltip.prototype.hide = function () {
  24977. this.foundation.hide();
  24978. };
  24979. MDCTooltip.prototype.isShown = function () {
  24980. this.foundation.isShown();
  24981. };
  24982. MDCTooltip.prototype.getDefaultFoundation = function () {
  24983. var _this = this;
  24984. var adapter = {
  24985. getAttribute: function getAttribute(attr) {
  24986. return _this.root.getAttribute(attr);
  24987. },
  24988. setAttribute: function setAttribute(attr, value) {
  24989. _this.root.setAttribute(attr, value);
  24990. },
  24991. addClass: function addClass(className) {
  24992. _this.root.classList.add(className);
  24993. },
  24994. hasClass: function hasClass(className) {
  24995. return _this.root.classList.contains(className);
  24996. },
  24997. removeClass: function removeClass(className) {
  24998. _this.root.classList.remove(className);
  24999. },
  25000. getComputedStyleProperty: function getComputedStyleProperty(propertyName) {
  25001. return window.getComputedStyle(_this.root).getPropertyValue(propertyName);
  25002. },
  25003. setStyleProperty: function setStyleProperty(propertyName, value) {
  25004. _this.root.style.setProperty(propertyName, value);
  25005. },
  25006. setSurfaceStyleProperty: function setSurfaceStyleProperty(propertyName, value) {
  25007. var surface = _this.root.querySelector("." + constants_1.CssClasses.SURFACE);
  25008. surface === null || surface === void 0 ? void 0 : surface.style.setProperty(propertyName, value);
  25009. },
  25010. getViewportWidth: function getViewportWidth() {
  25011. return window.innerWidth;
  25012. },
  25013. getViewportHeight: function getViewportHeight() {
  25014. return window.innerHeight;
  25015. },
  25016. getTooltipSize: function getTooltipSize() {
  25017. return {
  25018. width: _this.root.offsetWidth,
  25019. height: _this.root.offsetHeight
  25020. };
  25021. },
  25022. getAnchorBoundingRect: function getAnchorBoundingRect() {
  25023. return _this.anchorElem ? _this.anchorElem.getBoundingClientRect() : null;
  25024. },
  25025. getParentBoundingRect: function getParentBoundingRect() {
  25026. var _a, _b;
  25027. return (_b = (_a = _this.root.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) !== null && _b !== void 0 ? _b : null;
  25028. },
  25029. getAnchorAttribute: function getAnchorAttribute(attr) {
  25030. return _this.anchorElem ? _this.anchorElem.getAttribute(attr) : null;
  25031. },
  25032. setAnchorAttribute: function setAnchorAttribute(attr, value) {
  25033. var _a;
  25034. (_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.setAttribute(attr, value);
  25035. },
  25036. isRTL: function isRTL() {
  25037. return getComputedStyle(_this.root).direction === 'rtl';
  25038. },
  25039. anchorContainsElement: function anchorContainsElement(element) {
  25040. var _a;
  25041. return !!((_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.contains(element));
  25042. },
  25043. tooltipContainsElement: function tooltipContainsElement(element) {
  25044. return _this.root.contains(element);
  25045. },
  25046. focusAnchorElement: function focusAnchorElement() {
  25047. var _a;
  25048. (_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.focus();
  25049. },
  25050. registerEventHandler: function registerEventHandler(evt, handler) {
  25051. if (_this.root instanceof HTMLElement) {
  25052. _this.root.addEventListener(evt, handler);
  25053. }
  25054. },
  25055. deregisterEventHandler: function deregisterEventHandler(evt, handler) {
  25056. if (_this.root instanceof HTMLElement) {
  25057. _this.root.removeEventListener(evt, handler);
  25058. }
  25059. },
  25060. registerDocumentEventHandler: function registerDocumentEventHandler(evt, handler) {
  25061. document.body.addEventListener(evt, handler);
  25062. },
  25063. deregisterDocumentEventHandler: function deregisterDocumentEventHandler(evt, handler) {
  25064. document.body.removeEventListener(evt, handler);
  25065. },
  25066. registerWindowEventHandler: function registerWindowEventHandler(evt, handler) {
  25067. window.addEventListener(evt, handler);
  25068. },
  25069. deregisterWindowEventHandler: function deregisterWindowEventHandler(evt, handler) {
  25070. window.removeEventListener(evt, handler);
  25071. },
  25072. notifyHidden: function notifyHidden() {
  25073. _this.emit(constants_1.events.HIDDEN, {});
  25074. }
  25075. };
  25076. //tslint:enable:object-literal-sort-keys
  25077. return new foundation_1.MDCTooltipFoundation(adapter);
  25078. };
  25079. return MDCTooltip;
  25080. }(component_1.MDCComponent);
  25081. exports.MDCTooltip = MDCTooltip;
  25082. /***/ }),
  25083. /***/ "./packages/mdc-tooltip/constants.ts":
  25084. /*!*******************************************!*\
  25085. !*** ./packages/mdc-tooltip/constants.ts ***!
  25086. \*******************************************/
  25087. /*! no static exports found */
  25088. /***/ (function(module, exports, __webpack_require__) {
  25089. "use strict";
  25090. /**
  25091. * @license
  25092. * Copyright 2020 Google Inc.
  25093. *
  25094. * Permission is hereby granted, free of charge, to any person obtaining a copy
  25095. * of this software and associated documentation files (the "Software"), to deal
  25096. * in the Software without restriction, including without limitation the rights
  25097. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  25098. * copies of the Software, and to permit persons to whom the Software is
  25099. * furnished to do so, subject to the following conditions:
  25100. *
  25101. * The above copyright notice and this permission notice shall be included in
  25102. * all copies or substantial portions of the Software.
  25103. *
  25104. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25105. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25106. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25107. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25108. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25109. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25110. * THE SOFTWARE.
  25111. */
  25112. Object.defineProperty(exports, "__esModule", { value: true });
  25113. var CssClasses;
  25114. (function (CssClasses) {
  25115. CssClasses["RICH"] = "mdc-tooltip--rich";
  25116. CssClasses["SHOWN"] = "mdc-tooltip--shown";
  25117. CssClasses["SHOWING"] = "mdc-tooltip--showing";
  25118. CssClasses["SHOWING_TRANSITION"] = "mdc-tooltip--showing-transition";
  25119. CssClasses["HIDE"] = "mdc-tooltip--hide";
  25120. CssClasses["HIDE_TRANSITION"] = "mdc-tooltip--hide-transition";
  25121. CssClasses["MULTILINE_TOOLTIP"] = "mdc-tooltip--multiline";
  25122. CssClasses["SURFACE"] = "mdc-tooltip__surface";
  25123. })(CssClasses || (CssClasses = {}));
  25124. exports.CssClasses = CssClasses;
  25125. var numbers = {
  25126. BOUNDED_ANCHOR_GAP: 4,
  25127. UNBOUNDED_ANCHOR_GAP: 8,
  25128. MIN_VIEWPORT_TOOLTIP_THRESHOLD: 8,
  25129. HIDE_DELAY_MS: 600,
  25130. SHOW_DELAY_MS: 500,
  25131. // LINT.IfChange(tooltip-dimensions)
  25132. MIN_HEIGHT: 24,
  25133. MAX_WIDTH: 200
  25134. };
  25135. exports.numbers = numbers;
  25136. var attributes = {
  25137. ARIA_EXPANDED: 'aria-expanded',
  25138. ARIA_HASPOPUP: 'aria-haspopup',
  25139. PERSISTENT: 'data-mdc-tooltip-persistent'
  25140. };
  25141. exports.attributes = attributes;
  25142. var events = {
  25143. HIDDEN: 'MDCTooltip:hidden'
  25144. };
  25145. exports.events = events;
  25146. /** Enum for possible tooltip positioning relative to its anchor element. */
  25147. var XPosition;
  25148. (function (XPosition) {
  25149. XPosition[XPosition["DETECTED"] = 0] = "DETECTED";
  25150. XPosition[XPosition["START"] = 1] = "START";
  25151. // Note: CENTER is not valid for rich tooltips.
  25152. XPosition[XPosition["CENTER"] = 2] = "CENTER";
  25153. XPosition[XPosition["END"] = 3] = "END";
  25154. })(XPosition || (XPosition = {}));
  25155. exports.XPosition = XPosition;
  25156. var YPosition;
  25157. (function (YPosition) {
  25158. YPosition[YPosition["DETECTED"] = 0] = "DETECTED";
  25159. YPosition[YPosition["ABOVE"] = 1] = "ABOVE";
  25160. YPosition[YPosition["BELOW"] = 2] = "BELOW";
  25161. })(YPosition || (YPosition = {}));
  25162. exports.YPosition = YPosition;
  25163. /**
  25164. * Enum for possible anchor boundary types. This determines the gap between the
  25165. * bottom of the anchor and the tooltip element.
  25166. * Bounded anchors have an identifiable boundary (e.g. buttons).
  25167. * Unbounded anchors don't have a visually declared boundary (e.g. plain text).
  25168. */
  25169. var AnchorBoundaryType;
  25170. (function (AnchorBoundaryType) {
  25171. AnchorBoundaryType[AnchorBoundaryType["BOUNDED"] = 0] = "BOUNDED";
  25172. AnchorBoundaryType[AnchorBoundaryType["UNBOUNDED"] = 1] = "UNBOUNDED";
  25173. })(AnchorBoundaryType || (AnchorBoundaryType = {}));
  25174. exports.AnchorBoundaryType = AnchorBoundaryType;
  25175. var strings = {
  25176. LEFT: 'left',
  25177. RIGHT: 'right',
  25178. CENTER: 'center',
  25179. TOP: 'top',
  25180. BOTTOM: 'bottom'
  25181. };
  25182. exports.strings = strings;
  25183. /***/ }),
  25184. /***/ "./packages/mdc-tooltip/foundation.ts":
  25185. /*!********************************************!*\
  25186. !*** ./packages/mdc-tooltip/foundation.ts ***!
  25187. \********************************************/
  25188. /*! no static exports found */
  25189. /***/ (function(module, exports, __webpack_require__) {
  25190. "use strict";
  25191. /**
  25192. * @license
  25193. * Copyright 2020 Google Inc.
  25194. *
  25195. * Permission is hereby granted, free of charge, to any person obtaining a copy
  25196. * of this software and associated documentation files (the "Software"), to deal
  25197. * in the Software without restriction, including without limitation the rights
  25198. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  25199. * copies of the Software, and to permit persons to whom the Software is
  25200. * furnished to do so, subject to the following conditions:
  25201. *
  25202. * The above copyright notice and this permission notice shall be included in
  25203. * all copies or substantial portions of the Software.
  25204. *
  25205. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25206. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25207. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25208. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25209. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25210. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25211. * THE SOFTWARE.
  25212. */
  25213. var __extends = this && this.__extends || function () {
  25214. var _extendStatics = function extendStatics(d, b) {
  25215. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  25216. d.__proto__ = b;
  25217. } || function (d, b) {
  25218. for (var p in b) {
  25219. if (b.hasOwnProperty(p)) d[p] = b[p];
  25220. }
  25221. };
  25222. return _extendStatics(d, b);
  25223. };
  25224. return function (d, b) {
  25225. _extendStatics(d, b);
  25226. function __() {
  25227. this.constructor = d;
  25228. }
  25229. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25230. };
  25231. }();
  25232. var __assign = this && this.__assign || function () {
  25233. __assign = Object.assign || function (t) {
  25234. for (var s, i = 1, n = arguments.length; i < n; i++) {
  25235. s = arguments[i];
  25236. for (var p in s) {
  25237. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  25238. }
  25239. }
  25240. return t;
  25241. };
  25242. return __assign.apply(this, arguments);
  25243. };
  25244. var __values = this && this.__values || function (o) {
  25245. var s = typeof Symbol === "function" && Symbol.iterator,
  25246. m = s && o[s],
  25247. i = 0;
  25248. if (m) return m.call(o);
  25249. if (o && typeof o.length === "number") return {
  25250. next: function next() {
  25251. if (o && i >= o.length) o = void 0;
  25252. return { value: o && o[i++], done: !o };
  25253. }
  25254. };
  25255. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  25256. };
  25257. Object.defineProperty(exports, "__esModule", { value: true });
  25258. var animationframe_1 = __webpack_require__(/*! @material/animation/animationframe */ "./packages/mdc-animation/animationframe.ts");
  25259. var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
  25260. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  25261. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  25262. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts");
  25263. var RICH = constants_1.CssClasses.RICH,
  25264. SHOWN = constants_1.CssClasses.SHOWN,
  25265. SHOWING = constants_1.CssClasses.SHOWING,
  25266. SHOWING_TRANSITION = constants_1.CssClasses.SHOWING_TRANSITION,
  25267. HIDE = constants_1.CssClasses.HIDE,
  25268. HIDE_TRANSITION = constants_1.CssClasses.HIDE_TRANSITION,
  25269. MULTILINE_TOOLTIP = constants_1.CssClasses.MULTILINE_TOOLTIP;
  25270. var AnimationKeys;
  25271. (function (AnimationKeys) {
  25272. AnimationKeys["POLL_ANCHOR"] = "poll_anchor";
  25273. })(AnimationKeys || (AnimationKeys = {}));
  25274. // Accessing `window` without a `typeof` check will throw on Node environments.
  25275. var HAS_WINDOW = typeof window !== 'undefined';
  25276. var MDCTooltipFoundation = /** @class */function (_super) {
  25277. __extends(MDCTooltipFoundation, _super);
  25278. function MDCTooltipFoundation(adapter) {
  25279. var _this = _super.call(this, __assign(__assign({}, MDCTooltipFoundation.defaultAdapter), adapter)) || this;
  25280. _this.tooltipShown = false;
  25281. _this.anchorGap = constants_1.numbers.BOUNDED_ANCHOR_GAP;
  25282. _this.xTooltipPos = constants_1.XPosition.DETECTED;
  25283. _this.yTooltipPos = constants_1.YPosition.DETECTED;
  25284. // Minimum threshold distance needed between the tooltip and the viewport.
  25285. _this.minViewportTooltipThreshold = constants_1.numbers.MIN_VIEWPORT_TOOLTIP_THRESHOLD;
  25286. _this.hideDelayMs = constants_1.numbers.HIDE_DELAY_MS;
  25287. _this.showDelayMs = constants_1.numbers.SHOW_DELAY_MS;
  25288. _this.anchorRect = null;
  25289. _this.parentRect = null;
  25290. _this.frameId = null;
  25291. _this.hideTimeout = null;
  25292. _this.showTimeout = null;
  25293. _this.animFrame = new animationframe_1.AnimationFrame();
  25294. _this.documentClickHandler = function (evt) {
  25295. _this.handleDocumentClick(evt);
  25296. };
  25297. _this.documentKeydownHandler = function (evt) {
  25298. _this.handleKeydown(evt);
  25299. };
  25300. _this.richTooltipMouseEnterHandler = function () {
  25301. _this.handleRichTooltipMouseEnter();
  25302. };
  25303. _this.richTooltipMouseLeaveHandler = function () {
  25304. _this.handleRichTooltipMouseLeave();
  25305. };
  25306. _this.richTooltipFocusOutHandler = function (evt) {
  25307. _this.handleRichTooltipFocusOut(evt);
  25308. };
  25309. _this.windowScrollHandler = function () {
  25310. _this.handleWindowChangeEvent();
  25311. };
  25312. _this.windowResizeHandler = function () {
  25313. _this.handleWindowChangeEvent();
  25314. };
  25315. return _this;
  25316. }
  25317. Object.defineProperty(MDCTooltipFoundation, "defaultAdapter", {
  25318. get: function get() {
  25319. return {
  25320. getAttribute: function getAttribute() {
  25321. return null;
  25322. },
  25323. setAttribute: function setAttribute() {
  25324. return undefined;
  25325. },
  25326. addClass: function addClass() {
  25327. return undefined;
  25328. },
  25329. hasClass: function hasClass() {
  25330. return false;
  25331. },
  25332. removeClass: function removeClass() {
  25333. return undefined;
  25334. },
  25335. getComputedStyleProperty: function getComputedStyleProperty() {
  25336. return '';
  25337. },
  25338. setStyleProperty: function setStyleProperty() {
  25339. return undefined;
  25340. },
  25341. setSurfaceStyleProperty: function setSurfaceStyleProperty() {
  25342. return undefined;
  25343. },
  25344. getViewportWidth: function getViewportWidth() {
  25345. return 0;
  25346. },
  25347. getViewportHeight: function getViewportHeight() {
  25348. return 0;
  25349. },
  25350. getTooltipSize: function getTooltipSize() {
  25351. return { width: 0, height: 0 };
  25352. },
  25353. getAnchorBoundingRect: function getAnchorBoundingRect() {
  25354. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  25355. },
  25356. getParentBoundingRect: function getParentBoundingRect() {
  25357. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  25358. },
  25359. getAnchorAttribute: function getAnchorAttribute() {
  25360. return null;
  25361. },
  25362. setAnchorAttribute: function setAnchorAttribute() {
  25363. return null;
  25364. },
  25365. isRTL: function isRTL() {
  25366. return false;
  25367. },
  25368. anchorContainsElement: function anchorContainsElement() {
  25369. return false;
  25370. },
  25371. tooltipContainsElement: function tooltipContainsElement() {
  25372. return false;
  25373. },
  25374. focusAnchorElement: function focusAnchorElement() {
  25375. return undefined;
  25376. },
  25377. registerEventHandler: function registerEventHandler() {
  25378. return undefined;
  25379. },
  25380. deregisterEventHandler: function deregisterEventHandler() {
  25381. return undefined;
  25382. },
  25383. registerDocumentEventHandler: function registerDocumentEventHandler() {
  25384. return undefined;
  25385. },
  25386. deregisterDocumentEventHandler: function deregisterDocumentEventHandler() {
  25387. return undefined;
  25388. },
  25389. registerWindowEventHandler: function registerWindowEventHandler() {
  25390. return undefined;
  25391. },
  25392. deregisterWindowEventHandler: function deregisterWindowEventHandler() {
  25393. return undefined;
  25394. },
  25395. notifyHidden: function notifyHidden() {
  25396. return undefined;
  25397. }
  25398. };
  25399. },
  25400. enumerable: true,
  25401. configurable: true
  25402. });
  25403. MDCTooltipFoundation.prototype.init = function () {
  25404. this.richTooltip = this.adapter.hasClass(RICH);
  25405. this.persistentTooltip = this.adapter.getAttribute(constants_1.attributes.PERSISTENT) === 'true';
  25406. this.interactiveTooltip = !!this.adapter.getAnchorAttribute(constants_1.attributes.ARIA_EXPANDED) && this.adapter.getAnchorAttribute(constants_1.attributes.ARIA_HASPOPUP) === 'dialog';
  25407. };
  25408. MDCTooltipFoundation.prototype.isShown = function () {
  25409. return this.tooltipShown;
  25410. };
  25411. MDCTooltipFoundation.prototype.isRich = function () {
  25412. return this.richTooltip;
  25413. };
  25414. MDCTooltipFoundation.prototype.isPersistent = function () {
  25415. return this.persistentTooltip;
  25416. };
  25417. MDCTooltipFoundation.prototype.handleAnchorMouseEnter = function () {
  25418. var _this = this;
  25419. if (this.tooltipShown) {
  25420. // Covers the instance where a user hovers over the anchor to reveal the
  25421. // tooltip, and then quickly navigates away and then back to the anchor.
  25422. // The tooltip should stay visible without animating out and then back in
  25423. // again.
  25424. this.show();
  25425. } else {
  25426. // clearHideTimeout here since handleAnchorMouseLeave sets a hideTimeout
  25427. // and that can execute before the showTimeout executes, resulting in hide
  25428. // being called and the showTimeout set below to be cleared.
  25429. this.clearHideTimeout();
  25430. this.showTimeout = setTimeout(function () {
  25431. _this.show();
  25432. }, this.showDelayMs);
  25433. }
  25434. };
  25435. MDCTooltipFoundation.prototype.handleAnchorFocus = function (evt) {
  25436. var _this = this;
  25437. // TODO(b/157075286): Need to add some way to distinguish keyboard
  25438. // navigation focus events from other focus events, and only show the
  25439. // tooltip on the former of these events.
  25440. var relatedTarget = evt.relatedTarget;
  25441. var tooltipContainsRelatedTarget = relatedTarget instanceof HTMLElement && this.adapter.tooltipContainsElement(relatedTarget);
  25442. // Do not show tooltip if the previous focus was on a tooltip element. This
  25443. // occurs when a rich tooltip is closed and focus is restored to the anchor
  25444. // or when user tab-navigates back into the anchor from the rich tooltip.
  25445. if (tooltipContainsRelatedTarget) {
  25446. return;
  25447. }
  25448. this.showTimeout = setTimeout(function () {
  25449. _this.show();
  25450. }, this.showDelayMs);
  25451. };
  25452. MDCTooltipFoundation.prototype.handleAnchorMouseLeave = function () {
  25453. var _this = this;
  25454. this.clearShowTimeout();
  25455. this.hideTimeout = setTimeout(function () {
  25456. _this.hide();
  25457. }, this.hideDelayMs);
  25458. };
  25459. MDCTooltipFoundation.prototype.handleAnchorBlur = function (evt) {
  25460. if (this.richTooltip) {
  25461. var tooltipContainsRelatedTargetElement = evt.relatedTarget instanceof HTMLElement && this.adapter.tooltipContainsElement(evt.relatedTarget);
  25462. // If focus changed to the tooltip element, don't hide the tooltip.
  25463. if (tooltipContainsRelatedTargetElement) {
  25464. return;
  25465. }
  25466. }
  25467. // Hide tooltip immediately on focus change.
  25468. this.hide();
  25469. };
  25470. MDCTooltipFoundation.prototype.handleAnchorClick = function () {
  25471. if (this.tooltipShown) {
  25472. this.hide();
  25473. } else {
  25474. this.show();
  25475. }
  25476. };
  25477. MDCTooltipFoundation.prototype.handleDocumentClick = function (evt) {
  25478. var anchorOrTooltipContainsTargetElement = evt.target instanceof HTMLElement && (this.adapter.anchorContainsElement(evt.target) || this.adapter.tooltipContainsElement(evt.target));
  25479. // For persistent rich tooltips, we will not hide if:
  25480. // - The click target is within the anchor element. Otherwise, both
  25481. // the anchor element's click handler and this handler will handle the
  25482. // click (due to event propagation), resulting in a shown tooltip
  25483. // being immediately hidden if the tooltip was initially hidden.
  25484. // - The click target is within the tooltip element, since clicks
  25485. // on the tooltip do not close the tooltip.
  25486. if (this.richTooltip && this.persistentTooltip && anchorOrTooltipContainsTargetElement) {
  25487. return;
  25488. }
  25489. // Hide the tooltip immediately on click.
  25490. this.hide();
  25491. };
  25492. MDCTooltipFoundation.prototype.handleKeydown = function (evt) {
  25493. // Hide the tooltip immediately on ESC key.
  25494. var key = keyboard_1.normalizeKey(evt);
  25495. if (key === keyboard_1.KEY.ESCAPE) {
  25496. var tooltipContainsActiveElement = document.activeElement instanceof HTMLElement && this.adapter.tooltipContainsElement(document.activeElement);
  25497. if (tooltipContainsActiveElement) {
  25498. this.adapter.focusAnchorElement();
  25499. }
  25500. this.hide();
  25501. }
  25502. };
  25503. MDCTooltipFoundation.prototype.handleRichTooltipMouseEnter = function () {
  25504. this.show();
  25505. };
  25506. MDCTooltipFoundation.prototype.handleRichTooltipMouseLeave = function () {
  25507. var _this = this;
  25508. this.clearShowTimeout();
  25509. this.hideTimeout = setTimeout(function () {
  25510. _this.hide();
  25511. }, this.hideDelayMs);
  25512. };
  25513. MDCTooltipFoundation.prototype.handleRichTooltipFocusOut = function (evt) {
  25514. var anchorOrTooltipContainsRelatedTargetElement = evt.relatedTarget instanceof HTMLElement && (this.adapter.anchorContainsElement(evt.relatedTarget) || this.adapter.tooltipContainsElement(evt.relatedTarget));
  25515. // If the focus is still within the anchor or the tooltip, do not hide the
  25516. // tooltip.
  25517. if (anchorOrTooltipContainsRelatedTargetElement) {
  25518. return;
  25519. }
  25520. this.hide();
  25521. };
  25522. /**
  25523. * On window resize or scroll, check the anchor position and size and
  25524. * repostion tooltip if necessary.
  25525. */
  25526. MDCTooltipFoundation.prototype.handleWindowChangeEvent = function () {
  25527. var _this = this;
  25528. // Since scroll and resize events can fire at a high rate, we throttle
  25529. // the potential re-positioning of tooltip component using
  25530. // requestAnimationFrame.
  25531. this.animFrame.request(AnimationKeys.POLL_ANCHOR, function () {
  25532. _this.repositionTooltipOnAnchorMove();
  25533. });
  25534. };
  25535. MDCTooltipFoundation.prototype.show = function () {
  25536. var _this = this;
  25537. this.clearHideTimeout();
  25538. this.clearShowTimeout();
  25539. if (this.tooltipShown) {
  25540. return;
  25541. }
  25542. this.tooltipShown = true;
  25543. var showTooltipOptions = this.parseShowTooltipOptions();
  25544. if (!showTooltipOptions.hideFromScreenreader) {
  25545. this.adapter.setAttribute('aria-hidden', 'false');
  25546. }
  25547. if (this.richTooltip) {
  25548. if (this.interactiveTooltip) {
  25549. this.adapter.setAnchorAttribute('aria-expanded', 'true');
  25550. }
  25551. this.adapter.registerEventHandler('focusout', this.richTooltipFocusOutHandler);
  25552. if (!this.persistentTooltip) {
  25553. this.adapter.registerEventHandler('mouseenter', this.richTooltipMouseEnterHandler);
  25554. this.adapter.registerEventHandler('mouseleave', this.richTooltipMouseLeaveHandler);
  25555. }
  25556. }
  25557. this.adapter.removeClass(HIDE);
  25558. this.adapter.addClass(SHOWING);
  25559. if (this.isTooltipMultiline() && !this.richTooltip) {
  25560. this.adapter.addClass(MULTILINE_TOOLTIP);
  25561. }
  25562. this.anchorRect = this.adapter.getAnchorBoundingRect();
  25563. this.parentRect = this.adapter.getParentBoundingRect();
  25564. this.richTooltip ? this.positionRichTooltip() : this.positionPlainTooltip();
  25565. this.adapter.registerDocumentEventHandler('click', this.documentClickHandler);
  25566. this.adapter.registerDocumentEventHandler('keydown', this.documentKeydownHandler);
  25567. this.adapter.registerWindowEventHandler('scroll', this.windowScrollHandler);
  25568. this.adapter.registerWindowEventHandler('resize', this.windowResizeHandler);
  25569. this.frameId = requestAnimationFrame(function () {
  25570. _this.clearAllAnimationClasses();
  25571. _this.adapter.addClass(SHOWN);
  25572. _this.adapter.addClass(SHOWING_TRANSITION);
  25573. });
  25574. };
  25575. MDCTooltipFoundation.prototype.hide = function () {
  25576. this.clearHideTimeout();
  25577. this.clearShowTimeout();
  25578. if (!this.tooltipShown) {
  25579. return;
  25580. }
  25581. if (this.frameId) {
  25582. cancelAnimationFrame(this.frameId);
  25583. }
  25584. this.tooltipShown = false;
  25585. this.adapter.setAttribute('aria-hidden', 'true');
  25586. this.adapter.deregisterEventHandler('focusout', this.richTooltipFocusOutHandler);
  25587. if (this.richTooltip) {
  25588. if (this.interactiveTooltip) {
  25589. this.adapter.setAnchorAttribute('aria-expanded', 'false');
  25590. }
  25591. if (!this.persistentTooltip) {
  25592. this.adapter.deregisterEventHandler('mouseenter', this.richTooltipMouseEnterHandler);
  25593. this.adapter.deregisterEventHandler('mouseleave', this.richTooltipMouseLeaveHandler);
  25594. }
  25595. }
  25596. this.clearAllAnimationClasses();
  25597. this.adapter.addClass(HIDE);
  25598. this.adapter.addClass(HIDE_TRANSITION);
  25599. this.adapter.removeClass(SHOWN);
  25600. this.adapter.deregisterDocumentEventHandler('click', this.documentClickHandler);
  25601. this.adapter.deregisterDocumentEventHandler('keydown', this.documentKeydownHandler);
  25602. this.adapter.deregisterWindowEventHandler('scroll', this.windowScrollHandler);
  25603. this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
  25604. };
  25605. MDCTooltipFoundation.prototype.handleTransitionEnd = function () {
  25606. var isHidingTooltip = this.adapter.hasClass(HIDE);
  25607. this.adapter.removeClass(SHOWING);
  25608. this.adapter.removeClass(SHOWING_TRANSITION);
  25609. this.adapter.removeClass(HIDE);
  25610. this.adapter.removeClass(HIDE_TRANSITION);
  25611. // If handleTransitionEnd is called after hiding the tooltip, the tooltip
  25612. // will have the HIDE class (before calling the adapter removeClass method).
  25613. // If tooltip is now hidden, send a notification that the animation has
  25614. // completed and the tooltip is no longer visible.
  25615. if (isHidingTooltip) {
  25616. this.adapter.notifyHidden();
  25617. }
  25618. };
  25619. MDCTooltipFoundation.prototype.clearAllAnimationClasses = function () {
  25620. this.adapter.removeClass(SHOWING_TRANSITION);
  25621. this.adapter.removeClass(HIDE_TRANSITION);
  25622. };
  25623. MDCTooltipFoundation.prototype.setTooltipPosition = function (position) {
  25624. var xPos = position.xPos,
  25625. yPos = position.yPos;
  25626. if (xPos) {
  25627. this.xTooltipPos = xPos;
  25628. }
  25629. if (yPos) {
  25630. this.yTooltipPos = yPos;
  25631. }
  25632. };
  25633. MDCTooltipFoundation.prototype.setAnchorBoundaryType = function (type) {
  25634. if (type === constants_1.AnchorBoundaryType.UNBOUNDED) {
  25635. this.anchorGap = constants_1.numbers.UNBOUNDED_ANCHOR_GAP;
  25636. } else {
  25637. this.anchorGap = constants_1.numbers.BOUNDED_ANCHOR_GAP;
  25638. }
  25639. };
  25640. MDCTooltipFoundation.prototype.parseShowTooltipOptions = function () {
  25641. var hideFromScreenreader = Boolean(this.adapter.getAnchorAttribute('data-tooltip-id'));
  25642. return { hideFromScreenreader: hideFromScreenreader };
  25643. };
  25644. MDCTooltipFoundation.prototype.isTooltipMultiline = function () {
  25645. var tooltipSize = this.adapter.getTooltipSize();
  25646. return tooltipSize.height > constants_1.numbers.MIN_HEIGHT && tooltipSize.width >= constants_1.numbers.MAX_WIDTH;
  25647. };
  25648. MDCTooltipFoundation.prototype.positionPlainTooltip = function () {
  25649. // A plain tooltip has `fixed` positioning and is placed as an immediate
  25650. // child of the document body. Its positioning is calculated with respect to
  25651. // the viewport.
  25652. var _a = this.calculateTooltipStyles(this.anchorRect),
  25653. top = _a.top,
  25654. yTransformOrigin = _a.yTransformOrigin,
  25655. left = _a.left,
  25656. xTransformOrigin = _a.xTransformOrigin;
  25657. var transformProperty = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
  25658. this.adapter.setSurfaceStyleProperty(transformProperty + "-origin", yTransformOrigin + " " + xTransformOrigin);
  25659. this.adapter.setStyleProperty('top', top + "px");
  25660. this.adapter.setStyleProperty('left', left + "px");
  25661. };
  25662. MDCTooltipFoundation.prototype.positionRichTooltip = function () {
  25663. // TODO(b/177686782): Remove width setting when max-content is used to style
  25664. // the rich tooltip.
  25665. var _a, _b, _c, _d;
  25666. // getComputedStyleProperty is used instead of getTooltipSize since
  25667. // getTooltipSize returns the offSetWidth, which includes the border and
  25668. // padding. What we need is the width of the tooltip without border and
  25669. // padding.
  25670. var width = this.adapter.getComputedStyleProperty('width');
  25671. // When rich tooltips are positioned within their parent containers, the
  25672. // tooltip width might be shrunk if it collides with the edge of the parent
  25673. // container. We set the width of the tooltip to prevent this.
  25674. this.adapter.setStyleProperty('width', width);
  25675. var _e = this.calculateTooltipStyles(this.anchorRect),
  25676. top = _e.top,
  25677. yTransformOrigin = _e.yTransformOrigin,
  25678. left = _e.left,
  25679. xTransformOrigin = _e.xTransformOrigin;
  25680. var transformProperty = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
  25681. this.adapter.setSurfaceStyleProperty(transformProperty + "-origin", yTransformOrigin + " " + xTransformOrigin);
  25682. // A rich tooltip has `absolute` positioning and is placed as a sibling to
  25683. // the anchor element. Its positioning is calculated with respect to the
  25684. // parent element, and so the values need to be adjusted against the parent
  25685. // element.
  25686. var leftAdjustment = left - ((_b = (_a = this.parentRect) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0);
  25687. var topAdjustment = top - ((_d = (_c = this.parentRect) === null || _c === void 0 ? void 0 : _c.top) !== null && _d !== void 0 ? _d : 0);
  25688. this.adapter.setStyleProperty('top', topAdjustment + "px");
  25689. this.adapter.setStyleProperty('left', leftAdjustment + "px");
  25690. };
  25691. /**
  25692. * Calculates the position of the tooltip. A tooltip will be placed beneath
  25693. * the anchor element and aligned either with the 'start'/'end' edge of the
  25694. * anchor element or the 'center'.
  25695. *
  25696. * Tooltip alignment is selected such that the tooltip maintains a threshold
  25697. * distance away from the viewport (defaulting to 'center' alignment). If the
  25698. * placement of the anchor prevents this threshold distance from being
  25699. * maintained, the tooltip is positioned so that it does not collide with the
  25700. * viewport.
  25701. *
  25702. * Users can specify an alignment, however, if this alignment results in the
  25703. * tooltip colliding with the viewport, this specification is overwritten.
  25704. */
  25705. MDCTooltipFoundation.prototype.calculateTooltipStyles = function (anchorRect) {
  25706. if (!anchorRect) {
  25707. return { top: 0, left: 0 };
  25708. }
  25709. var tooltipSize = this.adapter.getTooltipSize();
  25710. var top = this.calculateYTooltipDistance(anchorRect, tooltipSize.height);
  25711. var left = this.calculateXTooltipDistance(anchorRect, tooltipSize.width);
  25712. return {
  25713. top: top.distance,
  25714. yTransformOrigin: top.yTransformOrigin,
  25715. left: left.distance,
  25716. xTransformOrigin: left.xTransformOrigin
  25717. };
  25718. };
  25719. /**
  25720. * Calculates the `left` distance for the tooltip.
  25721. * Returns the distance value and a string indicating the x-axis transform-
  25722. * origin that should be used when animating the tooltip.
  25723. */
  25724. MDCTooltipFoundation.prototype.calculateXTooltipDistance = function (anchorRect, tooltipWidth) {
  25725. var isLTR = !this.adapter.isRTL();
  25726. var startPos, endPos, centerPos;
  25727. var startTransformOrigin, endTransformOrigin;
  25728. if (this.richTooltip) {
  25729. startPos = isLTR ? anchorRect.left - tooltipWidth : anchorRect.right;
  25730. endPos = isLTR ? anchorRect.right : anchorRect.left - tooltipWidth;
  25731. startTransformOrigin = isLTR ? constants_1.strings.RIGHT : constants_1.strings.LEFT;
  25732. endTransformOrigin = isLTR ? constants_1.strings.LEFT : constants_1.strings.RIGHT;
  25733. } else {
  25734. startPos = isLTR ? anchorRect.left : anchorRect.right - tooltipWidth;
  25735. endPos = isLTR ? anchorRect.right - tooltipWidth : anchorRect.left;
  25736. centerPos = anchorRect.left + (anchorRect.width - tooltipWidth) / 2;
  25737. startTransformOrigin = isLTR ? constants_1.strings.LEFT : constants_1.strings.RIGHT;
  25738. endTransformOrigin = isLTR ? constants_1.strings.RIGHT : constants_1.strings.LEFT;
  25739. }
  25740. var positionOptions = this.richTooltip ? this.determineValidPositionOptions(startPos, endPos) :
  25741. // For plain tooltips, centerPos is defined
  25742. this.determineValidPositionOptions(centerPos, startPos, endPos);
  25743. if (this.xTooltipPos === constants_1.XPosition.START && positionOptions.has(startPos)) {
  25744. return { distance: startPos, xTransformOrigin: startTransformOrigin };
  25745. }
  25746. if (this.xTooltipPos === constants_1.XPosition.END && positionOptions.has(endPos)) {
  25747. return { distance: endPos, xTransformOrigin: endTransformOrigin };
  25748. }
  25749. if (this.xTooltipPos === constants_1.XPosition.CENTER && positionOptions.has(centerPos)) {
  25750. // This code path is only executed if calculating the distance for plain
  25751. // tooltips. In this instance, centerPos will always be defined, so we can
  25752. // safely assert that the returned value is non-null/undefined.
  25753. return { distance: centerPos, xTransformOrigin: constants_1.strings.CENTER };
  25754. }
  25755. // If no user position is supplied, rich tooltips default to end pos, then
  25756. // start position. Plain tooltips default to center, start, then end.
  25757. var possiblePositions = this.richTooltip ? [{ distance: endPos, xTransformOrigin: endTransformOrigin }, { distance: startPos, xTransformOrigin: startTransformOrigin }] : [{ distance: centerPos, xTransformOrigin: constants_1.strings.CENTER }, { distance: startPos, xTransformOrigin: startTransformOrigin }, { distance: endPos, xTransformOrigin: endTransformOrigin }];
  25758. var validPosition = possiblePositions.find(function (_a) {
  25759. var distance = _a.distance;
  25760. return positionOptions.has(distance);
  25761. });
  25762. if (validPosition) {
  25763. return validPosition;
  25764. }
  25765. // Indicates that all potential positions would result in the tooltip
  25766. // colliding with the viewport. This would only occur when the anchor
  25767. // element itself collides with the viewport, or the viewport is very
  25768. // narrow. In this case, we allow the tooltip to be mis-aligned from the
  25769. // anchor element.
  25770. if (anchorRect.left < 0) {
  25771. return {
  25772. distance: this.minViewportTooltipThreshold,
  25773. xTransformOrigin: constants_1.strings.LEFT
  25774. };
  25775. } else {
  25776. var viewportWidth = this.adapter.getViewportWidth();
  25777. var distance = viewportWidth - (tooltipWidth + this.minViewportTooltipThreshold);
  25778. return { distance: distance, xTransformOrigin: constants_1.strings.RIGHT };
  25779. }
  25780. };
  25781. /**
  25782. * Given the values for the horizontal alignments of the tooltip, calculates
  25783. * which of these options would result in the tooltip maintaining the required
  25784. * threshold distance vs which would result in the tooltip staying within the
  25785. * viewport.
  25786. *
  25787. * A Set of values is returned holding the distances that would honor the
  25788. * above requirements. Following the logic for determining the tooltip
  25789. * position, if all alignments violate the threshold, then the returned Set
  25790. * contains values that keep the tooltip within the viewport.
  25791. */
  25792. MDCTooltipFoundation.prototype.determineValidPositionOptions = function () {
  25793. var e_1, _a;
  25794. var positions = [];
  25795. for (var _i = 0; _i < arguments.length; _i++) {
  25796. positions[_i] = arguments[_i];
  25797. }
  25798. var posWithinThreshold = new Set();
  25799. var posWithinViewport = new Set();
  25800. try {
  25801. for (var positions_1 = __values(positions), positions_1_1 = positions_1.next(); !positions_1_1.done; positions_1_1 = positions_1.next()) {
  25802. var position = positions_1_1.value;
  25803. if (this.positionHonorsViewportThreshold(position)) {
  25804. posWithinThreshold.add(position);
  25805. } else if (this.positionDoesntCollideWithViewport(position)) {
  25806. posWithinViewport.add(position);
  25807. }
  25808. }
  25809. } catch (e_1_1) {
  25810. e_1 = { error: e_1_1 };
  25811. } finally {
  25812. try {
  25813. if (positions_1_1 && !positions_1_1.done && (_a = positions_1.return)) _a.call(positions_1);
  25814. } finally {
  25815. if (e_1) throw e_1.error;
  25816. }
  25817. }
  25818. return posWithinThreshold.size ? posWithinThreshold : posWithinViewport;
  25819. };
  25820. MDCTooltipFoundation.prototype.positionHonorsViewportThreshold = function (leftPos) {
  25821. var viewportWidth = this.adapter.getViewportWidth();
  25822. var tooltipWidth = this.adapter.getTooltipSize().width;
  25823. return leftPos + tooltipWidth <= viewportWidth - this.minViewportTooltipThreshold && leftPos >= this.minViewportTooltipThreshold;
  25824. };
  25825. MDCTooltipFoundation.prototype.positionDoesntCollideWithViewport = function (leftPos) {
  25826. var viewportWidth = this.adapter.getViewportWidth();
  25827. var tooltipWidth = this.adapter.getTooltipSize().width;
  25828. return leftPos + tooltipWidth <= viewportWidth && leftPos >= 0;
  25829. };
  25830. /**
  25831. * Calculates the `top` distance for the tooltip.
  25832. * Returns the distance value and a string indicating the y-axis transform-
  25833. * origin that should be used when animating the tooltip.
  25834. */
  25835. MDCTooltipFoundation.prototype.calculateYTooltipDistance = function (anchorRect, tooltipHeight) {
  25836. var belowYPos = anchorRect.bottom + this.anchorGap;
  25837. var aboveYPos = anchorRect.top - (this.anchorGap + tooltipHeight);
  25838. var yPositionOptions = this.determineValidYPositionOptions(aboveYPos, belowYPos);
  25839. if (this.yTooltipPos === constants_1.YPosition.ABOVE && yPositionOptions.has(aboveYPos)) {
  25840. return { distance: aboveYPos, yTransformOrigin: constants_1.strings.BOTTOM };
  25841. } else if (this.yTooltipPos === constants_1.YPosition.BELOW && yPositionOptions.has(belowYPos)) {
  25842. return { distance: belowYPos, yTransformOrigin: constants_1.strings.TOP };
  25843. }
  25844. if (yPositionOptions.has(belowYPos)) {
  25845. return { distance: belowYPos, yTransformOrigin: constants_1.strings.TOP };
  25846. }
  25847. if (yPositionOptions.has(aboveYPos)) {
  25848. return { distance: aboveYPos, yTransformOrigin: constants_1.strings.BOTTOM };
  25849. }
  25850. // Indicates that all potential positions would result in the tooltip
  25851. // colliding with the viewport. This would only occur when the viewport is
  25852. // very short.
  25853. return { distance: belowYPos, yTransformOrigin: constants_1.strings.TOP };
  25854. };
  25855. /**
  25856. * Given the values for above/below alignment of the tooltip, calculates
  25857. * which of these options would result in the tooltip maintaining the required
  25858. * threshold distance vs which would result in the tooltip staying within the
  25859. * viewport.
  25860. *
  25861. * A Set of values is returned holding the distances that would honor the
  25862. * above requirements. Following the logic for determining the tooltip
  25863. * position, if all possible alignments violate the threshold, then the
  25864. * returned Set contains values that keep the tooltip within the viewport.
  25865. */
  25866. MDCTooltipFoundation.prototype.determineValidYPositionOptions = function (aboveAnchorPos, belowAnchorPos) {
  25867. var posWithinThreshold = new Set();
  25868. var posWithinViewport = new Set();
  25869. if (this.yPositionHonorsViewportThreshold(aboveAnchorPos)) {
  25870. posWithinThreshold.add(aboveAnchorPos);
  25871. } else if (this.yPositionDoesntCollideWithViewport(aboveAnchorPos)) {
  25872. posWithinViewport.add(aboveAnchorPos);
  25873. }
  25874. if (this.yPositionHonorsViewportThreshold(belowAnchorPos)) {
  25875. posWithinThreshold.add(belowAnchorPos);
  25876. } else if (this.yPositionDoesntCollideWithViewport(belowAnchorPos)) {
  25877. posWithinViewport.add(belowAnchorPos);
  25878. }
  25879. return posWithinThreshold.size ? posWithinThreshold : posWithinViewport;
  25880. };
  25881. MDCTooltipFoundation.prototype.yPositionHonorsViewportThreshold = function (yPos) {
  25882. var viewportHeight = this.adapter.getViewportHeight();
  25883. var tooltipHeight = this.adapter.getTooltipSize().height;
  25884. return yPos + tooltipHeight + this.minViewportTooltipThreshold <= viewportHeight && yPos >= this.minViewportTooltipThreshold;
  25885. };
  25886. MDCTooltipFoundation.prototype.yPositionDoesntCollideWithViewport = function (yPos) {
  25887. var viewportHeight = this.adapter.getViewportHeight();
  25888. var tooltipHeight = this.adapter.getTooltipSize().height;
  25889. return yPos + tooltipHeight <= viewportHeight && yPos >= 0;
  25890. };
  25891. MDCTooltipFoundation.prototype.repositionTooltipOnAnchorMove = function () {
  25892. var newAnchorRect = this.adapter.getAnchorBoundingRect();
  25893. if (!newAnchorRect || !this.anchorRect) return;
  25894. if (newAnchorRect.top !== this.anchorRect.top || newAnchorRect.left !== this.anchorRect.left || newAnchorRect.height !== this.anchorRect.height || newAnchorRect.width !== this.anchorRect.width) {
  25895. this.anchorRect = newAnchorRect;
  25896. this.parentRect = this.adapter.getParentBoundingRect();
  25897. this.richTooltip ? this.positionRichTooltip() : this.positionPlainTooltip();
  25898. }
  25899. };
  25900. MDCTooltipFoundation.prototype.clearShowTimeout = function () {
  25901. if (this.showTimeout) {
  25902. clearTimeout(this.showTimeout);
  25903. this.showTimeout = null;
  25904. }
  25905. };
  25906. MDCTooltipFoundation.prototype.clearHideTimeout = function () {
  25907. if (this.hideTimeout) {
  25908. clearTimeout(this.hideTimeout);
  25909. this.hideTimeout = null;
  25910. }
  25911. };
  25912. MDCTooltipFoundation.prototype.destroy = function () {
  25913. if (this.frameId) {
  25914. cancelAnimationFrame(this.frameId);
  25915. this.frameId = null;
  25916. }
  25917. this.clearHideTimeout();
  25918. this.clearShowTimeout();
  25919. this.adapter.removeClass(SHOWN);
  25920. this.adapter.removeClass(SHOWING_TRANSITION);
  25921. this.adapter.removeClass(SHOWING);
  25922. this.adapter.removeClass(HIDE);
  25923. this.adapter.removeClass(HIDE_TRANSITION);
  25924. if (this.richTooltip) {
  25925. this.adapter.deregisterEventHandler('focusout', this.richTooltipFocusOutHandler);
  25926. if (!this.persistentTooltip) {
  25927. this.adapter.deregisterEventHandler('mouseenter', this.richTooltipMouseEnterHandler);
  25928. this.adapter.deregisterEventHandler('mouseleave', this.richTooltipMouseLeaveHandler);
  25929. }
  25930. }
  25931. this.adapter.deregisterDocumentEventHandler('click', this.documentClickHandler);
  25932. this.adapter.deregisterDocumentEventHandler('keydown', this.documentKeydownHandler);
  25933. this.adapter.deregisterWindowEventHandler('scroll', this.windowScrollHandler);
  25934. this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
  25935. this.animFrame.cancelAll();
  25936. };
  25937. return MDCTooltipFoundation;
  25938. }(foundation_1.MDCFoundation);
  25939. exports.MDCTooltipFoundation = MDCTooltipFoundation;
  25940. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  25941. exports.default = MDCTooltipFoundation;
  25942. /***/ }),
  25943. /***/ "./packages/mdc-tooltip/index.ts":
  25944. /*!***************************************!*\
  25945. !*** ./packages/mdc-tooltip/index.ts ***!
  25946. \***************************************/
  25947. /*! no static exports found */
  25948. /***/ (function(module, exports, __webpack_require__) {
  25949. "use strict";
  25950. /**
  25951. * @license
  25952. * Copyright 2020 Google Inc.
  25953. *
  25954. * Permission is hereby granted, free of charge, to any person obtaining a copy
  25955. * of this software and associated documentation files (the "Software"), to deal
  25956. * in the Software without restriction, including without limitation the rights
  25957. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  25958. * copies of the Software, and to permit persons to whom the Software is
  25959. * furnished to do so, subject to the following conditions:
  25960. *
  25961. * The above copyright notice and this permission notice shall be included in
  25962. * all copies or substantial portions of the Software.
  25963. *
  25964. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25965. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25966. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25967. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25968. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25969. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25970. * THE SOFTWARE.
  25971. */
  25972. function __export(m) {
  25973. for (var p in m) {
  25974. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  25975. }
  25976. }
  25977. Object.defineProperty(exports, "__esModule", { value: true });
  25978. __export(__webpack_require__(/*! ./component */ "./packages/mdc-tooltip/component.ts"));
  25979. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tooltip/foundation.ts"));
  25980. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts"));
  25981. /***/ }),
  25982. /***/ "./packages/mdc-top-app-bar/component.ts":
  25983. /*!***********************************************!*\
  25984. !*** ./packages/mdc-top-app-bar/component.ts ***!
  25985. \***********************************************/
  25986. /*! no static exports found */
  25987. /***/ (function(module, exports, __webpack_require__) {
  25988. "use strict";
  25989. /**
  25990. * @license
  25991. * Copyright 2018 Google Inc.
  25992. *
  25993. * Permission is hereby granted, free of charge, to any person obtaining a copy
  25994. * of this software and associated documentation files (the "Software"), to deal
  25995. * in the Software without restriction, including without limitation the rights
  25996. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  25997. * copies of the Software, and to permit persons to whom the Software is
  25998. * furnished to do so, subject to the following conditions:
  25999. *
  26000. * The above copyright notice and this permission notice shall be included in
  26001. * all copies or substantial portions of the Software.
  26002. *
  26003. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26004. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26005. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26006. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26007. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26008. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26009. * THE SOFTWARE.
  26010. */
  26011. var __extends = this && this.__extends || function () {
  26012. var _extendStatics = function extendStatics(d, b) {
  26013. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  26014. d.__proto__ = b;
  26015. } || function (d, b) {
  26016. for (var p in b) {
  26017. if (b.hasOwnProperty(p)) d[p] = b[p];
  26018. }
  26019. };
  26020. return _extendStatics(d, b);
  26021. };
  26022. return function (d, b) {
  26023. _extendStatics(d, b);
  26024. function __() {
  26025. this.constructor = d;
  26026. }
  26027. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26028. };
  26029. }();
  26030. Object.defineProperty(exports, "__esModule", { value: true });
  26031. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  26032. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  26033. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts");
  26034. var foundation_1 = __webpack_require__(/*! ./fixed/foundation */ "./packages/mdc-top-app-bar/fixed/foundation.ts");
  26035. var foundation_2 = __webpack_require__(/*! ./short/foundation */ "./packages/mdc-top-app-bar/short/foundation.ts");
  26036. var foundation_3 = __webpack_require__(/*! ./standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts");
  26037. var MDCTopAppBar = /** @class */function (_super) {
  26038. __extends(MDCTopAppBar, _super);
  26039. function MDCTopAppBar() {
  26040. return _super !== null && _super.apply(this, arguments) || this;
  26041. }
  26042. MDCTopAppBar.attachTo = function (root) {
  26043. return new MDCTopAppBar(root);
  26044. };
  26045. MDCTopAppBar.prototype.initialize = function (rippleFactory) {
  26046. if (rippleFactory === void 0) {
  26047. rippleFactory = function rippleFactory(el) {
  26048. return component_2.MDCRipple.attachTo(el);
  26049. };
  26050. }
  26051. this.navIcon_ = this.root.querySelector(constants_1.strings.NAVIGATION_ICON_SELECTOR);
  26052. // Get all icons in the toolbar and instantiate the ripples
  26053. var icons = [].slice.call(this.root.querySelectorAll(constants_1.strings.ACTION_ITEM_SELECTOR));
  26054. if (this.navIcon_) {
  26055. icons.push(this.navIcon_);
  26056. }
  26057. this.iconRipples_ = icons.map(function (icon) {
  26058. var ripple = rippleFactory(icon);
  26059. ripple.unbounded = true;
  26060. return ripple;
  26061. });
  26062. this.scrollTarget_ = window;
  26063. };
  26064. MDCTopAppBar.prototype.initialSyncWithDOM = function () {
  26065. this.handleNavigationClick_ = this.foundation.handleNavigationClick.bind(this.foundation);
  26066. this.handleWindowResize_ = this.foundation.handleWindowResize.bind(this.foundation);
  26067. this.handleTargetScroll_ = this.foundation.handleTargetScroll.bind(this.foundation);
  26068. this.scrollTarget_.addEventListener('scroll', this.handleTargetScroll_);
  26069. if (this.navIcon_) {
  26070. this.navIcon_.addEventListener('click', this.handleNavigationClick_);
  26071. }
  26072. var isFixed = this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS);
  26073. var isShort = this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS);
  26074. if (!isShort && !isFixed) {
  26075. window.addEventListener('resize', this.handleWindowResize_);
  26076. }
  26077. };
  26078. MDCTopAppBar.prototype.destroy = function () {
  26079. this.iconRipples_.forEach(function (iconRipple) {
  26080. return iconRipple.destroy();
  26081. });
  26082. this.scrollTarget_.removeEventListener('scroll', this.handleTargetScroll_);
  26083. if (this.navIcon_) {
  26084. this.navIcon_.removeEventListener('click', this.handleNavigationClick_);
  26085. }
  26086. var isFixed = this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS);
  26087. var isShort = this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS);
  26088. if (!isShort && !isFixed) {
  26089. window.removeEventListener('resize', this.handleWindowResize_);
  26090. }
  26091. _super.prototype.destroy.call(this);
  26092. };
  26093. MDCTopAppBar.prototype.setScrollTarget = function (target) {
  26094. // Remove scroll handler from the previous scroll target
  26095. this.scrollTarget_.removeEventListener('scroll', this.handleTargetScroll_);
  26096. this.scrollTarget_ = target;
  26097. // Initialize scroll handler on the new scroll target
  26098. this.handleTargetScroll_ = this.foundation.handleTargetScroll.bind(this.foundation);
  26099. this.scrollTarget_.addEventListener('scroll', this.handleTargetScroll_);
  26100. };
  26101. MDCTopAppBar.prototype.getDefaultFoundation = function () {
  26102. var _this = this;
  26103. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  26104. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  26105. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  26106. var adapter = {
  26107. hasClass: function hasClass(className) {
  26108. return _this.root.classList.contains(className);
  26109. },
  26110. addClass: function addClass(className) {
  26111. return _this.root.classList.add(className);
  26112. },
  26113. removeClass: function removeClass(className) {
  26114. return _this.root.classList.remove(className);
  26115. },
  26116. setStyle: function setStyle(property, value) {
  26117. return _this.root.style.setProperty(property, value);
  26118. },
  26119. getTopAppBarHeight: function getTopAppBarHeight() {
  26120. return _this.root.clientHeight;
  26121. },
  26122. notifyNavigationIconClicked: function notifyNavigationIconClicked() {
  26123. return _this.emit(constants_1.strings.NAVIGATION_EVENT, {});
  26124. },
  26125. getViewportScrollY: function getViewportScrollY() {
  26126. var win = _this.scrollTarget_;
  26127. var el = _this.scrollTarget_;
  26128. return win.pageYOffset !== undefined ? win.pageYOffset : el.scrollTop;
  26129. },
  26130. getTotalActionItems: function getTotalActionItems() {
  26131. return _this.root.querySelectorAll(constants_1.strings.ACTION_ITEM_SELECTOR).length;
  26132. }
  26133. };
  26134. // tslint:enable:object-literal-sort-keys
  26135. var foundation;
  26136. if (this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS)) {
  26137. foundation = new foundation_2.MDCShortTopAppBarFoundation(adapter);
  26138. } else if (this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS)) {
  26139. foundation = new foundation_1.MDCFixedTopAppBarFoundation(adapter);
  26140. } else {
  26141. foundation = new foundation_3.MDCTopAppBarFoundation(adapter);
  26142. }
  26143. return foundation;
  26144. };
  26145. return MDCTopAppBar;
  26146. }(component_1.MDCComponent);
  26147. exports.MDCTopAppBar = MDCTopAppBar;
  26148. /***/ }),
  26149. /***/ "./packages/mdc-top-app-bar/constants.ts":
  26150. /*!***********************************************!*\
  26151. !*** ./packages/mdc-top-app-bar/constants.ts ***!
  26152. \***********************************************/
  26153. /*! no static exports found */
  26154. /***/ (function(module, exports, __webpack_require__) {
  26155. "use strict";
  26156. /**
  26157. * @license
  26158. * Copyright 2018 Google Inc.
  26159. *
  26160. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26161. * of this software and associated documentation files (the "Software"), to deal
  26162. * in the Software without restriction, including without limitation the rights
  26163. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26164. * copies of the Software, and to permit persons to whom the Software is
  26165. * furnished to do so, subject to the following conditions:
  26166. *
  26167. * The above copyright notice and this permission notice shall be included in
  26168. * all copies or substantial portions of the Software.
  26169. *
  26170. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26171. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26172. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26173. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26174. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26175. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26176. * THE SOFTWARE.
  26177. */
  26178. Object.defineProperty(exports, "__esModule", { value: true });
  26179. var cssClasses = {
  26180. FIXED_CLASS: 'mdc-top-app-bar--fixed',
  26181. FIXED_SCROLLED_CLASS: 'mdc-top-app-bar--fixed-scrolled',
  26182. SHORT_CLASS: 'mdc-top-app-bar--short',
  26183. SHORT_COLLAPSED_CLASS: 'mdc-top-app-bar--short-collapsed',
  26184. SHORT_HAS_ACTION_ITEM_CLASS: 'mdc-top-app-bar--short-has-action-item'
  26185. };
  26186. exports.cssClasses = cssClasses;
  26187. var numbers = {
  26188. DEBOUNCE_THROTTLE_RESIZE_TIME_MS: 100,
  26189. MAX_TOP_APP_BAR_HEIGHT: 128
  26190. };
  26191. exports.numbers = numbers;
  26192. var strings = {
  26193. ACTION_ITEM_SELECTOR: '.mdc-top-app-bar__action-item',
  26194. NAVIGATION_EVENT: 'MDCTopAppBar:nav',
  26195. NAVIGATION_ICON_SELECTOR: '.mdc-top-app-bar__navigation-icon',
  26196. ROOT_SELECTOR: '.mdc-top-app-bar',
  26197. TITLE_SELECTOR: '.mdc-top-app-bar__title'
  26198. };
  26199. exports.strings = strings;
  26200. /***/ }),
  26201. /***/ "./packages/mdc-top-app-bar/fixed/foundation.ts":
  26202. /*!******************************************************!*\
  26203. !*** ./packages/mdc-top-app-bar/fixed/foundation.ts ***!
  26204. \******************************************************/
  26205. /*! no static exports found */
  26206. /***/ (function(module, exports, __webpack_require__) {
  26207. "use strict";
  26208. /**
  26209. * @license
  26210. * Copyright 2018 Google Inc.
  26211. *
  26212. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26213. * of this software and associated documentation files (the "Software"), to deal
  26214. * in the Software without restriction, including without limitation the rights
  26215. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26216. * copies of the Software, and to permit persons to whom the Software is
  26217. * furnished to do so, subject to the following conditions:
  26218. *
  26219. * The above copyright notice and this permission notice shall be included in
  26220. * all copies or substantial portions of the Software.
  26221. *
  26222. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26223. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26224. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26225. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26226. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26227. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26228. * THE SOFTWARE.
  26229. */
  26230. var __extends = this && this.__extends || function () {
  26231. var _extendStatics = function extendStatics(d, b) {
  26232. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  26233. d.__proto__ = b;
  26234. } || function (d, b) {
  26235. for (var p in b) {
  26236. if (b.hasOwnProperty(p)) d[p] = b[p];
  26237. }
  26238. };
  26239. return _extendStatics(d, b);
  26240. };
  26241. return function (d, b) {
  26242. _extendStatics(d, b);
  26243. function __() {
  26244. this.constructor = d;
  26245. }
  26246. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26247. };
  26248. }();
  26249. Object.defineProperty(exports, "__esModule", { value: true });
  26250. var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
  26251. var foundation_1 = __webpack_require__(/*! ../standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts");
  26252. var MDCFixedTopAppBarFoundation = /** @class */function (_super) {
  26253. __extends(MDCFixedTopAppBarFoundation, _super);
  26254. function MDCFixedTopAppBarFoundation() {
  26255. var _this = _super !== null && _super.apply(this, arguments) || this;
  26256. /**
  26257. * State variable for the previous scroll iteration top app bar state
  26258. */
  26259. _this.wasScrolled_ = false;
  26260. return _this;
  26261. }
  26262. /**
  26263. * Scroll handler for applying/removing the modifier class on the fixed top app bar.
  26264. * @override
  26265. */
  26266. MDCFixedTopAppBarFoundation.prototype.handleTargetScroll = function () {
  26267. var currentScroll = this.adapter.getViewportScrollY();
  26268. if (currentScroll <= 0) {
  26269. if (this.wasScrolled_) {
  26270. this.adapter.removeClass(constants_1.cssClasses.FIXED_SCROLLED_CLASS);
  26271. this.wasScrolled_ = false;
  26272. }
  26273. } else {
  26274. if (!this.wasScrolled_) {
  26275. this.adapter.addClass(constants_1.cssClasses.FIXED_SCROLLED_CLASS);
  26276. this.wasScrolled_ = true;
  26277. }
  26278. }
  26279. };
  26280. return MDCFixedTopAppBarFoundation;
  26281. }(foundation_1.MDCTopAppBarFoundation);
  26282. exports.MDCFixedTopAppBarFoundation = MDCFixedTopAppBarFoundation;
  26283. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  26284. exports.default = MDCFixedTopAppBarFoundation;
  26285. /***/ }),
  26286. /***/ "./packages/mdc-top-app-bar/foundation.ts":
  26287. /*!************************************************!*\
  26288. !*** ./packages/mdc-top-app-bar/foundation.ts ***!
  26289. \************************************************/
  26290. /*! no static exports found */
  26291. /***/ (function(module, exports, __webpack_require__) {
  26292. "use strict";
  26293. /**
  26294. * @license
  26295. * Copyright 2018 Google Inc.
  26296. *
  26297. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26298. * of this software and associated documentation files (the "Software"), to deal
  26299. * in the Software without restriction, including without limitation the rights
  26300. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26301. * copies of the Software, and to permit persons to whom the Software is
  26302. * furnished to do so, subject to the following conditions:
  26303. *
  26304. * The above copyright notice and this permission notice shall be included in
  26305. * all copies or substantial portions of the Software.
  26306. *
  26307. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26308. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26309. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26310. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26311. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26312. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26313. * THE SOFTWARE.
  26314. */
  26315. var __extends = this && this.__extends || function () {
  26316. var _extendStatics = function extendStatics(d, b) {
  26317. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  26318. d.__proto__ = b;
  26319. } || function (d, b) {
  26320. for (var p in b) {
  26321. if (b.hasOwnProperty(p)) d[p] = b[p];
  26322. }
  26323. };
  26324. return _extendStatics(d, b);
  26325. };
  26326. return function (d, b) {
  26327. _extendStatics(d, b);
  26328. function __() {
  26329. this.constructor = d;
  26330. }
  26331. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26332. };
  26333. }();
  26334. var __assign = this && this.__assign || function () {
  26335. __assign = Object.assign || function (t) {
  26336. for (var s, i = 1, n = arguments.length; i < n; i++) {
  26337. s = arguments[i];
  26338. for (var p in s) {
  26339. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  26340. }
  26341. }
  26342. return t;
  26343. };
  26344. return __assign.apply(this, arguments);
  26345. };
  26346. Object.defineProperty(exports, "__esModule", { value: true });
  26347. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  26348. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts");
  26349. var MDCTopAppBarBaseFoundation = /** @class */function (_super) {
  26350. __extends(MDCTopAppBarBaseFoundation, _super);
  26351. /* istanbul ignore next: optional argument is not a branch statement */
  26352. function MDCTopAppBarBaseFoundation(adapter) {
  26353. return _super.call(this, __assign(__assign({}, MDCTopAppBarBaseFoundation.defaultAdapter), adapter)) || this;
  26354. }
  26355. Object.defineProperty(MDCTopAppBarBaseFoundation, "strings", {
  26356. get: function get() {
  26357. return constants_1.strings;
  26358. },
  26359. enumerable: true,
  26360. configurable: true
  26361. });
  26362. Object.defineProperty(MDCTopAppBarBaseFoundation, "cssClasses", {
  26363. get: function get() {
  26364. return constants_1.cssClasses;
  26365. },
  26366. enumerable: true,
  26367. configurable: true
  26368. });
  26369. Object.defineProperty(MDCTopAppBarBaseFoundation, "numbers", {
  26370. get: function get() {
  26371. return constants_1.numbers;
  26372. },
  26373. enumerable: true,
  26374. configurable: true
  26375. });
  26376. Object.defineProperty(MDCTopAppBarBaseFoundation, "defaultAdapter", {
  26377. /**
  26378. * See {@link MDCTopAppBarAdapter} for typing information on parameters and return types.
  26379. */
  26380. get: function get() {
  26381. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  26382. return {
  26383. addClass: function addClass() {
  26384. return undefined;
  26385. },
  26386. removeClass: function removeClass() {
  26387. return undefined;
  26388. },
  26389. hasClass: function hasClass() {
  26390. return false;
  26391. },
  26392. setStyle: function setStyle() {
  26393. return undefined;
  26394. },
  26395. getTopAppBarHeight: function getTopAppBarHeight() {
  26396. return 0;
  26397. },
  26398. notifyNavigationIconClicked: function notifyNavigationIconClicked() {
  26399. return undefined;
  26400. },
  26401. getViewportScrollY: function getViewportScrollY() {
  26402. return 0;
  26403. },
  26404. getTotalActionItems: function getTotalActionItems() {
  26405. return 0;
  26406. }
  26407. };
  26408. // tslint:enable:object-literal-sort-keys
  26409. },
  26410. enumerable: true,
  26411. configurable: true
  26412. });
  26413. /** Other variants of TopAppBar foundation overrides this method */
  26414. MDCTopAppBarBaseFoundation.prototype.handleTargetScroll = function () {}; // tslint:disable-line:no-empty
  26415. /** Other variants of TopAppBar foundation overrides this method */
  26416. MDCTopAppBarBaseFoundation.prototype.handleWindowResize = function () {}; // tslint:disable-line:no-empty
  26417. MDCTopAppBarBaseFoundation.prototype.handleNavigationClick = function () {
  26418. this.adapter.notifyNavigationIconClicked();
  26419. };
  26420. return MDCTopAppBarBaseFoundation;
  26421. }(foundation_1.MDCFoundation);
  26422. exports.MDCTopAppBarBaseFoundation = MDCTopAppBarBaseFoundation;
  26423. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  26424. exports.default = MDCTopAppBarBaseFoundation;
  26425. /***/ }),
  26426. /***/ "./packages/mdc-top-app-bar/index.ts":
  26427. /*!*******************************************!*\
  26428. !*** ./packages/mdc-top-app-bar/index.ts ***!
  26429. \*******************************************/
  26430. /*! no static exports found */
  26431. /***/ (function(module, exports, __webpack_require__) {
  26432. "use strict";
  26433. /**
  26434. * @license
  26435. * Copyright 2019 Google Inc.
  26436. *
  26437. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26438. * of this software and associated documentation files (the "Software"), to deal
  26439. * in the Software without restriction, including without limitation the rights
  26440. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26441. * copies of the Software, and to permit persons to whom the Software is
  26442. * furnished to do so, subject to the following conditions:
  26443. *
  26444. * The above copyright notice and this permission notice shall be included in
  26445. * all copies or substantial portions of the Software.
  26446. *
  26447. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26448. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26449. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26450. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26451. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26452. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26453. * THE SOFTWARE.
  26454. */
  26455. function __export(m) {
  26456. for (var p in m) {
  26457. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  26458. }
  26459. }
  26460. Object.defineProperty(exports, "__esModule", { value: true });
  26461. __export(__webpack_require__(/*! ./component */ "./packages/mdc-top-app-bar/component.ts"));
  26462. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts"));
  26463. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-top-app-bar/foundation.ts"));
  26464. __export(__webpack_require__(/*! ./fixed/foundation */ "./packages/mdc-top-app-bar/fixed/foundation.ts"));
  26465. __export(__webpack_require__(/*! ./short/foundation */ "./packages/mdc-top-app-bar/short/foundation.ts"));
  26466. __export(__webpack_require__(/*! ./standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts"));
  26467. /***/ }),
  26468. /***/ "./packages/mdc-top-app-bar/short/foundation.ts":
  26469. /*!******************************************************!*\
  26470. !*** ./packages/mdc-top-app-bar/short/foundation.ts ***!
  26471. \******************************************************/
  26472. /*! no static exports found */
  26473. /***/ (function(module, exports, __webpack_require__) {
  26474. "use strict";
  26475. /**
  26476. * @license
  26477. * Copyright 2018 Google Inc.
  26478. *
  26479. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26480. * of this software and associated documentation files (the "Software"), to deal
  26481. * in the Software without restriction, including without limitation the rights
  26482. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26483. * copies of the Software, and to permit persons to whom the Software is
  26484. * furnished to do so, subject to the following conditions:
  26485. *
  26486. * The above copyright notice and this permission notice shall be included in
  26487. * all copies or substantial portions of the Software.
  26488. *
  26489. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26490. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26491. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26492. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26493. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26494. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26495. * THE SOFTWARE.
  26496. */
  26497. var __extends = this && this.__extends || function () {
  26498. var _extendStatics = function extendStatics(d, b) {
  26499. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  26500. d.__proto__ = b;
  26501. } || function (d, b) {
  26502. for (var p in b) {
  26503. if (b.hasOwnProperty(p)) d[p] = b[p];
  26504. }
  26505. };
  26506. return _extendStatics(d, b);
  26507. };
  26508. return function (d, b) {
  26509. _extendStatics(d, b);
  26510. function __() {
  26511. this.constructor = d;
  26512. }
  26513. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26514. };
  26515. }();
  26516. Object.defineProperty(exports, "__esModule", { value: true });
  26517. var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
  26518. var foundation_1 = __webpack_require__(/*! ../foundation */ "./packages/mdc-top-app-bar/foundation.ts");
  26519. var MDCShortTopAppBarFoundation = /** @class */function (_super) {
  26520. __extends(MDCShortTopAppBarFoundation, _super);
  26521. /* istanbul ignore next: optional argument is not a branch statement */
  26522. function MDCShortTopAppBarFoundation(adapter) {
  26523. var _this = _super.call(this, adapter) || this;
  26524. _this.isCollapsed_ = false;
  26525. _this.isAlwaysCollapsed_ = false;
  26526. return _this;
  26527. }
  26528. Object.defineProperty(MDCShortTopAppBarFoundation.prototype, "isCollapsed", {
  26529. // Public visibility for backward compatibility.
  26530. get: function get() {
  26531. return this.isCollapsed_;
  26532. },
  26533. enumerable: true,
  26534. configurable: true
  26535. });
  26536. MDCShortTopAppBarFoundation.prototype.init = function () {
  26537. _super.prototype.init.call(this);
  26538. if (this.adapter.getTotalActionItems() > 0) {
  26539. this.adapter.addClass(constants_1.cssClasses.SHORT_HAS_ACTION_ITEM_CLASS);
  26540. }
  26541. // If initialized with SHORT_COLLAPSED_CLASS, the bar should always be collapsed
  26542. this.setAlwaysCollapsed(this.adapter.hasClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS));
  26543. };
  26544. /**
  26545. * Set if the short top app bar should always be collapsed.
  26546. *
  26547. * @param value When `true`, bar will always be collapsed. When `false`, bar may collapse or expand based on scroll.
  26548. */
  26549. MDCShortTopAppBarFoundation.prototype.setAlwaysCollapsed = function (value) {
  26550. this.isAlwaysCollapsed_ = !!value;
  26551. if (this.isAlwaysCollapsed_) {
  26552. this.collapse_();
  26553. } else {
  26554. // let maybeCollapseBar_ determine if the bar should be collapsed
  26555. this.maybeCollapseBar_();
  26556. }
  26557. };
  26558. MDCShortTopAppBarFoundation.prototype.getAlwaysCollapsed = function () {
  26559. return this.isAlwaysCollapsed_;
  26560. };
  26561. /**
  26562. * Scroll handler for applying/removing the collapsed modifier class on the short top app bar.
  26563. * @override
  26564. */
  26565. MDCShortTopAppBarFoundation.prototype.handleTargetScroll = function () {
  26566. this.maybeCollapseBar_();
  26567. };
  26568. MDCShortTopAppBarFoundation.prototype.maybeCollapseBar_ = function () {
  26569. if (this.isAlwaysCollapsed_) {
  26570. return;
  26571. }
  26572. var currentScroll = this.adapter.getViewportScrollY();
  26573. if (currentScroll <= 0) {
  26574. if (this.isCollapsed_) {
  26575. this.uncollapse_();
  26576. }
  26577. } else {
  26578. if (!this.isCollapsed_) {
  26579. this.collapse_();
  26580. }
  26581. }
  26582. };
  26583. MDCShortTopAppBarFoundation.prototype.uncollapse_ = function () {
  26584. this.adapter.removeClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS);
  26585. this.isCollapsed_ = false;
  26586. };
  26587. MDCShortTopAppBarFoundation.prototype.collapse_ = function () {
  26588. this.adapter.addClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS);
  26589. this.isCollapsed_ = true;
  26590. };
  26591. return MDCShortTopAppBarFoundation;
  26592. }(foundation_1.MDCTopAppBarBaseFoundation);
  26593. exports.MDCShortTopAppBarFoundation = MDCShortTopAppBarFoundation;
  26594. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  26595. exports.default = MDCShortTopAppBarFoundation;
  26596. /***/ }),
  26597. /***/ "./packages/mdc-top-app-bar/standard/foundation.ts":
  26598. /*!*********************************************************!*\
  26599. !*** ./packages/mdc-top-app-bar/standard/foundation.ts ***!
  26600. \*********************************************************/
  26601. /*! no static exports found */
  26602. /***/ (function(module, exports, __webpack_require__) {
  26603. "use strict";
  26604. /**
  26605. * @license
  26606. * Copyright 2018 Google Inc.
  26607. *
  26608. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26609. * of this software and associated documentation files (the "Software"), to deal
  26610. * in the Software without restriction, including without limitation the rights
  26611. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26612. * copies of the Software, and to permit persons to whom the Software is
  26613. * furnished to do so, subject to the following conditions:
  26614. *
  26615. * The above copyright notice and this permission notice shall be included in
  26616. * all copies or substantial portions of the Software.
  26617. *
  26618. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26619. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26620. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26621. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26622. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26623. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26624. * THE SOFTWARE.
  26625. */
  26626. var __extends = this && this.__extends || function () {
  26627. var _extendStatics = function extendStatics(d, b) {
  26628. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  26629. d.__proto__ = b;
  26630. } || function (d, b) {
  26631. for (var p in b) {
  26632. if (b.hasOwnProperty(p)) d[p] = b[p];
  26633. }
  26634. };
  26635. return _extendStatics(d, b);
  26636. };
  26637. return function (d, b) {
  26638. _extendStatics(d, b);
  26639. function __() {
  26640. this.constructor = d;
  26641. }
  26642. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26643. };
  26644. }();
  26645. Object.defineProperty(exports, "__esModule", { value: true });
  26646. var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
  26647. var foundation_1 = __webpack_require__(/*! ../foundation */ "./packages/mdc-top-app-bar/foundation.ts");
  26648. var INITIAL_VALUE = 0;
  26649. var MDCTopAppBarFoundation = /** @class */function (_super) {
  26650. __extends(MDCTopAppBarFoundation, _super);
  26651. /* istanbul ignore next: optional argument is not a branch statement */
  26652. function MDCTopAppBarFoundation(adapter) {
  26653. var _this = _super.call(this, adapter) || this;
  26654. /**
  26655. * Indicates if the top app bar was docked in the previous scroll handler iteration.
  26656. */
  26657. _this.wasDocked_ = true;
  26658. /**
  26659. * Indicates if the top app bar is docked in the fully shown position.
  26660. */
  26661. _this.isDockedShowing_ = true;
  26662. /**
  26663. * Variable for current scroll position of the top app bar
  26664. */
  26665. _this.currentAppBarOffsetTop_ = 0;
  26666. /**
  26667. * Used to prevent the top app bar from being scrolled out of view during resize events
  26668. */
  26669. _this.isCurrentlyBeingResized_ = false;
  26670. /**
  26671. * The timeout that's used to throttle the resize events
  26672. */
  26673. _this.resizeThrottleId_ = INITIAL_VALUE;
  26674. /**
  26675. * The timeout that's used to debounce toggling the isCurrentlyBeingResized_ variable after a resize
  26676. */
  26677. _this.resizeDebounceId_ = INITIAL_VALUE;
  26678. _this.lastScrollPosition_ = _this.adapter.getViewportScrollY();
  26679. _this.topAppBarHeight_ = _this.adapter.getTopAppBarHeight();
  26680. return _this;
  26681. }
  26682. MDCTopAppBarFoundation.prototype.destroy = function () {
  26683. _super.prototype.destroy.call(this);
  26684. this.adapter.setStyle('top', '');
  26685. };
  26686. /**
  26687. * Scroll handler for the default scroll behavior of the top app bar.
  26688. * @override
  26689. */
  26690. MDCTopAppBarFoundation.prototype.handleTargetScroll = function () {
  26691. var currentScrollPosition = Math.max(this.adapter.getViewportScrollY(), 0);
  26692. var diff = currentScrollPosition - this.lastScrollPosition_;
  26693. this.lastScrollPosition_ = currentScrollPosition;
  26694. // If the window is being resized the lastScrollPosition_ needs to be updated but the
  26695. // current scroll of the top app bar should stay in the same position.
  26696. if (!this.isCurrentlyBeingResized_) {
  26697. this.currentAppBarOffsetTop_ -= diff;
  26698. if (this.currentAppBarOffsetTop_ > 0) {
  26699. this.currentAppBarOffsetTop_ = 0;
  26700. } else if (Math.abs(this.currentAppBarOffsetTop_) > this.topAppBarHeight_) {
  26701. this.currentAppBarOffsetTop_ = -this.topAppBarHeight_;
  26702. }
  26703. this.moveTopAppBar_();
  26704. }
  26705. };
  26706. /**
  26707. * Top app bar resize handler that throttle/debounce functions that execute updates.
  26708. * @override
  26709. */
  26710. MDCTopAppBarFoundation.prototype.handleWindowResize = function () {
  26711. var _this = this;
  26712. // Throttle resize events 10 p/s
  26713. if (!this.resizeThrottleId_) {
  26714. this.resizeThrottleId_ = setTimeout(function () {
  26715. _this.resizeThrottleId_ = INITIAL_VALUE;
  26716. _this.throttledResizeHandler_();
  26717. }, constants_1.numbers.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
  26718. }
  26719. this.isCurrentlyBeingResized_ = true;
  26720. if (this.resizeDebounceId_) {
  26721. clearTimeout(this.resizeDebounceId_);
  26722. }
  26723. this.resizeDebounceId_ = setTimeout(function () {
  26724. _this.handleTargetScroll();
  26725. _this.isCurrentlyBeingResized_ = false;
  26726. _this.resizeDebounceId_ = INITIAL_VALUE;
  26727. }, constants_1.numbers.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
  26728. };
  26729. /**
  26730. * Function to determine if the DOM needs to update.
  26731. */
  26732. MDCTopAppBarFoundation.prototype.checkForUpdate_ = function () {
  26733. var offscreenBoundaryTop = -this.topAppBarHeight_;
  26734. var hasAnyPixelsOffscreen = this.currentAppBarOffsetTop_ < 0;
  26735. var hasAnyPixelsOnscreen = this.currentAppBarOffsetTop_ > offscreenBoundaryTop;
  26736. var partiallyShowing = hasAnyPixelsOffscreen && hasAnyPixelsOnscreen;
  26737. // If it's partially showing, it can't be docked.
  26738. if (partiallyShowing) {
  26739. this.wasDocked_ = false;
  26740. } else {
  26741. // Not previously docked and not partially showing, it's now docked.
  26742. if (!this.wasDocked_) {
  26743. this.wasDocked_ = true;
  26744. return true;
  26745. } else if (this.isDockedShowing_ !== hasAnyPixelsOnscreen) {
  26746. this.isDockedShowing_ = hasAnyPixelsOnscreen;
  26747. return true;
  26748. }
  26749. }
  26750. return partiallyShowing;
  26751. };
  26752. /**
  26753. * Function to move the top app bar if needed.
  26754. */
  26755. MDCTopAppBarFoundation.prototype.moveTopAppBar_ = function () {
  26756. if (this.checkForUpdate_()) {
  26757. // Once the top app bar is fully hidden we use the max potential top app bar height as our offset
  26758. // so the top app bar doesn't show if the window resizes and the new height > the old height.
  26759. var offset = this.currentAppBarOffsetTop_;
  26760. if (Math.abs(offset) >= this.topAppBarHeight_) {
  26761. offset = -constants_1.numbers.MAX_TOP_APP_BAR_HEIGHT;
  26762. }
  26763. this.adapter.setStyle('top', offset + 'px');
  26764. }
  26765. };
  26766. /**
  26767. * Throttled function that updates the top app bar scrolled values if the
  26768. * top app bar height changes.
  26769. */
  26770. MDCTopAppBarFoundation.prototype.throttledResizeHandler_ = function () {
  26771. var currentHeight = this.adapter.getTopAppBarHeight();
  26772. if (this.topAppBarHeight_ !== currentHeight) {
  26773. this.wasDocked_ = false;
  26774. // Since the top app bar has a different height depending on the screen width, this
  26775. // will ensure that the top app bar remains in the correct location if
  26776. // completely hidden and a resize makes the top app bar a different height.
  26777. this.currentAppBarOffsetTop_ -= this.topAppBarHeight_ - currentHeight;
  26778. this.topAppBarHeight_ = currentHeight;
  26779. }
  26780. this.handleTargetScroll();
  26781. };
  26782. return MDCTopAppBarFoundation;
  26783. }(foundation_1.MDCTopAppBarBaseFoundation);
  26784. exports.MDCTopAppBarFoundation = MDCTopAppBarFoundation;
  26785. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  26786. exports.default = MDCTopAppBarFoundation;
  26787. /***/ })
  26788. /******/ });
  26789. });
  26790. //# sourceMappingURL=material-components-web.js.map