material-components-web.js 1.1 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598
  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. return window.addEventListener(evtType, _this.handleLayout_);
  5508. });
  5509. document.addEventListener('keydown', _this.handleDocumentKeydown_);
  5510. };
  5511. this.handleClosing_ = function () {
  5512. LAYOUT_EVENTS.forEach(function (evtType) {
  5513. return 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. return 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. return _this.defaultButton_ && _this.defaultButton_.click();
  5561. },
  5562. eventTargetMatches: function eventTargetMatches(target, selector) {
  5563. return target ? ponyfill_1.matches(target, selector) : false;
  5564. },
  5565. getActionFromEvent: function getActionFromEvent(evt) {
  5566. if (!evt.target) {
  5567. return '';
  5568. }
  5569. var element = ponyfill_1.closest(evt.target, "[" + strings.ACTION_ATTRIBUTE + "]");
  5570. return element && element.getAttribute(strings.ACTION_ATTRIBUTE);
  5571. },
  5572. getInitialFocusEl: function getInitialFocusEl() {
  5573. return _this.getInitialFocusEl_();
  5574. },
  5575. hasClass: function hasClass(className) {
  5576. return _this.root.classList.contains(className);
  5577. },
  5578. isContentScrollable: function isContentScrollable() {
  5579. return util.isScrollable(_this.content_);
  5580. },
  5581. notifyClosed: function notifyClosed(action) {
  5582. return _this.emit(strings.CLOSED_EVENT, action ? { action: action } : {});
  5583. },
  5584. notifyClosing: function notifyClosing(action) {
  5585. return _this.emit(strings.CLOSING_EVENT, action ? { action: action } : {});
  5586. },
  5587. notifyOpened: function notifyOpened() {
  5588. return _this.emit(strings.OPENED_EVENT, {});
  5589. },
  5590. notifyOpening: function notifyOpening() {
  5591. return _this.emit(strings.OPENING_EVENT, {});
  5592. },
  5593. releaseFocus: function releaseFocus() {
  5594. return _this.focusTrap_.releaseFocus();
  5595. },
  5596. removeBodyClass: function removeBodyClass(className) {
  5597. return document.body.classList.remove(className);
  5598. },
  5599. removeClass: function removeClass(className) {
  5600. return _this.root.classList.remove(className);
  5601. },
  5602. reverseButtons: function reverseButtons() {
  5603. _this.buttons_.reverse();
  5604. _this.buttons_.forEach(function (button) {
  5605. button.parentElement.appendChild(button);
  5606. });
  5607. },
  5608. trapFocus: function trapFocus() {
  5609. return _this.focusTrap_.trapFocus();
  5610. }
  5611. };
  5612. return new foundation_1.MDCDialogFoundation(adapter);
  5613. };
  5614. MDCDialog.prototype.getInitialFocusEl_ = function () {
  5615. return this.root.querySelector("[" + strings.INITIAL_FOCUS_ATTRIBUTE + "]");
  5616. };
  5617. return MDCDialog;
  5618. }(component_1.MDCComponent);
  5619. exports.MDCDialog = MDCDialog;
  5620. /***/ }),
  5621. /***/ "./packages/mdc-dialog/constants.ts":
  5622. /*!******************************************!*\
  5623. !*** ./packages/mdc-dialog/constants.ts ***!
  5624. \******************************************/
  5625. /*! no static exports found */
  5626. /***/ (function(module, exports, __webpack_require__) {
  5627. "use strict";
  5628. /**
  5629. * @license
  5630. * Copyright 2016 Google Inc.
  5631. *
  5632. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5633. * of this software and associated documentation files (the "Software"), to deal
  5634. * in the Software without restriction, including without limitation the rights
  5635. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5636. * copies of the Software, and to permit persons to whom the Software is
  5637. * furnished to do so, subject to the following conditions:
  5638. *
  5639. * The above copyright notice and this permission notice shall be included in
  5640. * all copies or substantial portions of the Software.
  5641. *
  5642. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5643. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5644. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5645. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5646. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5647. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5648. * THE SOFTWARE.
  5649. */
  5650. Object.defineProperty(exports, "__esModule", { value: true });
  5651. exports.cssClasses = {
  5652. CLOSING: 'mdc-dialog--closing',
  5653. OPEN: 'mdc-dialog--open',
  5654. OPENING: 'mdc-dialog--opening',
  5655. SCROLLABLE: 'mdc-dialog--scrollable',
  5656. SCROLL_LOCK: 'mdc-dialog-scroll-lock',
  5657. STACKED: 'mdc-dialog--stacked'
  5658. };
  5659. exports.strings = {
  5660. ACTION_ATTRIBUTE: 'data-mdc-dialog-action',
  5661. BUTTON_DEFAULT_ATTRIBUTE: 'data-mdc-dialog-button-default',
  5662. BUTTON_SELECTOR: '.mdc-dialog__button',
  5663. CLOSED_EVENT: 'MDCDialog:closed',
  5664. CLOSE_ACTION: 'close',
  5665. CLOSING_EVENT: 'MDCDialog:closing',
  5666. CONTAINER_SELECTOR: '.mdc-dialog__container',
  5667. CONTENT_SELECTOR: '.mdc-dialog__content',
  5668. DESTROY_ACTION: 'destroy',
  5669. INITIAL_FOCUS_ATTRIBUTE: 'data-mdc-dialog-initial-focus',
  5670. OPENED_EVENT: 'MDCDialog:opened',
  5671. OPENING_EVENT: 'MDCDialog:opening',
  5672. SCRIM_SELECTOR: '.mdc-dialog__scrim',
  5673. SUPPRESS_DEFAULT_PRESS_SELECTOR: ['textarea', '.mdc-menu .mdc-list-item'].join(', '),
  5674. SURFACE_SELECTOR: '.mdc-dialog__surface'
  5675. };
  5676. exports.numbers = {
  5677. DIALOG_ANIMATION_CLOSE_TIME_MS: 75,
  5678. DIALOG_ANIMATION_OPEN_TIME_MS: 150
  5679. };
  5680. /***/ }),
  5681. /***/ "./packages/mdc-dialog/foundation.ts":
  5682. /*!*******************************************!*\
  5683. !*** ./packages/mdc-dialog/foundation.ts ***!
  5684. \*******************************************/
  5685. /*! no static exports found */
  5686. /***/ (function(module, exports, __webpack_require__) {
  5687. "use strict";
  5688. /**
  5689. * @license
  5690. * Copyright 2017 Google Inc.
  5691. *
  5692. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5693. * of this software and associated documentation files (the "Software"), to deal
  5694. * in the Software without restriction, including without limitation the rights
  5695. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5696. * copies of the Software, and to permit persons to whom the Software is
  5697. * furnished to do so, subject to the following conditions:
  5698. *
  5699. * The above copyright notice and this permission notice shall be included in
  5700. * all copies or substantial portions of the Software.
  5701. *
  5702. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5703. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5704. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5705. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5706. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5707. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5708. * THE SOFTWARE.
  5709. */
  5710. var __extends = this && this.__extends || function () {
  5711. var _extendStatics = function extendStatics(d, b) {
  5712. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  5713. d.__proto__ = b;
  5714. } || function (d, b) {
  5715. for (var p in b) {
  5716. if (b.hasOwnProperty(p)) d[p] = b[p];
  5717. }
  5718. };
  5719. return _extendStatics(d, b);
  5720. };
  5721. return function (d, b) {
  5722. _extendStatics(d, b);
  5723. function __() {
  5724. this.constructor = d;
  5725. }
  5726. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5727. };
  5728. }();
  5729. var __assign = this && this.__assign || function () {
  5730. __assign = Object.assign || function (t) {
  5731. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5732. s = arguments[i];
  5733. for (var p in s) {
  5734. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  5735. }
  5736. }
  5737. return t;
  5738. };
  5739. return __assign.apply(this, arguments);
  5740. };
  5741. Object.defineProperty(exports, "__esModule", { value: true });
  5742. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  5743. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts");
  5744. var MDCDialogFoundation = /** @class */function (_super) {
  5745. __extends(MDCDialogFoundation, _super);
  5746. function MDCDialogFoundation(adapter) {
  5747. var _this = _super.call(this, __assign(__assign({}, MDCDialogFoundation.defaultAdapter), adapter)) || this;
  5748. _this.isOpen_ = false;
  5749. _this.animationFrame_ = 0;
  5750. _this.animationTimer_ = 0;
  5751. _this.layoutFrame_ = 0;
  5752. _this.escapeKeyAction_ = constants_1.strings.CLOSE_ACTION;
  5753. _this.scrimClickAction_ = constants_1.strings.CLOSE_ACTION;
  5754. _this.autoStackButtons_ = true;
  5755. _this.areButtonsStacked_ = false;
  5756. _this.suppressDefaultPressSelector = constants_1.strings.SUPPRESS_DEFAULT_PRESS_SELECTOR;
  5757. return _this;
  5758. }
  5759. Object.defineProperty(MDCDialogFoundation, "cssClasses", {
  5760. get: function get() {
  5761. return constants_1.cssClasses;
  5762. },
  5763. enumerable: true,
  5764. configurable: true
  5765. });
  5766. Object.defineProperty(MDCDialogFoundation, "strings", {
  5767. get: function get() {
  5768. return constants_1.strings;
  5769. },
  5770. enumerable: true,
  5771. configurable: true
  5772. });
  5773. Object.defineProperty(MDCDialogFoundation, "numbers", {
  5774. get: function get() {
  5775. return constants_1.numbers;
  5776. },
  5777. enumerable: true,
  5778. configurable: true
  5779. });
  5780. Object.defineProperty(MDCDialogFoundation, "defaultAdapter", {
  5781. get: function get() {
  5782. return {
  5783. addBodyClass: function addBodyClass() {
  5784. return undefined;
  5785. },
  5786. addClass: function addClass() {
  5787. return undefined;
  5788. },
  5789. areButtonsStacked: function areButtonsStacked() {
  5790. return false;
  5791. },
  5792. clickDefaultButton: function clickDefaultButton() {
  5793. return undefined;
  5794. },
  5795. eventTargetMatches: function eventTargetMatches() {
  5796. return false;
  5797. },
  5798. getActionFromEvent: function getActionFromEvent() {
  5799. return '';
  5800. },
  5801. getInitialFocusEl: function getInitialFocusEl() {
  5802. return null;
  5803. },
  5804. hasClass: function hasClass() {
  5805. return false;
  5806. },
  5807. isContentScrollable: function isContentScrollable() {
  5808. return false;
  5809. },
  5810. notifyClosed: function notifyClosed() {
  5811. return undefined;
  5812. },
  5813. notifyClosing: function notifyClosing() {
  5814. return undefined;
  5815. },
  5816. notifyOpened: function notifyOpened() {
  5817. return undefined;
  5818. },
  5819. notifyOpening: function notifyOpening() {
  5820. return undefined;
  5821. },
  5822. releaseFocus: function releaseFocus() {
  5823. return undefined;
  5824. },
  5825. removeBodyClass: function removeBodyClass() {
  5826. return undefined;
  5827. },
  5828. removeClass: function removeClass() {
  5829. return undefined;
  5830. },
  5831. reverseButtons: function reverseButtons() {
  5832. return undefined;
  5833. },
  5834. trapFocus: function trapFocus() {
  5835. return undefined;
  5836. }
  5837. };
  5838. },
  5839. enumerable: true,
  5840. configurable: true
  5841. });
  5842. MDCDialogFoundation.prototype.init = function () {
  5843. if (this.adapter.hasClass(constants_1.cssClasses.STACKED)) {
  5844. this.setAutoStackButtons(false);
  5845. }
  5846. };
  5847. MDCDialogFoundation.prototype.destroy = function () {
  5848. if (this.isOpen_) {
  5849. this.close(constants_1.strings.DESTROY_ACTION);
  5850. }
  5851. if (this.animationTimer_) {
  5852. clearTimeout(this.animationTimer_);
  5853. this.handleAnimationTimerEnd_();
  5854. }
  5855. if (this.layoutFrame_) {
  5856. cancelAnimationFrame(this.layoutFrame_);
  5857. this.layoutFrame_ = 0;
  5858. }
  5859. };
  5860. MDCDialogFoundation.prototype.open = function () {
  5861. var _this = this;
  5862. this.isOpen_ = true;
  5863. this.adapter.notifyOpening();
  5864. this.adapter.addClass(constants_1.cssClasses.OPENING);
  5865. // Wait a frame once display is no longer "none", to establish basis for animation
  5866. this.runNextAnimationFrame_(function () {
  5867. _this.adapter.addClass(constants_1.cssClasses.OPEN);
  5868. _this.adapter.addBodyClass(constants_1.cssClasses.SCROLL_LOCK);
  5869. _this.layout();
  5870. _this.animationTimer_ = setTimeout(function () {
  5871. _this.handleAnimationTimerEnd_();
  5872. _this.adapter.trapFocus(_this.adapter.getInitialFocusEl());
  5873. _this.adapter.notifyOpened();
  5874. }, constants_1.numbers.DIALOG_ANIMATION_OPEN_TIME_MS);
  5875. });
  5876. };
  5877. MDCDialogFoundation.prototype.close = function (action) {
  5878. var _this = this;
  5879. if (action === void 0) {
  5880. action = '';
  5881. }
  5882. if (!this.isOpen_) {
  5883. // Avoid redundant close calls (and events), e.g. from keydown on elements that inherently emit click
  5884. return;
  5885. }
  5886. this.isOpen_ = false;
  5887. this.adapter.notifyClosing(action);
  5888. this.adapter.addClass(constants_1.cssClasses.CLOSING);
  5889. this.adapter.removeClass(constants_1.cssClasses.OPEN);
  5890. this.adapter.removeBodyClass(constants_1.cssClasses.SCROLL_LOCK);
  5891. cancelAnimationFrame(this.animationFrame_);
  5892. this.animationFrame_ = 0;
  5893. clearTimeout(this.animationTimer_);
  5894. this.animationTimer_ = setTimeout(function () {
  5895. _this.adapter.releaseFocus();
  5896. _this.handleAnimationTimerEnd_();
  5897. _this.adapter.notifyClosed(action);
  5898. }, constants_1.numbers.DIALOG_ANIMATION_CLOSE_TIME_MS);
  5899. };
  5900. MDCDialogFoundation.prototype.isOpen = function () {
  5901. return this.isOpen_;
  5902. };
  5903. MDCDialogFoundation.prototype.getEscapeKeyAction = function () {
  5904. return this.escapeKeyAction_;
  5905. };
  5906. MDCDialogFoundation.prototype.setEscapeKeyAction = function (action) {
  5907. this.escapeKeyAction_ = action;
  5908. };
  5909. MDCDialogFoundation.prototype.getScrimClickAction = function () {
  5910. return this.scrimClickAction_;
  5911. };
  5912. MDCDialogFoundation.prototype.setScrimClickAction = function (action) {
  5913. this.scrimClickAction_ = action;
  5914. };
  5915. MDCDialogFoundation.prototype.getAutoStackButtons = function () {
  5916. return this.autoStackButtons_;
  5917. };
  5918. MDCDialogFoundation.prototype.setAutoStackButtons = function (autoStack) {
  5919. this.autoStackButtons_ = autoStack;
  5920. };
  5921. MDCDialogFoundation.prototype.getSuppressDefaultPressSelector = function () {
  5922. return this.suppressDefaultPressSelector;
  5923. };
  5924. MDCDialogFoundation.prototype.setSuppressDefaultPressSelector = function (selector) {
  5925. this.suppressDefaultPressSelector = selector;
  5926. };
  5927. MDCDialogFoundation.prototype.layout = function () {
  5928. var _this = this;
  5929. if (this.layoutFrame_) {
  5930. cancelAnimationFrame(this.layoutFrame_);
  5931. }
  5932. this.layoutFrame_ = requestAnimationFrame(function () {
  5933. _this.layoutInternal_();
  5934. _this.layoutFrame_ = 0;
  5935. });
  5936. };
  5937. /** Handles click on the dialog root element. */
  5938. MDCDialogFoundation.prototype.handleClick = function (evt) {
  5939. var isScrim = this.adapter.eventTargetMatches(evt.target, constants_1.strings.SCRIM_SELECTOR);
  5940. // Check for scrim click first since it doesn't require querying ancestors.
  5941. if (isScrim && this.scrimClickAction_ !== '') {
  5942. this.close(this.scrimClickAction_);
  5943. } else {
  5944. var action = this.adapter.getActionFromEvent(evt);
  5945. if (action) {
  5946. this.close(action);
  5947. }
  5948. }
  5949. };
  5950. /** Handles keydown on the dialog root element. */
  5951. MDCDialogFoundation.prototype.handleKeydown = function (evt) {
  5952. var isEnter = evt.key === 'Enter' || evt.keyCode === 13;
  5953. if (!isEnter) {
  5954. return;
  5955. }
  5956. var action = this.adapter.getActionFromEvent(evt);
  5957. if (action) {
  5958. // Action button callback is handled in `handleClick`,
  5959. // since space/enter keydowns on buttons trigger click events.
  5960. return;
  5961. }
  5962. // `composedPath` is used here, when available, to account for use cases
  5963. // where a target meant to suppress the default press behaviour
  5964. // may exist in a shadow root.
  5965. // For example, a textarea inside a web component:
  5966. // <mwc-dialog>
  5967. // <horizontal-layout>
  5968. // #shadow-root (open)
  5969. // <mwc-textarea>
  5970. // #shadow-root (open)
  5971. // <textarea></textarea>
  5972. // </mwc-textarea>
  5973. // </horizontal-layout>
  5974. // </mwc-dialog>
  5975. var target = evt.composedPath ? evt.composedPath()[0] : evt.target;
  5976. var isDefault = this.suppressDefaultPressSelector ? !this.adapter.eventTargetMatches(target, this.suppressDefaultPressSelector) : true;
  5977. if (isEnter && isDefault) {
  5978. this.adapter.clickDefaultButton();
  5979. }
  5980. };
  5981. /** Handles keydown on the document. */
  5982. MDCDialogFoundation.prototype.handleDocumentKeydown = function (evt) {
  5983. var isEscape = evt.key === 'Escape' || evt.keyCode === 27;
  5984. if (isEscape && this.escapeKeyAction_ !== '') {
  5985. this.close(this.escapeKeyAction_);
  5986. }
  5987. };
  5988. MDCDialogFoundation.prototype.layoutInternal_ = function () {
  5989. if (this.autoStackButtons_) {
  5990. this.detectStackedButtons_();
  5991. }
  5992. this.detectScrollableContent_();
  5993. };
  5994. MDCDialogFoundation.prototype.handleAnimationTimerEnd_ = function () {
  5995. this.animationTimer_ = 0;
  5996. this.adapter.removeClass(constants_1.cssClasses.OPENING);
  5997. this.adapter.removeClass(constants_1.cssClasses.CLOSING);
  5998. };
  5999. /**
  6000. * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
  6001. */
  6002. MDCDialogFoundation.prototype.runNextAnimationFrame_ = function (callback) {
  6003. var _this = this;
  6004. cancelAnimationFrame(this.animationFrame_);
  6005. this.animationFrame_ = requestAnimationFrame(function () {
  6006. _this.animationFrame_ = 0;
  6007. clearTimeout(_this.animationTimer_);
  6008. _this.animationTimer_ = setTimeout(callback, 0);
  6009. });
  6010. };
  6011. MDCDialogFoundation.prototype.detectStackedButtons_ = function () {
  6012. // Remove the class first to let us measure the buttons' natural positions.
  6013. this.adapter.removeClass(constants_1.cssClasses.STACKED);
  6014. var areButtonsStacked = this.adapter.areButtonsStacked();
  6015. if (areButtonsStacked) {
  6016. this.adapter.addClass(constants_1.cssClasses.STACKED);
  6017. }
  6018. if (areButtonsStacked !== this.areButtonsStacked_) {
  6019. this.adapter.reverseButtons();
  6020. this.areButtonsStacked_ = areButtonsStacked;
  6021. }
  6022. };
  6023. MDCDialogFoundation.prototype.detectScrollableContent_ = function () {
  6024. // Remove the class first to let us measure the natural height of the content.
  6025. this.adapter.removeClass(constants_1.cssClasses.SCROLLABLE);
  6026. if (this.adapter.isContentScrollable()) {
  6027. this.adapter.addClass(constants_1.cssClasses.SCROLLABLE);
  6028. }
  6029. };
  6030. return MDCDialogFoundation;
  6031. }(foundation_1.MDCFoundation);
  6032. exports.MDCDialogFoundation = MDCDialogFoundation;
  6033. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  6034. exports.default = MDCDialogFoundation;
  6035. /***/ }),
  6036. /***/ "./packages/mdc-dialog/index.ts":
  6037. /*!**************************************!*\
  6038. !*** ./packages/mdc-dialog/index.ts ***!
  6039. \**************************************/
  6040. /*! no static exports found */
  6041. /***/ (function(module, exports, __webpack_require__) {
  6042. "use strict";
  6043. /**
  6044. * @license
  6045. * Copyright 2019 Google Inc.
  6046. *
  6047. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6048. * of this software and associated documentation files (the "Software"), to deal
  6049. * in the Software without restriction, including without limitation the rights
  6050. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6051. * copies of the Software, and to permit persons to whom the Software is
  6052. * furnished to do so, subject to the following conditions:
  6053. *
  6054. * The above copyright notice and this permission notice shall be included in
  6055. * all copies or substantial portions of the Software.
  6056. *
  6057. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6058. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6059. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6060. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6061. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6062. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6063. * THE SOFTWARE.
  6064. */
  6065. function __export(m) {
  6066. for (var p in m) {
  6067. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  6068. }
  6069. }
  6070. var __importStar = this && this.__importStar || function (mod) {
  6071. if (mod && mod.__esModule) return mod;
  6072. var result = {};
  6073. if (mod != null) for (var k in mod) {
  6074. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  6075. }result["default"] = mod;
  6076. return result;
  6077. };
  6078. Object.defineProperty(exports, "__esModule", { value: true });
  6079. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
  6080. exports.util = util;
  6081. __export(__webpack_require__(/*! ./component */ "./packages/mdc-dialog/component.ts"));
  6082. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts"));
  6083. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts"));
  6084. /***/ }),
  6085. /***/ "./packages/mdc-dialog/util.ts":
  6086. /*!*************************************!*\
  6087. !*** ./packages/mdc-dialog/util.ts ***!
  6088. \*************************************/
  6089. /*! no static exports found */
  6090. /***/ (function(module, exports, __webpack_require__) {
  6091. "use strict";
  6092. /**
  6093. * @license
  6094. * Copyright 2016 Google Inc.
  6095. *
  6096. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6097. * of this software and associated documentation files (the "Software"), to deal
  6098. * in the Software without restriction, including without limitation the rights
  6099. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6100. * copies of the Software, and to permit persons to whom the Software is
  6101. * furnished to do so, subject to the following conditions:
  6102. *
  6103. * The above copyright notice and this permission notice shall be included in
  6104. * all copies or substantial portions of the Software.
  6105. *
  6106. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6107. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6108. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6109. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6110. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6111. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6112. * THE SOFTWARE.
  6113. */
  6114. Object.defineProperty(exports, "__esModule", { value: true });
  6115. function createFocusTrapInstance(surfaceEl, focusTrapFactory, initialFocusEl) {
  6116. return focusTrapFactory(surfaceEl, { initialFocusEl: initialFocusEl });
  6117. }
  6118. exports.createFocusTrapInstance = createFocusTrapInstance;
  6119. function isScrollable(el) {
  6120. return el ? el.scrollHeight > el.offsetHeight : false;
  6121. }
  6122. exports.isScrollable = isScrollable;
  6123. function areTopsMisaligned(els) {
  6124. var tops = new Set();
  6125. [].forEach.call(els, function (el) {
  6126. return tops.add(el.offsetTop);
  6127. });
  6128. return tops.size > 1;
  6129. }
  6130. exports.areTopsMisaligned = areTopsMisaligned;
  6131. /***/ }),
  6132. /***/ "./packages/mdc-dom/announce.ts":
  6133. /*!**************************************!*\
  6134. !*** ./packages/mdc-dom/announce.ts ***!
  6135. \**************************************/
  6136. /*! no static exports found */
  6137. /***/ (function(module, exports, __webpack_require__) {
  6138. "use strict";
  6139. /**
  6140. * @license
  6141. * Copyright 2020 Google Inc.
  6142. *
  6143. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6144. * of this software and associated documentation files (the "Software"), to deal
  6145. * in the Software without restriction, including without limitation the rights
  6146. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6147. * copies of the Software, and to permit persons to whom the Software is
  6148. * furnished to do so, subject to the following conditions:
  6149. *
  6150. * The above copyright notice and this permission notice shall be included in
  6151. * all copies or substantial portions of the Software.
  6152. *
  6153. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6154. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6155. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6156. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6157. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6158. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6159. * THE SOFTWARE.
  6160. */
  6161. Object.defineProperty(exports, "__esModule", { value: true });
  6162. /**
  6163. * Priorities for the announce function
  6164. */
  6165. var AnnouncerPriority;
  6166. (function (AnnouncerPriority) {
  6167. AnnouncerPriority["POLITE"] = "polite";
  6168. AnnouncerPriority["ASSERTIVE"] = "assertive";
  6169. })(AnnouncerPriority = exports.AnnouncerPriority || (exports.AnnouncerPriority = {}));
  6170. /**
  6171. * Data attribute added to live region element.
  6172. */
  6173. exports.DATA_MDC_DOM_ANNOUNCE = 'data-mdc-dom-announce';
  6174. /**
  6175. * Announces the given message with optional priority, defaulting to "polite"
  6176. */
  6177. function announce(message, priority) {
  6178. Announcer.getInstance().say(message, priority);
  6179. }
  6180. exports.announce = announce;
  6181. var Announcer = /** @class */function () {
  6182. // Constructor made private to ensure only the singleton is used
  6183. function Announcer() {
  6184. this.liveRegions = new Map();
  6185. }
  6186. Announcer.getInstance = function () {
  6187. if (!Announcer.instance) {
  6188. Announcer.instance = new Announcer();
  6189. }
  6190. return Announcer.instance;
  6191. };
  6192. Announcer.prototype.say = function (message, priority) {
  6193. if (priority === void 0) {
  6194. priority = AnnouncerPriority.POLITE;
  6195. }
  6196. var liveRegion = this.getLiveRegion(priority);
  6197. // Reset the region to pick up the message, even if the message is the
  6198. // exact same as before.
  6199. liveRegion.textContent = '';
  6200. // Timeout is necessary for screen readers like NVDA and VoiceOver.
  6201. setTimeout(function () {
  6202. liveRegion.textContent = message;
  6203. document.addEventListener('click', clearLiveRegion);
  6204. }, 1);
  6205. function clearLiveRegion() {
  6206. liveRegion.textContent = '';
  6207. document.removeEventListener('click', clearLiveRegion);
  6208. }
  6209. };
  6210. Announcer.prototype.getLiveRegion = function (priority) {
  6211. var existingLiveRegion = this.liveRegions.get(priority);
  6212. if (existingLiveRegion && document.body.contains(existingLiveRegion)) {
  6213. return existingLiveRegion;
  6214. }
  6215. var liveRegion = this.createLiveRegion(priority);
  6216. this.liveRegions.set(priority, liveRegion);
  6217. return liveRegion;
  6218. };
  6219. Announcer.prototype.createLiveRegion = function (priority) {
  6220. var el = document.createElement('div');
  6221. el.style.position = 'absolute';
  6222. el.style.top = '-9999px';
  6223. el.style.left = '-9999px';
  6224. el.style.height = '1px';
  6225. el.style.overflow = 'hidden';
  6226. el.setAttribute('aria-atomic', 'true');
  6227. el.setAttribute('aria-live', priority);
  6228. el.setAttribute(exports.DATA_MDC_DOM_ANNOUNCE, 'true');
  6229. document.body.appendChild(el);
  6230. return el;
  6231. };
  6232. return Announcer;
  6233. }();
  6234. /***/ }),
  6235. /***/ "./packages/mdc-dom/events.ts":
  6236. /*!************************************!*\
  6237. !*** ./packages/mdc-dom/events.ts ***!
  6238. \************************************/
  6239. /*! no static exports found */
  6240. /***/ (function(module, exports, __webpack_require__) {
  6241. "use strict";
  6242. /**
  6243. * @license
  6244. * Copyright 2019 Google Inc.
  6245. *
  6246. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6247. * of this software and associated documentation files (the "Software"), to deal
  6248. * in the Software without restriction, including without limitation the rights
  6249. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6250. * copies of the Software, and to permit persons to whom the Software is
  6251. * furnished to do so, subject to the following conditions:
  6252. *
  6253. * The above copyright notice and this permission notice shall be included in
  6254. * all copies or substantial portions of the Software.
  6255. *
  6256. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6257. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6258. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6259. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6260. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6261. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6262. * THE SOFTWARE.
  6263. */
  6264. Object.defineProperty(exports, "__esModule", { value: true });
  6265. /**
  6266. * Determine whether the current browser supports passive event listeners, and
  6267. * if so, use them.
  6268. */
  6269. function applyPassive(globalObj) {
  6270. if (globalObj === void 0) {
  6271. globalObj = window;
  6272. }
  6273. return supportsPassiveOption(globalObj) ? { passive: true } : false;
  6274. }
  6275. exports.applyPassive = applyPassive;
  6276. function supportsPassiveOption(globalObj) {
  6277. if (globalObj === void 0) {
  6278. globalObj = window;
  6279. }
  6280. // See
  6281. // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
  6282. var passiveSupported = false;
  6283. try {
  6284. var options = {
  6285. // This function will be called when the browser
  6286. // attempts to access the passive property.
  6287. get passive() {
  6288. passiveSupported = true;
  6289. return false;
  6290. }
  6291. };
  6292. var handler = function handler() {};
  6293. globalObj.document.addEventListener('test', handler, options);
  6294. globalObj.document.removeEventListener('test', handler, options);
  6295. } catch (err) {
  6296. passiveSupported = false;
  6297. }
  6298. return passiveSupported;
  6299. }
  6300. /***/ }),
  6301. /***/ "./packages/mdc-dom/focus-trap.ts":
  6302. /*!****************************************!*\
  6303. !*** ./packages/mdc-dom/focus-trap.ts ***!
  6304. \****************************************/
  6305. /*! no static exports found */
  6306. /***/ (function(module, exports, __webpack_require__) {
  6307. "use strict";
  6308. /**
  6309. * @license
  6310. * Copyright 2020 Google Inc.
  6311. *
  6312. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6313. * of this software and associated documentation files (the "Software"), to deal
  6314. * in the Software without restriction, including without limitation the rights
  6315. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6316. * copies of the Software, and to permit persons to whom the Software is
  6317. * furnished to do so, subject to the following conditions:
  6318. *
  6319. * The above copyright notice and this permission notice shall be included in
  6320. * all copies or substantial portions of the Software.
  6321. *
  6322. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6323. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6324. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6325. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6326. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6327. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6328. * THE SOFTWARE.
  6329. */
  6330. Object.defineProperty(exports, "__esModule", { value: true });
  6331. var FOCUS_SENTINEL_CLASS = 'mdc-dom-focus-sentinel';
  6332. /**
  6333. * Utility to trap focus in a given root element, e.g. for modal components such
  6334. * as dialogs. The root should have at least one focusable child element,
  6335. * for setting initial focus when trapping focus.
  6336. * Also tracks the previously focused element, and restores focus to that
  6337. * element when releasing focus.
  6338. */
  6339. var FocusTrap = /** @class */function () {
  6340. function FocusTrap(root, options) {
  6341. if (options === void 0) {
  6342. options = {};
  6343. }
  6344. this.root = root;
  6345. this.options = options;
  6346. // Previously focused element before trapping focus.
  6347. this.elFocusedBeforeTrapFocus = null;
  6348. }
  6349. /**
  6350. * Traps focus in `root`. Also focuses on either `initialFocusEl` if set;
  6351. * otherwises sets initial focus to the first focusable child element.
  6352. */
  6353. FocusTrap.prototype.trapFocus = function () {
  6354. var focusableEls = this.getFocusableElements(this.root);
  6355. if (focusableEls.length === 0) {
  6356. throw new Error('FocusTrap: Element must have at least one focusable child.');
  6357. }
  6358. this.elFocusedBeforeTrapFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
  6359. this.wrapTabFocus(this.root, focusableEls);
  6360. if (!this.options.skipInitialFocus) {
  6361. this.focusInitialElement(focusableEls, this.options.initialFocusEl);
  6362. }
  6363. };
  6364. /**
  6365. * Releases focus from `root`. Also restores focus to the previously focused
  6366. * element.
  6367. */
  6368. FocusTrap.prototype.releaseFocus = function () {
  6369. [].slice.call(this.root.querySelectorAll("." + FOCUS_SENTINEL_CLASS)).forEach(function (sentinelEl) {
  6370. sentinelEl.parentElement.removeChild(sentinelEl);
  6371. });
  6372. if (this.elFocusedBeforeTrapFocus) {
  6373. this.elFocusedBeforeTrapFocus.focus();
  6374. }
  6375. };
  6376. /**
  6377. * Wraps tab focus within `el` by adding two hidden sentinel divs which are
  6378. * used to mark the beginning and the end of the tabbable region. When
  6379. * focused, these sentinel elements redirect focus to the first/last
  6380. * children elements of the tabbable region, ensuring that focus is trapped
  6381. * within that region.
  6382. */
  6383. FocusTrap.prototype.wrapTabFocus = function (el, focusableEls) {
  6384. var sentinelStart = this.createSentinel();
  6385. var sentinelEnd = this.createSentinel();
  6386. sentinelStart.addEventListener('focus', function () {
  6387. if (focusableEls.length > 0) {
  6388. focusableEls[focusableEls.length - 1].focus();
  6389. }
  6390. });
  6391. sentinelEnd.addEventListener('focus', function () {
  6392. if (focusableEls.length > 0) {
  6393. focusableEls[0].focus();
  6394. }
  6395. });
  6396. el.insertBefore(sentinelStart, el.children[0]);
  6397. el.appendChild(sentinelEnd);
  6398. };
  6399. /**
  6400. * Focuses on `initialFocusEl` if defined and a child of the root element.
  6401. * Otherwise, focuses on the first focusable child element of the root.
  6402. */
  6403. FocusTrap.prototype.focusInitialElement = function (focusableEls, initialFocusEl) {
  6404. var focusIndex = 0;
  6405. if (initialFocusEl) {
  6406. focusIndex = Math.max(focusableEls.indexOf(initialFocusEl), 0);
  6407. }
  6408. focusableEls[focusIndex].focus();
  6409. };
  6410. FocusTrap.prototype.getFocusableElements = function (root) {
  6411. var focusableEls = [].slice.call(root.querySelectorAll('[autofocus], [tabindex], a, input, textarea, select, button'));
  6412. return focusableEls.filter(function (el) {
  6413. var isDisabledOrHidden = el.getAttribute('aria-disabled') === 'true' || el.getAttribute('disabled') != null || el.getAttribute('hidden') != null || el.getAttribute('aria-hidden') === 'true';
  6414. var isTabbableAndVisible = el.tabIndex >= 0 && el.getBoundingClientRect().width > 0 && !el.classList.contains(FOCUS_SENTINEL_CLASS) && !isDisabledOrHidden;
  6415. var isProgrammaticallyHidden = false;
  6416. if (isTabbableAndVisible) {
  6417. var style = getComputedStyle(el);
  6418. isProgrammaticallyHidden = style.display === 'none' || style.visibility === 'hidden';
  6419. }
  6420. return isTabbableAndVisible && !isProgrammaticallyHidden;
  6421. });
  6422. };
  6423. FocusTrap.prototype.createSentinel = function () {
  6424. var sentinel = document.createElement('div');
  6425. sentinel.setAttribute('tabindex', '0');
  6426. // Don't announce in screen readers.
  6427. sentinel.setAttribute('aria-hidden', 'true');
  6428. sentinel.classList.add(FOCUS_SENTINEL_CLASS);
  6429. return sentinel;
  6430. };
  6431. return FocusTrap;
  6432. }();
  6433. exports.FocusTrap = FocusTrap;
  6434. /***/ }),
  6435. /***/ "./packages/mdc-dom/index.ts":
  6436. /*!***********************************!*\
  6437. !*** ./packages/mdc-dom/index.ts ***!
  6438. \***********************************/
  6439. /*! no static exports found */
  6440. /***/ (function(module, exports, __webpack_require__) {
  6441. "use strict";
  6442. /**
  6443. * @license
  6444. * Copyright 2018 Google Inc.
  6445. *
  6446. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6447. * of this software and associated documentation files (the "Software"), to deal
  6448. * in the Software without restriction, including without limitation the rights
  6449. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6450. * copies of the Software, and to permit persons to whom the Software is
  6451. * furnished to do so, subject to the following conditions:
  6452. *
  6453. * The above copyright notice and this permission notice shall be included in
  6454. * all copies or substantial portions of the Software.
  6455. *
  6456. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6457. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6458. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6459. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6460. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6461. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6462. * THE SOFTWARE.
  6463. */
  6464. var __importStar = this && this.__importStar || function (mod) {
  6465. if (mod && mod.__esModule) return mod;
  6466. var result = {};
  6467. if (mod != null) for (var k in mod) {
  6468. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  6469. }result["default"] = mod;
  6470. return result;
  6471. };
  6472. Object.defineProperty(exports, "__esModule", { value: true });
  6473. var events = __importStar(__webpack_require__(/*! ./events */ "./packages/mdc-dom/events.ts"));
  6474. exports.events = events;
  6475. var focusTrap = __importStar(__webpack_require__(/*! ./focus-trap */ "./packages/mdc-dom/focus-trap.ts"));
  6476. exports.focusTrap = focusTrap;
  6477. var keyboard = __importStar(__webpack_require__(/*! ./keyboard */ "./packages/mdc-dom/keyboard.ts"));
  6478. exports.keyboard = keyboard;
  6479. var ponyfill = __importStar(__webpack_require__(/*! ./ponyfill */ "./packages/mdc-dom/ponyfill.ts"));
  6480. exports.ponyfill = ponyfill;
  6481. /***/ }),
  6482. /***/ "./packages/mdc-dom/keyboard.ts":
  6483. /*!**************************************!*\
  6484. !*** ./packages/mdc-dom/keyboard.ts ***!
  6485. \**************************************/
  6486. /*! no static exports found */
  6487. /***/ (function(module, exports, __webpack_require__) {
  6488. "use strict";
  6489. /**
  6490. * @license
  6491. * Copyright 2020 Google Inc.
  6492. *
  6493. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6494. * of this software and associated documentation files (the "Software"), to deal
  6495. * in the Software without restriction, including without limitation the rights
  6496. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6497. * copies of the Software, and to permit persons to whom the Software is
  6498. * furnished to do so, subject to the following conditions:
  6499. *
  6500. * The above copyright notice and this permission notice shall be included in
  6501. * all copies or substantial portions of the Software.
  6502. *
  6503. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6504. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6505. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6506. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6507. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6508. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6509. * THE SOFTWARE.
  6510. */
  6511. Object.defineProperty(exports, "__esModule", { value: true });
  6512. /**
  6513. * KEY provides normalized string values for keys.
  6514. */
  6515. exports.KEY = {
  6516. UNKNOWN: 'Unknown',
  6517. BACKSPACE: 'Backspace',
  6518. ENTER: 'Enter',
  6519. SPACEBAR: 'Spacebar',
  6520. PAGE_UP: 'PageUp',
  6521. PAGE_DOWN: 'PageDown',
  6522. END: 'End',
  6523. HOME: 'Home',
  6524. ARROW_LEFT: 'ArrowLeft',
  6525. ARROW_UP: 'ArrowUp',
  6526. ARROW_RIGHT: 'ArrowRight',
  6527. ARROW_DOWN: 'ArrowDown',
  6528. DELETE: 'Delete',
  6529. ESCAPE: 'Escape'
  6530. };
  6531. var normalizedKeys = new Set();
  6532. // IE11 has no support for new Map with iterable so we need to initialize this
  6533. // by hand.
  6534. normalizedKeys.add(exports.KEY.BACKSPACE);
  6535. normalizedKeys.add(exports.KEY.ENTER);
  6536. normalizedKeys.add(exports.KEY.SPACEBAR);
  6537. normalizedKeys.add(exports.KEY.PAGE_UP);
  6538. normalizedKeys.add(exports.KEY.PAGE_DOWN);
  6539. normalizedKeys.add(exports.KEY.END);
  6540. normalizedKeys.add(exports.KEY.HOME);
  6541. normalizedKeys.add(exports.KEY.ARROW_LEFT);
  6542. normalizedKeys.add(exports.KEY.ARROW_UP);
  6543. normalizedKeys.add(exports.KEY.ARROW_RIGHT);
  6544. normalizedKeys.add(exports.KEY.ARROW_DOWN);
  6545. normalizedKeys.add(exports.KEY.DELETE);
  6546. normalizedKeys.add(exports.KEY.ESCAPE);
  6547. var KEY_CODE = {
  6548. BACKSPACE: 8,
  6549. ENTER: 13,
  6550. SPACEBAR: 32,
  6551. PAGE_UP: 33,
  6552. PAGE_DOWN: 34,
  6553. END: 35,
  6554. HOME: 36,
  6555. ARROW_LEFT: 37,
  6556. ARROW_UP: 38,
  6557. ARROW_RIGHT: 39,
  6558. ARROW_DOWN: 40,
  6559. DELETE: 46,
  6560. ESCAPE: 27
  6561. };
  6562. var mappedKeyCodes = new Map();
  6563. // IE11 has no support for new Map with iterable so we need to initialize this
  6564. // by hand.
  6565. mappedKeyCodes.set(KEY_CODE.BACKSPACE, exports.KEY.BACKSPACE);
  6566. mappedKeyCodes.set(KEY_CODE.ENTER, exports.KEY.ENTER);
  6567. mappedKeyCodes.set(KEY_CODE.SPACEBAR, exports.KEY.SPACEBAR);
  6568. mappedKeyCodes.set(KEY_CODE.PAGE_UP, exports.KEY.PAGE_UP);
  6569. mappedKeyCodes.set(KEY_CODE.PAGE_DOWN, exports.KEY.PAGE_DOWN);
  6570. mappedKeyCodes.set(KEY_CODE.END, exports.KEY.END);
  6571. mappedKeyCodes.set(KEY_CODE.HOME, exports.KEY.HOME);
  6572. mappedKeyCodes.set(KEY_CODE.ARROW_LEFT, exports.KEY.ARROW_LEFT);
  6573. mappedKeyCodes.set(KEY_CODE.ARROW_UP, exports.KEY.ARROW_UP);
  6574. mappedKeyCodes.set(KEY_CODE.ARROW_RIGHT, exports.KEY.ARROW_RIGHT);
  6575. mappedKeyCodes.set(KEY_CODE.ARROW_DOWN, exports.KEY.ARROW_DOWN);
  6576. mappedKeyCodes.set(KEY_CODE.DELETE, exports.KEY.DELETE);
  6577. mappedKeyCodes.set(KEY_CODE.ESCAPE, exports.KEY.ESCAPE);
  6578. var navigationKeys = new Set();
  6579. // IE11 has no support for new Set with iterable so we need to initialize this
  6580. // by hand.
  6581. navigationKeys.add(exports.KEY.PAGE_UP);
  6582. navigationKeys.add(exports.KEY.PAGE_DOWN);
  6583. navigationKeys.add(exports.KEY.END);
  6584. navigationKeys.add(exports.KEY.HOME);
  6585. navigationKeys.add(exports.KEY.ARROW_LEFT);
  6586. navigationKeys.add(exports.KEY.ARROW_UP);
  6587. navigationKeys.add(exports.KEY.ARROW_RIGHT);
  6588. navigationKeys.add(exports.KEY.ARROW_DOWN);
  6589. /**
  6590. * normalizeKey returns the normalized string for a navigational action.
  6591. */
  6592. function normalizeKey(evt) {
  6593. var key = evt.key;
  6594. // If the event already has a normalized key, return it
  6595. if (normalizedKeys.has(key)) {
  6596. return key;
  6597. }
  6598. // tslint:disable-next-line:deprecation
  6599. var mappedKey = mappedKeyCodes.get(evt.keyCode);
  6600. if (mappedKey) {
  6601. return mappedKey;
  6602. }
  6603. return exports.KEY.UNKNOWN;
  6604. }
  6605. exports.normalizeKey = normalizeKey;
  6606. /**
  6607. * isNavigationEvent returns whether the event is a navigation event
  6608. */
  6609. function isNavigationEvent(evt) {
  6610. return navigationKeys.has(normalizeKey(evt));
  6611. }
  6612. exports.isNavigationEvent = isNavigationEvent;
  6613. /***/ }),
  6614. /***/ "./packages/mdc-dom/ponyfill.ts":
  6615. /*!**************************************!*\
  6616. !*** ./packages/mdc-dom/ponyfill.ts ***!
  6617. \**************************************/
  6618. /*! no static exports found */
  6619. /***/ (function(module, exports, __webpack_require__) {
  6620. "use strict";
  6621. /**
  6622. * @license
  6623. * Copyright 2018 Google Inc.
  6624. *
  6625. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6626. * of this software and associated documentation files (the "Software"), to deal
  6627. * in the Software without restriction, including without limitation the rights
  6628. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6629. * copies of the Software, and to permit persons to whom the Software is
  6630. * furnished to do so, subject to the following conditions:
  6631. *
  6632. * The above copyright notice and this permission notice shall be included in
  6633. * all copies or substantial portions of the Software.
  6634. *
  6635. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6636. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6637. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6638. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6639. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6640. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6641. * THE SOFTWARE.
  6642. */
  6643. Object.defineProperty(exports, "__esModule", { value: true });
  6644. /**
  6645. * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
  6646. * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
  6647. */
  6648. function closest(element, selector) {
  6649. if (element.closest) {
  6650. return element.closest(selector);
  6651. }
  6652. var el = element;
  6653. while (el) {
  6654. if (matches(el, selector)) {
  6655. return el;
  6656. }
  6657. el = el.parentElement;
  6658. }
  6659. return null;
  6660. }
  6661. exports.closest = closest;
  6662. function matches(element, selector) {
  6663. var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
  6664. return nativeMatches.call(element, selector);
  6665. }
  6666. exports.matches = matches;
  6667. /**
  6668. * Used to compute the estimated scroll width of elements. When an element is
  6669. * hidden due to display: none; being applied to a parent element, the width is
  6670. * returned as 0. However, the element will have a true width once no longer
  6671. * inside a display: none context. This method computes an estimated width when
  6672. * the element is hidden or returns the true width when the element is visble.
  6673. * @param {Element} element the element whose width to estimate
  6674. */
  6675. function estimateScrollWidth(element) {
  6676. // Check the offsetParent. If the element inherits display: none from any
  6677. // parent, the offsetParent property will be null (see
  6678. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
  6679. // This check ensures we only clone the node when necessary.
  6680. var htmlEl = element;
  6681. if (htmlEl.offsetParent !== null) {
  6682. return htmlEl.scrollWidth;
  6683. }
  6684. var clone = htmlEl.cloneNode(true);
  6685. clone.style.setProperty('position', 'absolute');
  6686. clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
  6687. document.documentElement.appendChild(clone);
  6688. var scrollWidth = clone.scrollWidth;
  6689. document.documentElement.removeChild(clone);
  6690. return scrollWidth;
  6691. }
  6692. exports.estimateScrollWidth = estimateScrollWidth;
  6693. /***/ }),
  6694. /***/ "./packages/mdc-drawer/component.ts":
  6695. /*!******************************************!*\
  6696. !*** ./packages/mdc-drawer/component.ts ***!
  6697. \******************************************/
  6698. /*! no static exports found */
  6699. /***/ (function(module, exports, __webpack_require__) {
  6700. "use strict";
  6701. /**
  6702. * @license
  6703. * Copyright 2016 Google Inc.
  6704. *
  6705. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6706. * of this software and associated documentation files (the "Software"), to deal
  6707. * in the Software without restriction, including without limitation the rights
  6708. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6709. * copies of the Software, and to permit persons to whom the Software is
  6710. * furnished to do so, subject to the following conditions:
  6711. *
  6712. * The above copyright notice and this permission notice shall be included in
  6713. * all copies or substantial portions of the Software.
  6714. *
  6715. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6716. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6717. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6718. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6719. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6720. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6721. * THE SOFTWARE.
  6722. */
  6723. var __extends = this && this.__extends || function () {
  6724. var _extendStatics = function extendStatics(d, b) {
  6725. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  6726. d.__proto__ = b;
  6727. } || function (d, b) {
  6728. for (var p in b) {
  6729. if (b.hasOwnProperty(p)) d[p] = b[p];
  6730. }
  6731. };
  6732. return _extendStatics(d, b);
  6733. };
  6734. return function (d, b) {
  6735. _extendStatics(d, b);
  6736. function __() {
  6737. this.constructor = d;
  6738. }
  6739. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6740. };
  6741. }();
  6742. var __importStar = this && this.__importStar || function (mod) {
  6743. if (mod && mod.__esModule) return mod;
  6744. var result = {};
  6745. if (mod != null) for (var k in mod) {
  6746. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  6747. }result["default"] = mod;
  6748. return result;
  6749. };
  6750. Object.defineProperty(exports, "__esModule", { value: true });
  6751. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  6752. var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
  6753. var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
  6754. var foundation_1 = __webpack_require__(/*! @material/list/foundation */ "./packages/mdc-list/foundation.ts");
  6755. var foundation_2 = __webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
  6756. var foundation_3 = __webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts");
  6757. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
  6758. var cssClasses = foundation_2.MDCDismissibleDrawerFoundation.cssClasses,
  6759. strings = foundation_2.MDCDismissibleDrawerFoundation.strings;
  6760. /**
  6761. * @events `MDCDrawer:closed {}` Emits when the navigation drawer has closed.
  6762. * @events `MDCDrawer:opened {}` Emits when the navigation drawer has opened.
  6763. */
  6764. var MDCDrawer = /** @class */function (_super) {
  6765. __extends(MDCDrawer, _super);
  6766. function MDCDrawer() {
  6767. return _super !== null && _super.apply(this, arguments) || this;
  6768. }
  6769. MDCDrawer.attachTo = function (root) {
  6770. return new MDCDrawer(root);
  6771. };
  6772. Object.defineProperty(MDCDrawer.prototype, "open", {
  6773. /**
  6774. * @return boolean Proxies to the foundation's `open`/`close` methods.
  6775. * Also returns true if drawer is in the open position.
  6776. */
  6777. get: function get() {
  6778. return this.foundation.isOpen();
  6779. },
  6780. /**
  6781. * Toggles the drawer open and closed.
  6782. */
  6783. set: function set(isOpen) {
  6784. if (isOpen) {
  6785. this.foundation.open();
  6786. } else {
  6787. this.foundation.close();
  6788. }
  6789. },
  6790. enumerable: true,
  6791. configurable: true
  6792. });
  6793. Object.defineProperty(MDCDrawer.prototype, "list", {
  6794. get: function get() {
  6795. return this.list_;
  6796. },
  6797. enumerable: true,
  6798. configurable: true
  6799. });
  6800. MDCDrawer.prototype.initialize = function (focusTrapFactory, listFactory) {
  6801. if (focusTrapFactory === void 0) {
  6802. focusTrapFactory = function focusTrapFactory(el) {
  6803. return new focus_trap_1.FocusTrap(el);
  6804. };
  6805. }
  6806. if (listFactory === void 0) {
  6807. listFactory = function listFactory(el) {
  6808. return new component_2.MDCList(el);
  6809. };
  6810. }
  6811. var listEl = this.root.querySelector("." + foundation_1.MDCListFoundation.cssClasses.ROOT);
  6812. if (listEl) {
  6813. this.list_ = listFactory(listEl);
  6814. this.list_.wrapFocus = true;
  6815. }
  6816. this.focusTrapFactory_ = focusTrapFactory;
  6817. };
  6818. MDCDrawer.prototype.initialSyncWithDOM = function () {
  6819. var _this = this;
  6820. var MODAL = cssClasses.MODAL;
  6821. var SCRIM_SELECTOR = strings.SCRIM_SELECTOR;
  6822. this.scrim_ = this.root.parentNode.querySelector(SCRIM_SELECTOR);
  6823. if (this.scrim_ && this.root.classList.contains(MODAL)) {
  6824. this.handleScrimClick_ = function () {
  6825. return _this.foundation.handleScrimClick();
  6826. };
  6827. this.scrim_.addEventListener('click', this.handleScrimClick_);
  6828. this.focusTrap_ = util.createFocusTrapInstance(this.root, this.focusTrapFactory_);
  6829. }
  6830. this.handleKeydown_ = function (evt) {
  6831. return _this.foundation.handleKeydown(evt);
  6832. };
  6833. this.handleTransitionEnd_ = function (evt) {
  6834. return _this.foundation.handleTransitionEnd(evt);
  6835. };
  6836. this.listen('keydown', this.handleKeydown_);
  6837. this.listen('transitionend', this.handleTransitionEnd_);
  6838. };
  6839. MDCDrawer.prototype.destroy = function () {
  6840. this.unlisten('keydown', this.handleKeydown_);
  6841. this.unlisten('transitionend', this.handleTransitionEnd_);
  6842. if (this.list_) {
  6843. this.list_.destroy();
  6844. }
  6845. var MODAL = cssClasses.MODAL;
  6846. if (this.scrim_ && this.handleScrimClick_ && this.root.classList.contains(MODAL)) {
  6847. this.scrim_.removeEventListener('click', this.handleScrimClick_);
  6848. // Ensure drawer is closed to hide scrim and release focus
  6849. this.open = false;
  6850. }
  6851. };
  6852. MDCDrawer.prototype.getDefaultFoundation = function () {
  6853. var _this = this;
  6854. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  6855. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  6856. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  6857. var adapter = {
  6858. addClass: function addClass(className) {
  6859. return _this.root.classList.add(className);
  6860. },
  6861. removeClass: function removeClass(className) {
  6862. return _this.root.classList.remove(className);
  6863. },
  6864. hasClass: function hasClass(className) {
  6865. return _this.root.classList.contains(className);
  6866. },
  6867. elementHasClass: function elementHasClass(element, className) {
  6868. return element.classList.contains(className);
  6869. },
  6870. saveFocus: function saveFocus() {
  6871. return _this.previousFocus_ = document.activeElement;
  6872. },
  6873. restoreFocus: function restoreFocus() {
  6874. var previousFocus = _this.previousFocus_;
  6875. if (previousFocus && previousFocus.focus && _this.root.contains(document.activeElement)) {
  6876. previousFocus.focus();
  6877. }
  6878. },
  6879. focusActiveNavigationItem: function focusActiveNavigationItem() {
  6880. var activeNavItemEl = _this.root.querySelector("." + foundation_1.MDCListFoundation.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
  6881. if (activeNavItemEl) {
  6882. activeNavItemEl.focus();
  6883. }
  6884. },
  6885. notifyClose: function notifyClose() {
  6886. return _this.emit(strings.CLOSE_EVENT, {}, true /* shouldBubble */);
  6887. },
  6888. notifyOpen: function notifyOpen() {
  6889. return _this.emit(strings.OPEN_EVENT, {}, true /* shouldBubble */);
  6890. },
  6891. trapFocus: function trapFocus() {
  6892. return _this.focusTrap_.trapFocus();
  6893. },
  6894. releaseFocus: function releaseFocus() {
  6895. return _this.focusTrap_.releaseFocus();
  6896. }
  6897. };
  6898. // tslint:enable:object-literal-sort-keys
  6899. var DISMISSIBLE = cssClasses.DISMISSIBLE,
  6900. MODAL = cssClasses.MODAL;
  6901. if (this.root.classList.contains(DISMISSIBLE)) {
  6902. return new foundation_2.MDCDismissibleDrawerFoundation(adapter);
  6903. } else if (this.root.classList.contains(MODAL)) {
  6904. return new foundation_3.MDCModalDrawerFoundation(adapter);
  6905. } else {
  6906. throw new Error("MDCDrawer: Failed to instantiate component. Supported variants are " + DISMISSIBLE + " and " + MODAL + ".");
  6907. }
  6908. };
  6909. return MDCDrawer;
  6910. }(component_1.MDCComponent);
  6911. exports.MDCDrawer = MDCDrawer;
  6912. /***/ }),
  6913. /***/ "./packages/mdc-drawer/constants.ts":
  6914. /*!******************************************!*\
  6915. !*** ./packages/mdc-drawer/constants.ts ***!
  6916. \******************************************/
  6917. /*! no static exports found */
  6918. /***/ (function(module, exports, __webpack_require__) {
  6919. "use strict";
  6920. /**
  6921. * @license
  6922. * Copyright 2016 Google Inc.
  6923. *
  6924. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6925. * of this software and associated documentation files (the "Software"), to deal
  6926. * in the Software without restriction, including without limitation the rights
  6927. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6928. * copies of the Software, and to permit persons to whom the Software is
  6929. * furnished to do so, subject to the following conditions:
  6930. *
  6931. * The above copyright notice and this permission notice shall be included in
  6932. * all copies or substantial portions of the Software.
  6933. *
  6934. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6935. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6936. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6937. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6938. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6939. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6940. * THE SOFTWARE.
  6941. */
  6942. Object.defineProperty(exports, "__esModule", { value: true });
  6943. var cssClasses = {
  6944. ANIMATE: 'mdc-drawer--animate',
  6945. CLOSING: 'mdc-drawer--closing',
  6946. DISMISSIBLE: 'mdc-drawer--dismissible',
  6947. MODAL: 'mdc-drawer--modal',
  6948. OPEN: 'mdc-drawer--open',
  6949. OPENING: 'mdc-drawer--opening',
  6950. ROOT: 'mdc-drawer'
  6951. };
  6952. exports.cssClasses = cssClasses;
  6953. var strings = {
  6954. APP_CONTENT_SELECTOR: '.mdc-drawer-app-content',
  6955. CLOSE_EVENT: 'MDCDrawer:closed',
  6956. OPEN_EVENT: 'MDCDrawer:opened',
  6957. SCRIM_SELECTOR: '.mdc-drawer-scrim'
  6958. };
  6959. exports.strings = strings;
  6960. /***/ }),
  6961. /***/ "./packages/mdc-drawer/dismissible/foundation.ts":
  6962. /*!*******************************************************!*\
  6963. !*** ./packages/mdc-drawer/dismissible/foundation.ts ***!
  6964. \*******************************************************/
  6965. /*! no static exports found */
  6966. /***/ (function(module, exports, __webpack_require__) {
  6967. "use strict";
  6968. /**
  6969. * @license
  6970. * Copyright 2018 Google Inc.
  6971. *
  6972. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6973. * of this software and associated documentation files (the "Software"), to deal
  6974. * in the Software without restriction, including without limitation the rights
  6975. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6976. * copies of the Software, and to permit persons to whom the Software is
  6977. * furnished to do so, subject to the following conditions:
  6978. *
  6979. * The above copyright notice and this permission notice shall be included in
  6980. * all copies or substantial portions of the Software.
  6981. *
  6982. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6983. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6984. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6985. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6986. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6987. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6988. * THE SOFTWARE.
  6989. */
  6990. var __extends = this && this.__extends || function () {
  6991. var _extendStatics = function extendStatics(d, b) {
  6992. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  6993. d.__proto__ = b;
  6994. } || function (d, b) {
  6995. for (var p in b) {
  6996. if (b.hasOwnProperty(p)) d[p] = b[p];
  6997. }
  6998. };
  6999. return _extendStatics(d, b);
  7000. };
  7001. return function (d, b) {
  7002. _extendStatics(d, b);
  7003. function __() {
  7004. this.constructor = d;
  7005. }
  7006. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7007. };
  7008. }();
  7009. var __assign = this && this.__assign || function () {
  7010. __assign = Object.assign || function (t) {
  7011. for (var s, i = 1, n = arguments.length; i < n; i++) {
  7012. s = arguments[i];
  7013. for (var p in s) {
  7014. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  7015. }
  7016. }
  7017. return t;
  7018. };
  7019. return __assign.apply(this, arguments);
  7020. };
  7021. Object.defineProperty(exports, "__esModule", { value: true });
  7022. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  7023. var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-drawer/constants.ts");
  7024. var MDCDismissibleDrawerFoundation = /** @class */function (_super) {
  7025. __extends(MDCDismissibleDrawerFoundation, _super);
  7026. function MDCDismissibleDrawerFoundation(adapter) {
  7027. var _this = _super.call(this, __assign(__assign({}, MDCDismissibleDrawerFoundation.defaultAdapter), adapter)) || this;
  7028. _this.animationFrame_ = 0;
  7029. _this.animationTimer_ = 0;
  7030. return _this;
  7031. }
  7032. Object.defineProperty(MDCDismissibleDrawerFoundation, "strings", {
  7033. get: function get() {
  7034. return constants_1.strings;
  7035. },
  7036. enumerable: true,
  7037. configurable: true
  7038. });
  7039. Object.defineProperty(MDCDismissibleDrawerFoundation, "cssClasses", {
  7040. get: function get() {
  7041. return constants_1.cssClasses;
  7042. },
  7043. enumerable: true,
  7044. configurable: true
  7045. });
  7046. Object.defineProperty(MDCDismissibleDrawerFoundation, "defaultAdapter", {
  7047. get: function get() {
  7048. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  7049. return {
  7050. addClass: function addClass() {
  7051. return undefined;
  7052. },
  7053. removeClass: function removeClass() {
  7054. return undefined;
  7055. },
  7056. hasClass: function hasClass() {
  7057. return false;
  7058. },
  7059. elementHasClass: function elementHasClass() {
  7060. return false;
  7061. },
  7062. notifyClose: function notifyClose() {
  7063. return undefined;
  7064. },
  7065. notifyOpen: function notifyOpen() {
  7066. return undefined;
  7067. },
  7068. saveFocus: function saveFocus() {
  7069. return undefined;
  7070. },
  7071. restoreFocus: function restoreFocus() {
  7072. return undefined;
  7073. },
  7074. focusActiveNavigationItem: function focusActiveNavigationItem() {
  7075. return undefined;
  7076. },
  7077. trapFocus: function trapFocus() {
  7078. return undefined;
  7079. },
  7080. releaseFocus: function releaseFocus() {
  7081. return undefined;
  7082. }
  7083. };
  7084. // tslint:enable:object-literal-sort-keys
  7085. },
  7086. enumerable: true,
  7087. configurable: true
  7088. });
  7089. MDCDismissibleDrawerFoundation.prototype.destroy = function () {
  7090. if (this.animationFrame_) {
  7091. cancelAnimationFrame(this.animationFrame_);
  7092. }
  7093. if (this.animationTimer_) {
  7094. clearTimeout(this.animationTimer_);
  7095. }
  7096. };
  7097. /**
  7098. * Opens the drawer from the closed state.
  7099. */
  7100. MDCDismissibleDrawerFoundation.prototype.open = function () {
  7101. var _this = this;
  7102. if (this.isOpen() || this.isOpening() || this.isClosing()) {
  7103. return;
  7104. }
  7105. this.adapter.addClass(constants_1.cssClasses.OPEN);
  7106. this.adapter.addClass(constants_1.cssClasses.ANIMATE);
  7107. // Wait a frame once display is no longer "none", to establish basis for animation
  7108. this.runNextAnimationFrame_(function () {
  7109. _this.adapter.addClass(constants_1.cssClasses.OPENING);
  7110. });
  7111. this.adapter.saveFocus();
  7112. };
  7113. /**
  7114. * Closes the drawer from the open state.
  7115. */
  7116. MDCDismissibleDrawerFoundation.prototype.close = function () {
  7117. if (!this.isOpen() || this.isOpening() || this.isClosing()) {
  7118. return;
  7119. }
  7120. this.adapter.addClass(constants_1.cssClasses.CLOSING);
  7121. };
  7122. /**
  7123. * Returns true if the drawer is in the open position.
  7124. * @return true if drawer is in open state.
  7125. */
  7126. MDCDismissibleDrawerFoundation.prototype.isOpen = function () {
  7127. return this.adapter.hasClass(constants_1.cssClasses.OPEN);
  7128. };
  7129. /**
  7130. * Returns true if the drawer is animating open.
  7131. * @return true if drawer is animating open.
  7132. */
  7133. MDCDismissibleDrawerFoundation.prototype.isOpening = function () {
  7134. return this.adapter.hasClass(constants_1.cssClasses.OPENING) || this.adapter.hasClass(constants_1.cssClasses.ANIMATE);
  7135. };
  7136. /**
  7137. * Returns true if the drawer is animating closed.
  7138. * @return true if drawer is animating closed.
  7139. */
  7140. MDCDismissibleDrawerFoundation.prototype.isClosing = function () {
  7141. return this.adapter.hasClass(constants_1.cssClasses.CLOSING);
  7142. };
  7143. /**
  7144. * Keydown handler to close drawer when key is escape.
  7145. */
  7146. MDCDismissibleDrawerFoundation.prototype.handleKeydown = function (evt) {
  7147. var keyCode = evt.keyCode,
  7148. key = evt.key;
  7149. var isEscape = key === 'Escape' || keyCode === 27;
  7150. if (isEscape) {
  7151. this.close();
  7152. }
  7153. };
  7154. /**
  7155. * Handles the `transitionend` event when the drawer finishes opening/closing.
  7156. */
  7157. MDCDismissibleDrawerFoundation.prototype.handleTransitionEnd = function (evt) {
  7158. var OPENING = constants_1.cssClasses.OPENING,
  7159. CLOSING = constants_1.cssClasses.CLOSING,
  7160. OPEN = constants_1.cssClasses.OPEN,
  7161. ANIMATE = constants_1.cssClasses.ANIMATE,
  7162. ROOT = constants_1.cssClasses.ROOT;
  7163. // In Edge, transitionend on ripple pseudo-elements yields a target without classList, so check for Element first.
  7164. var isRootElement = this.isElement_(evt.target) && this.adapter.elementHasClass(evt.target, ROOT);
  7165. if (!isRootElement) {
  7166. return;
  7167. }
  7168. if (this.isClosing()) {
  7169. this.adapter.removeClass(OPEN);
  7170. this.closed_();
  7171. this.adapter.restoreFocus();
  7172. this.adapter.notifyClose();
  7173. } else {
  7174. this.adapter.focusActiveNavigationItem();
  7175. this.opened_();
  7176. this.adapter.notifyOpen();
  7177. }
  7178. this.adapter.removeClass(ANIMATE);
  7179. this.adapter.removeClass(OPENING);
  7180. this.adapter.removeClass(CLOSING);
  7181. };
  7182. /**
  7183. * Extension point for when drawer finishes open animation.
  7184. */
  7185. MDCDismissibleDrawerFoundation.prototype.opened_ = function () {}; // tslint:disable-line:no-empty
  7186. /**
  7187. * Extension point for when drawer finishes close animation.
  7188. */
  7189. MDCDismissibleDrawerFoundation.prototype.closed_ = function () {}; // tslint:disable-line:no-empty
  7190. /**
  7191. * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
  7192. */
  7193. MDCDismissibleDrawerFoundation.prototype.runNextAnimationFrame_ = function (callback) {
  7194. var _this = this;
  7195. cancelAnimationFrame(this.animationFrame_);
  7196. this.animationFrame_ = requestAnimationFrame(function () {
  7197. _this.animationFrame_ = 0;
  7198. clearTimeout(_this.animationTimer_);
  7199. _this.animationTimer_ = setTimeout(callback, 0);
  7200. });
  7201. };
  7202. MDCDismissibleDrawerFoundation.prototype.isElement_ = function (element) {
  7203. // In Edge, transitionend on ripple pseudo-elements yields a target without classList.
  7204. return Boolean(element.classList);
  7205. };
  7206. return MDCDismissibleDrawerFoundation;
  7207. }(foundation_1.MDCFoundation);
  7208. exports.MDCDismissibleDrawerFoundation = MDCDismissibleDrawerFoundation;
  7209. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  7210. exports.default = MDCDismissibleDrawerFoundation;
  7211. /***/ }),
  7212. /***/ "./packages/mdc-drawer/index.ts":
  7213. /*!**************************************!*\
  7214. !*** ./packages/mdc-drawer/index.ts ***!
  7215. \**************************************/
  7216. /*! no static exports found */
  7217. /***/ (function(module, exports, __webpack_require__) {
  7218. "use strict";
  7219. /**
  7220. * @license
  7221. * Copyright 2019 Google Inc.
  7222. *
  7223. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7224. * of this software and associated documentation files (the "Software"), to deal
  7225. * in the Software without restriction, including without limitation the rights
  7226. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7227. * copies of the Software, and to permit persons to whom the Software is
  7228. * furnished to do so, subject to the following conditions:
  7229. *
  7230. * The above copyright notice and this permission notice shall be included in
  7231. * all copies or substantial portions of the Software.
  7232. *
  7233. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7234. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7235. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7236. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7237. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7238. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7239. * THE SOFTWARE.
  7240. */
  7241. function __export(m) {
  7242. for (var p in m) {
  7243. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  7244. }
  7245. }
  7246. var __importStar = this && this.__importStar || function (mod) {
  7247. if (mod && mod.__esModule) return mod;
  7248. var result = {};
  7249. if (mod != null) for (var k in mod) {
  7250. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  7251. }result["default"] = mod;
  7252. return result;
  7253. };
  7254. Object.defineProperty(exports, "__esModule", { value: true });
  7255. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
  7256. exports.util = util;
  7257. __export(__webpack_require__(/*! ./component */ "./packages/mdc-drawer/component.ts"));
  7258. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-drawer/constants.ts"));
  7259. __export(__webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts"));
  7260. __export(__webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts"));
  7261. /***/ }),
  7262. /***/ "./packages/mdc-drawer/modal/foundation.ts":
  7263. /*!*************************************************!*\
  7264. !*** ./packages/mdc-drawer/modal/foundation.ts ***!
  7265. \*************************************************/
  7266. /*! no static exports found */
  7267. /***/ (function(module, exports, __webpack_require__) {
  7268. "use strict";
  7269. /**
  7270. * @license
  7271. * Copyright 2018 Google Inc.
  7272. *
  7273. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7274. * of this software and associated documentation files (the "Software"), to deal
  7275. * in the Software without restriction, including without limitation the rights
  7276. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7277. * copies of the Software, and to permit persons to whom the Software is
  7278. * furnished to do so, subject to the following conditions:
  7279. *
  7280. * The above copyright notice and this permission notice shall be included in
  7281. * all copies or substantial portions of the Software.
  7282. *
  7283. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7284. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7285. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7286. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7287. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7288. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7289. * THE SOFTWARE.
  7290. */
  7291. var __extends = this && this.__extends || function () {
  7292. var _extendStatics = function extendStatics(d, b) {
  7293. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7294. d.__proto__ = b;
  7295. } || function (d, b) {
  7296. for (var p in b) {
  7297. if (b.hasOwnProperty(p)) d[p] = b[p];
  7298. }
  7299. };
  7300. return _extendStatics(d, b);
  7301. };
  7302. return function (d, b) {
  7303. _extendStatics(d, b);
  7304. function __() {
  7305. this.constructor = d;
  7306. }
  7307. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7308. };
  7309. }();
  7310. Object.defineProperty(exports, "__esModule", { value: true });
  7311. var foundation_1 = __webpack_require__(/*! ../dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
  7312. /* istanbul ignore next: subclass is not a branch statement */
  7313. var MDCModalDrawerFoundation = /** @class */function (_super) {
  7314. __extends(MDCModalDrawerFoundation, _super);
  7315. function MDCModalDrawerFoundation() {
  7316. return _super !== null && _super.apply(this, arguments) || this;
  7317. }
  7318. /**
  7319. * Handles click event on scrim.
  7320. */
  7321. MDCModalDrawerFoundation.prototype.handleScrimClick = function () {
  7322. this.close();
  7323. };
  7324. /**
  7325. * Called when drawer finishes open animation.
  7326. */
  7327. MDCModalDrawerFoundation.prototype.opened_ = function () {
  7328. this.adapter.trapFocus();
  7329. };
  7330. /**
  7331. * Called when drawer finishes close animation.
  7332. */
  7333. MDCModalDrawerFoundation.prototype.closed_ = function () {
  7334. this.adapter.releaseFocus();
  7335. };
  7336. return MDCModalDrawerFoundation;
  7337. }(foundation_1.MDCDismissibleDrawerFoundation);
  7338. exports.MDCModalDrawerFoundation = MDCModalDrawerFoundation;
  7339. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  7340. exports.default = MDCModalDrawerFoundation;
  7341. /***/ }),
  7342. /***/ "./packages/mdc-drawer/util.ts":
  7343. /*!*************************************!*\
  7344. !*** ./packages/mdc-drawer/util.ts ***!
  7345. \*************************************/
  7346. /*! no static exports found */
  7347. /***/ (function(module, exports, __webpack_require__) {
  7348. "use strict";
  7349. /**
  7350. * @license
  7351. * Copyright 2016 Google Inc.
  7352. *
  7353. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7354. * of this software and associated documentation files (the "Software"), to deal
  7355. * in the Software without restriction, including without limitation the rights
  7356. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7357. * copies of the Software, and to permit persons to whom the Software is
  7358. * furnished to do so, subject to the following conditions:
  7359. *
  7360. * The above copyright notice and this permission notice shall be included in
  7361. * all copies or substantial portions of the Software.
  7362. *
  7363. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7364. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7365. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7366. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7367. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7368. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7369. * THE SOFTWARE.
  7370. */
  7371. Object.defineProperty(exports, "__esModule", { value: true });
  7372. function createFocusTrapInstance(surfaceEl, focusTrapFactory) {
  7373. return focusTrapFactory(surfaceEl, {
  7374. // Component handles focusing on active nav item.
  7375. skipInitialFocus: true
  7376. });
  7377. }
  7378. exports.createFocusTrapInstance = createFocusTrapInstance;
  7379. /***/ }),
  7380. /***/ "./packages/mdc-floating-label/component.ts":
  7381. /*!**************************************************!*\
  7382. !*** ./packages/mdc-floating-label/component.ts ***!
  7383. \**************************************************/
  7384. /*! no static exports found */
  7385. /***/ (function(module, exports, __webpack_require__) {
  7386. "use strict";
  7387. /**
  7388. * @license
  7389. * Copyright 2016 Google Inc.
  7390. *
  7391. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7392. * of this software and associated documentation files (the "Software"), to deal
  7393. * in the Software without restriction, including without limitation the rights
  7394. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7395. * copies of the Software, and to permit persons to whom the Software is
  7396. * furnished to do so, subject to the following conditions:
  7397. *
  7398. * The above copyright notice and this permission notice shall be included in
  7399. * all copies or substantial portions of the Software.
  7400. *
  7401. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7402. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7403. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7404. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7405. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7406. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7407. * THE SOFTWARE.
  7408. */
  7409. var __extends = this && this.__extends || function () {
  7410. var _extendStatics = function extendStatics(d, b) {
  7411. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7412. d.__proto__ = b;
  7413. } || function (d, b) {
  7414. for (var p in b) {
  7415. if (b.hasOwnProperty(p)) d[p] = b[p];
  7416. }
  7417. };
  7418. return _extendStatics(d, b);
  7419. };
  7420. return function (d, b) {
  7421. _extendStatics(d, b);
  7422. function __() {
  7423. this.constructor = d;
  7424. }
  7425. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7426. };
  7427. }();
  7428. Object.defineProperty(exports, "__esModule", { value: true });
  7429. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  7430. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  7431. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts");
  7432. var MDCFloatingLabel = /** @class */function (_super) {
  7433. __extends(MDCFloatingLabel, _super);
  7434. function MDCFloatingLabel() {
  7435. return _super !== null && _super.apply(this, arguments) || this;
  7436. }
  7437. MDCFloatingLabel.attachTo = function (root) {
  7438. return new MDCFloatingLabel(root);
  7439. };
  7440. /**
  7441. * Styles the label to produce the label shake for errors.
  7442. * @param shouldShake If true, shakes the label by adding a CSS class; otherwise, stops shaking by removing the class.
  7443. */
  7444. MDCFloatingLabel.prototype.shake = function (shouldShake) {
  7445. this.foundation.shake(shouldShake);
  7446. };
  7447. /**
  7448. * Styles the label to float/dock.
  7449. * @param shouldFloat If true, floats the label by adding a CSS class; otherwise, docks it by removing the class.
  7450. */
  7451. MDCFloatingLabel.prototype.float = function (shouldFloat) {
  7452. this.foundation.float(shouldFloat);
  7453. };
  7454. /**
  7455. * Styles the label as required.
  7456. * @param isRequired If true, adds an asterisk to the label, indicating that it is required.
  7457. */
  7458. MDCFloatingLabel.prototype.setRequired = function (isRequired) {
  7459. this.foundation.setRequired(isRequired);
  7460. };
  7461. MDCFloatingLabel.prototype.getWidth = function () {
  7462. return this.foundation.getWidth();
  7463. };
  7464. MDCFloatingLabel.prototype.getDefaultFoundation = function () {
  7465. var _this = this;
  7466. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  7467. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  7468. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  7469. var adapter = {
  7470. addClass: function addClass(className) {
  7471. return _this.root.classList.add(className);
  7472. },
  7473. removeClass: function removeClass(className) {
  7474. return _this.root.classList.remove(className);
  7475. },
  7476. getWidth: function getWidth() {
  7477. return ponyfill_1.estimateScrollWidth(_this.root);
  7478. },
  7479. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  7480. return _this.listen(evtType, handler);
  7481. },
  7482. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  7483. return _this.unlisten(evtType, handler);
  7484. }
  7485. };
  7486. // tslint:enable:object-literal-sort-keys
  7487. return new foundation_1.MDCFloatingLabelFoundation(adapter);
  7488. };
  7489. return MDCFloatingLabel;
  7490. }(component_1.MDCComponent);
  7491. exports.MDCFloatingLabel = MDCFloatingLabel;
  7492. /***/ }),
  7493. /***/ "./packages/mdc-floating-label/constants.ts":
  7494. /*!**************************************************!*\
  7495. !*** ./packages/mdc-floating-label/constants.ts ***!
  7496. \**************************************************/
  7497. /*! no static exports found */
  7498. /***/ (function(module, exports, __webpack_require__) {
  7499. "use strict";
  7500. /**
  7501. * @license
  7502. * Copyright 2016 Google Inc.
  7503. *
  7504. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7505. * of this software and associated documentation files (the "Software"), to deal
  7506. * in the Software without restriction, including without limitation the rights
  7507. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7508. * copies of the Software, and to permit persons to whom the Software is
  7509. * furnished to do so, subject to the following conditions:
  7510. *
  7511. * The above copyright notice and this permission notice shall be included in
  7512. * all copies or substantial portions of the Software.
  7513. *
  7514. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7515. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7516. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7517. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7518. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7519. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7520. * THE SOFTWARE.
  7521. */
  7522. Object.defineProperty(exports, "__esModule", { value: true });
  7523. exports.cssClasses = {
  7524. LABEL_FLOAT_ABOVE: 'mdc-floating-label--float-above',
  7525. LABEL_REQUIRED: 'mdc-floating-label--required',
  7526. LABEL_SHAKE: 'mdc-floating-label--shake',
  7527. ROOT: 'mdc-floating-label'
  7528. };
  7529. /***/ }),
  7530. /***/ "./packages/mdc-floating-label/foundation.ts":
  7531. /*!***************************************************!*\
  7532. !*** ./packages/mdc-floating-label/foundation.ts ***!
  7533. \***************************************************/
  7534. /*! no static exports found */
  7535. /***/ (function(module, exports, __webpack_require__) {
  7536. "use strict";
  7537. /**
  7538. * @license
  7539. * Copyright 2016 Google Inc.
  7540. *
  7541. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7542. * of this software and associated documentation files (the "Software"), to deal
  7543. * in the Software without restriction, including without limitation the rights
  7544. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7545. * copies of the Software, and to permit persons to whom the Software is
  7546. * furnished to do so, subject to the following conditions:
  7547. *
  7548. * The above copyright notice and this permission notice shall be included in
  7549. * all copies or substantial portions of the Software.
  7550. *
  7551. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7552. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7553. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7554. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7555. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7556. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7557. * THE SOFTWARE.
  7558. */
  7559. var __extends = this && this.__extends || function () {
  7560. var _extendStatics = function extendStatics(d, b) {
  7561. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7562. d.__proto__ = b;
  7563. } || function (d, b) {
  7564. for (var p in b) {
  7565. if (b.hasOwnProperty(p)) d[p] = b[p];
  7566. }
  7567. };
  7568. return _extendStatics(d, b);
  7569. };
  7570. return function (d, b) {
  7571. _extendStatics(d, b);
  7572. function __() {
  7573. this.constructor = d;
  7574. }
  7575. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7576. };
  7577. }();
  7578. var __assign = this && this.__assign || function () {
  7579. __assign = Object.assign || function (t) {
  7580. for (var s, i = 1, n = arguments.length; i < n; i++) {
  7581. s = arguments[i];
  7582. for (var p in s) {
  7583. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  7584. }
  7585. }
  7586. return t;
  7587. };
  7588. return __assign.apply(this, arguments);
  7589. };
  7590. Object.defineProperty(exports, "__esModule", { value: true });
  7591. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  7592. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts");
  7593. var MDCFloatingLabelFoundation = /** @class */function (_super) {
  7594. __extends(MDCFloatingLabelFoundation, _super);
  7595. function MDCFloatingLabelFoundation(adapter) {
  7596. var _this = _super.call(this, __assign(__assign({}, MDCFloatingLabelFoundation.defaultAdapter), adapter)) || this;
  7597. _this.shakeAnimationEndHandler_ = function () {
  7598. return _this.handleShakeAnimationEnd_();
  7599. };
  7600. return _this;
  7601. }
  7602. Object.defineProperty(MDCFloatingLabelFoundation, "cssClasses", {
  7603. get: function get() {
  7604. return constants_1.cssClasses;
  7605. },
  7606. enumerable: true,
  7607. configurable: true
  7608. });
  7609. Object.defineProperty(MDCFloatingLabelFoundation, "defaultAdapter", {
  7610. /**
  7611. * See {@link MDCFloatingLabelAdapter} for typing information on parameters and return types.
  7612. */
  7613. get: function get() {
  7614. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  7615. return {
  7616. addClass: function addClass() {
  7617. return undefined;
  7618. },
  7619. removeClass: function removeClass() {
  7620. return undefined;
  7621. },
  7622. getWidth: function getWidth() {
  7623. return 0;
  7624. },
  7625. registerInteractionHandler: function registerInteractionHandler() {
  7626. return undefined;
  7627. },
  7628. deregisterInteractionHandler: function deregisterInteractionHandler() {
  7629. return undefined;
  7630. }
  7631. };
  7632. // tslint:enable:object-literal-sort-keys
  7633. },
  7634. enumerable: true,
  7635. configurable: true
  7636. });
  7637. MDCFloatingLabelFoundation.prototype.init = function () {
  7638. this.adapter.registerInteractionHandler('animationend', this.shakeAnimationEndHandler_);
  7639. };
  7640. MDCFloatingLabelFoundation.prototype.destroy = function () {
  7641. this.adapter.deregisterInteractionHandler('animationend', this.shakeAnimationEndHandler_);
  7642. };
  7643. /**
  7644. * Returns the width of the label element.
  7645. */
  7646. MDCFloatingLabelFoundation.prototype.getWidth = function () {
  7647. return this.adapter.getWidth();
  7648. };
  7649. /**
  7650. * Styles the label to produce a shake animation to indicate an error.
  7651. * @param shouldShake If true, adds the shake CSS class; otherwise, removes shake class.
  7652. */
  7653. MDCFloatingLabelFoundation.prototype.shake = function (shouldShake) {
  7654. var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
  7655. if (shouldShake) {
  7656. this.adapter.addClass(LABEL_SHAKE);
  7657. } else {
  7658. this.adapter.removeClass(LABEL_SHAKE);
  7659. }
  7660. };
  7661. /**
  7662. * Styles the label to float or dock.
  7663. * @param shouldFloat If true, adds the float CSS class; otherwise, removes float and shake classes to dock the label.
  7664. */
  7665. MDCFloatingLabelFoundation.prototype.float = function (shouldFloat) {
  7666. var _a = MDCFloatingLabelFoundation.cssClasses,
  7667. LABEL_FLOAT_ABOVE = _a.LABEL_FLOAT_ABOVE,
  7668. LABEL_SHAKE = _a.LABEL_SHAKE;
  7669. if (shouldFloat) {
  7670. this.adapter.addClass(LABEL_FLOAT_ABOVE);
  7671. } else {
  7672. this.adapter.removeClass(LABEL_FLOAT_ABOVE);
  7673. this.adapter.removeClass(LABEL_SHAKE);
  7674. }
  7675. };
  7676. /**
  7677. * Styles the label as required.
  7678. * @param isRequired If true, adds an asterisk to the label, indicating that it is required.
  7679. */
  7680. MDCFloatingLabelFoundation.prototype.setRequired = function (isRequired) {
  7681. var LABEL_REQUIRED = MDCFloatingLabelFoundation.cssClasses.LABEL_REQUIRED;
  7682. if (isRequired) {
  7683. this.adapter.addClass(LABEL_REQUIRED);
  7684. } else {
  7685. this.adapter.removeClass(LABEL_REQUIRED);
  7686. }
  7687. };
  7688. MDCFloatingLabelFoundation.prototype.handleShakeAnimationEnd_ = function () {
  7689. var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
  7690. this.adapter.removeClass(LABEL_SHAKE);
  7691. };
  7692. return MDCFloatingLabelFoundation;
  7693. }(foundation_1.MDCFoundation);
  7694. exports.MDCFloatingLabelFoundation = MDCFloatingLabelFoundation;
  7695. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  7696. exports.default = MDCFloatingLabelFoundation;
  7697. /***/ }),
  7698. /***/ "./packages/mdc-floating-label/index.ts":
  7699. /*!**********************************************!*\
  7700. !*** ./packages/mdc-floating-label/index.ts ***!
  7701. \**********************************************/
  7702. /*! no static exports found */
  7703. /***/ (function(module, exports, __webpack_require__) {
  7704. "use strict";
  7705. /**
  7706. * @license
  7707. * Copyright 2019 Google Inc.
  7708. *
  7709. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7710. * of this software and associated documentation files (the "Software"), to deal
  7711. * in the Software without restriction, including without limitation the rights
  7712. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7713. * copies of the Software, and to permit persons to whom the Software is
  7714. * furnished to do so, subject to the following conditions:
  7715. *
  7716. * The above copyright notice and this permission notice shall be included in
  7717. * all copies or substantial portions of the Software.
  7718. *
  7719. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7720. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7721. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7722. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7723. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7724. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7725. * THE SOFTWARE.
  7726. */
  7727. function __export(m) {
  7728. for (var p in m) {
  7729. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  7730. }
  7731. }
  7732. Object.defineProperty(exports, "__esModule", { value: true });
  7733. __export(__webpack_require__(/*! ./component */ "./packages/mdc-floating-label/component.ts"));
  7734. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts"));
  7735. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts"));
  7736. /***/ }),
  7737. /***/ "./packages/mdc-form-field/component.ts":
  7738. /*!**********************************************!*\
  7739. !*** ./packages/mdc-form-field/component.ts ***!
  7740. \**********************************************/
  7741. /*! no static exports found */
  7742. /***/ (function(module, exports, __webpack_require__) {
  7743. "use strict";
  7744. /**
  7745. * @license
  7746. * Copyright 2017 Google Inc.
  7747. *
  7748. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7749. * of this software and associated documentation files (the "Software"), to deal
  7750. * in the Software without restriction, including without limitation the rights
  7751. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7752. * copies of the Software, and to permit persons to whom the Software is
  7753. * furnished to do so, subject to the following conditions:
  7754. *
  7755. * The above copyright notice and this permission notice shall be included in
  7756. * all copies or substantial portions of the Software.
  7757. *
  7758. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7759. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7760. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7761. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7762. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7763. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7764. * THE SOFTWARE.
  7765. */
  7766. var __extends = this && this.__extends || function () {
  7767. var _extendStatics = function extendStatics(d, b) {
  7768. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7769. d.__proto__ = b;
  7770. } || function (d, b) {
  7771. for (var p in b) {
  7772. if (b.hasOwnProperty(p)) d[p] = b[p];
  7773. }
  7774. };
  7775. return _extendStatics(d, b);
  7776. };
  7777. return function (d, b) {
  7778. _extendStatics(d, b);
  7779. function __() {
  7780. this.constructor = d;
  7781. }
  7782. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7783. };
  7784. }();
  7785. Object.defineProperty(exports, "__esModule", { value: true });
  7786. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  7787. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-form-field/foundation.ts");
  7788. var MDCFormField = /** @class */function (_super) {
  7789. __extends(MDCFormField, _super);
  7790. function MDCFormField() {
  7791. return _super !== null && _super.apply(this, arguments) || this;
  7792. }
  7793. MDCFormField.attachTo = function (root) {
  7794. return new MDCFormField(root);
  7795. };
  7796. MDCFormField.prototype.labelEl = function () {
  7797. var LABEL_SELECTOR = foundation_1.MDCFormFieldFoundation.strings.LABEL_SELECTOR;
  7798. return this.root.querySelector(LABEL_SELECTOR);
  7799. };
  7800. MDCFormField.prototype.getDefaultFoundation = function () {
  7801. var _this = this;
  7802. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  7803. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  7804. var adapter = {
  7805. activateInputRipple: function activateInputRipple() {
  7806. if (_this.input && _this.input.ripple) {
  7807. _this.input.ripple.activate();
  7808. }
  7809. },
  7810. deactivateInputRipple: function deactivateInputRipple() {
  7811. if (_this.input && _this.input.ripple) {
  7812. _this.input.ripple.deactivate();
  7813. }
  7814. },
  7815. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  7816. var labelEl = _this.labelEl();
  7817. if (labelEl) {
  7818. labelEl.removeEventListener(evtType, handler);
  7819. }
  7820. },
  7821. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  7822. var labelEl = _this.labelEl();
  7823. if (labelEl) {
  7824. labelEl.addEventListener(evtType, handler);
  7825. }
  7826. }
  7827. };
  7828. return new foundation_1.MDCFormFieldFoundation(adapter);
  7829. };
  7830. return MDCFormField;
  7831. }(component_1.MDCComponent);
  7832. exports.MDCFormField = MDCFormField;
  7833. /***/ }),
  7834. /***/ "./packages/mdc-form-field/constants.ts":
  7835. /*!**********************************************!*\
  7836. !*** ./packages/mdc-form-field/constants.ts ***!
  7837. \**********************************************/
  7838. /*! no static exports found */
  7839. /***/ (function(module, exports, __webpack_require__) {
  7840. "use strict";
  7841. /**
  7842. * @license
  7843. * Copyright 2017 Google Inc.
  7844. *
  7845. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7846. * of this software and associated documentation files (the "Software"), to deal
  7847. * in the Software without restriction, including without limitation the rights
  7848. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7849. * copies of the Software, and to permit persons to whom the Software is
  7850. * furnished to do so, subject to the following conditions:
  7851. *
  7852. * The above copyright notice and this permission notice shall be included in
  7853. * all copies or substantial portions of the Software.
  7854. *
  7855. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7856. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7857. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7858. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7859. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7860. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7861. * THE SOFTWARE.
  7862. */
  7863. Object.defineProperty(exports, "__esModule", { value: true });
  7864. exports.cssClasses = {
  7865. ROOT: 'mdc-form-field'
  7866. };
  7867. exports.strings = {
  7868. LABEL_SELECTOR: '.mdc-form-field > label'
  7869. };
  7870. /***/ }),
  7871. /***/ "./packages/mdc-form-field/foundation.ts":
  7872. /*!***********************************************!*\
  7873. !*** ./packages/mdc-form-field/foundation.ts ***!
  7874. \***********************************************/
  7875. /*! no static exports found */
  7876. /***/ (function(module, exports, __webpack_require__) {
  7877. "use strict";
  7878. /**
  7879. * @license
  7880. * Copyright 2017 Google Inc.
  7881. *
  7882. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7883. * of this software and associated documentation files (the "Software"), to deal
  7884. * in the Software without restriction, including without limitation the rights
  7885. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7886. * copies of the Software, and to permit persons to whom the Software is
  7887. * furnished to do so, subject to the following conditions:
  7888. *
  7889. * The above copyright notice and this permission notice shall be included in
  7890. * all copies or substantial portions of the Software.
  7891. *
  7892. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7893. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7894. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7895. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7896. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7897. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7898. * THE SOFTWARE.
  7899. */
  7900. var __extends = this && this.__extends || function () {
  7901. var _extendStatics = function extendStatics(d, b) {
  7902. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7903. d.__proto__ = b;
  7904. } || function (d, b) {
  7905. for (var p in b) {
  7906. if (b.hasOwnProperty(p)) d[p] = b[p];
  7907. }
  7908. };
  7909. return _extendStatics(d, b);
  7910. };
  7911. return function (d, b) {
  7912. _extendStatics(d, b);
  7913. function __() {
  7914. this.constructor = d;
  7915. }
  7916. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7917. };
  7918. }();
  7919. var __assign = this && this.__assign || function () {
  7920. __assign = Object.assign || function (t) {
  7921. for (var s, i = 1, n = arguments.length; i < n; i++) {
  7922. s = arguments[i];
  7923. for (var p in s) {
  7924. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  7925. }
  7926. }
  7927. return t;
  7928. };
  7929. return __assign.apply(this, arguments);
  7930. };
  7931. Object.defineProperty(exports, "__esModule", { value: true });
  7932. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  7933. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-form-field/constants.ts");
  7934. var MDCFormFieldFoundation = /** @class */function (_super) {
  7935. __extends(MDCFormFieldFoundation, _super);
  7936. function MDCFormFieldFoundation(adapter) {
  7937. var _this = _super.call(this, __assign(__assign({}, MDCFormFieldFoundation.defaultAdapter), adapter)) || this;
  7938. _this.click = function () {
  7939. _this.handleClick();
  7940. };
  7941. return _this;
  7942. }
  7943. Object.defineProperty(MDCFormFieldFoundation, "cssClasses", {
  7944. get: function get() {
  7945. return constants_1.cssClasses;
  7946. },
  7947. enumerable: true,
  7948. configurable: true
  7949. });
  7950. Object.defineProperty(MDCFormFieldFoundation, "strings", {
  7951. get: function get() {
  7952. return constants_1.strings;
  7953. },
  7954. enumerable: true,
  7955. configurable: true
  7956. });
  7957. Object.defineProperty(MDCFormFieldFoundation, "defaultAdapter", {
  7958. get: function get() {
  7959. return {
  7960. activateInputRipple: function activateInputRipple() {
  7961. return undefined;
  7962. },
  7963. deactivateInputRipple: function deactivateInputRipple() {
  7964. return undefined;
  7965. },
  7966. deregisterInteractionHandler: function deregisterInteractionHandler() {
  7967. return undefined;
  7968. },
  7969. registerInteractionHandler: function registerInteractionHandler() {
  7970. return undefined;
  7971. }
  7972. };
  7973. },
  7974. enumerable: true,
  7975. configurable: true
  7976. });
  7977. MDCFormFieldFoundation.prototype.init = function () {
  7978. this.adapter.registerInteractionHandler('click', this.click);
  7979. };
  7980. MDCFormFieldFoundation.prototype.destroy = function () {
  7981. this.adapter.deregisterInteractionHandler('click', this.click);
  7982. };
  7983. MDCFormFieldFoundation.prototype.handleClick = function () {
  7984. var _this = this;
  7985. this.adapter.activateInputRipple();
  7986. requestAnimationFrame(function () {
  7987. _this.adapter.deactivateInputRipple();
  7988. });
  7989. };
  7990. return MDCFormFieldFoundation;
  7991. }(foundation_1.MDCFoundation);
  7992. exports.MDCFormFieldFoundation = MDCFormFieldFoundation;
  7993. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  7994. exports.default = MDCFormFieldFoundation;
  7995. /***/ }),
  7996. /***/ "./packages/mdc-form-field/index.ts":
  7997. /*!******************************************!*\
  7998. !*** ./packages/mdc-form-field/index.ts ***!
  7999. \******************************************/
  8000. /*! no static exports found */
  8001. /***/ (function(module, exports, __webpack_require__) {
  8002. "use strict";
  8003. /**
  8004. * @license
  8005. * Copyright 2019 Google Inc.
  8006. *
  8007. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8008. * of this software and associated documentation files (the "Software"), to deal
  8009. * in the Software without restriction, including without limitation the rights
  8010. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8011. * copies of the Software, and to permit persons to whom the Software is
  8012. * furnished to do so, subject to the following conditions:
  8013. *
  8014. * The above copyright notice and this permission notice shall be included in
  8015. * all copies or substantial portions of the Software.
  8016. *
  8017. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8018. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8019. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8020. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8021. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8022. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8023. * THE SOFTWARE.
  8024. */
  8025. function __export(m) {
  8026. for (var p in m) {
  8027. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  8028. }
  8029. }
  8030. Object.defineProperty(exports, "__esModule", { value: true });
  8031. __export(__webpack_require__(/*! ./component */ "./packages/mdc-form-field/component.ts"));
  8032. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-form-field/constants.ts"));
  8033. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-form-field/foundation.ts"));
  8034. /***/ }),
  8035. /***/ "./packages/mdc-icon-button/component.ts":
  8036. /*!***********************************************!*\
  8037. !*** ./packages/mdc-icon-button/component.ts ***!
  8038. \***********************************************/
  8039. /*! no static exports found */
  8040. /***/ (function(module, exports, __webpack_require__) {
  8041. "use strict";
  8042. /**
  8043. * @license
  8044. * Copyright 2018 Google Inc.
  8045. *
  8046. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8047. * of this software and associated documentation files (the "Software"), to deal
  8048. * in the Software without restriction, including without limitation the rights
  8049. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8050. * copies of the Software, and to permit persons to whom the Software is
  8051. * furnished to do so, subject to the following conditions:
  8052. *
  8053. * The above copyright notice and this permission notice shall be included in
  8054. * all copies or substantial portions of the Software.
  8055. *
  8056. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8057. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8058. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8059. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8060. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8061. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8062. * THE SOFTWARE.
  8063. */
  8064. var __extends = this && this.__extends || function () {
  8065. var _extendStatics = function extendStatics(d, b) {
  8066. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8067. d.__proto__ = b;
  8068. } || function (d, b) {
  8069. for (var p in b) {
  8070. if (b.hasOwnProperty(p)) d[p] = b[p];
  8071. }
  8072. };
  8073. return _extendStatics(d, b);
  8074. };
  8075. return function (d, b) {
  8076. _extendStatics(d, b);
  8077. function __() {
  8078. this.constructor = d;
  8079. }
  8080. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8081. };
  8082. }();
  8083. Object.defineProperty(exports, "__esModule", { value: true });
  8084. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  8085. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  8086. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-icon-button/foundation.ts");
  8087. var strings = foundation_1.MDCIconButtonToggleFoundation.strings;
  8088. var MDCIconButtonToggle = /** @class */function (_super) {
  8089. __extends(MDCIconButtonToggle, _super);
  8090. function MDCIconButtonToggle() {
  8091. var _this = _super !== null && _super.apply(this, arguments) || this;
  8092. _this.rippleComponent = _this.createRipple();
  8093. return _this;
  8094. }
  8095. MDCIconButtonToggle.attachTo = function (root) {
  8096. return new MDCIconButtonToggle(root);
  8097. };
  8098. MDCIconButtonToggle.prototype.initialSyncWithDOM = function () {
  8099. var _this = this;
  8100. this.handleClick = function () {
  8101. _this.foundation.handleClick();
  8102. };
  8103. this.listen('click', this.handleClick);
  8104. };
  8105. MDCIconButtonToggle.prototype.destroy = function () {
  8106. this.unlisten('click', this.handleClick);
  8107. this.ripple.destroy();
  8108. _super.prototype.destroy.call(this);
  8109. };
  8110. MDCIconButtonToggle.prototype.getDefaultFoundation = function () {
  8111. var _this = this;
  8112. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  8113. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  8114. var adapter = {
  8115. addClass: function addClass(className) {
  8116. return _this.root.classList.add(className);
  8117. },
  8118. hasClass: function hasClass(className) {
  8119. return _this.root.classList.contains(className);
  8120. },
  8121. notifyChange: function notifyChange(evtData) {
  8122. _this.emit(strings.CHANGE_EVENT, evtData);
  8123. },
  8124. removeClass: function removeClass(className) {
  8125. return _this.root.classList.remove(className);
  8126. },
  8127. getAttr: function getAttr(attrName) {
  8128. return _this.root.getAttribute(attrName);
  8129. },
  8130. setAttr: function setAttr(attrName, attrValue) {
  8131. return _this.root.setAttribute(attrName, attrValue);
  8132. }
  8133. };
  8134. return new foundation_1.MDCIconButtonToggleFoundation(adapter);
  8135. };
  8136. Object.defineProperty(MDCIconButtonToggle.prototype, "ripple", {
  8137. get: function get() {
  8138. return this.rippleComponent;
  8139. },
  8140. enumerable: true,
  8141. configurable: true
  8142. });
  8143. Object.defineProperty(MDCIconButtonToggle.prototype, "on", {
  8144. get: function get() {
  8145. return this.foundation.isOn();
  8146. },
  8147. set: function set(isOn) {
  8148. this.foundation.toggle(isOn);
  8149. },
  8150. enumerable: true,
  8151. configurable: true
  8152. });
  8153. MDCIconButtonToggle.prototype.createRipple = function () {
  8154. var ripple = new component_2.MDCRipple(this.root);
  8155. ripple.unbounded = true;
  8156. return ripple;
  8157. };
  8158. return MDCIconButtonToggle;
  8159. }(component_1.MDCComponent);
  8160. exports.MDCIconButtonToggle = MDCIconButtonToggle;
  8161. /***/ }),
  8162. /***/ "./packages/mdc-icon-button/constants.ts":
  8163. /*!***********************************************!*\
  8164. !*** ./packages/mdc-icon-button/constants.ts ***!
  8165. \***********************************************/
  8166. /*! no static exports found */
  8167. /***/ (function(module, exports, __webpack_require__) {
  8168. "use strict";
  8169. /**
  8170. * @license
  8171. * Copyright 2018 Google Inc.
  8172. *
  8173. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8174. * of this software and associated documentation files (the "Software"), to deal
  8175. * in the Software without restriction, including without limitation the rights
  8176. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8177. * copies of the Software, and to permit persons to whom the Software is
  8178. * furnished to do so, subject to the following conditions:
  8179. *
  8180. * The above copyright notice and this permission notice shall be included in
  8181. * all copies or substantial portions of the Software.
  8182. *
  8183. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8184. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8185. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8186. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8187. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8188. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8189. * THE SOFTWARE.
  8190. */
  8191. Object.defineProperty(exports, "__esModule", { value: true });
  8192. exports.cssClasses = {
  8193. ICON_BUTTON_ON: 'mdc-icon-button--on',
  8194. ROOT: 'mdc-icon-button'
  8195. };
  8196. exports.strings = {
  8197. ARIA_LABEL: 'aria-label',
  8198. ARIA_PRESSED: 'aria-pressed',
  8199. DATA_ARIA_LABEL_OFF: 'data-aria-label-off',
  8200. DATA_ARIA_LABEL_ON: 'data-aria-label-on',
  8201. CHANGE_EVENT: 'MDCIconButtonToggle:change'
  8202. };
  8203. /***/ }),
  8204. /***/ "./packages/mdc-icon-button/foundation.ts":
  8205. /*!************************************************!*\
  8206. !*** ./packages/mdc-icon-button/foundation.ts ***!
  8207. \************************************************/
  8208. /*! no static exports found */
  8209. /***/ (function(module, exports, __webpack_require__) {
  8210. "use strict";
  8211. /**
  8212. * @license
  8213. * Copyright 2018 Google Inc.
  8214. *
  8215. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8216. * of this software and associated documentation files (the "Software"), to deal
  8217. * in the Software without restriction, including without limitation the rights
  8218. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8219. * copies of the Software, and to permit persons to whom the Software is
  8220. * furnished to do so, subject to the following conditions:
  8221. *
  8222. * The above copyright notice and this permission notice shall be included in
  8223. * all copies or substantial portions of the Software.
  8224. *
  8225. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8226. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8227. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8228. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8229. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8230. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8231. * THE SOFTWARE.
  8232. */
  8233. var __extends = this && this.__extends || function () {
  8234. var _extendStatics = function extendStatics(d, b) {
  8235. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8236. d.__proto__ = b;
  8237. } || function (d, b) {
  8238. for (var p in b) {
  8239. if (b.hasOwnProperty(p)) d[p] = b[p];
  8240. }
  8241. };
  8242. return _extendStatics(d, b);
  8243. };
  8244. return function (d, b) {
  8245. _extendStatics(d, b);
  8246. function __() {
  8247. this.constructor = d;
  8248. }
  8249. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8250. };
  8251. }();
  8252. var __assign = this && this.__assign || function () {
  8253. __assign = Object.assign || function (t) {
  8254. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8255. s = arguments[i];
  8256. for (var p in s) {
  8257. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  8258. }
  8259. }
  8260. return t;
  8261. };
  8262. return __assign.apply(this, arguments);
  8263. };
  8264. Object.defineProperty(exports, "__esModule", { value: true });
  8265. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  8266. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-icon-button/constants.ts");
  8267. var MDCIconButtonToggleFoundation = /** @class */function (_super) {
  8268. __extends(MDCIconButtonToggleFoundation, _super);
  8269. function MDCIconButtonToggleFoundation(adapter) {
  8270. var _this = _super.call(this, __assign(__assign({}, MDCIconButtonToggleFoundation.defaultAdapter), adapter)) || this;
  8271. /**
  8272. * Whether the icon button has an aria label that changes depending on
  8273. * toggled state.
  8274. */
  8275. _this.hasToggledAriaLabel = false;
  8276. return _this;
  8277. }
  8278. Object.defineProperty(MDCIconButtonToggleFoundation, "cssClasses", {
  8279. get: function get() {
  8280. return constants_1.cssClasses;
  8281. },
  8282. enumerable: true,
  8283. configurable: true
  8284. });
  8285. Object.defineProperty(MDCIconButtonToggleFoundation, "strings", {
  8286. get: function get() {
  8287. return constants_1.strings;
  8288. },
  8289. enumerable: true,
  8290. configurable: true
  8291. });
  8292. Object.defineProperty(MDCIconButtonToggleFoundation, "defaultAdapter", {
  8293. get: function get() {
  8294. return {
  8295. addClass: function addClass() {
  8296. return undefined;
  8297. },
  8298. hasClass: function hasClass() {
  8299. return false;
  8300. },
  8301. notifyChange: function notifyChange() {
  8302. return undefined;
  8303. },
  8304. removeClass: function removeClass() {
  8305. return undefined;
  8306. },
  8307. getAttr: function getAttr() {
  8308. return null;
  8309. },
  8310. setAttr: function setAttr() {
  8311. return undefined;
  8312. }
  8313. };
  8314. },
  8315. enumerable: true,
  8316. configurable: true
  8317. });
  8318. MDCIconButtonToggleFoundation.prototype.init = function () {
  8319. var ariaLabelOn = this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_ON);
  8320. var ariaLabelOff = this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_OFF);
  8321. if (ariaLabelOn && ariaLabelOff) {
  8322. if (this.adapter.getAttr(constants_1.strings.ARIA_PRESSED) !== null) {
  8323. throw new Error('MDCIconButtonToggleFoundation: Button should not set ' + '`aria-pressed` if it has a toggled aria label.');
  8324. }
  8325. this.hasToggledAriaLabel = true;
  8326. } else {
  8327. this.adapter.setAttr(constants_1.strings.ARIA_PRESSED, String(this.isOn()));
  8328. }
  8329. };
  8330. MDCIconButtonToggleFoundation.prototype.handleClick = function () {
  8331. this.toggle();
  8332. this.adapter.notifyChange({ isOn: this.isOn() });
  8333. };
  8334. MDCIconButtonToggleFoundation.prototype.isOn = function () {
  8335. return this.adapter.hasClass(constants_1.cssClasses.ICON_BUTTON_ON);
  8336. };
  8337. MDCIconButtonToggleFoundation.prototype.toggle = function (isOn) {
  8338. if (isOn === void 0) {
  8339. isOn = !this.isOn();
  8340. }
  8341. // Toggle UI based on state.
  8342. if (isOn) {
  8343. this.adapter.addClass(constants_1.cssClasses.ICON_BUTTON_ON);
  8344. } else {
  8345. this.adapter.removeClass(constants_1.cssClasses.ICON_BUTTON_ON);
  8346. }
  8347. // Toggle aria attributes based on state.
  8348. if (this.hasToggledAriaLabel) {
  8349. var ariaLabel = isOn ? this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_ON) : this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_OFF);
  8350. this.adapter.setAttr(constants_1.strings.ARIA_LABEL, ariaLabel || '');
  8351. } else {
  8352. this.adapter.setAttr(constants_1.strings.ARIA_PRESSED, "" + isOn);
  8353. }
  8354. };
  8355. return MDCIconButtonToggleFoundation;
  8356. }(foundation_1.MDCFoundation);
  8357. exports.MDCIconButtonToggleFoundation = MDCIconButtonToggleFoundation;
  8358. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  8359. exports.default = MDCIconButtonToggleFoundation;
  8360. /***/ }),
  8361. /***/ "./packages/mdc-icon-button/index.ts":
  8362. /*!*******************************************!*\
  8363. !*** ./packages/mdc-icon-button/index.ts ***!
  8364. \*******************************************/
  8365. /*! no static exports found */
  8366. /***/ (function(module, exports, __webpack_require__) {
  8367. "use strict";
  8368. /**
  8369. * @license
  8370. * Copyright 2019 Google Inc.
  8371. *
  8372. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8373. * of this software and associated documentation files (the "Software"), to deal
  8374. * in the Software without restriction, including without limitation the rights
  8375. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8376. * copies of the Software, and to permit persons to whom the Software is
  8377. * furnished to do so, subject to the following conditions:
  8378. *
  8379. * The above copyright notice and this permission notice shall be included in
  8380. * all copies or substantial portions of the Software.
  8381. *
  8382. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8383. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8384. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8385. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8386. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8387. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8388. * THE SOFTWARE.
  8389. */
  8390. function __export(m) {
  8391. for (var p in m) {
  8392. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  8393. }
  8394. }
  8395. Object.defineProperty(exports, "__esModule", { value: true });
  8396. __export(__webpack_require__(/*! ./component */ "./packages/mdc-icon-button/component.ts"));
  8397. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-icon-button/constants.ts"));
  8398. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-icon-button/foundation.ts"));
  8399. /***/ }),
  8400. /***/ "./packages/mdc-line-ripple/component.ts":
  8401. /*!***********************************************!*\
  8402. !*** ./packages/mdc-line-ripple/component.ts ***!
  8403. \***********************************************/
  8404. /*! no static exports found */
  8405. /***/ (function(module, exports, __webpack_require__) {
  8406. "use strict";
  8407. /**
  8408. * @license
  8409. * Copyright 2018 Google Inc.
  8410. *
  8411. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8412. * of this software and associated documentation files (the "Software"), to deal
  8413. * in the Software without restriction, including without limitation the rights
  8414. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8415. * copies of the Software, and to permit persons to whom the Software is
  8416. * furnished to do so, subject to the following conditions:
  8417. *
  8418. * The above copyright notice and this permission notice shall be included in
  8419. * all copies or substantial portions of the Software.
  8420. *
  8421. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8422. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8423. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8424. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8425. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8426. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8427. * THE SOFTWARE.
  8428. */
  8429. var __extends = this && this.__extends || function () {
  8430. var _extendStatics = function extendStatics(d, b) {
  8431. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8432. d.__proto__ = b;
  8433. } || function (d, b) {
  8434. for (var p in b) {
  8435. if (b.hasOwnProperty(p)) d[p] = b[p];
  8436. }
  8437. };
  8438. return _extendStatics(d, b);
  8439. };
  8440. return function (d, b) {
  8441. _extendStatics(d, b);
  8442. function __() {
  8443. this.constructor = d;
  8444. }
  8445. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8446. };
  8447. }();
  8448. Object.defineProperty(exports, "__esModule", { value: true });
  8449. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  8450. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-line-ripple/foundation.ts");
  8451. var MDCLineRipple = /** @class */function (_super) {
  8452. __extends(MDCLineRipple, _super);
  8453. function MDCLineRipple() {
  8454. return _super !== null && _super.apply(this, arguments) || this;
  8455. }
  8456. MDCLineRipple.attachTo = function (root) {
  8457. return new MDCLineRipple(root);
  8458. };
  8459. /**
  8460. * Activates the line ripple
  8461. */
  8462. MDCLineRipple.prototype.activate = function () {
  8463. this.foundation.activate();
  8464. };
  8465. /**
  8466. * Deactivates the line ripple
  8467. */
  8468. MDCLineRipple.prototype.deactivate = function () {
  8469. this.foundation.deactivate();
  8470. };
  8471. /**
  8472. * Sets the transform origin given a user's click location.
  8473. * The `rippleCenter` is the x-coordinate of the middle of the ripple.
  8474. */
  8475. MDCLineRipple.prototype.setRippleCenter = function (xCoordinate) {
  8476. this.foundation.setRippleCenter(xCoordinate);
  8477. };
  8478. MDCLineRipple.prototype.getDefaultFoundation = function () {
  8479. var _this = this;
  8480. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  8481. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  8482. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  8483. var adapter = {
  8484. addClass: function addClass(className) {
  8485. return _this.root.classList.add(className);
  8486. },
  8487. removeClass: function removeClass(className) {
  8488. return _this.root.classList.remove(className);
  8489. },
  8490. hasClass: function hasClass(className) {
  8491. return _this.root.classList.contains(className);
  8492. },
  8493. setStyle: function setStyle(propertyName, value) {
  8494. return _this.root.style.setProperty(propertyName, value);
  8495. },
  8496. registerEventHandler: function registerEventHandler(evtType, handler) {
  8497. return _this.listen(evtType, handler);
  8498. },
  8499. deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
  8500. return _this.unlisten(evtType, handler);
  8501. }
  8502. };
  8503. // tslint:enable:object-literal-sort-keys
  8504. return new foundation_1.MDCLineRippleFoundation(adapter);
  8505. };
  8506. return MDCLineRipple;
  8507. }(component_1.MDCComponent);
  8508. exports.MDCLineRipple = MDCLineRipple;
  8509. /***/ }),
  8510. /***/ "./packages/mdc-line-ripple/constants.ts":
  8511. /*!***********************************************!*\
  8512. !*** ./packages/mdc-line-ripple/constants.ts ***!
  8513. \***********************************************/
  8514. /*! no static exports found */
  8515. /***/ (function(module, exports, __webpack_require__) {
  8516. "use strict";
  8517. /**
  8518. * @license
  8519. * Copyright 2018 Google Inc.
  8520. *
  8521. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8522. * of this software and associated documentation files (the "Software"), to deal
  8523. * in the Software without restriction, including without limitation the rights
  8524. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8525. * copies of the Software, and to permit persons to whom the Software is
  8526. * furnished to do so, subject to the following conditions:
  8527. *
  8528. * The above copyright notice and this permission notice shall be included in
  8529. * all copies or substantial portions of the Software.
  8530. *
  8531. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8532. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8533. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8534. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8535. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8536. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8537. * THE SOFTWARE.
  8538. */
  8539. Object.defineProperty(exports, "__esModule", { value: true });
  8540. var cssClasses = {
  8541. LINE_RIPPLE_ACTIVE: 'mdc-line-ripple--active',
  8542. LINE_RIPPLE_DEACTIVATING: 'mdc-line-ripple--deactivating'
  8543. };
  8544. exports.cssClasses = cssClasses;
  8545. /***/ }),
  8546. /***/ "./packages/mdc-line-ripple/foundation.ts":
  8547. /*!************************************************!*\
  8548. !*** ./packages/mdc-line-ripple/foundation.ts ***!
  8549. \************************************************/
  8550. /*! no static exports found */
  8551. /***/ (function(module, exports, __webpack_require__) {
  8552. "use strict";
  8553. /**
  8554. * @license
  8555. * Copyright 2018 Google Inc.
  8556. *
  8557. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8558. * of this software and associated documentation files (the "Software"), to deal
  8559. * in the Software without restriction, including without limitation the rights
  8560. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8561. * copies of the Software, and to permit persons to whom the Software is
  8562. * furnished to do so, subject to the following conditions:
  8563. *
  8564. * The above copyright notice and this permission notice shall be included in
  8565. * all copies or substantial portions of the Software.
  8566. *
  8567. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8568. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8569. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8570. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8571. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8572. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8573. * THE SOFTWARE.
  8574. */
  8575. var __extends = this && this.__extends || function () {
  8576. var _extendStatics = function extendStatics(d, b) {
  8577. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8578. d.__proto__ = b;
  8579. } || function (d, b) {
  8580. for (var p in b) {
  8581. if (b.hasOwnProperty(p)) d[p] = b[p];
  8582. }
  8583. };
  8584. return _extendStatics(d, b);
  8585. };
  8586. return function (d, b) {
  8587. _extendStatics(d, b);
  8588. function __() {
  8589. this.constructor = d;
  8590. }
  8591. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8592. };
  8593. }();
  8594. var __assign = this && this.__assign || function () {
  8595. __assign = Object.assign || function (t) {
  8596. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8597. s = arguments[i];
  8598. for (var p in s) {
  8599. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  8600. }
  8601. }
  8602. return t;
  8603. };
  8604. return __assign.apply(this, arguments);
  8605. };
  8606. Object.defineProperty(exports, "__esModule", { value: true });
  8607. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  8608. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-line-ripple/constants.ts");
  8609. var MDCLineRippleFoundation = /** @class */function (_super) {
  8610. __extends(MDCLineRippleFoundation, _super);
  8611. function MDCLineRippleFoundation(adapter) {
  8612. var _this = _super.call(this, __assign(__assign({}, MDCLineRippleFoundation.defaultAdapter), adapter)) || this;
  8613. _this.transitionEndHandler_ = function (evt) {
  8614. return _this.handleTransitionEnd(evt);
  8615. };
  8616. return _this;
  8617. }
  8618. Object.defineProperty(MDCLineRippleFoundation, "cssClasses", {
  8619. get: function get() {
  8620. return constants_1.cssClasses;
  8621. },
  8622. enumerable: true,
  8623. configurable: true
  8624. });
  8625. Object.defineProperty(MDCLineRippleFoundation, "defaultAdapter", {
  8626. /**
  8627. * See {@link MDCLineRippleAdapter} for typing information on parameters and return types.
  8628. */
  8629. get: function get() {
  8630. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  8631. return {
  8632. addClass: function addClass() {
  8633. return undefined;
  8634. },
  8635. removeClass: function removeClass() {
  8636. return undefined;
  8637. },
  8638. hasClass: function hasClass() {
  8639. return false;
  8640. },
  8641. setStyle: function setStyle() {
  8642. return undefined;
  8643. },
  8644. registerEventHandler: function registerEventHandler() {
  8645. return undefined;
  8646. },
  8647. deregisterEventHandler: function deregisterEventHandler() {
  8648. return undefined;
  8649. }
  8650. };
  8651. // tslint:enable:object-literal-sort-keys
  8652. },
  8653. enumerable: true,
  8654. configurable: true
  8655. });
  8656. MDCLineRippleFoundation.prototype.init = function () {
  8657. this.adapter.registerEventHandler('transitionend', this.transitionEndHandler_);
  8658. };
  8659. MDCLineRippleFoundation.prototype.destroy = function () {
  8660. this.adapter.deregisterEventHandler('transitionend', this.transitionEndHandler_);
  8661. };
  8662. MDCLineRippleFoundation.prototype.activate = function () {
  8663. this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  8664. this.adapter.addClass(constants_1.cssClasses.LINE_RIPPLE_ACTIVE);
  8665. };
  8666. MDCLineRippleFoundation.prototype.setRippleCenter = function (xCoordinate) {
  8667. this.adapter.setStyle('transform-origin', xCoordinate + "px center");
  8668. };
  8669. MDCLineRippleFoundation.prototype.deactivate = function () {
  8670. this.adapter.addClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  8671. };
  8672. MDCLineRippleFoundation.prototype.handleTransitionEnd = function (evt) {
  8673. // Wait for the line ripple to be either transparent or opaque
  8674. // before emitting the animation end event
  8675. var isDeactivating = this.adapter.hasClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  8676. if (evt.propertyName === 'opacity') {
  8677. if (isDeactivating) {
  8678. this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_ACTIVE);
  8679. this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  8680. }
  8681. }
  8682. };
  8683. return MDCLineRippleFoundation;
  8684. }(foundation_1.MDCFoundation);
  8685. exports.MDCLineRippleFoundation = MDCLineRippleFoundation;
  8686. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  8687. exports.default = MDCLineRippleFoundation;
  8688. /***/ }),
  8689. /***/ "./packages/mdc-line-ripple/index.ts":
  8690. /*!*******************************************!*\
  8691. !*** ./packages/mdc-line-ripple/index.ts ***!
  8692. \*******************************************/
  8693. /*! no static exports found */
  8694. /***/ (function(module, exports, __webpack_require__) {
  8695. "use strict";
  8696. /**
  8697. * @license
  8698. * Copyright 2019 Google Inc.
  8699. *
  8700. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8701. * of this software and associated documentation files (the "Software"), to deal
  8702. * in the Software without restriction, including without limitation the rights
  8703. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8704. * copies of the Software, and to permit persons to whom the Software is
  8705. * furnished to do so, subject to the following conditions:
  8706. *
  8707. * The above copyright notice and this permission notice shall be included in
  8708. * all copies or substantial portions of the Software.
  8709. *
  8710. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8711. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8712. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8713. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8714. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8715. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8716. * THE SOFTWARE.
  8717. */
  8718. function __export(m) {
  8719. for (var p in m) {
  8720. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  8721. }
  8722. }
  8723. Object.defineProperty(exports, "__esModule", { value: true });
  8724. __export(__webpack_require__(/*! ./component */ "./packages/mdc-line-ripple/component.ts"));
  8725. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-line-ripple/constants.ts"));
  8726. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-line-ripple/foundation.ts"));
  8727. /***/ }),
  8728. /***/ "./packages/mdc-linear-progress/component.ts":
  8729. /*!***************************************************!*\
  8730. !*** ./packages/mdc-linear-progress/component.ts ***!
  8731. \***************************************************/
  8732. /*! no static exports found */
  8733. /***/ (function(module, exports, __webpack_require__) {
  8734. "use strict";
  8735. /**
  8736. * @license
  8737. * Copyright 2017 Google Inc.
  8738. *
  8739. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8740. * of this software and associated documentation files (the "Software"), to deal
  8741. * in the Software without restriction, including without limitation the rights
  8742. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8743. * copies of the Software, and to permit persons to whom the Software is
  8744. * furnished to do so, subject to the following conditions:
  8745. *
  8746. * The above copyright notice and this permission notice shall be included in
  8747. * all copies or substantial portions of the Software.
  8748. *
  8749. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8750. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8751. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8752. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8753. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8754. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8755. * THE SOFTWARE.
  8756. */
  8757. var __extends = this && this.__extends || function () {
  8758. var _extendStatics = function extendStatics(d, b) {
  8759. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8760. d.__proto__ = b;
  8761. } || function (d, b) {
  8762. for (var p in b) {
  8763. if (b.hasOwnProperty(p)) d[p] = b[p];
  8764. }
  8765. };
  8766. return _extendStatics(d, b);
  8767. };
  8768. return function (d, b) {
  8769. _extendStatics(d, b);
  8770. function __() {
  8771. this.constructor = d;
  8772. }
  8773. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8774. };
  8775. }();
  8776. Object.defineProperty(exports, "__esModule", { value: true });
  8777. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  8778. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-linear-progress/foundation.ts");
  8779. var MDCLinearProgress = /** @class */function (_super) {
  8780. __extends(MDCLinearProgress, _super);
  8781. function MDCLinearProgress() {
  8782. return _super !== null && _super.apply(this, arguments) || this;
  8783. }
  8784. MDCLinearProgress.attachTo = function (root) {
  8785. return new MDCLinearProgress(root);
  8786. };
  8787. Object.defineProperty(MDCLinearProgress.prototype, "determinate", {
  8788. set: function set(value) {
  8789. this.foundation.setDeterminate(value);
  8790. },
  8791. enumerable: true,
  8792. configurable: true
  8793. });
  8794. Object.defineProperty(MDCLinearProgress.prototype, "progress", {
  8795. set: function set(value) {
  8796. this.foundation.setProgress(value);
  8797. },
  8798. enumerable: true,
  8799. configurable: true
  8800. });
  8801. Object.defineProperty(MDCLinearProgress.prototype, "buffer", {
  8802. set: function set(value) {
  8803. this.foundation.setBuffer(value);
  8804. },
  8805. enumerable: true,
  8806. configurable: true
  8807. });
  8808. Object.defineProperty(MDCLinearProgress.prototype, "reverse", {
  8809. set: function set(value) {
  8810. this.foundation.setReverse(value);
  8811. },
  8812. enumerable: true,
  8813. configurable: true
  8814. });
  8815. MDCLinearProgress.prototype.open = function () {
  8816. this.foundation.open();
  8817. };
  8818. MDCLinearProgress.prototype.close = function () {
  8819. this.foundation.close();
  8820. };
  8821. MDCLinearProgress.prototype.initialSyncWithDOM = function () {
  8822. var _this = this;
  8823. this.root.addEventListener('transitionend', function () {
  8824. _this.foundation.handleTransitionEnd();
  8825. });
  8826. };
  8827. MDCLinearProgress.prototype.getDefaultFoundation = function () {
  8828. var _this = this;
  8829. // DO NOT INLINE this variable. For backward compatibility, foundations take
  8830. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  8831. // methods, we need a separate, strongly typed adapter variable.
  8832. var adapter = {
  8833. addClass: function addClass(className) {
  8834. _this.root.classList.add(className);
  8835. },
  8836. forceLayout: function forceLayout() {
  8837. _this.root.getBoundingClientRect();
  8838. },
  8839. setBufferBarStyle: function setBufferBarStyle(styleProperty, value) {
  8840. var bufferBar = _this.root.querySelector(foundation_1.MDCLinearProgressFoundation.strings.BUFFER_BAR_SELECTOR);
  8841. if (bufferBar) {
  8842. bufferBar.style.setProperty(styleProperty, value);
  8843. }
  8844. },
  8845. setPrimaryBarStyle: function setPrimaryBarStyle(styleProperty, value) {
  8846. var primaryBar = _this.root.querySelector(foundation_1.MDCLinearProgressFoundation.strings.PRIMARY_BAR_SELECTOR);
  8847. if (primaryBar) {
  8848. primaryBar.style.setProperty(styleProperty, value);
  8849. }
  8850. },
  8851. hasClass: function hasClass(className) {
  8852. return _this.root.classList.contains(className);
  8853. },
  8854. removeAttribute: function removeAttribute(attributeName) {
  8855. _this.root.removeAttribute(attributeName);
  8856. },
  8857. removeClass: function removeClass(className) {
  8858. _this.root.classList.remove(className);
  8859. },
  8860. setAttribute: function setAttribute(attributeName, value) {
  8861. _this.root.setAttribute(attributeName, value);
  8862. },
  8863. setStyle: function setStyle(name, value) {
  8864. _this.root.style.setProperty(name, value);
  8865. },
  8866. attachResizeObserver: function attachResizeObserver(callback) {
  8867. if (window.ResizeObserver) {
  8868. var ro = new ResizeObserver(callback);
  8869. ro.observe(_this.root);
  8870. return ro;
  8871. }
  8872. return null;
  8873. },
  8874. getWidth: function getWidth() {
  8875. return _this.root.offsetWidth;
  8876. }
  8877. };
  8878. return new foundation_1.MDCLinearProgressFoundation(adapter);
  8879. };
  8880. return MDCLinearProgress;
  8881. }(component_1.MDCComponent);
  8882. exports.MDCLinearProgress = MDCLinearProgress;
  8883. /***/ }),
  8884. /***/ "./packages/mdc-linear-progress/constants.ts":
  8885. /*!***************************************************!*\
  8886. !*** ./packages/mdc-linear-progress/constants.ts ***!
  8887. \***************************************************/
  8888. /*! no static exports found */
  8889. /***/ (function(module, exports, __webpack_require__) {
  8890. "use strict";
  8891. /**
  8892. * @license
  8893. * Copyright 2017 Google Inc.
  8894. *
  8895. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8896. * of this software and associated documentation files (the "Software"), to deal
  8897. * in the Software without restriction, including without limitation the rights
  8898. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8899. * copies of the Software, and to permit persons to whom the Software is
  8900. * furnished to do so, subject to the following conditions:
  8901. *
  8902. * The above copyright notice and this permission notice shall be included in
  8903. * all copies or substantial portions of the Software.
  8904. *
  8905. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8906. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8907. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8908. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8909. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8910. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8911. * THE SOFTWARE.
  8912. */
  8913. Object.defineProperty(exports, "__esModule", { value: true });
  8914. exports.cssClasses = {
  8915. CLOSED_CLASS: 'mdc-linear-progress--closed',
  8916. CLOSED_ANIMATION_OFF_CLASS: 'mdc-linear-progress--closed-animation-off',
  8917. INDETERMINATE_CLASS: 'mdc-linear-progress--indeterminate',
  8918. REVERSED_CLASS: 'mdc-linear-progress--reversed',
  8919. ANIMATION_READY_CLASS: 'mdc-linear-progress--animation-ready'
  8920. };
  8921. exports.strings = {
  8922. ARIA_VALUEMAX: 'aria-valuemax',
  8923. ARIA_VALUEMIN: 'aria-valuemin',
  8924. ARIA_VALUENOW: 'aria-valuenow',
  8925. BUFFER_BAR_SELECTOR: '.mdc-linear-progress__buffer-bar',
  8926. FLEX_BASIS: 'flex-basis',
  8927. PRIMARY_BAR_SELECTOR: '.mdc-linear-progress__primary-bar'
  8928. };
  8929. // these are percentages pulled from keyframes.scss
  8930. exports.animationDimensionPercentages = {
  8931. PRIMARY_HALF: .8367142,
  8932. PRIMARY_FULL: 2.00611057,
  8933. SECONDARY_QUARTER: .37651913,
  8934. SECONDARY_HALF: .84386165,
  8935. SECONDARY_FULL: 1.60277782
  8936. };
  8937. /***/ }),
  8938. /***/ "./packages/mdc-linear-progress/foundation.ts":
  8939. /*!****************************************************!*\
  8940. !*** ./packages/mdc-linear-progress/foundation.ts ***!
  8941. \****************************************************/
  8942. /*! no static exports found */
  8943. /***/ (function(module, exports, __webpack_require__) {
  8944. "use strict";
  8945. /**
  8946. * @license
  8947. * Copyright 2017 Google Inc.
  8948. *
  8949. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8950. * of this software and associated documentation files (the "Software"), to deal
  8951. * in the Software without restriction, including without limitation the rights
  8952. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8953. * copies of the Software, and to permit persons to whom the Software is
  8954. * furnished to do so, subject to the following conditions:
  8955. *
  8956. * The above copyright notice and this permission notice shall be included in
  8957. * all copies or substantial portions of the Software.
  8958. *
  8959. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8960. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8961. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8962. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8963. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8964. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8965. * THE SOFTWARE.
  8966. */
  8967. var __extends = this && this.__extends || function () {
  8968. var _extendStatics = function extendStatics(d, b) {
  8969. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8970. d.__proto__ = b;
  8971. } || function (d, b) {
  8972. for (var p in b) {
  8973. if (b.hasOwnProperty(p)) d[p] = b[p];
  8974. }
  8975. };
  8976. return _extendStatics(d, b);
  8977. };
  8978. return function (d, b) {
  8979. _extendStatics(d, b);
  8980. function __() {
  8981. this.constructor = d;
  8982. }
  8983. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8984. };
  8985. }();
  8986. var __assign = this && this.__assign || function () {
  8987. __assign = Object.assign || function (t) {
  8988. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8989. s = arguments[i];
  8990. for (var p in s) {
  8991. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  8992. }
  8993. }
  8994. return t;
  8995. };
  8996. return __assign.apply(this, arguments);
  8997. };
  8998. var __values = this && this.__values || function (o) {
  8999. var s = typeof Symbol === "function" && Symbol.iterator,
  9000. m = s && o[s],
  9001. i = 0;
  9002. if (m) return m.call(o);
  9003. if (o && typeof o.length === "number") return {
  9004. next: function next() {
  9005. if (o && i >= o.length) o = void 0;
  9006. return { value: o && o[i++], done: !o };
  9007. }
  9008. };
  9009. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  9010. };
  9011. Object.defineProperty(exports, "__esModule", { value: true });
  9012. var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
  9013. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  9014. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-linear-progress/constants.ts");
  9015. var MDCLinearProgressFoundation = /** @class */function (_super) {
  9016. __extends(MDCLinearProgressFoundation, _super);
  9017. function MDCLinearProgressFoundation(adapter) {
  9018. var _this = _super.call(this, __assign(__assign({}, MDCLinearProgressFoundation.defaultAdapter), adapter)) || this;
  9019. _this.observer = null;
  9020. return _this;
  9021. }
  9022. Object.defineProperty(MDCLinearProgressFoundation, "cssClasses", {
  9023. get: function get() {
  9024. return constants_1.cssClasses;
  9025. },
  9026. enumerable: true,
  9027. configurable: true
  9028. });
  9029. Object.defineProperty(MDCLinearProgressFoundation, "strings", {
  9030. get: function get() {
  9031. return constants_1.strings;
  9032. },
  9033. enumerable: true,
  9034. configurable: true
  9035. });
  9036. Object.defineProperty(MDCLinearProgressFoundation, "defaultAdapter", {
  9037. get: function get() {
  9038. return {
  9039. addClass: function addClass() {
  9040. return undefined;
  9041. },
  9042. attachResizeObserver: function attachResizeObserver() {
  9043. return null;
  9044. },
  9045. forceLayout: function forceLayout() {
  9046. return undefined;
  9047. },
  9048. getWidth: function getWidth() {
  9049. return 0;
  9050. },
  9051. hasClass: function hasClass() {
  9052. return false;
  9053. },
  9054. setBufferBarStyle: function setBufferBarStyle() {
  9055. return null;
  9056. },
  9057. setPrimaryBarStyle: function setPrimaryBarStyle() {
  9058. return null;
  9059. },
  9060. setStyle: function setStyle() {
  9061. return undefined;
  9062. },
  9063. removeAttribute: function removeAttribute() {
  9064. return undefined;
  9065. },
  9066. removeClass: function removeClass() {
  9067. return undefined;
  9068. },
  9069. setAttribute: function setAttribute() {
  9070. return undefined;
  9071. }
  9072. };
  9073. },
  9074. enumerable: true,
  9075. configurable: true
  9076. });
  9077. MDCLinearProgressFoundation.prototype.init = function () {
  9078. var _this = this;
  9079. this.isDeterminate = !this.adapter.hasClass(constants_1.cssClasses.INDETERMINATE_CLASS);
  9080. this.adapter.addClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
  9081. this.isReversed = this.adapter.hasClass(constants_1.cssClasses.REVERSED_CLASS);
  9082. this.progress = 0;
  9083. this.buffer = 1;
  9084. this.observer = this.adapter.attachResizeObserver(function (entries) {
  9085. var e_1, _a;
  9086. if (_this.isDeterminate) {
  9087. return;
  9088. }
  9089. try {
  9090. for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
  9091. var entry = entries_1_1.value;
  9092. if (entry.contentRect) {
  9093. _this.calculateAndSetDimensions(entry.contentRect.width);
  9094. }
  9095. }
  9096. } catch (e_1_1) {
  9097. e_1 = { error: e_1_1 };
  9098. } finally {
  9099. try {
  9100. if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
  9101. } finally {
  9102. if (e_1) throw e_1.error;
  9103. }
  9104. }
  9105. });
  9106. if (!this.isDeterminate && this.observer) {
  9107. this.calculateAndSetDimensions(this.adapter.getWidth());
  9108. }
  9109. };
  9110. MDCLinearProgressFoundation.prototype.setDeterminate = function (isDeterminate) {
  9111. this.isDeterminate = isDeterminate;
  9112. if (this.isDeterminate) {
  9113. this.adapter.removeClass(constants_1.cssClasses.INDETERMINATE_CLASS);
  9114. this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress.toString());
  9115. this.adapter.setAttribute(constants_1.strings.ARIA_VALUEMAX, '1');
  9116. this.adapter.setAttribute(constants_1.strings.ARIA_VALUEMIN, '0');
  9117. this.setPrimaryBarProgress(this.progress);
  9118. this.setBufferBarProgress(this.buffer);
  9119. return;
  9120. }
  9121. if (this.isReversed) {
  9122. // Adding/removing REVERSED_CLASS starts a translate animation, while
  9123. // adding INDETERMINATE_CLASS starts a scale animation. Here, we reset
  9124. // the translate animation in order to keep it in sync with the new
  9125. // scale animation that will start from adding INDETERMINATE_CLASS
  9126. // below.
  9127. this.adapter.removeClass(constants_1.cssClasses.REVERSED_CLASS);
  9128. this.adapter.forceLayout();
  9129. this.adapter.addClass(constants_1.cssClasses.REVERSED_CLASS);
  9130. }
  9131. if (this.observer) {
  9132. this.calculateAndSetDimensions(this.adapter.getWidth());
  9133. }
  9134. this.adapter.addClass(constants_1.cssClasses.INDETERMINATE_CLASS);
  9135. this.adapter.removeAttribute(constants_1.strings.ARIA_VALUENOW);
  9136. this.adapter.removeAttribute(constants_1.strings.ARIA_VALUEMAX);
  9137. this.adapter.removeAttribute(constants_1.strings.ARIA_VALUEMIN);
  9138. this.setPrimaryBarProgress(1);
  9139. this.setBufferBarProgress(1);
  9140. };
  9141. MDCLinearProgressFoundation.prototype.getDeterminate = function () {
  9142. return this.isDeterminate;
  9143. };
  9144. MDCLinearProgressFoundation.prototype.setProgress = function (value) {
  9145. this.progress = value;
  9146. if (this.isDeterminate) {
  9147. this.setPrimaryBarProgress(value);
  9148. this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, value.toString());
  9149. }
  9150. };
  9151. MDCLinearProgressFoundation.prototype.getProgress = function () {
  9152. return this.progress;
  9153. };
  9154. MDCLinearProgressFoundation.prototype.setBuffer = function (value) {
  9155. this.buffer = value;
  9156. if (this.isDeterminate) {
  9157. this.setBufferBarProgress(value);
  9158. }
  9159. };
  9160. MDCLinearProgressFoundation.prototype.setReverse = function (isReversed) {
  9161. this.isReversed = isReversed;
  9162. if (!this.isDeterminate) {
  9163. // Adding ANIMATION_READY_CLASS starts a scale animation, while
  9164. // adding/removing REVERSED_CLASS starts a translate animation. Here, we
  9165. // reset the scale animation in order to keep it in sync with the new
  9166. // translate animation that will start from adding/removing REVERSED_CLASS
  9167. // below.
  9168. this.restartAnimation();
  9169. }
  9170. if (this.isReversed) {
  9171. this.adapter.addClass(constants_1.cssClasses.REVERSED_CLASS);
  9172. return;
  9173. }
  9174. this.adapter.removeClass(constants_1.cssClasses.REVERSED_CLASS);
  9175. };
  9176. MDCLinearProgressFoundation.prototype.open = function () {
  9177. this.adapter.removeClass(constants_1.cssClasses.CLOSED_CLASS);
  9178. this.adapter.removeClass(constants_1.cssClasses.CLOSED_ANIMATION_OFF_CLASS);
  9179. };
  9180. MDCLinearProgressFoundation.prototype.close = function () {
  9181. this.adapter.addClass(constants_1.cssClasses.CLOSED_CLASS);
  9182. };
  9183. /**
  9184. * Handles the transitionend event emitted after `close()` is called and the
  9185. * opacity fades out. This is so that animations are removed only after the
  9186. * progress indicator is completely hidden.
  9187. */
  9188. MDCLinearProgressFoundation.prototype.handleTransitionEnd = function () {
  9189. if (this.adapter.hasClass(constants_1.cssClasses.CLOSED_CLASS)) {
  9190. this.adapter.addClass(constants_1.cssClasses.CLOSED_ANIMATION_OFF_CLASS);
  9191. }
  9192. };
  9193. MDCLinearProgressFoundation.prototype.destroy = function () {
  9194. _super.prototype.destroy.call(this);
  9195. if (this.observer) {
  9196. this.observer.disconnect();
  9197. }
  9198. };
  9199. MDCLinearProgressFoundation.prototype.setPrimaryBarProgress = function (progressValue) {
  9200. var value = "scaleX(" + progressValue + ")";
  9201. // Accessing `window` without a `typeof` check will throw on Node
  9202. // environments.
  9203. var transformProp = typeof window !== 'undefined' ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
  9204. this.adapter.setPrimaryBarStyle(transformProp, value);
  9205. };
  9206. MDCLinearProgressFoundation.prototype.setBufferBarProgress = function (progressValue) {
  9207. var value = progressValue * 100 + "%";
  9208. this.adapter.setBufferBarStyle(constants_1.strings.FLEX_BASIS, value);
  9209. };
  9210. MDCLinearProgressFoundation.prototype.restartAnimation = function () {
  9211. this.adapter.removeClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
  9212. this.adapter.forceLayout();
  9213. this.adapter.addClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
  9214. };
  9215. MDCLinearProgressFoundation.prototype.calculateAndSetDimensions = function (width) {
  9216. var primaryHalf = width * constants_1.animationDimensionPercentages.PRIMARY_HALF;
  9217. var primaryFull = width * constants_1.animationDimensionPercentages.PRIMARY_FULL;
  9218. var secondaryQuarter = width * constants_1.animationDimensionPercentages.SECONDARY_QUARTER;
  9219. var secondaryHalf = width * constants_1.animationDimensionPercentages.SECONDARY_HALF;
  9220. var secondaryFull = width * constants_1.animationDimensionPercentages.SECONDARY_FULL;
  9221. this.adapter.setStyle('--mdc-linear-progress-primary-half', primaryHalf + "px");
  9222. this.adapter.setStyle('--mdc-linear-progress-primary-half-neg', -primaryHalf + "px");
  9223. this.adapter.setStyle('--mdc-linear-progress-primary-full', primaryFull + "px");
  9224. this.adapter.setStyle('--mdc-linear-progress-primary-full-neg', -primaryFull + "px");
  9225. this.adapter.setStyle('--mdc-linear-progress-secondary-quarter', secondaryQuarter + "px");
  9226. this.adapter.setStyle('--mdc-linear-progress-secondary-quarter-neg', -secondaryQuarter + "px");
  9227. this.adapter.setStyle('--mdc-linear-progress-secondary-half', secondaryHalf + "px");
  9228. this.adapter.setStyle('--mdc-linear-progress-secondary-half-neg', -secondaryHalf + "px");
  9229. this.adapter.setStyle('--mdc-linear-progress-secondary-full', secondaryFull + "px");
  9230. this.adapter.setStyle('--mdc-linear-progress-secondary-full-neg', -secondaryFull + "px");
  9231. // need to restart animation for custom props to apply to keyframes
  9232. this.restartAnimation();
  9233. };
  9234. return MDCLinearProgressFoundation;
  9235. }(foundation_1.MDCFoundation);
  9236. exports.MDCLinearProgressFoundation = MDCLinearProgressFoundation;
  9237. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  9238. exports.default = MDCLinearProgressFoundation;
  9239. /***/ }),
  9240. /***/ "./packages/mdc-linear-progress/index.ts":
  9241. /*!***********************************************!*\
  9242. !*** ./packages/mdc-linear-progress/index.ts ***!
  9243. \***********************************************/
  9244. /*! no static exports found */
  9245. /***/ (function(module, exports, __webpack_require__) {
  9246. "use strict";
  9247. /**
  9248. * @license
  9249. * Copyright 2019 Google Inc.
  9250. *
  9251. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9252. * of this software and associated documentation files (the "Software"), to deal
  9253. * in the Software without restriction, including without limitation the rights
  9254. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9255. * copies of the Software, and to permit persons to whom the Software is
  9256. * furnished to do so, subject to the following conditions:
  9257. *
  9258. * The above copyright notice and this permission notice shall be included in
  9259. * all copies or substantial portions of the Software.
  9260. *
  9261. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9262. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9263. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9264. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9265. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9266. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9267. * THE SOFTWARE.
  9268. */
  9269. function __export(m) {
  9270. for (var p in m) {
  9271. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  9272. }
  9273. }
  9274. Object.defineProperty(exports, "__esModule", { value: true });
  9275. __export(__webpack_require__(/*! ./component */ "./packages/mdc-linear-progress/component.ts"));
  9276. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-linear-progress/constants.ts"));
  9277. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-linear-progress/foundation.ts"));
  9278. /***/ }),
  9279. /***/ "./packages/mdc-list/component.ts":
  9280. /*!****************************************!*\
  9281. !*** ./packages/mdc-list/component.ts ***!
  9282. \****************************************/
  9283. /*! no static exports found */
  9284. /***/ (function(module, exports, __webpack_require__) {
  9285. "use strict";
  9286. /**
  9287. * @license
  9288. * Copyright 2018 Google Inc.
  9289. *
  9290. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9291. * of this software and associated documentation files (the "Software"), to deal
  9292. * in the Software without restriction, including without limitation the rights
  9293. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9294. * copies of the Software, and to permit persons to whom the Software is
  9295. * furnished to do so, subject to the following conditions:
  9296. *
  9297. * The above copyright notice and this permission notice shall be included in
  9298. * all copies or substantial portions of the Software.
  9299. *
  9300. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9301. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9302. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9303. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9304. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9305. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9306. * THE SOFTWARE.
  9307. */
  9308. var __extends = this && this.__extends || function () {
  9309. var _extendStatics = function extendStatics(d, b) {
  9310. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  9311. d.__proto__ = b;
  9312. } || function (d, b) {
  9313. for (var p in b) {
  9314. if (b.hasOwnProperty(p)) d[p] = b[p];
  9315. }
  9316. };
  9317. return _extendStatics(d, b);
  9318. };
  9319. return function (d, b) {
  9320. _extendStatics(d, b);
  9321. function __() {
  9322. this.constructor = d;
  9323. }
  9324. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9325. };
  9326. }();
  9327. Object.defineProperty(exports, "__esModule", { value: true });
  9328. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  9329. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  9330. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  9331. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-list/foundation.ts");
  9332. var MDCList = /** @class */function (_super) {
  9333. __extends(MDCList, _super);
  9334. function MDCList() {
  9335. return _super !== null && _super.apply(this, arguments) || this;
  9336. }
  9337. Object.defineProperty(MDCList.prototype, "vertical", {
  9338. set: function set(value) {
  9339. this.foundation.setVerticalOrientation(value);
  9340. },
  9341. enumerable: true,
  9342. configurable: true
  9343. });
  9344. Object.defineProperty(MDCList.prototype, "listElements", {
  9345. get: function get() {
  9346. return Array.from(this.root.querySelectorAll("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]));
  9347. },
  9348. enumerable: true,
  9349. configurable: true
  9350. });
  9351. Object.defineProperty(MDCList.prototype, "wrapFocus", {
  9352. set: function set(value) {
  9353. this.foundation.setWrapFocus(value);
  9354. },
  9355. enumerable: true,
  9356. configurable: true
  9357. });
  9358. Object.defineProperty(MDCList.prototype, "typeaheadInProgress", {
  9359. /**
  9360. * @return Whether typeahead is currently matching a user-specified prefix.
  9361. */
  9362. get: function get() {
  9363. return this.foundation.isTypeaheadInProgress();
  9364. },
  9365. enumerable: true,
  9366. configurable: true
  9367. });
  9368. Object.defineProperty(MDCList.prototype, "hasTypeahead", {
  9369. /**
  9370. * Sets whether typeahead functionality is enabled on the list.
  9371. * @param hasTypeahead Whether typeahead is enabled.
  9372. */
  9373. set: function set(hasTypeahead) {
  9374. this.foundation.setHasTypeahead(hasTypeahead);
  9375. },
  9376. enumerable: true,
  9377. configurable: true
  9378. });
  9379. Object.defineProperty(MDCList.prototype, "singleSelection", {
  9380. set: function set(isSingleSelectionList) {
  9381. this.foundation.setSingleSelection(isSingleSelectionList);
  9382. },
  9383. enumerable: true,
  9384. configurable: true
  9385. });
  9386. Object.defineProperty(MDCList.prototype, "selectedIndex", {
  9387. get: function get() {
  9388. return this.foundation.getSelectedIndex();
  9389. },
  9390. set: function set(index) {
  9391. this.foundation.setSelectedIndex(index);
  9392. },
  9393. enumerable: true,
  9394. configurable: true
  9395. });
  9396. MDCList.attachTo = function (root) {
  9397. return new MDCList(root);
  9398. };
  9399. MDCList.prototype.initialSyncWithDOM = function () {
  9400. this.isEvolutionEnabled = constants_1.evolutionAttribute in this.root.dataset;
  9401. this.classNameMap = this.isEvolutionEnabled ? constants_1.evolutionClassNameMap : Object.values(constants_1.cssClasses).reduce(function (obj, className) {
  9402. obj[className] = className;
  9403. return obj;
  9404. }, {});
  9405. this.handleClick = this.handleClickEvent.bind(this);
  9406. this.handleKeydown = this.handleKeydownEvent.bind(this);
  9407. this.focusInEventListener = this.handleFocusInEvent.bind(this);
  9408. this.focusOutEventListener = this.handleFocusOutEvent.bind(this);
  9409. this.listen('keydown', this.handleKeydown);
  9410. this.listen('click', this.handleClick);
  9411. this.listen('focusin', this.focusInEventListener);
  9412. this.listen('focusout', this.focusOutEventListener);
  9413. this.layout();
  9414. this.initializeListType();
  9415. this.ensureFocusable();
  9416. };
  9417. MDCList.prototype.destroy = function () {
  9418. this.unlisten('keydown', this.handleKeydown);
  9419. this.unlisten('click', this.handleClick);
  9420. this.unlisten('focusin', this.focusInEventListener);
  9421. this.unlisten('focusout', this.focusOutEventListener);
  9422. };
  9423. MDCList.prototype.layout = function () {
  9424. var direction = this.root.getAttribute(constants_1.strings.ARIA_ORIENTATION);
  9425. this.vertical = direction !== constants_1.strings.ARIA_ORIENTATION_HORIZONTAL;
  9426. var itemSelector = "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not([tabindex])";
  9427. var childSelector = "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + " " + constants_1.strings.FOCUSABLE_CHILD_ELEMENTS;
  9428. // List items need to have at least tabindex=-1 to be focusable.
  9429. Array.prototype.forEach.call(this.root.querySelectorAll(itemSelector), function (el) {
  9430. el.setAttribute('tabindex', '-1');
  9431. });
  9432. // Child button/a elements are not tabbable until the list item is focused.
  9433. Array.prototype.forEach.call(this.root.querySelectorAll(childSelector), function (el) {
  9434. el.setAttribute('tabindex', '-1');
  9435. });
  9436. if (this.isEvolutionEnabled) {
  9437. this.foundation.setUseSelectedAttribute(true);
  9438. }
  9439. this.foundation.layout();
  9440. };
  9441. /**
  9442. * Extracts the primary text from a list item.
  9443. * @param item The list item element.
  9444. * @return The primary text in the element.
  9445. */
  9446. MDCList.prototype.getPrimaryText = function (item) {
  9447. var _a;
  9448. var primaryText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS]);
  9449. if (this.isEvolutionEnabled || primaryText) {
  9450. return (_a = primaryText === null || primaryText === void 0 ? void 0 : primaryText.textContent) !== null && _a !== void 0 ? _a : '';
  9451. }
  9452. var singleLineText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_TEXT_CLASS]);
  9453. return singleLineText && singleLineText.textContent || '';
  9454. };
  9455. /**
  9456. * Initialize selectedIndex value based on pre-selected list items.
  9457. */
  9458. MDCList.prototype.initializeListType = function () {
  9459. var _this = this;
  9460. this.isInteractive = ponyfill_1.matches(this.root, constants_1.strings.ARIA_INTERACTIVE_ROLES_SELECTOR);
  9461. if (this.isEvolutionEnabled && this.isInteractive) {
  9462. var selection = Array.from(this.root.querySelectorAll(constants_1.strings.SELECTED_ITEM_SELECTOR), function (listItem) {
  9463. return _this.listElements.indexOf(listItem);
  9464. });
  9465. if (ponyfill_1.matches(this.root, constants_1.strings.ARIA_MULTI_SELECTABLE_SELECTOR)) {
  9466. this.selectedIndex = selection;
  9467. } else if (selection.length > 0) {
  9468. this.selectedIndex = selection[0];
  9469. }
  9470. return;
  9471. }
  9472. var checkboxListItems = this.root.querySelectorAll(constants_1.strings.ARIA_ROLE_CHECKBOX_SELECTOR);
  9473. var radioSelectedListItem = this.root.querySelector(constants_1.strings.ARIA_CHECKED_RADIO_SELECTOR);
  9474. if (checkboxListItems.length) {
  9475. var preselectedItems = this.root.querySelectorAll(constants_1.strings.ARIA_CHECKED_CHECKBOX_SELECTOR);
  9476. this.selectedIndex = Array.from(preselectedItems, function (listItem) {
  9477. return _this.listElements.indexOf(listItem);
  9478. });
  9479. } else if (radioSelectedListItem) {
  9480. this.selectedIndex = this.listElements.indexOf(radioSelectedListItem);
  9481. }
  9482. };
  9483. /**
  9484. * Updates the list item at itemIndex to the desired isEnabled state.
  9485. * @param itemIndex Index of the list item
  9486. * @param isEnabled Sets the list item to enabled or disabled.
  9487. */
  9488. MDCList.prototype.setEnabled = function (itemIndex, isEnabled) {
  9489. this.foundation.setEnabled(itemIndex, isEnabled);
  9490. };
  9491. /**
  9492. * Given the next desired character from the user, adds it to the typeahead
  9493. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  9494. * around if at the end of options.
  9495. *
  9496. * @param nextChar The next character to add to the prefix buffer.
  9497. * @param startingIndex The index from which to start matching. Defaults to
  9498. * the currently focused index.
  9499. * @return The index of the matched item.
  9500. */
  9501. MDCList.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
  9502. return this.foundation.typeaheadMatchItem(nextChar, startingIndex, /** skipFocus */true);
  9503. };
  9504. MDCList.prototype.getDefaultFoundation = function () {
  9505. var _this = this;
  9506. // DO NOT INLINE this variable. For backward compatibility, foundations take
  9507. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  9508. // methods, we need a separate, strongly typed adapter variable.
  9509. var adapter = {
  9510. addClassForElementIndex: function addClassForElementIndex(index, className) {
  9511. var element = _this.listElements[index];
  9512. if (element) {
  9513. element.classList.add(_this.classNameMap[className]);
  9514. }
  9515. },
  9516. focusItemAtIndex: function focusItemAtIndex(index) {
  9517. var element = _this.listElements[index];
  9518. if (element) {
  9519. element.focus();
  9520. }
  9521. },
  9522. getAttributeForElementIndex: function getAttributeForElementIndex(index, attr) {
  9523. return _this.listElements[index].getAttribute(attr);
  9524. },
  9525. getFocusedElementIndex: function getFocusedElementIndex() {
  9526. return _this.listElements.indexOf(document.activeElement);
  9527. },
  9528. getListItemCount: function getListItemCount() {
  9529. return _this.listElements.length;
  9530. },
  9531. getPrimaryTextAtIndex: function getPrimaryTextAtIndex(index) {
  9532. return _this.getPrimaryText(_this.listElements[index]);
  9533. },
  9534. hasCheckboxAtIndex: function hasCheckboxAtIndex(index) {
  9535. var listItem = _this.listElements[index];
  9536. return !!listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
  9537. },
  9538. hasRadioAtIndex: function hasRadioAtIndex(index) {
  9539. var listItem = _this.listElements[index];
  9540. return !!listItem.querySelector(constants_1.strings.RADIO_SELECTOR);
  9541. },
  9542. isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex(index) {
  9543. var listItem = _this.listElements[index];
  9544. var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
  9545. return toggleEl.checked;
  9546. },
  9547. isFocusInsideList: function isFocusInsideList() {
  9548. return _this.root !== document.activeElement && _this.root.contains(document.activeElement);
  9549. },
  9550. isRootFocused: function isRootFocused() {
  9551. return document.activeElement === _this.root;
  9552. },
  9553. listItemAtIndexHasClass: function listItemAtIndexHasClass(index, className) {
  9554. return _this.listElements[index].classList.contains(_this.classNameMap[className]);
  9555. },
  9556. notifyAction: function notifyAction(index) {
  9557. _this.emit(constants_1.strings.ACTION_EVENT, { index: index }, /** shouldBubble */true);
  9558. },
  9559. removeClassForElementIndex: function removeClassForElementIndex(index, className) {
  9560. var element = _this.listElements[index];
  9561. if (element) {
  9562. element.classList.remove(_this.classNameMap[className]);
  9563. }
  9564. },
  9565. setAttributeForElementIndex: function setAttributeForElementIndex(index, attr, value) {
  9566. var element = _this.listElements[index];
  9567. if (element) {
  9568. element.setAttribute(attr, value);
  9569. }
  9570. },
  9571. setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex(index, isChecked) {
  9572. var listItem = _this.listElements[index];
  9573. var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_RADIO_SELECTOR);
  9574. toggleEl.checked = isChecked;
  9575. var event = document.createEvent('Event');
  9576. event.initEvent('change', true, true);
  9577. toggleEl.dispatchEvent(event);
  9578. },
  9579. setTabIndexForListItemChildren: function setTabIndexForListItemChildren(listItemIndex, tabIndexValue) {
  9580. var element = _this.listElements[listItemIndex];
  9581. var selector = "." + _this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + " " + constants_1.strings.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX;
  9582. Array.prototype.forEach.call(element.querySelectorAll(selector), function (el) {
  9583. el.setAttribute('tabindex', tabIndexValue);
  9584. });
  9585. }
  9586. };
  9587. return new foundation_1.MDCListFoundation(adapter);
  9588. };
  9589. /**
  9590. * Ensures that at least one item is focusable if the list is interactive and
  9591. * doesn't specify a suitable tabindex.
  9592. */
  9593. MDCList.prototype.ensureFocusable = function () {
  9594. if (this.isEvolutionEnabled && this.isInteractive) {
  9595. if (!this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + "[tabindex=\"0\"]")) {
  9596. var index = this.initialFocusIndex();
  9597. if (index !== -1) {
  9598. this.listElements[index].tabIndex = 0;
  9599. }
  9600. }
  9601. }
  9602. };
  9603. MDCList.prototype.initialFocusIndex = function () {
  9604. if (this.selectedIndex instanceof Array && this.selectedIndex.length > 0) {
  9605. return this.selectedIndex[0];
  9606. }
  9607. if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  9608. return this.selectedIndex;
  9609. }
  9610. var el = this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not(." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS] + ")");
  9611. if (el === null) {
  9612. return -1;
  9613. }
  9614. return this.getListItemIndex(el);
  9615. };
  9616. /**
  9617. * Used to figure out which list item this event is targetting. Or returns -1
  9618. * if there is no list item
  9619. */
  9620. MDCList.prototype.getListItemIndex = function (el) {
  9621. var nearestParent = ponyfill_1.closest(el, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ", ." + this.classNameMap[constants_1.cssClasses.ROOT]);
  9622. // Get the index of the element if it is a list item.
  9623. if (nearestParent && ponyfill_1.matches(nearestParent, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS])) {
  9624. return this.listElements.indexOf(nearestParent);
  9625. }
  9626. return -1;
  9627. };
  9628. /**
  9629. * Used to figure out which element was clicked before sending the event to
  9630. * the foundation.
  9631. */
  9632. MDCList.prototype.handleFocusInEvent = function (evt) {
  9633. var index = this.getListItemIndex(evt.target);
  9634. this.foundation.handleFocusIn(evt, index);
  9635. };
  9636. /**
  9637. * Used to figure out which element was clicked before sending the event to
  9638. * the foundation.
  9639. */
  9640. MDCList.prototype.handleFocusOutEvent = function (evt) {
  9641. var index = this.getListItemIndex(evt.target);
  9642. this.foundation.handleFocusOut(evt, index);
  9643. };
  9644. /**
  9645. * Used to figure out which element was focused when keydown event occurred
  9646. * before sending the event to the foundation.
  9647. */
  9648. MDCList.prototype.handleKeydownEvent = function (evt) {
  9649. var index = this.getListItemIndex(evt.target);
  9650. var target = evt.target;
  9651. this.foundation.handleKeydown(evt, target.classList.contains(this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]), index);
  9652. };
  9653. /**
  9654. * Used to figure out which element was clicked before sending the event to
  9655. * the foundation.
  9656. */
  9657. MDCList.prototype.handleClickEvent = function (evt) {
  9658. var index = this.getListItemIndex(evt.target);
  9659. var target = evt.target;
  9660. // Toggle the checkbox only if it's not the target of the event, or the
  9661. // checkbox will have 2 change events.
  9662. var toggleCheckbox = !ponyfill_1.matches(target, constants_1.strings.CHECKBOX_RADIO_SELECTOR);
  9663. this.foundation.handleClick(index, toggleCheckbox);
  9664. };
  9665. return MDCList;
  9666. }(component_1.MDCComponent);
  9667. exports.MDCList = MDCList;
  9668. /***/ }),
  9669. /***/ "./packages/mdc-list/constants.ts":
  9670. /*!****************************************!*\
  9671. !*** ./packages/mdc-list/constants.ts ***!
  9672. \****************************************/
  9673. /*! no static exports found */
  9674. /***/ (function(module, exports, __webpack_require__) {
  9675. "use strict";
  9676. /**
  9677. * @license
  9678. * Copyright 2018 Google Inc.
  9679. *
  9680. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9681. * of this software and associated documentation files (the "Software"), to deal
  9682. * in the Software without restriction, including without limitation the rights
  9683. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9684. * copies of the Software, and to permit persons to whom the Software is
  9685. * furnished to do so, subject to the following conditions:
  9686. *
  9687. * The above copyright notice and this permission notice shall be included in
  9688. * all copies or substantial portions of the Software.
  9689. *
  9690. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9691. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9692. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9693. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9694. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9695. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9696. * THE SOFTWARE.
  9697. */
  9698. var _a;
  9699. Object.defineProperty(exports, "__esModule", { value: true });
  9700. var cssClasses = {
  9701. LIST_ITEM_ACTIVATED_CLASS: 'mdc-list-item--activated',
  9702. LIST_ITEM_CLASS: 'mdc-list-item',
  9703. LIST_ITEM_DISABLED_CLASS: 'mdc-list-item--disabled',
  9704. LIST_ITEM_SELECTED_CLASS: 'mdc-list-item--selected',
  9705. LIST_ITEM_TEXT_CLASS: 'mdc-list-item__text',
  9706. LIST_ITEM_PRIMARY_TEXT_CLASS: 'mdc-list-item__primary-text',
  9707. ROOT: 'mdc-list'
  9708. };
  9709. exports.cssClasses = cssClasses;
  9710. var strings = {
  9711. ACTION_EVENT: 'MDCList:action',
  9712. ARIA_CHECKED: 'aria-checked',
  9713. ARIA_CHECKED_CHECKBOX_SELECTOR: '[role="checkbox"][aria-checked="true"]',
  9714. ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]',
  9715. ARIA_CURRENT: 'aria-current',
  9716. ARIA_DISABLED: 'aria-disabled',
  9717. ARIA_ORIENTATION: 'aria-orientation',
  9718. ARIA_ORIENTATION_HORIZONTAL: 'horizontal',
  9719. ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]',
  9720. ARIA_SELECTED: 'aria-selected',
  9721. ARIA_INTERACTIVE_ROLES_SELECTOR: '[role="listbox"], [role="menu"]',
  9722. ARIA_MULTI_SELECTABLE_SELECTOR: '[aria-multiselectable="true"]',
  9723. CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"], input[type="radio"]',
  9724. CHECKBOX_SELECTOR: 'input[type="checkbox"]',
  9725. CHILD_ELEMENTS_TO_TOGGLE_TABINDEX: 'button:not(:disabled), a',
  9726. FOCUSABLE_CHILD_ELEMENTS: 'button:not(:disabled), a, input[type="radio"]:not(:disabled), input[type="checkbox"]:not(:disabled)',
  9727. RADIO_SELECTOR: 'input[type="radio"]',
  9728. SELECTED_ITEM_SELECTOR: '[aria-selected="true"], [aria-current="true"]'
  9729. };
  9730. exports.strings = strings;
  9731. var numbers = {
  9732. UNSET_INDEX: -1,
  9733. TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS: 300
  9734. };
  9735. exports.numbers = numbers;
  9736. 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);
  9737. exports.evolutionClassNameMap = evolutionClassNameMap;
  9738. var evolutionAttribute = 'evolution';
  9739. exports.evolutionAttribute = evolutionAttribute;
  9740. /***/ }),
  9741. /***/ "./packages/mdc-list/events.ts":
  9742. /*!*************************************!*\
  9743. !*** ./packages/mdc-list/events.ts ***!
  9744. \*************************************/
  9745. /*! no static exports found */
  9746. /***/ (function(module, exports, __webpack_require__) {
  9747. "use strict";
  9748. /**
  9749. * @license
  9750. * Copyright 2020 Google Inc.
  9751. *
  9752. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9753. * of this software and associated documentation files (the "Software"), to deal
  9754. * in the Software without restriction, including without limitation the rights
  9755. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9756. * copies of the Software, and to permit persons to whom the Software is
  9757. * furnished to do so, subject to the following conditions:
  9758. *
  9759. * The above copyright notice and this permission notice shall be included in
  9760. * all copies or substantial portions of the Software.
  9761. *
  9762. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9763. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9764. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9765. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9766. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9767. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9768. * THE SOFTWARE.
  9769. */
  9770. Object.defineProperty(exports, "__esModule", { value: true });
  9771. var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select'];
  9772. /**
  9773. * Ensures that preventDefault is only called if the containing element
  9774. * doesn't consume the event, and it will cause an unintended scroll.
  9775. *
  9776. * @param evt keyboard event to be prevented.
  9777. */
  9778. exports.preventDefaultEvent = function (evt) {
  9779. var target = evt.target;
  9780. if (!target) {
  9781. return;
  9782. }
  9783. var tagName = ("" + target.tagName).toLowerCase();
  9784. if (ELEMENTS_KEY_ALLOWED_IN.indexOf(tagName) === -1) {
  9785. evt.preventDefault();
  9786. }
  9787. };
  9788. /***/ }),
  9789. /***/ "./packages/mdc-list/foundation.ts":
  9790. /*!*****************************************!*\
  9791. !*** ./packages/mdc-list/foundation.ts ***!
  9792. \*****************************************/
  9793. /*! no static exports found */
  9794. /***/ (function(module, exports, __webpack_require__) {
  9795. "use strict";
  9796. /**
  9797. * @license
  9798. * Copyright 2018 Google Inc.
  9799. *
  9800. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9801. * of this software and associated documentation files (the "Software"), to deal
  9802. * in the Software without restriction, including without limitation the rights
  9803. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9804. * copies of the Software, and to permit persons to whom the Software is
  9805. * furnished to do so, subject to the following conditions:
  9806. *
  9807. * The above copyright notice and this permission notice shall be included in
  9808. * all copies or substantial portions of the Software.
  9809. *
  9810. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9811. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9812. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9813. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9814. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9815. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9816. * THE SOFTWARE.
  9817. */
  9818. var __extends = this && this.__extends || function () {
  9819. var _extendStatics = function extendStatics(d, b) {
  9820. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  9821. d.__proto__ = b;
  9822. } || function (d, b) {
  9823. for (var p in b) {
  9824. if (b.hasOwnProperty(p)) d[p] = b[p];
  9825. }
  9826. };
  9827. return _extendStatics(d, b);
  9828. };
  9829. return function (d, b) {
  9830. _extendStatics(d, b);
  9831. function __() {
  9832. this.constructor = d;
  9833. }
  9834. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9835. };
  9836. }();
  9837. var __assign = this && this.__assign || function () {
  9838. __assign = Object.assign || function (t) {
  9839. for (var s, i = 1, n = arguments.length; i < n; i++) {
  9840. s = arguments[i];
  9841. for (var p in s) {
  9842. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  9843. }
  9844. }
  9845. return t;
  9846. };
  9847. return __assign.apply(this, arguments);
  9848. };
  9849. var __importStar = this && this.__importStar || function (mod) {
  9850. if (mod && mod.__esModule) return mod;
  9851. var result = {};
  9852. if (mod != null) for (var k in mod) {
  9853. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  9854. }result["default"] = mod;
  9855. return result;
  9856. };
  9857. Object.defineProperty(exports, "__esModule", { value: true });
  9858. // TODO(b/152410470): Remove trailing underscores from private properties
  9859. // tslint:disable:strip-private-property-underscore
  9860. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  9861. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  9862. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  9863. var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
  9864. var typeahead = __importStar(__webpack_require__(/*! ./typeahead */ "./packages/mdc-list/typeahead.ts"));
  9865. function isNumberArray(selectedIndex) {
  9866. return selectedIndex instanceof Array;
  9867. }
  9868. var MDCListFoundation = /** @class */function (_super) {
  9869. __extends(MDCListFoundation, _super);
  9870. function MDCListFoundation(adapter) {
  9871. var _this = _super.call(this, __assign(__assign({}, MDCListFoundation.defaultAdapter), adapter)) || this;
  9872. _this.wrapFocus_ = false;
  9873. _this.isVertical_ = true;
  9874. _this.isSingleSelectionList_ = false;
  9875. _this.selectedIndex_ = constants_1.numbers.UNSET_INDEX;
  9876. _this.focusedItemIndex = constants_1.numbers.UNSET_INDEX;
  9877. _this.useActivatedClass_ = false;
  9878. _this.useSelectedAttr_ = false;
  9879. _this.ariaCurrentAttrValue_ = null;
  9880. _this.isCheckboxList_ = false;
  9881. _this.isRadioList_ = false;
  9882. _this.hasTypeahead = false;
  9883. // Transiently holds current typeahead prefix from user.
  9884. _this.typeaheadState = typeahead.initState();
  9885. _this.sortedIndexByFirstChar = new Map();
  9886. return _this;
  9887. }
  9888. Object.defineProperty(MDCListFoundation, "strings", {
  9889. get: function get() {
  9890. return constants_1.strings;
  9891. },
  9892. enumerable: true,
  9893. configurable: true
  9894. });
  9895. Object.defineProperty(MDCListFoundation, "cssClasses", {
  9896. get: function get() {
  9897. return constants_1.cssClasses;
  9898. },
  9899. enumerable: true,
  9900. configurable: true
  9901. });
  9902. Object.defineProperty(MDCListFoundation, "numbers", {
  9903. get: function get() {
  9904. return constants_1.numbers;
  9905. },
  9906. enumerable: true,
  9907. configurable: true
  9908. });
  9909. Object.defineProperty(MDCListFoundation, "defaultAdapter", {
  9910. get: function get() {
  9911. return {
  9912. addClassForElementIndex: function addClassForElementIndex() {
  9913. return undefined;
  9914. },
  9915. focusItemAtIndex: function focusItemAtIndex() {
  9916. return undefined;
  9917. },
  9918. getAttributeForElementIndex: function getAttributeForElementIndex() {
  9919. return null;
  9920. },
  9921. getFocusedElementIndex: function getFocusedElementIndex() {
  9922. return 0;
  9923. },
  9924. getListItemCount: function getListItemCount() {
  9925. return 0;
  9926. },
  9927. hasCheckboxAtIndex: function hasCheckboxAtIndex() {
  9928. return false;
  9929. },
  9930. hasRadioAtIndex: function hasRadioAtIndex() {
  9931. return false;
  9932. },
  9933. isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex() {
  9934. return false;
  9935. },
  9936. isFocusInsideList: function isFocusInsideList() {
  9937. return false;
  9938. },
  9939. isRootFocused: function isRootFocused() {
  9940. return false;
  9941. },
  9942. listItemAtIndexHasClass: function listItemAtIndexHasClass() {
  9943. return false;
  9944. },
  9945. notifyAction: function notifyAction() {
  9946. return undefined;
  9947. },
  9948. removeClassForElementIndex: function removeClassForElementIndex() {
  9949. return undefined;
  9950. },
  9951. setAttributeForElementIndex: function setAttributeForElementIndex() {
  9952. return undefined;
  9953. },
  9954. setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex() {
  9955. return undefined;
  9956. },
  9957. setTabIndexForListItemChildren: function setTabIndexForListItemChildren() {
  9958. return undefined;
  9959. },
  9960. getPrimaryTextAtIndex: function getPrimaryTextAtIndex() {
  9961. return '';
  9962. }
  9963. };
  9964. },
  9965. enumerable: true,
  9966. configurable: true
  9967. });
  9968. MDCListFoundation.prototype.layout = function () {
  9969. if (this.adapter.getListItemCount() === 0) {
  9970. return;
  9971. }
  9972. // TODO(b/172274142): consider all items when determining the list's type.
  9973. if (this.adapter.hasCheckboxAtIndex(0)) {
  9974. this.isCheckboxList_ = true;
  9975. } else if (this.adapter.hasRadioAtIndex(0)) {
  9976. this.isRadioList_ = true;
  9977. } else {
  9978. this.maybeInitializeSingleSelection();
  9979. }
  9980. if (this.hasTypeahead) {
  9981. this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
  9982. }
  9983. };
  9984. /**
  9985. * Sets the private wrapFocus_ variable.
  9986. */
  9987. MDCListFoundation.prototype.setWrapFocus = function (value) {
  9988. this.wrapFocus_ = value;
  9989. };
  9990. /**
  9991. * Sets the isVertical_ private variable.
  9992. */
  9993. MDCListFoundation.prototype.setVerticalOrientation = function (value) {
  9994. this.isVertical_ = value;
  9995. };
  9996. /**
  9997. * Sets the isSingleSelectionList_ private variable.
  9998. */
  9999. MDCListFoundation.prototype.setSingleSelection = function (value) {
  10000. this.isSingleSelectionList_ = value;
  10001. if (value) {
  10002. this.maybeInitializeSingleSelection();
  10003. }
  10004. };
  10005. /**
  10006. * Automatically determines whether the list is single selection list. If so,
  10007. * initializes the internal state to match the selected item.
  10008. */
  10009. MDCListFoundation.prototype.maybeInitializeSingleSelection = function () {
  10010. var listItemsCount = this.adapter.getListItemCount();
  10011. for (var i = 0; i < listItemsCount; i++) {
  10012. var hasSelectedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS);
  10013. var hasActivatedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
  10014. if (!(hasSelectedClass || hasActivatedClass)) {
  10015. continue;
  10016. }
  10017. if (hasActivatedClass) {
  10018. this.setUseActivatedClass(true);
  10019. }
  10020. this.isSingleSelectionList_ = true;
  10021. this.selectedIndex_ = i;
  10022. return;
  10023. }
  10024. };
  10025. /**
  10026. * Sets whether typeahead is enabled on the list.
  10027. * @param hasTypeahead Whether typeahead is enabled.
  10028. */
  10029. MDCListFoundation.prototype.setHasTypeahead = function (hasTypeahead) {
  10030. this.hasTypeahead = hasTypeahead;
  10031. if (hasTypeahead) {
  10032. this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
  10033. }
  10034. };
  10035. /**
  10036. * @return Whether typeahead is currently matching a user-specified prefix.
  10037. */
  10038. MDCListFoundation.prototype.isTypeaheadInProgress = function () {
  10039. return this.hasTypeahead && typeahead.isTypingInProgress(this.typeaheadState);
  10040. };
  10041. /**
  10042. * Sets the useActivatedClass_ private variable.
  10043. */
  10044. MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) {
  10045. this.useActivatedClass_ = useActivated;
  10046. };
  10047. /**
  10048. * Sets the useSelectedAttr_ private variable.
  10049. */
  10050. MDCListFoundation.prototype.setUseSelectedAttribute = function (useSelected) {
  10051. this.useSelectedAttr_ = useSelected;
  10052. };
  10053. MDCListFoundation.prototype.getSelectedIndex = function () {
  10054. return this.selectedIndex_;
  10055. };
  10056. MDCListFoundation.prototype.setSelectedIndex = function (index) {
  10057. if (!this.isIndexValid_(index)) {
  10058. return;
  10059. }
  10060. if (this.isCheckboxList_) {
  10061. this.setCheckboxAtIndex_(index);
  10062. } else if (this.isRadioList_) {
  10063. this.setRadioAtIndex_(index);
  10064. } else {
  10065. this.setSingleSelectionAtIndex_(index);
  10066. }
  10067. };
  10068. /**
  10069. * Focus in handler for the list items.
  10070. */
  10071. MDCListFoundation.prototype.handleFocusIn = function (_, listItemIndex) {
  10072. if (listItemIndex >= 0) {
  10073. this.focusedItemIndex = listItemIndex;
  10074. this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '0');
  10075. this.adapter.setTabIndexForListItemChildren(listItemIndex, '0');
  10076. }
  10077. };
  10078. /**
  10079. * Focus out handler for the list items.
  10080. */
  10081. MDCListFoundation.prototype.handleFocusOut = function (_, listItemIndex) {
  10082. var _this = this;
  10083. if (listItemIndex >= 0) {
  10084. this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '-1');
  10085. this.adapter.setTabIndexForListItemChildren(listItemIndex, '-1');
  10086. }
  10087. /**
  10088. * Between Focusout & Focusin some browsers do not have focus on any
  10089. * element. Setting a delay to wait till the focus is moved to next element.
  10090. */
  10091. setTimeout(function () {
  10092. if (!_this.adapter.isFocusInsideList()) {
  10093. _this.setTabindexToFirstSelectedOrFocusedItem();
  10094. }
  10095. }, 0);
  10096. };
  10097. /**
  10098. * Key handler for the list.
  10099. */
  10100. MDCListFoundation.prototype.handleKeydown = function (event, isRootListItem, listItemIndex) {
  10101. var _this = this;
  10102. var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
  10103. var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
  10104. var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
  10105. var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
  10106. var isHome = keyboard_1.normalizeKey(event) === 'Home';
  10107. var isEnd = keyboard_1.normalizeKey(event) === 'End';
  10108. var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
  10109. var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
  10110. // Have to check both upper and lower case, because having caps lock on affects the value.
  10111. var isLetterA = event.key === 'A' || event.key === 'a';
  10112. if (this.adapter.isRootFocused()) {
  10113. if (isArrowUp || isEnd) {
  10114. event.preventDefault();
  10115. this.focusLastElement();
  10116. } else if (isArrowDown || isHome) {
  10117. event.preventDefault();
  10118. this.focusFirstElement();
  10119. }
  10120. if (this.hasTypeahead) {
  10121. var handleKeydownOpts = {
  10122. event: event,
  10123. focusItemAtIndex: function focusItemAtIndex(index) {
  10124. _this.focusItemAtIndex(index);
  10125. },
  10126. focusedItemIndex: -1,
  10127. isTargetListItem: isRootListItem,
  10128. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  10129. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  10130. return _this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  10131. }
  10132. };
  10133. typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
  10134. }
  10135. return;
  10136. }
  10137. var currentIndex = this.adapter.getFocusedElementIndex();
  10138. if (currentIndex === -1) {
  10139. currentIndex = listItemIndex;
  10140. if (currentIndex < 0) {
  10141. // If this event doesn't have a mdc-list-item ancestor from the
  10142. // current list (not from a sublist), return early.
  10143. return;
  10144. }
  10145. }
  10146. if (this.isVertical_ && isArrowDown || !this.isVertical_ && isArrowRight) {
  10147. events_1.preventDefaultEvent(event);
  10148. this.focusNextElement(currentIndex);
  10149. } else if (this.isVertical_ && isArrowUp || !this.isVertical_ && isArrowLeft) {
  10150. events_1.preventDefaultEvent(event);
  10151. this.focusPrevElement(currentIndex);
  10152. } else if (isHome) {
  10153. events_1.preventDefaultEvent(event);
  10154. this.focusFirstElement();
  10155. } else if (isEnd) {
  10156. events_1.preventDefaultEvent(event);
  10157. this.focusLastElement();
  10158. } else if (isLetterA && event.ctrlKey && this.isCheckboxList_) {
  10159. event.preventDefault();
  10160. this.toggleAll(this.selectedIndex_ === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex_);
  10161. } else if (isEnter || isSpace) {
  10162. if (isRootListItem) {
  10163. // Return early if enter key is pressed on anchor element which triggers
  10164. // synthetic MouseEvent event.
  10165. var target = event.target;
  10166. if (target && target.tagName === 'A' && isEnter) {
  10167. return;
  10168. }
  10169. events_1.preventDefaultEvent(event);
  10170. if (this.adapter.listItemAtIndexHasClass(currentIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS)) {
  10171. return;
  10172. }
  10173. if (!this.isTypeaheadInProgress()) {
  10174. if (this.isSelectableList_()) {
  10175. this.setSelectedIndexOnAction_(currentIndex);
  10176. }
  10177. this.adapter.notifyAction(currentIndex);
  10178. }
  10179. }
  10180. }
  10181. if (this.hasTypeahead) {
  10182. var handleKeydownOpts = {
  10183. event: event,
  10184. focusItemAtIndex: function focusItemAtIndex(index) {
  10185. _this.focusItemAtIndex(index);
  10186. },
  10187. focusedItemIndex: this.focusedItemIndex,
  10188. isTargetListItem: isRootListItem,
  10189. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  10190. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  10191. return _this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  10192. }
  10193. };
  10194. typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
  10195. }
  10196. };
  10197. /**
  10198. * Click handler for the list.
  10199. */
  10200. MDCListFoundation.prototype.handleClick = function (index, toggleCheckbox) {
  10201. if (index === constants_1.numbers.UNSET_INDEX) {
  10202. return;
  10203. }
  10204. if (this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS)) {
  10205. return;
  10206. }
  10207. if (this.isSelectableList_()) {
  10208. this.setSelectedIndexOnAction_(index, toggleCheckbox);
  10209. }
  10210. this.adapter.notifyAction(index);
  10211. };
  10212. /**
  10213. * Focuses the next element on the list.
  10214. */
  10215. MDCListFoundation.prototype.focusNextElement = function (index) {
  10216. var count = this.adapter.getListItemCount();
  10217. var nextIndex = index + 1;
  10218. if (nextIndex >= count) {
  10219. if (this.wrapFocus_) {
  10220. nextIndex = 0;
  10221. } else {
  10222. // Return early because last item is already focused.
  10223. return index;
  10224. }
  10225. }
  10226. this.focusItemAtIndex(nextIndex);
  10227. return nextIndex;
  10228. };
  10229. /**
  10230. * Focuses the previous element on the list.
  10231. */
  10232. MDCListFoundation.prototype.focusPrevElement = function (index) {
  10233. var prevIndex = index - 1;
  10234. if (prevIndex < 0) {
  10235. if (this.wrapFocus_) {
  10236. prevIndex = this.adapter.getListItemCount() - 1;
  10237. } else {
  10238. // Return early because first item is already focused.
  10239. return index;
  10240. }
  10241. }
  10242. this.focusItemAtIndex(prevIndex);
  10243. return prevIndex;
  10244. };
  10245. MDCListFoundation.prototype.focusFirstElement = function () {
  10246. this.focusItemAtIndex(0);
  10247. return 0;
  10248. };
  10249. MDCListFoundation.prototype.focusLastElement = function () {
  10250. var lastIndex = this.adapter.getListItemCount() - 1;
  10251. this.focusItemAtIndex(lastIndex);
  10252. return lastIndex;
  10253. };
  10254. MDCListFoundation.prototype.focusInitialElement = function () {
  10255. var initialIndex = this.getFirstSelectedOrFocusedItemIndex();
  10256. this.focusItemAtIndex(initialIndex);
  10257. return initialIndex;
  10258. };
  10259. /**
  10260. * @param itemIndex Index of the list item
  10261. * @param isEnabled Sets the list item to enabled or disabled.
  10262. */
  10263. MDCListFoundation.prototype.setEnabled = function (itemIndex, isEnabled) {
  10264. if (!this.isIndexValid_(itemIndex)) {
  10265. return;
  10266. }
  10267. if (isEnabled) {
  10268. this.adapter.removeClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  10269. this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'false');
  10270. } else {
  10271. this.adapter.addClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  10272. this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'true');
  10273. }
  10274. };
  10275. MDCListFoundation.prototype.setSingleSelectionAtIndex_ = function (index) {
  10276. if (this.selectedIndex_ === index) {
  10277. return;
  10278. }
  10279. var selectedClassName = constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS;
  10280. if (this.useActivatedClass_) {
  10281. selectedClassName = constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS;
  10282. }
  10283. if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
  10284. this.adapter.removeClassForElementIndex(this.selectedIndex_, selectedClassName);
  10285. }
  10286. this.setAriaForSingleSelectionAtIndex_(index);
  10287. this.setTabindexAtIndex(index);
  10288. if (index !== constants_1.numbers.UNSET_INDEX) {
  10289. this.adapter.addClassForElementIndex(index, selectedClassName);
  10290. }
  10291. this.selectedIndex_ = index;
  10292. };
  10293. /**
  10294. * Sets aria attribute for single selection at given index.
  10295. */
  10296. MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex_ = function (index) {
  10297. // Detect the presence of aria-current and get the value only during list
  10298. // initialization when it is in unset state.
  10299. if (this.selectedIndex_ === constants_1.numbers.UNSET_INDEX) {
  10300. this.ariaCurrentAttrValue_ = this.adapter.getAttributeForElementIndex(index, constants_1.strings.ARIA_CURRENT);
  10301. }
  10302. var isAriaCurrent = this.ariaCurrentAttrValue_ !== null;
  10303. var ariaAttribute = isAriaCurrent ? constants_1.strings.ARIA_CURRENT : constants_1.strings.ARIA_SELECTED;
  10304. if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
  10305. this.adapter.setAttributeForElementIndex(this.selectedIndex_, ariaAttribute, 'false');
  10306. }
  10307. if (index !== constants_1.numbers.UNSET_INDEX) {
  10308. var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue_ : 'true';
  10309. this.adapter.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
  10310. }
  10311. };
  10312. /**
  10313. * Returns the attribute to use for indicating selection status.
  10314. */
  10315. MDCListFoundation.prototype.getSelectionAttribute = function () {
  10316. return this.useSelectedAttr_ ? constants_1.strings.ARIA_SELECTED : constants_1.strings.ARIA_CHECKED;
  10317. };
  10318. /**
  10319. * Toggles radio at give index. Radio doesn't change the checked state if it
  10320. * is already checked.
  10321. */
  10322. MDCListFoundation.prototype.setRadioAtIndex_ = function (index) {
  10323. var selectionAttribute = this.getSelectionAttribute();
  10324. this.adapter.setCheckedCheckboxOrRadioAtIndex(index, true);
  10325. if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
  10326. this.adapter.setAttributeForElementIndex(this.selectedIndex_, selectionAttribute, 'false');
  10327. }
  10328. this.adapter.setAttributeForElementIndex(index, selectionAttribute, 'true');
  10329. this.selectedIndex_ = index;
  10330. };
  10331. MDCListFoundation.prototype.setCheckboxAtIndex_ = function (index) {
  10332. var selectionAttribute = this.getSelectionAttribute();
  10333. for (var i = 0; i < this.adapter.getListItemCount(); i++) {
  10334. var isChecked = false;
  10335. if (index.indexOf(i) >= 0) {
  10336. isChecked = true;
  10337. }
  10338. this.adapter.setCheckedCheckboxOrRadioAtIndex(i, isChecked);
  10339. this.adapter.setAttributeForElementIndex(i, selectionAttribute, isChecked ? 'true' : 'false');
  10340. }
  10341. this.selectedIndex_ = index;
  10342. };
  10343. MDCListFoundation.prototype.setTabindexAtIndex = function (index) {
  10344. if (this.focusedItemIndex === constants_1.numbers.UNSET_INDEX && index !== 0) {
  10345. // If some list item was selected set first list item's tabindex to -1.
  10346. // Generally, tabindex is set to 0 on first list item of list that has no
  10347. // preselected items.
  10348. this.adapter.setAttributeForElementIndex(0, 'tabindex', '-1');
  10349. } else if (this.focusedItemIndex >= 0 && this.focusedItemIndex !== index) {
  10350. this.adapter.setAttributeForElementIndex(this.focusedItemIndex, 'tabindex', '-1');
  10351. }
  10352. // Set the previous selection's tabindex to -1. We need this because
  10353. // in selection menus that are not visible, programmatically setting an
  10354. // option will not change focus but will change where tabindex should be 0.
  10355. if (!(this.selectedIndex_ instanceof Array) && this.selectedIndex_ !== index) {
  10356. this.adapter.setAttributeForElementIndex(this.selectedIndex_, 'tabindex', '-1');
  10357. }
  10358. if (index !== constants_1.numbers.UNSET_INDEX) {
  10359. this.adapter.setAttributeForElementIndex(index, 'tabindex', '0');
  10360. }
  10361. };
  10362. /**
  10363. * @return Return true if it is single selectin list, checkbox list or radio
  10364. * list.
  10365. */
  10366. MDCListFoundation.prototype.isSelectableList_ = function () {
  10367. return this.isSingleSelectionList_ || this.isCheckboxList_ || this.isRadioList_;
  10368. };
  10369. MDCListFoundation.prototype.setTabindexToFirstSelectedOrFocusedItem = function () {
  10370. var targetIndex = this.getFirstSelectedOrFocusedItemIndex();
  10371. this.setTabindexAtIndex(targetIndex);
  10372. };
  10373. MDCListFoundation.prototype.getFirstSelectedOrFocusedItemIndex = function () {
  10374. var targetIndex = this.focusedItemIndex >= 0 ? this.focusedItemIndex : 0;
  10375. if (this.isSelectableList_()) {
  10376. if (typeof this.selectedIndex_ === 'number' && this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
  10377. targetIndex = this.selectedIndex_;
  10378. } else if (isNumberArray(this.selectedIndex_) && this.selectedIndex_.length > 0) {
  10379. targetIndex = this.selectedIndex_.reduce(function (currentIndex, minIndex) {
  10380. return Math.min(currentIndex, minIndex);
  10381. });
  10382. }
  10383. }
  10384. return targetIndex;
  10385. };
  10386. MDCListFoundation.prototype.isIndexValid_ = function (index) {
  10387. var _this = this;
  10388. if (index instanceof Array) {
  10389. if (!this.isCheckboxList_) {
  10390. throw new Error('MDCListFoundation: Array of index is only supported for checkbox based list');
  10391. }
  10392. if (index.length === 0) {
  10393. return true;
  10394. } else {
  10395. return index.some(function (i) {
  10396. return _this.isIndexInRange_(i);
  10397. });
  10398. }
  10399. } else if (typeof index === 'number') {
  10400. if (this.isCheckboxList_) {
  10401. throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: " + index);
  10402. }
  10403. return this.isIndexInRange_(index) || this.isSingleSelectionList_ && index === constants_1.numbers.UNSET_INDEX;
  10404. } else {
  10405. return false;
  10406. }
  10407. };
  10408. MDCListFoundation.prototype.isIndexInRange_ = function (index) {
  10409. var listSize = this.adapter.getListItemCount();
  10410. return index >= 0 && index < listSize;
  10411. };
  10412. /**
  10413. * Sets selected index on user action, toggles checkbox / radio based on
  10414. * toggleCheckbox value. User interaction should not toggle list item(s) when
  10415. * disabled.
  10416. */
  10417. MDCListFoundation.prototype.setSelectedIndexOnAction_ = function (index, toggleCheckbox) {
  10418. if (toggleCheckbox === void 0) {
  10419. toggleCheckbox = true;
  10420. }
  10421. if (this.isCheckboxList_) {
  10422. this.toggleCheckboxAtIndex_(index, toggleCheckbox);
  10423. } else {
  10424. this.setSelectedIndex(index);
  10425. }
  10426. };
  10427. MDCListFoundation.prototype.toggleCheckboxAtIndex_ = function (index, toggleCheckbox) {
  10428. var selectionAttribute = this.getSelectionAttribute();
  10429. var isChecked = this.adapter.isCheckboxCheckedAtIndex(index);
  10430. if (toggleCheckbox) {
  10431. isChecked = !isChecked;
  10432. this.adapter.setCheckedCheckboxOrRadioAtIndex(index, isChecked);
  10433. }
  10434. this.adapter.setAttributeForElementIndex(index, selectionAttribute, isChecked ? 'true' : 'false');
  10435. // If none of the checkbox items are selected and selectedIndex is not
  10436. // initialized then provide a default value.
  10437. var selectedIndexes = this.selectedIndex_ === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex_.slice();
  10438. if (isChecked) {
  10439. selectedIndexes.push(index);
  10440. } else {
  10441. selectedIndexes = selectedIndexes.filter(function (i) {
  10442. return i !== index;
  10443. });
  10444. }
  10445. this.selectedIndex_ = selectedIndexes;
  10446. };
  10447. MDCListFoundation.prototype.focusItemAtIndex = function (index) {
  10448. this.adapter.focusItemAtIndex(index);
  10449. this.focusedItemIndex = index;
  10450. };
  10451. MDCListFoundation.prototype.toggleAll = function (currentlySelectedIndexes) {
  10452. var count = this.adapter.getListItemCount();
  10453. // If all items are selected, deselect everything.
  10454. if (currentlySelectedIndexes.length === count) {
  10455. this.setCheckboxAtIndex_([]);
  10456. } else {
  10457. // Otherwise select all enabled options.
  10458. var allIndexes = [];
  10459. for (var i = 0; i < count; i++) {
  10460. if (!this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS) || currentlySelectedIndexes.indexOf(i) > -1) {
  10461. allIndexes.push(i);
  10462. }
  10463. }
  10464. this.setCheckboxAtIndex_(allIndexes);
  10465. }
  10466. };
  10467. /**
  10468. * Given the next desired character from the user, adds it to the typeahead
  10469. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  10470. * around if at the end of options.
  10471. *
  10472. * @param nextChar The next character to add to the prefix buffer.
  10473. * @param startingIndex The index from which to start matching. Only relevant
  10474. * when starting a new match sequence. To start a new match sequence,
  10475. * clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
  10476. * to clear after a set interval defined in list foundation. Defaults to
  10477. * the currently focused index.
  10478. * @return The index of the matched item, or -1 if no match.
  10479. */
  10480. MDCListFoundation.prototype.typeaheadMatchItem = function (nextChar, startingIndex, skipFocus) {
  10481. var _this = this;
  10482. if (skipFocus === void 0) {
  10483. skipFocus = false;
  10484. }
  10485. var opts = {
  10486. focusItemAtIndex: function focusItemAtIndex(index) {
  10487. _this.focusItemAtIndex(index);
  10488. },
  10489. focusedItemIndex: startingIndex ? startingIndex : this.focusedItemIndex,
  10490. nextChar: nextChar,
  10491. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  10492. skipFocus: skipFocus,
  10493. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  10494. return _this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  10495. }
  10496. };
  10497. return typeahead.matchItem(opts, this.typeaheadState);
  10498. };
  10499. /**
  10500. * Initializes the MDCListTextAndIndex data structure by indexing the current
  10501. * list items by primary text.
  10502. *
  10503. * @return The primary texts of all the list items sorted by first character.
  10504. */
  10505. MDCListFoundation.prototype.typeaheadInitSortedIndex = function () {
  10506. return typeahead.initSortedIndex(this.adapter.getListItemCount(), this.adapter.getPrimaryTextAtIndex);
  10507. };
  10508. /**
  10509. * Clears the typeahead buffer.
  10510. */
  10511. MDCListFoundation.prototype.clearTypeaheadBuffer = function () {
  10512. typeahead.clearBuffer(this.typeaheadState);
  10513. };
  10514. return MDCListFoundation;
  10515. }(foundation_1.MDCFoundation);
  10516. exports.MDCListFoundation = MDCListFoundation;
  10517. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  10518. exports.default = MDCListFoundation;
  10519. /***/ }),
  10520. /***/ "./packages/mdc-list/index.ts":
  10521. /*!************************************!*\
  10522. !*** ./packages/mdc-list/index.ts ***!
  10523. \************************************/
  10524. /*! no static exports found */
  10525. /***/ (function(module, exports, __webpack_require__) {
  10526. "use strict";
  10527. /**
  10528. * @license
  10529. * Copyright 2019 Google Inc.
  10530. *
  10531. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10532. * of this software and associated documentation files (the "Software"), to deal
  10533. * in the Software without restriction, including without limitation the rights
  10534. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10535. * copies of the Software, and to permit persons to whom the Software is
  10536. * furnished to do so, subject to the following conditions:
  10537. *
  10538. * The above copyright notice and this permission notice shall be included in
  10539. * all copies or substantial portions of the Software.
  10540. *
  10541. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10542. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10543. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10544. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10545. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10546. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  10547. * THE SOFTWARE.
  10548. */
  10549. function __export(m) {
  10550. for (var p in m) {
  10551. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  10552. }
  10553. }
  10554. Object.defineProperty(exports, "__esModule", { value: true });
  10555. __export(__webpack_require__(/*! ./component */ "./packages/mdc-list/component.ts"));
  10556. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts"));
  10557. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-list/foundation.ts"));
  10558. /***/ }),
  10559. /***/ "./packages/mdc-list/typeahead.ts":
  10560. /*!****************************************!*\
  10561. !*** ./packages/mdc-list/typeahead.ts ***!
  10562. \****************************************/
  10563. /*! no static exports found */
  10564. /***/ (function(module, exports, __webpack_require__) {
  10565. "use strict";
  10566. /**
  10567. * @license
  10568. * Copyright 2020 Google Inc.
  10569. *
  10570. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10571. * of this software and associated documentation files (the "Software"), to deal
  10572. * in the Software without restriction, including without limitation the rights
  10573. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10574. * copies of the Software, and to permit persons to whom the Software is
  10575. * furnished to do so, subject to the following conditions:
  10576. *
  10577. * The above copyright notice and this permission notice shall be included in
  10578. * all copies or substantial portions of the Software.
  10579. *
  10580. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10581. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10582. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10583. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10584. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10585. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  10586. * THE SOFTWARE.
  10587. */
  10588. Object.defineProperty(exports, "__esModule", { value: true });
  10589. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  10590. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  10591. var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
  10592. /**
  10593. * Initializes a state object for typeahead. Use the same reference for calls to
  10594. * typeahead functions.
  10595. *
  10596. * @return The current state of the typeahead process. Each state reference
  10597. * represents a typeahead instance as the reference is typically mutated
  10598. * in-place.
  10599. */
  10600. function initState() {
  10601. var state = {
  10602. bufferClearTimeout: 0,
  10603. currentFirstChar: '',
  10604. sortedIndexCursor: 0,
  10605. typeaheadBuffer: ''
  10606. };
  10607. return state;
  10608. }
  10609. exports.initState = initState;
  10610. /**
  10611. * Initializes typeahead state by indexing the current list items by primary
  10612. * text into the sortedIndexByFirstChar data structure.
  10613. *
  10614. * @param listItemCount numer of items in the list
  10615. * @param getPrimaryTextByItemIndex function that returns the primary text at a
  10616. * given index
  10617. *
  10618. * @return Map that maps the first character of the primary text to the full
  10619. * list text and it's index
  10620. */
  10621. function initSortedIndex(listItemCount, getPrimaryTextByItemIndex) {
  10622. var sortedIndexByFirstChar = new Map();
  10623. // Aggregate item text to index mapping
  10624. for (var i = 0; i < listItemCount; i++) {
  10625. var primaryText = getPrimaryTextByItemIndex(i).trim();
  10626. if (!primaryText) {
  10627. continue;
  10628. }
  10629. var firstChar = primaryText[0].toLowerCase();
  10630. if (!sortedIndexByFirstChar.has(firstChar)) {
  10631. sortedIndexByFirstChar.set(firstChar, []);
  10632. }
  10633. sortedIndexByFirstChar.get(firstChar).push({ text: primaryText.toLowerCase(), index: i });
  10634. }
  10635. // Sort the mapping
  10636. // TODO(b/157162694): Investigate replacing forEach with Map.values()
  10637. sortedIndexByFirstChar.forEach(function (values) {
  10638. values.sort(function (first, second) {
  10639. return first.index - second.index;
  10640. });
  10641. });
  10642. return sortedIndexByFirstChar;
  10643. }
  10644. exports.initSortedIndex = initSortedIndex;
  10645. /**
  10646. * Given the next desired character from the user, it attempts to find the next
  10647. * list option matching the buffer. Wraps around if at the end of options.
  10648. *
  10649. * @param opts Options and accessors
  10650. * - nextChar - the next character to match against items
  10651. * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
  10652. * - focusedItemIndex - the index of the currently focused item
  10653. * - focusItemAtIndex - function that focuses a list item at given index
  10654. * - skipFocus - whether or not to focus the matched item
  10655. * - isItemAtIndexDisabled - function that determines whether an item at a
  10656. * given index is disabled
  10657. * @param state The typeahead state instance. See `initState`.
  10658. *
  10659. * @return The index of the matched item, or -1 if no match.
  10660. */
  10661. function matchItem(opts, state) {
  10662. var nextChar = opts.nextChar,
  10663. focusItemAtIndex = opts.focusItemAtIndex,
  10664. sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
  10665. focusedItemIndex = opts.focusedItemIndex,
  10666. skipFocus = opts.skipFocus,
  10667. isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
  10668. clearTimeout(state.bufferClearTimeout);
  10669. state.bufferClearTimeout = setTimeout(function () {
  10670. clearBuffer(state);
  10671. }, constants_1.numbers.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS);
  10672. state.typeaheadBuffer = state.typeaheadBuffer + nextChar;
  10673. var index;
  10674. if (state.typeaheadBuffer.length === 1) {
  10675. index = matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state);
  10676. } else {
  10677. index = matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state);
  10678. }
  10679. if (index !== -1 && !skipFocus) {
  10680. focusItemAtIndex(index);
  10681. }
  10682. return index;
  10683. }
  10684. exports.matchItem = matchItem;
  10685. /**
  10686. * Matches the user's single input character in the buffer to the
  10687. * next option that begins with such character. Wraps around if at
  10688. * end of options. Returns -1 if no match is found.
  10689. */
  10690. function matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state) {
  10691. var firstChar = state.typeaheadBuffer[0];
  10692. var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
  10693. if (!itemsMatchingFirstChar) {
  10694. return -1;
  10695. }
  10696. // Has the same firstChar been recently matched?
  10697. // Also, did starting index remain the same between key presses?
  10698. // If both hold true, simply increment index.
  10699. if (firstChar === state.currentFirstChar && itemsMatchingFirstChar[state.sortedIndexCursor].index === focusedItemIndex) {
  10700. state.sortedIndexCursor = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
  10701. var newIndex = itemsMatchingFirstChar[state.sortedIndexCursor].index;
  10702. if (!isItemAtIndexDisabled(newIndex)) {
  10703. return newIndex;
  10704. }
  10705. }
  10706. // If we're here, it means one of the following happened:
  10707. // - either firstChar or startingIndex has changed, invalidating the
  10708. // cursor.
  10709. // - The next item of typeahead is disabled, so we have to look further.
  10710. state.currentFirstChar = firstChar;
  10711. var newCursorPosition = -1;
  10712. var cursorPosition;
  10713. // Find the first non-disabled item as a fallback.
  10714. for (cursorPosition = 0; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
  10715. if (!isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
  10716. newCursorPosition = cursorPosition;
  10717. break;
  10718. }
  10719. }
  10720. // Advance cursor to first item matching the firstChar that is positioned
  10721. // after starting item. Cursor is unchanged from fallback if there's no
  10722. // such item.
  10723. for (; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
  10724. if (itemsMatchingFirstChar[cursorPosition].index > focusedItemIndex && !isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
  10725. newCursorPosition = cursorPosition;
  10726. break;
  10727. }
  10728. }
  10729. if (newCursorPosition !== -1) {
  10730. state.sortedIndexCursor = newCursorPosition;
  10731. return itemsMatchingFirstChar[state.sortedIndexCursor].index;
  10732. }
  10733. return -1;
  10734. }
  10735. /**
  10736. * Attempts to find the next item that matches all of the typeahead buffer.
  10737. * Wraps around if at end of options. Returns -1 if no match is found.
  10738. */
  10739. function matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state) {
  10740. var firstChar = state.typeaheadBuffer[0];
  10741. var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
  10742. if (!itemsMatchingFirstChar) {
  10743. return -1;
  10744. }
  10745. // Do nothing if text already matches
  10746. var startingItem = itemsMatchingFirstChar[state.sortedIndexCursor];
  10747. if (startingItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0 && !isItemAtIndexDisabled(startingItem.index)) {
  10748. return startingItem.index;
  10749. }
  10750. // Find next item that matches completely; if no match, we'll eventually
  10751. // loop around to same position
  10752. var cursorPosition = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
  10753. var nextCursorPosition = -1;
  10754. while (cursorPosition !== state.sortedIndexCursor) {
  10755. var currentItem = itemsMatchingFirstChar[cursorPosition];
  10756. var matches = currentItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0;
  10757. var isEnabled = !isItemAtIndexDisabled(currentItem.index);
  10758. if (matches && isEnabled) {
  10759. nextCursorPosition = cursorPosition;
  10760. break;
  10761. }
  10762. cursorPosition = (cursorPosition + 1) % itemsMatchingFirstChar.length;
  10763. }
  10764. if (nextCursorPosition !== -1) {
  10765. state.sortedIndexCursor = nextCursorPosition;
  10766. return itemsMatchingFirstChar[state.sortedIndexCursor].index;
  10767. }
  10768. return -1;
  10769. }
  10770. /**
  10771. * Whether or not the given typeahead instaance state is currently typing.
  10772. *
  10773. * @param state The typeahead state instance. See `initState`.
  10774. */
  10775. function isTypingInProgress(state) {
  10776. return state.typeaheadBuffer.length > 0;
  10777. }
  10778. exports.isTypingInProgress = isTypingInProgress;
  10779. /**
  10780. * Clears the typeahaed buffer so that it resets item matching to the first
  10781. * character.
  10782. *
  10783. * @param state The typeahead state instance. See `initState`.
  10784. */
  10785. function clearBuffer(state) {
  10786. state.typeaheadBuffer = '';
  10787. }
  10788. exports.clearBuffer = clearBuffer;
  10789. /**
  10790. * Given a keydown event, it calculates whether or not to automatically focus a
  10791. * list item depending on what was typed mimicing the typeahead functionality of
  10792. * a standard <select> element that is open.
  10793. *
  10794. * @param opts Options and accessors
  10795. * - event - the KeyboardEvent to handle and parse
  10796. * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
  10797. * - focusedItemIndex - the index of the currently focused item
  10798. * - focusItemAtIndex - function that focuses a list item at given index
  10799. * - isItemAtFocusedIndexDisabled - whether or not the currently focused item
  10800. * is disabled
  10801. * - isTargetListItem - whether or not the event target is a list item
  10802. * @param state The typeahead state instance. See `initState`.
  10803. *
  10804. * @returns index of the item matched by the keydown. -1 if not matched.
  10805. */
  10806. function handleKeydown(opts, state) {
  10807. var event = opts.event,
  10808. isTargetListItem = opts.isTargetListItem,
  10809. focusedItemIndex = opts.focusedItemIndex,
  10810. focusItemAtIndex = opts.focusItemAtIndex,
  10811. sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
  10812. isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
  10813. var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
  10814. var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
  10815. var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
  10816. var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
  10817. var isHome = keyboard_1.normalizeKey(event) === 'Home';
  10818. var isEnd = keyboard_1.normalizeKey(event) === 'End';
  10819. var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
  10820. var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
  10821. if (isArrowLeft || isArrowUp || isArrowRight || isArrowDown || isHome || isEnd || isEnter) {
  10822. return -1;
  10823. }
  10824. var isCharacterKey = !isSpace && event.key.length === 1;
  10825. if (isCharacterKey) {
  10826. events_1.preventDefaultEvent(event);
  10827. var matchItemOpts = {
  10828. focusItemAtIndex: focusItemAtIndex,
  10829. focusedItemIndex: focusedItemIndex,
  10830. nextChar: event.key.toLowerCase(),
  10831. sortedIndexByFirstChar: sortedIndexByFirstChar,
  10832. skipFocus: false,
  10833. isItemAtIndexDisabled: isItemAtIndexDisabled
  10834. };
  10835. return matchItem(matchItemOpts, state);
  10836. }
  10837. if (!isSpace) {
  10838. return -1;
  10839. }
  10840. if (isTargetListItem) {
  10841. events_1.preventDefaultEvent(event);
  10842. }
  10843. var typeaheadOnListItem = isTargetListItem && isTypingInProgress(state);
  10844. if (typeaheadOnListItem) {
  10845. var matchItemOpts = {
  10846. focusItemAtIndex: focusItemAtIndex,
  10847. focusedItemIndex: focusedItemIndex,
  10848. nextChar: ' ',
  10849. sortedIndexByFirstChar: sortedIndexByFirstChar,
  10850. skipFocus: false,
  10851. isItemAtIndexDisabled: isItemAtIndexDisabled
  10852. };
  10853. // space participates in typeahead matching if in rapid typing mode
  10854. return matchItem(matchItemOpts, state);
  10855. }
  10856. return -1;
  10857. }
  10858. exports.handleKeydown = handleKeydown;
  10859. /***/ }),
  10860. /***/ "./packages/mdc-menu-surface/component.ts":
  10861. /*!************************************************!*\
  10862. !*** ./packages/mdc-menu-surface/component.ts ***!
  10863. \************************************************/
  10864. /*! no static exports found */
  10865. /***/ (function(module, exports, __webpack_require__) {
  10866. "use strict";
  10867. /**
  10868. * @license
  10869. * Copyright 2018 Google Inc.
  10870. *
  10871. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10872. * of this software and associated documentation files (the "Software"), to deal
  10873. * in the Software without restriction, including without limitation the rights
  10874. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10875. * copies of the Software, and to permit persons to whom the Software is
  10876. * furnished to do so, subject to the following conditions:
  10877. *
  10878. * The above copyright notice and this permission notice shall be included in
  10879. * all copies or substantial portions of the Software.
  10880. *
  10881. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10882. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10883. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10884. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10885. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10886. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  10887. * THE SOFTWARE.
  10888. */
  10889. var __extends = this && this.__extends || function () {
  10890. var _extendStatics = function extendStatics(d, b) {
  10891. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  10892. d.__proto__ = b;
  10893. } || function (d, b) {
  10894. for (var p in b) {
  10895. if (b.hasOwnProperty(p)) d[p] = b[p];
  10896. }
  10897. };
  10898. return _extendStatics(d, b);
  10899. };
  10900. return function (d, b) {
  10901. _extendStatics(d, b);
  10902. function __() {
  10903. this.constructor = d;
  10904. }
  10905. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10906. };
  10907. }();
  10908. var __importStar = this && this.__importStar || function (mod) {
  10909. if (mod && mod.__esModule) return mod;
  10910. var result = {};
  10911. if (mod != null) for (var k in mod) {
  10912. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  10913. }result["default"] = mod;
  10914. return result;
  10915. };
  10916. Object.defineProperty(exports, "__esModule", { value: true });
  10917. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  10918. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
  10919. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu-surface/foundation.ts");
  10920. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-menu-surface/util.ts"));
  10921. var MDCMenuSurface = /** @class */function (_super) {
  10922. __extends(MDCMenuSurface, _super);
  10923. function MDCMenuSurface() {
  10924. return _super !== null && _super.apply(this, arguments) || this;
  10925. }
  10926. MDCMenuSurface.attachTo = function (root) {
  10927. return new MDCMenuSurface(root);
  10928. };
  10929. MDCMenuSurface.prototype.initialSyncWithDOM = function () {
  10930. var _this = this;
  10931. var parentEl = this.root.parentElement;
  10932. this.anchorElement = parentEl && parentEl.classList.contains(constants_1.cssClasses.ANCHOR) ? parentEl : null;
  10933. if (this.root.classList.contains(constants_1.cssClasses.FIXED)) {
  10934. this.setFixedPosition(true);
  10935. }
  10936. this.handleKeydown = function (event) {
  10937. _this.foundation.handleKeydown(event);
  10938. };
  10939. this.handleBodyClick = function (event) {
  10940. _this.foundation.handleBodyClick(event);
  10941. };
  10942. // capture so that no race between handleBodyClick and quickOpen when
  10943. // menusurface opened on button click which registers this listener
  10944. this.registerBodyClickListener = function () {
  10945. document.body.addEventListener('click', _this.handleBodyClick, { capture: true });
  10946. };
  10947. this.deregisterBodyClickListener = function () {
  10948. document.body.removeEventListener('click', _this.handleBodyClick, { capture: true });
  10949. };
  10950. this.listen('keydown', this.handleKeydown);
  10951. this.listen(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
  10952. this.listen(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
  10953. };
  10954. MDCMenuSurface.prototype.destroy = function () {
  10955. this.unlisten('keydown', this.handleKeydown);
  10956. this.unlisten(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
  10957. this.unlisten(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
  10958. _super.prototype.destroy.call(this);
  10959. };
  10960. MDCMenuSurface.prototype.isOpen = function () {
  10961. return this.foundation.isOpen();
  10962. };
  10963. MDCMenuSurface.prototype.open = function () {
  10964. this.foundation.open();
  10965. };
  10966. MDCMenuSurface.prototype.close = function (skipRestoreFocus) {
  10967. if (skipRestoreFocus === void 0) {
  10968. skipRestoreFocus = false;
  10969. }
  10970. this.foundation.close(skipRestoreFocus);
  10971. };
  10972. Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", {
  10973. set: function set(quickOpen) {
  10974. this.foundation.setQuickOpen(quickOpen);
  10975. },
  10976. enumerable: true,
  10977. configurable: true
  10978. });
  10979. /** Sets the foundation to use page offsets for an positioning when the menu is hoisted to the body. */
  10980. MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) {
  10981. this.foundation.setIsHoisted(isHoisted);
  10982. };
  10983. /** Sets the element that the menu-surface is anchored to. */
  10984. MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) {
  10985. this.anchorElement = element;
  10986. };
  10987. /** Sets the menu-surface to position: fixed. */
  10988. MDCMenuSurface.prototype.setFixedPosition = function (isFixed) {
  10989. if (isFixed) {
  10990. this.root.classList.add(constants_1.cssClasses.FIXED);
  10991. } else {
  10992. this.root.classList.remove(constants_1.cssClasses.FIXED);
  10993. }
  10994. this.foundation.setFixedPosition(isFixed);
  10995. };
  10996. /** Sets the absolute x/y position to position based on. Requires the menu to be hoisted. */
  10997. MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) {
  10998. this.foundation.setAbsolutePosition(x, y);
  10999. this.setIsHoisted(true);
  11000. };
  11001. /**
  11002. * @param corner Default anchor corner alignment of top-left surface corner.
  11003. */
  11004. MDCMenuSurface.prototype.setAnchorCorner = function (corner) {
  11005. this.foundation.setAnchorCorner(corner);
  11006. };
  11007. MDCMenuSurface.prototype.setAnchorMargin = function (margin) {
  11008. this.foundation.setAnchorMargin(margin);
  11009. };
  11010. MDCMenuSurface.prototype.getDefaultFoundation = function () {
  11011. var _this = this;
  11012. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  11013. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  11014. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  11015. var adapter = {
  11016. addClass: function addClass(className) {
  11017. return _this.root.classList.add(className);
  11018. },
  11019. removeClass: function removeClass(className) {
  11020. return _this.root.classList.remove(className);
  11021. },
  11022. hasClass: function hasClass(className) {
  11023. return _this.root.classList.contains(className);
  11024. },
  11025. hasAnchor: function hasAnchor() {
  11026. return !!_this.anchorElement;
  11027. },
  11028. notifyClose: function notifyClose() {
  11029. return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {});
  11030. },
  11031. notifyOpen: function notifyOpen() {
  11032. return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {});
  11033. },
  11034. isElementInContainer: function isElementInContainer(el) {
  11035. return _this.root.contains(el);
  11036. },
  11037. isRtl: function isRtl() {
  11038. return getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
  11039. },
  11040. setTransformOrigin: function setTransformOrigin(origin) {
  11041. var propertyName = util.getTransformPropertyName(window) + "-origin";
  11042. _this.root.style.setProperty(propertyName, origin);
  11043. },
  11044. isFocused: function isFocused() {
  11045. return document.activeElement === _this.root;
  11046. },
  11047. saveFocus: function saveFocus() {
  11048. _this.previousFocus = document.activeElement;
  11049. },
  11050. restoreFocus: function restoreFocus() {
  11051. if (_this.root.contains(document.activeElement)) {
  11052. if (_this.previousFocus && _this.previousFocus.focus) {
  11053. _this.previousFocus.focus();
  11054. }
  11055. }
  11056. },
  11057. getInnerDimensions: function getInnerDimensions() {
  11058. return {
  11059. width: _this.root.offsetWidth,
  11060. height: _this.root.offsetHeight
  11061. };
  11062. },
  11063. getAnchorDimensions: function getAnchorDimensions() {
  11064. return _this.anchorElement ? _this.anchorElement.getBoundingClientRect() : null;
  11065. },
  11066. getWindowDimensions: function getWindowDimensions() {
  11067. return { width: window.innerWidth, height: window.innerHeight };
  11068. },
  11069. getBodyDimensions: function getBodyDimensions() {
  11070. return { width: document.body.clientWidth, height: document.body.clientHeight };
  11071. },
  11072. getWindowScroll: function getWindowScroll() {
  11073. return { x: window.pageXOffset, y: window.pageYOffset };
  11074. },
  11075. setPosition: function setPosition(position) {
  11076. var rootHTML = _this.root;
  11077. rootHTML.style.left = 'left' in position ? position.left + "px" : '';
  11078. rootHTML.style.right = 'right' in position ? position.right + "px" : '';
  11079. rootHTML.style.top = 'top' in position ? position.top + "px" : '';
  11080. rootHTML.style.bottom = 'bottom' in position ? position.bottom + "px" : '';
  11081. },
  11082. setMaxHeight: function setMaxHeight(height) {
  11083. _this.root.style.maxHeight = height;
  11084. }
  11085. };
  11086. // tslint:enable:object-literal-sort-keys
  11087. return new foundation_1.MDCMenuSurfaceFoundation(adapter);
  11088. };
  11089. return MDCMenuSurface;
  11090. }(component_1.MDCComponent);
  11091. exports.MDCMenuSurface = MDCMenuSurface;
  11092. /***/ }),
  11093. /***/ "./packages/mdc-menu-surface/constants.ts":
  11094. /*!************************************************!*\
  11095. !*** ./packages/mdc-menu-surface/constants.ts ***!
  11096. \************************************************/
  11097. /*! no static exports found */
  11098. /***/ (function(module, exports, __webpack_require__) {
  11099. "use strict";
  11100. /**
  11101. * @license
  11102. * Copyright 2018 Google Inc.
  11103. *
  11104. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11105. * of this software and associated documentation files (the "Software"), to deal
  11106. * in the Software without restriction, including without limitation the rights
  11107. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11108. * copies of the Software, and to permit persons to whom the Software is
  11109. * furnished to do so, subject to the following conditions:
  11110. *
  11111. * The above copyright notice and this permission notice shall be included in
  11112. * all copies or substantial portions of the Software.
  11113. *
  11114. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11115. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11116. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11117. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11118. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11119. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11120. * THE SOFTWARE.
  11121. */
  11122. Object.defineProperty(exports, "__esModule", { value: true });
  11123. var cssClasses = {
  11124. ANCHOR: 'mdc-menu-surface--anchor',
  11125. ANIMATING_CLOSED: 'mdc-menu-surface--animating-closed',
  11126. ANIMATING_OPEN: 'mdc-menu-surface--animating-open',
  11127. FIXED: 'mdc-menu-surface--fixed',
  11128. IS_OPEN_BELOW: 'mdc-menu-surface--is-open-below',
  11129. OPEN: 'mdc-menu-surface--open',
  11130. ROOT: 'mdc-menu-surface'
  11131. };
  11132. exports.cssClasses = cssClasses;
  11133. // tslint:disable:object-literal-sort-keys
  11134. var strings = {
  11135. CLOSED_EVENT: 'MDCMenuSurface:closed',
  11136. OPENED_EVENT: 'MDCMenuSurface:opened',
  11137. 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(', ')
  11138. };
  11139. exports.strings = strings;
  11140. // tslint:enable:object-literal-sort-keys
  11141. var numbers = {
  11142. /** Total duration of menu-surface open animation. */
  11143. TRANSITION_OPEN_DURATION: 120,
  11144. /** Total duration of menu-surface close animation. */
  11145. TRANSITION_CLOSE_DURATION: 75,
  11146. /** Margin left to the edge of the viewport when menu-surface is at maximum possible height. Also used as a viewport margin. */
  11147. MARGIN_TO_EDGE: 32,
  11148. /** Ratio of anchor width to menu-surface width for switching from corner positioning to center positioning. */
  11149. ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67
  11150. };
  11151. exports.numbers = numbers;
  11152. /**
  11153. * Enum for bits in the {@see Corner) bitmap.
  11154. */
  11155. var CornerBit;
  11156. (function (CornerBit) {
  11157. CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM";
  11158. CornerBit[CornerBit["CENTER"] = 2] = "CENTER";
  11159. CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT";
  11160. CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL";
  11161. })(CornerBit || (CornerBit = {}));
  11162. exports.CornerBit = CornerBit;
  11163. /**
  11164. * Enum for representing an element corner for positioning the menu-surface.
  11165. *
  11166. * The START constants map to LEFT if element directionality is left
  11167. * to right and RIGHT if the directionality is right to left.
  11168. * Likewise END maps to RIGHT or LEFT depending on the directionality.
  11169. */
  11170. var Corner;
  11171. (function (Corner) {
  11172. Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT";
  11173. Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT";
  11174. Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT";
  11175. Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT";
  11176. Corner[Corner["TOP_START"] = 8] = "TOP_START";
  11177. Corner[Corner["TOP_END"] = 12] = "TOP_END";
  11178. Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START";
  11179. Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END";
  11180. })(Corner || (Corner = {}));
  11181. exports.Corner = Corner;
  11182. /***/ }),
  11183. /***/ "./packages/mdc-menu-surface/foundation.ts":
  11184. /*!*************************************************!*\
  11185. !*** ./packages/mdc-menu-surface/foundation.ts ***!
  11186. \*************************************************/
  11187. /*! no static exports found */
  11188. /***/ (function(module, exports, __webpack_require__) {
  11189. "use strict";
  11190. /**
  11191. * @license
  11192. * Copyright 2018 Google Inc.
  11193. *
  11194. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11195. * of this software and associated documentation files (the "Software"), to deal
  11196. * in the Software without restriction, including without limitation the rights
  11197. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11198. * copies of the Software, and to permit persons to whom the Software is
  11199. * furnished to do so, subject to the following conditions:
  11200. *
  11201. * The above copyright notice and this permission notice shall be included in
  11202. * all copies or substantial portions of the Software.
  11203. *
  11204. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11205. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11206. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11207. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11208. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11209. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11210. * THE SOFTWARE.
  11211. */
  11212. var __extends = this && this.__extends || function () {
  11213. var _extendStatics = function extendStatics(d, b) {
  11214. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  11215. d.__proto__ = b;
  11216. } || function (d, b) {
  11217. for (var p in b) {
  11218. if (b.hasOwnProperty(p)) d[p] = b[p];
  11219. }
  11220. };
  11221. return _extendStatics(d, b);
  11222. };
  11223. return function (d, b) {
  11224. _extendStatics(d, b);
  11225. function __() {
  11226. this.constructor = d;
  11227. }
  11228. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11229. };
  11230. }();
  11231. var __assign = this && this.__assign || function () {
  11232. __assign = Object.assign || function (t) {
  11233. for (var s, i = 1, n = arguments.length; i < n; i++) {
  11234. s = arguments[i];
  11235. for (var p in s) {
  11236. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  11237. }
  11238. }
  11239. return t;
  11240. };
  11241. return __assign.apply(this, arguments);
  11242. };
  11243. var __values = this && this.__values || function (o) {
  11244. var s = typeof Symbol === "function" && Symbol.iterator,
  11245. m = s && o[s],
  11246. i = 0;
  11247. if (m) return m.call(o);
  11248. if (o && typeof o.length === "number") return {
  11249. next: function next() {
  11250. if (o && i >= o.length) o = void 0;
  11251. return { value: o && o[i++], done: !o };
  11252. }
  11253. };
  11254. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  11255. };
  11256. Object.defineProperty(exports, "__esModule", { value: true });
  11257. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  11258. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
  11259. var MDCMenuSurfaceFoundation = /** @class */function (_super) {
  11260. __extends(MDCMenuSurfaceFoundation, _super);
  11261. function MDCMenuSurfaceFoundation(adapter) {
  11262. var _this = _super.call(this, __assign(__assign({}, MDCMenuSurfaceFoundation.defaultAdapter), adapter)) || this;
  11263. _this.isSurfaceOpen = false;
  11264. _this.isQuickOpen = false;
  11265. _this.isHoistedElement = false;
  11266. _this.isFixedPosition = false;
  11267. _this.openAnimationEndTimerId = 0;
  11268. _this.closeAnimationEndTimerId = 0;
  11269. _this.animationRequestId = 0;
  11270. _this.anchorCorner = constants_1.Corner.TOP_START;
  11271. /**
  11272. * Corner of the menu surface to which menu surface is attached to anchor.
  11273. *
  11274. * Anchor corner --->+----------+
  11275. * | ANCHOR |
  11276. * +----------+
  11277. * Origin corner --->+--------------+
  11278. * | |
  11279. * | |
  11280. * | MENU SURFACE |
  11281. * | |
  11282. * | |
  11283. * +--------------+
  11284. */
  11285. _this.originCorner = constants_1.Corner.TOP_START;
  11286. _this.anchorMargin = { top: 0, right: 0, bottom: 0, left: 0 };
  11287. _this.position = { x: 0, y: 0 };
  11288. return _this;
  11289. }
  11290. Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", {
  11291. get: function get() {
  11292. return constants_1.cssClasses;
  11293. },
  11294. enumerable: true,
  11295. configurable: true
  11296. });
  11297. Object.defineProperty(MDCMenuSurfaceFoundation, "strings", {
  11298. get: function get() {
  11299. return constants_1.strings;
  11300. },
  11301. enumerable: true,
  11302. configurable: true
  11303. });
  11304. Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", {
  11305. get: function get() {
  11306. return constants_1.numbers;
  11307. },
  11308. enumerable: true,
  11309. configurable: true
  11310. });
  11311. Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", {
  11312. get: function get() {
  11313. return constants_1.Corner;
  11314. },
  11315. enumerable: true,
  11316. configurable: true
  11317. });
  11318. Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", {
  11319. /**
  11320. * @see {@link MDCMenuSurfaceAdapter} for typing information on parameters and return types.
  11321. */
  11322. get: function get() {
  11323. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  11324. return {
  11325. addClass: function addClass() {
  11326. return undefined;
  11327. },
  11328. removeClass: function removeClass() {
  11329. return undefined;
  11330. },
  11331. hasClass: function hasClass() {
  11332. return false;
  11333. },
  11334. hasAnchor: function hasAnchor() {
  11335. return false;
  11336. },
  11337. isElementInContainer: function isElementInContainer() {
  11338. return false;
  11339. },
  11340. isFocused: function isFocused() {
  11341. return false;
  11342. },
  11343. isRtl: function isRtl() {
  11344. return false;
  11345. },
  11346. getInnerDimensions: function getInnerDimensions() {
  11347. return { height: 0, width: 0 };
  11348. },
  11349. getAnchorDimensions: function getAnchorDimensions() {
  11350. return null;
  11351. },
  11352. getWindowDimensions: function getWindowDimensions() {
  11353. return { height: 0, width: 0 };
  11354. },
  11355. getBodyDimensions: function getBodyDimensions() {
  11356. return { height: 0, width: 0 };
  11357. },
  11358. getWindowScroll: function getWindowScroll() {
  11359. return { x: 0, y: 0 };
  11360. },
  11361. setPosition: function setPosition() {
  11362. return undefined;
  11363. },
  11364. setMaxHeight: function setMaxHeight() {
  11365. return undefined;
  11366. },
  11367. setTransformOrigin: function setTransformOrigin() {
  11368. return undefined;
  11369. },
  11370. saveFocus: function saveFocus() {
  11371. return undefined;
  11372. },
  11373. restoreFocus: function restoreFocus() {
  11374. return undefined;
  11375. },
  11376. notifyClose: function notifyClose() {
  11377. return undefined;
  11378. },
  11379. notifyOpen: function notifyOpen() {
  11380. return undefined;
  11381. }
  11382. };
  11383. // tslint:enable:object-literal-sort-keys
  11384. },
  11385. enumerable: true,
  11386. configurable: true
  11387. });
  11388. MDCMenuSurfaceFoundation.prototype.init = function () {
  11389. var _a = MDCMenuSurfaceFoundation.cssClasses,
  11390. ROOT = _a.ROOT,
  11391. OPEN = _a.OPEN;
  11392. if (!this.adapter.hasClass(ROOT)) {
  11393. throw new Error(ROOT + " class required in root element.");
  11394. }
  11395. if (this.adapter.hasClass(OPEN)) {
  11396. this.isSurfaceOpen = true;
  11397. }
  11398. };
  11399. MDCMenuSurfaceFoundation.prototype.destroy = function () {
  11400. clearTimeout(this.openAnimationEndTimerId);
  11401. clearTimeout(this.closeAnimationEndTimerId);
  11402. // Cancel any currently running animations.
  11403. cancelAnimationFrame(this.animationRequestId);
  11404. };
  11405. /**
  11406. * @param corner Default anchor corner alignment of top-left menu surface corner.
  11407. */
  11408. MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) {
  11409. this.anchorCorner = corner;
  11410. };
  11411. /**
  11412. * Flip menu corner horizontally.
  11413. */
  11414. MDCMenuSurfaceFoundation.prototype.flipCornerHorizontally = function () {
  11415. this.originCorner = this.originCorner ^ constants_1.CornerBit.RIGHT;
  11416. };
  11417. /**
  11418. * @param margin Set of margin values from anchor.
  11419. */
  11420. MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) {
  11421. this.anchorMargin.top = margin.top || 0;
  11422. this.anchorMargin.right = margin.right || 0;
  11423. this.anchorMargin.bottom = margin.bottom || 0;
  11424. this.anchorMargin.left = margin.left || 0;
  11425. };
  11426. /** Used to indicate if the menu-surface is hoisted to the body. */
  11427. MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) {
  11428. this.isHoistedElement = isHoisted;
  11429. };
  11430. /** Used to set the menu-surface calculations based on a fixed position menu. */
  11431. MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) {
  11432. this.isFixedPosition = isFixedPosition;
  11433. };
  11434. /** Sets the menu-surface position on the page. */
  11435. MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) {
  11436. this.position.x = this.isFinite(x) ? x : 0;
  11437. this.position.y = this.isFinite(y) ? y : 0;
  11438. };
  11439. MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) {
  11440. this.isQuickOpen = quickOpen;
  11441. };
  11442. MDCMenuSurfaceFoundation.prototype.isOpen = function () {
  11443. return this.isSurfaceOpen;
  11444. };
  11445. /**
  11446. * Open the menu surface.
  11447. */
  11448. MDCMenuSurfaceFoundation.prototype.open = function () {
  11449. var _this = this;
  11450. if (this.isSurfaceOpen) {
  11451. return;
  11452. }
  11453. this.adapter.saveFocus();
  11454. if (this.isQuickOpen) {
  11455. this.isSurfaceOpen = true;
  11456. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  11457. this.dimensions = this.adapter.getInnerDimensions();
  11458. this.autoposition();
  11459. this.adapter.notifyOpen();
  11460. } else {
  11461. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
  11462. this.animationRequestId = requestAnimationFrame(function () {
  11463. _this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  11464. _this.dimensions = _this.adapter.getInnerDimensions();
  11465. _this.autoposition();
  11466. _this.openAnimationEndTimerId = setTimeout(function () {
  11467. _this.openAnimationEndTimerId = 0;
  11468. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
  11469. _this.adapter.notifyOpen();
  11470. }, constants_1.numbers.TRANSITION_OPEN_DURATION);
  11471. });
  11472. this.isSurfaceOpen = true;
  11473. }
  11474. };
  11475. /**
  11476. * Closes the menu surface.
  11477. */
  11478. MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) {
  11479. var _this = this;
  11480. if (skipRestoreFocus === void 0) {
  11481. skipRestoreFocus = false;
  11482. }
  11483. if (!this.isSurfaceOpen) {
  11484. return;
  11485. }
  11486. if (this.isQuickOpen) {
  11487. this.isSurfaceOpen = false;
  11488. if (!skipRestoreFocus) {
  11489. this.maybeRestoreFocus();
  11490. }
  11491. this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  11492. this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
  11493. this.adapter.notifyClose();
  11494. } else {
  11495. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
  11496. requestAnimationFrame(function () {
  11497. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  11498. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
  11499. _this.closeAnimationEndTimerId = setTimeout(function () {
  11500. _this.closeAnimationEndTimerId = 0;
  11501. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
  11502. _this.adapter.notifyClose();
  11503. }, constants_1.numbers.TRANSITION_CLOSE_DURATION);
  11504. });
  11505. this.isSurfaceOpen = false;
  11506. if (!skipRestoreFocus) {
  11507. this.maybeRestoreFocus();
  11508. }
  11509. }
  11510. };
  11511. /** Handle clicks and close if not within menu-surface element. */
  11512. MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) {
  11513. var el = evt.target;
  11514. if (this.adapter.isElementInContainer(el)) {
  11515. return;
  11516. }
  11517. this.close();
  11518. };
  11519. /** Handle keys that close the surface. */
  11520. MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) {
  11521. var keyCode = evt.keyCode,
  11522. key = evt.key;
  11523. var isEscape = key === 'Escape' || keyCode === 27;
  11524. if (isEscape) {
  11525. this.close();
  11526. }
  11527. };
  11528. MDCMenuSurfaceFoundation.prototype.autoposition = function () {
  11529. var _a;
  11530. // Compute measurements for autoposition methods reuse.
  11531. this.measurements = this.getAutoLayoutmeasurements();
  11532. var corner = this.getoriginCorner();
  11533. var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight(corner);
  11534. var verticalAlignment = this.hasBit(corner, constants_1.CornerBit.BOTTOM) ? 'bottom' : 'top';
  11535. var horizontalAlignment = this.hasBit(corner, constants_1.CornerBit.RIGHT) ? 'right' : 'left';
  11536. var horizontalOffset = this.getHorizontalOriginOffset(corner);
  11537. var verticalOffset = this.getVerticalOriginOffset(corner);
  11538. var _b = this.measurements,
  11539. anchorSize = _b.anchorSize,
  11540. surfaceSize = _b.surfaceSize;
  11541. var position = (_a = {}, _a[horizontalAlignment] = horizontalOffset, _a[verticalAlignment] = verticalOffset, _a);
  11542. // Center align when anchor width is comparable or greater than menu surface, otherwise keep corner.
  11543. if (anchorSize.width / surfaceSize.width > constants_1.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) {
  11544. horizontalAlignment = 'center';
  11545. }
  11546. // If the menu-surface has been hoisted to the body, it's no longer relative to the anchor element
  11547. if (this.isHoistedElement || this.isFixedPosition) {
  11548. this.adjustPositionForHoistedElement(position);
  11549. }
  11550. this.adapter.setTransformOrigin(horizontalAlignment + " " + verticalAlignment);
  11551. this.adapter.setPosition(position);
  11552. this.adapter.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : '');
  11553. // If it is opened from the top then add is-open-below class
  11554. if (!this.hasBit(corner, constants_1.CornerBit.BOTTOM)) {
  11555. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
  11556. }
  11557. };
  11558. /**
  11559. * @return Measurements used to position menu surface popup.
  11560. */
  11561. MDCMenuSurfaceFoundation.prototype.getAutoLayoutmeasurements = function () {
  11562. var anchorRect = this.adapter.getAnchorDimensions();
  11563. var bodySize = this.adapter.getBodyDimensions();
  11564. var viewportSize = this.adapter.getWindowDimensions();
  11565. var windowScroll = this.adapter.getWindowScroll();
  11566. if (!anchorRect) {
  11567. // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
  11568. anchorRect = {
  11569. top: this.position.y,
  11570. right: this.position.x,
  11571. bottom: this.position.y,
  11572. left: this.position.x,
  11573. width: 0,
  11574. height: 0
  11575. };
  11576. // tslint:enable:object-literal-sort-keys
  11577. }
  11578. return {
  11579. anchorSize: anchorRect,
  11580. bodySize: bodySize,
  11581. surfaceSize: this.dimensions,
  11582. viewportDistance: {
  11583. // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
  11584. top: anchorRect.top,
  11585. right: viewportSize.width - anchorRect.right,
  11586. bottom: viewportSize.height - anchorRect.bottom,
  11587. left: anchorRect.left
  11588. },
  11589. viewportSize: viewportSize,
  11590. windowScroll: windowScroll
  11591. };
  11592. };
  11593. /**
  11594. * Computes the corner of the anchor from which to animate and position the
  11595. * menu surface.
  11596. *
  11597. * Only LEFT or RIGHT bit is used to position the menu surface ignoring RTL
  11598. * context. E.g., menu surface will be positioned from right side on TOP_END.
  11599. */
  11600. MDCMenuSurfaceFoundation.prototype.getoriginCorner = function () {
  11601. var corner = this.originCorner;
  11602. var _a = this.measurements,
  11603. viewportDistance = _a.viewportDistance,
  11604. anchorSize = _a.anchorSize,
  11605. surfaceSize = _a.surfaceSize;
  11606. var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
  11607. var isAnchoredToBottom = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
  11608. var availableTop;
  11609. var availableBottom;
  11610. if (isAnchoredToBottom) {
  11611. availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.bottom;
  11612. availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE - this.anchorMargin.bottom;
  11613. } else {
  11614. availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.top;
  11615. availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE + anchorSize.height - this.anchorMargin.top;
  11616. }
  11617. var isAvailableBottom = availableBottom - surfaceSize.height > 0;
  11618. if (!isAvailableBottom && availableTop > availableBottom) {
  11619. // Attach bottom side of surface to the anchor.
  11620. corner = this.setBit(corner, constants_1.CornerBit.BOTTOM);
  11621. }
  11622. var isRtl = this.adapter.isRtl();
  11623. var isFlipRtl = this.hasBit(this.anchorCorner, constants_1.CornerBit.FLIP_RTL);
  11624. var hasRightBit = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT) || this.hasBit(corner, constants_1.CornerBit.RIGHT);
  11625. // Whether surface attached to right side of anchor element.
  11626. var isAnchoredToRight = false;
  11627. // Anchored to start
  11628. if (isRtl && isFlipRtl) {
  11629. isAnchoredToRight = !hasRightBit;
  11630. } else {
  11631. // Anchored to right
  11632. isAnchoredToRight = hasRightBit;
  11633. }
  11634. var availableLeft;
  11635. var availableRight;
  11636. if (isAnchoredToRight) {
  11637. availableLeft = viewportDistance.left + anchorSize.width + this.anchorMargin.right;
  11638. availableRight = viewportDistance.right - this.anchorMargin.right;
  11639. } else {
  11640. availableLeft = viewportDistance.left + this.anchorMargin.left;
  11641. availableRight = viewportDistance.right + anchorSize.width - this.anchorMargin.left;
  11642. }
  11643. var isAvailableLeft = availableLeft - surfaceSize.width > 0;
  11644. var isAvailableRight = availableRight - surfaceSize.width > 0;
  11645. var isOriginCornerAlignedToEnd = this.hasBit(corner, constants_1.CornerBit.FLIP_RTL) && this.hasBit(corner, constants_1.CornerBit.RIGHT);
  11646. if (isAvailableRight && isOriginCornerAlignedToEnd && isRtl || !isAvailableLeft && isOriginCornerAlignedToEnd) {
  11647. // Attach left side of surface to the anchor.
  11648. corner = this.unsetBit(corner, constants_1.CornerBit.RIGHT);
  11649. } else if (isAvailableLeft && isAnchoredToRight && isRtl || isAvailableLeft && !isAnchoredToRight && hasRightBit || !isAvailableRight && availableLeft >= availableRight) {
  11650. // Attach right side of surface to the anchor.
  11651. corner = this.setBit(corner, constants_1.CornerBit.RIGHT);
  11652. }
  11653. return corner;
  11654. };
  11655. /**
  11656. * @param corner Origin corner of the menu surface.
  11657. * @return Maximum height of the menu surface, based on available space. 0 indicates should not be set.
  11658. */
  11659. MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) {
  11660. var viewportDistance = this.measurements.viewportDistance;
  11661. var maxHeight = 0;
  11662. var isBottomAligned = this.hasBit(corner, constants_1.CornerBit.BOTTOM);
  11663. var isBottomAnchored = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
  11664. var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
  11665. // When maximum height is not specified, it is handled from CSS.
  11666. if (isBottomAligned) {
  11667. maxHeight = viewportDistance.top + this.anchorMargin.top - MARGIN_TO_EDGE;
  11668. if (!isBottomAnchored) {
  11669. maxHeight += this.measurements.anchorSize.height;
  11670. }
  11671. } else {
  11672. maxHeight = viewportDistance.bottom - this.anchorMargin.bottom + this.measurements.anchorSize.height - MARGIN_TO_EDGE;
  11673. if (isBottomAnchored) {
  11674. maxHeight -= this.measurements.anchorSize.height;
  11675. }
  11676. }
  11677. return maxHeight;
  11678. };
  11679. /**
  11680. * @param corner Origin corner of the menu surface.
  11681. * @return Horizontal offset of menu surface origin corner from corresponding anchor corner.
  11682. */
  11683. MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset = function (corner) {
  11684. var anchorSize = this.measurements.anchorSize;
  11685. // isRightAligned corresponds to using the 'right' property on the surface.
  11686. var isRightAligned = this.hasBit(corner, constants_1.CornerBit.RIGHT);
  11687. var avoidHorizontalOverlap = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT);
  11688. if (isRightAligned) {
  11689. var rightOffset = avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.left : this.anchorMargin.right;
  11690. // For hoisted or fixed elements, adjust the offset by the difference
  11691. // between viewport width and body width so when we calculate the right
  11692. // value (`adjustPositionForHoistedElement`) based on the element
  11693. // position, the right property is correct.
  11694. if (this.isHoistedElement || this.isFixedPosition) {
  11695. return rightOffset - (this.measurements.viewportSize.width - this.measurements.bodySize.width);
  11696. }
  11697. return rightOffset;
  11698. }
  11699. return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.right : this.anchorMargin.left;
  11700. };
  11701. /**
  11702. * @param corner Origin corner of the menu surface.
  11703. * @return Vertical offset of menu surface origin corner from corresponding anchor corner.
  11704. */
  11705. MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset = function (corner) {
  11706. var anchorSize = this.measurements.anchorSize;
  11707. var isBottomAligned = this.hasBit(corner, constants_1.CornerBit.BOTTOM);
  11708. var avoidVerticalOverlap = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
  11709. var y = 0;
  11710. if (isBottomAligned) {
  11711. y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin.top : -this.anchorMargin.bottom;
  11712. } else {
  11713. y = avoidVerticalOverlap ? anchorSize.height + this.anchorMargin.bottom : this.anchorMargin.top;
  11714. }
  11715. return y;
  11716. };
  11717. /** Calculates the offsets for positioning the menu-surface when the menu-surface has been hoisted to the body. */
  11718. MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement = function (position) {
  11719. var e_1, _a;
  11720. var _b = this.measurements,
  11721. windowScroll = _b.windowScroll,
  11722. viewportDistance = _b.viewportDistance;
  11723. var props = Object.keys(position);
  11724. try {
  11725. for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
  11726. var prop = props_1_1.value;
  11727. var value = position[prop] || 0;
  11728. // Hoisted surfaces need to have the anchor elements location on the page added to the
  11729. // position properties for proper alignment on the body.
  11730. value += viewportDistance[prop];
  11731. // Surfaces that are absolutely positioned need to have additional calculations for scroll
  11732. // and bottom positioning.
  11733. if (!this.isFixedPosition) {
  11734. if (prop === 'top') {
  11735. value += windowScroll.y;
  11736. } else if (prop === 'bottom') {
  11737. value -= windowScroll.y;
  11738. } else if (prop === 'left') {
  11739. value += windowScroll.x;
  11740. } else {
  11741. // prop === 'right'
  11742. value -= windowScroll.x;
  11743. }
  11744. }
  11745. position[prop] = value;
  11746. }
  11747. } catch (e_1_1) {
  11748. e_1 = { error: e_1_1 };
  11749. } finally {
  11750. try {
  11751. if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
  11752. } finally {
  11753. if (e_1) throw e_1.error;
  11754. }
  11755. }
  11756. };
  11757. /**
  11758. * The last focused element when the menu surface was opened should regain focus, if the user is
  11759. * focused on or within the menu surface when it is closed.
  11760. */
  11761. MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus = function () {
  11762. var isRootFocused = this.adapter.isFocused();
  11763. var childHasFocus = document.activeElement && this.adapter.isElementInContainer(document.activeElement);
  11764. if (isRootFocused || childHasFocus) {
  11765. this.adapter.restoreFocus();
  11766. }
  11767. };
  11768. MDCMenuSurfaceFoundation.prototype.hasBit = function (corner, bit) {
  11769. return Boolean(corner & bit); // tslint:disable-line:no-bitwise
  11770. };
  11771. MDCMenuSurfaceFoundation.prototype.setBit = function (corner, bit) {
  11772. return corner | bit; // tslint:disable-line:no-bitwise
  11773. };
  11774. MDCMenuSurfaceFoundation.prototype.unsetBit = function (corner, bit) {
  11775. return corner ^ bit;
  11776. };
  11777. /**
  11778. * isFinite that doesn't force conversion to number type.
  11779. * Equivalent to Number.isFinite in ES2015, which is not supported in IE.
  11780. */
  11781. MDCMenuSurfaceFoundation.prototype.isFinite = function (num) {
  11782. return typeof num === 'number' && isFinite(num);
  11783. };
  11784. return MDCMenuSurfaceFoundation;
  11785. }(foundation_1.MDCFoundation);
  11786. exports.MDCMenuSurfaceFoundation = MDCMenuSurfaceFoundation;
  11787. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  11788. exports.default = MDCMenuSurfaceFoundation;
  11789. /***/ }),
  11790. /***/ "./packages/mdc-menu-surface/index.ts":
  11791. /*!********************************************!*\
  11792. !*** ./packages/mdc-menu-surface/index.ts ***!
  11793. \********************************************/
  11794. /*! no static exports found */
  11795. /***/ (function(module, exports, __webpack_require__) {
  11796. "use strict";
  11797. /**
  11798. * @license
  11799. * Copyright 2019 Google Inc.
  11800. *
  11801. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11802. * of this software and associated documentation files (the "Software"), to deal
  11803. * in the Software without restriction, including without limitation the rights
  11804. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11805. * copies of the Software, and to permit persons to whom the Software is
  11806. * furnished to do so, subject to the following conditions:
  11807. *
  11808. * The above copyright notice and this permission notice shall be included in
  11809. * all copies or substantial portions of the Software.
  11810. *
  11811. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11812. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11813. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11814. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11815. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11816. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11817. * THE SOFTWARE.
  11818. */
  11819. function __export(m) {
  11820. for (var p in m) {
  11821. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  11822. }
  11823. }
  11824. var __importStar = this && this.__importStar || function (mod) {
  11825. if (mod && mod.__esModule) return mod;
  11826. var result = {};
  11827. if (mod != null) for (var k in mod) {
  11828. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  11829. }result["default"] = mod;
  11830. return result;
  11831. };
  11832. Object.defineProperty(exports, "__esModule", { value: true });
  11833. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-menu-surface/util.ts"));
  11834. exports.util = util;
  11835. __export(__webpack_require__(/*! ./component */ "./packages/mdc-menu-surface/component.ts"));
  11836. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts"));
  11837. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-menu-surface/foundation.ts"));
  11838. /***/ }),
  11839. /***/ "./packages/mdc-menu-surface/util.ts":
  11840. /*!*******************************************!*\
  11841. !*** ./packages/mdc-menu-surface/util.ts ***!
  11842. \*******************************************/
  11843. /*! no static exports found */
  11844. /***/ (function(module, exports, __webpack_require__) {
  11845. "use strict";
  11846. /**
  11847. * @license
  11848. * Copyright 2018 Google Inc.
  11849. *
  11850. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11851. * of this software and associated documentation files (the "Software"), to deal
  11852. * in the Software without restriction, including without limitation the rights
  11853. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11854. * copies of the Software, and to permit persons to whom the Software is
  11855. * furnished to do so, subject to the following conditions:
  11856. *
  11857. * The above copyright notice and this permission notice shall be included in
  11858. * all copies or substantial portions of the Software.
  11859. *
  11860. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11861. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11862. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11863. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11864. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11865. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11866. * THE SOFTWARE.
  11867. */
  11868. Object.defineProperty(exports, "__esModule", { value: true });
  11869. var cachedCssTransformPropertyName_;
  11870. /**
  11871. * Returns the name of the correct transform property to use on the current browser.
  11872. */
  11873. function getTransformPropertyName(globalObj, forceRefresh) {
  11874. if (forceRefresh === void 0) {
  11875. forceRefresh = false;
  11876. }
  11877. if (cachedCssTransformPropertyName_ === undefined || forceRefresh) {
  11878. var el = globalObj.document.createElement('div');
  11879. cachedCssTransformPropertyName_ = 'transform' in el.style ? 'transform' : 'webkitTransform';
  11880. }
  11881. return cachedCssTransformPropertyName_;
  11882. }
  11883. exports.getTransformPropertyName = getTransformPropertyName;
  11884. /***/ }),
  11885. /***/ "./packages/mdc-menu/component.ts":
  11886. /*!****************************************!*\
  11887. !*** ./packages/mdc-menu/component.ts ***!
  11888. \****************************************/
  11889. /*! no static exports found */
  11890. /***/ (function(module, exports, __webpack_require__) {
  11891. "use strict";
  11892. /**
  11893. * @license
  11894. * Copyright 2018 Google Inc.
  11895. *
  11896. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11897. * of this software and associated documentation files (the "Software"), to deal
  11898. * in the Software without restriction, including without limitation the rights
  11899. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11900. * copies of the Software, and to permit persons to whom the Software is
  11901. * furnished to do so, subject to the following conditions:
  11902. *
  11903. * The above copyright notice and this permission notice shall be included in
  11904. * all copies or substantial portions of the Software.
  11905. *
  11906. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11907. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11908. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11909. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11910. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11911. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11912. * THE SOFTWARE.
  11913. */
  11914. var __extends = this && this.__extends || function () {
  11915. var _extendStatics = function extendStatics(d, b) {
  11916. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  11917. d.__proto__ = b;
  11918. } || function (d, b) {
  11919. for (var p in b) {
  11920. if (b.hasOwnProperty(p)) d[p] = b[p];
  11921. }
  11922. };
  11923. return _extendStatics(d, b);
  11924. };
  11925. return function (d, b) {
  11926. _extendStatics(d, b);
  11927. function __() {
  11928. this.constructor = d;
  11929. }
  11930. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11931. };
  11932. }();
  11933. Object.defineProperty(exports, "__esModule", { value: true });
  11934. // TODO(b/152410470): Remove trailing underscores from private properties
  11935. // tslint:disable:strip-private-property-underscore
  11936. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  11937. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  11938. var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
  11939. var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
  11940. var foundation_1 = __webpack_require__(/*! @material/list/foundation */ "./packages/mdc-list/foundation.ts");
  11941. var component_3 = __webpack_require__(/*! @material/menu-surface/component */ "./packages/mdc-menu-surface/component.ts");
  11942. var foundation_2 = __webpack_require__(/*! @material/menu-surface/foundation */ "./packages/mdc-menu-surface/foundation.ts");
  11943. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
  11944. var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts");
  11945. var MDCMenu = /** @class */function (_super) {
  11946. __extends(MDCMenu, _super);
  11947. function MDCMenu() {
  11948. return _super !== null && _super.apply(this, arguments) || this;
  11949. }
  11950. MDCMenu.attachTo = function (root) {
  11951. return new MDCMenu(root);
  11952. };
  11953. MDCMenu.prototype.initialize = function (menuSurfaceFactory, listFactory) {
  11954. if (menuSurfaceFactory === void 0) {
  11955. menuSurfaceFactory = function menuSurfaceFactory(el) {
  11956. return new component_3.MDCMenuSurface(el);
  11957. };
  11958. }
  11959. if (listFactory === void 0) {
  11960. listFactory = function listFactory(el) {
  11961. return new component_2.MDCList(el);
  11962. };
  11963. }
  11964. this.menuSurfaceFactory_ = menuSurfaceFactory;
  11965. this.listFactory_ = listFactory;
  11966. };
  11967. MDCMenu.prototype.initialSyncWithDOM = function () {
  11968. var _this = this;
  11969. this.menuSurface_ = this.menuSurfaceFactory_(this.root);
  11970. var list = this.root.querySelector(constants_2.strings.LIST_SELECTOR);
  11971. if (list) {
  11972. this.list_ = this.listFactory_(list);
  11973. this.list_.wrapFocus = true;
  11974. } else {
  11975. this.list_ = null;
  11976. }
  11977. this.handleKeydown_ = function (evt) {
  11978. return _this.foundation.handleKeydown(evt);
  11979. };
  11980. this.handleItemAction_ = function (evt) {
  11981. return _this.foundation.handleItemAction(_this.items[evt.detail.index]);
  11982. };
  11983. this.handleMenuSurfaceOpened_ = function () {
  11984. return _this.foundation.handleMenuSurfaceOpened();
  11985. };
  11986. this.menuSurface_.listen(foundation_2.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened_);
  11987. this.listen('keydown', this.handleKeydown_);
  11988. this.listen(foundation_1.MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction_);
  11989. };
  11990. MDCMenu.prototype.destroy = function () {
  11991. if (this.list_) {
  11992. this.list_.destroy();
  11993. }
  11994. this.menuSurface_.destroy();
  11995. this.menuSurface_.unlisten(foundation_2.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened_);
  11996. this.unlisten('keydown', this.handleKeydown_);
  11997. this.unlisten(foundation_1.MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction_);
  11998. _super.prototype.destroy.call(this);
  11999. };
  12000. Object.defineProperty(MDCMenu.prototype, "open", {
  12001. get: function get() {
  12002. return this.menuSurface_.isOpen();
  12003. },
  12004. set: function set(value) {
  12005. if (value) {
  12006. this.menuSurface_.open();
  12007. } else {
  12008. this.menuSurface_.close();
  12009. }
  12010. },
  12011. enumerable: true,
  12012. configurable: true
  12013. });
  12014. Object.defineProperty(MDCMenu.prototype, "wrapFocus", {
  12015. get: function get() {
  12016. return this.list_ ? this.list_.wrapFocus : false;
  12017. },
  12018. set: function set(value) {
  12019. if (this.list_) {
  12020. this.list_.wrapFocus = value;
  12021. }
  12022. },
  12023. enumerable: true,
  12024. configurable: true
  12025. });
  12026. Object.defineProperty(MDCMenu.prototype, "hasTypeahead", {
  12027. /**
  12028. * Sets whether the menu has typeahead functionality.
  12029. * @param value Whether typeahead is enabled.
  12030. */
  12031. set: function set(value) {
  12032. if (this.list_) {
  12033. this.list_.hasTypeahead = value;
  12034. }
  12035. },
  12036. enumerable: true,
  12037. configurable: true
  12038. });
  12039. Object.defineProperty(MDCMenu.prototype, "typeaheadInProgress", {
  12040. /**
  12041. * @return Whether typeahead logic is currently matching some user prefix.
  12042. */
  12043. get: function get() {
  12044. return this.list_ ? this.list_.typeaheadInProgress : false;
  12045. },
  12046. enumerable: true,
  12047. configurable: true
  12048. });
  12049. /**
  12050. * Given the next desired character from the user, adds it to the typeahead
  12051. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  12052. * around if at the end of options.
  12053. *
  12054. * @param nextChar The next character to add to the prefix buffer.
  12055. * @param startingIndex The index from which to start matching. Only relevant
  12056. * when starting a new match sequence. To start a new match sequence,
  12057. * clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
  12058. * to clear after a set interval defined in list foundation. Defaults to
  12059. * the currently focused index.
  12060. * @return The index of the matched item, or -1 if no match.
  12061. */
  12062. MDCMenu.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
  12063. if (this.list_) {
  12064. return this.list_.typeaheadMatchItem(nextChar, startingIndex);
  12065. }
  12066. return -1;
  12067. };
  12068. /**
  12069. * Layout the underlying list element in the case of any dynamic updates
  12070. * to its structure.
  12071. */
  12072. MDCMenu.prototype.layout = function () {
  12073. if (this.list_) {
  12074. this.list_.layout();
  12075. }
  12076. };
  12077. Object.defineProperty(MDCMenu.prototype, "items", {
  12078. /**
  12079. * Return the items within the menu. Note that this only contains the set of elements within
  12080. * the items container that are proper list items, and not supplemental / presentational DOM
  12081. * elements.
  12082. */
  12083. get: function get() {
  12084. return this.list_ ? this.list_.listElements : [];
  12085. },
  12086. enumerable: true,
  12087. configurable: true
  12088. });
  12089. Object.defineProperty(MDCMenu.prototype, "singleSelection", {
  12090. /**
  12091. * Turns on/off the underlying list's single selection mode. Used mainly
  12092. * by select menu.
  12093. *
  12094. * @param singleSelection Whether to enable single selection mode.
  12095. */
  12096. set: function set(singleSelection) {
  12097. if (this.list_) {
  12098. this.list_.singleSelection = singleSelection;
  12099. }
  12100. },
  12101. enumerable: true,
  12102. configurable: true
  12103. });
  12104. Object.defineProperty(MDCMenu.prototype, "selectedIndex", {
  12105. /**
  12106. * Retrieves the selected index. Only applicable to select menus.
  12107. * @return The selected index, which is a number for single selection and
  12108. * radio lists, and an array of numbers for checkbox lists.
  12109. */
  12110. get: function get() {
  12111. return this.list_ ? this.list_.selectedIndex : constants_1.numbers.UNSET_INDEX;
  12112. },
  12113. /**
  12114. * Sets the selected index of the list. Only applicable to select menus.
  12115. * @param index The selected index, which is a number for single selection and
  12116. * radio lists, and an array of numbers for checkbox lists.
  12117. */
  12118. set: function set(index) {
  12119. if (this.list_) {
  12120. this.list_.selectedIndex = index;
  12121. }
  12122. },
  12123. enumerable: true,
  12124. configurable: true
  12125. });
  12126. Object.defineProperty(MDCMenu.prototype, "quickOpen", {
  12127. set: function set(quickOpen) {
  12128. this.menuSurface_.quickOpen = quickOpen;
  12129. },
  12130. enumerable: true,
  12131. configurable: true
  12132. });
  12133. /**
  12134. * Sets default focus state where the menu should focus every time when menu
  12135. * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
  12136. * default.
  12137. * @param focusState Default focus state.
  12138. */
  12139. MDCMenu.prototype.setDefaultFocusState = function (focusState) {
  12140. this.foundation.setDefaultFocusState(focusState);
  12141. };
  12142. /**
  12143. * @param corner Default anchor corner alignment of top-left menu corner.
  12144. */
  12145. MDCMenu.prototype.setAnchorCorner = function (corner) {
  12146. this.menuSurface_.setAnchorCorner(corner);
  12147. };
  12148. MDCMenu.prototype.setAnchorMargin = function (margin) {
  12149. this.menuSurface_.setAnchorMargin(margin);
  12150. };
  12151. /**
  12152. * Sets the list item as the selected row at the specified index.
  12153. * @param index Index of list item within menu.
  12154. */
  12155. MDCMenu.prototype.setSelectedIndex = function (index) {
  12156. this.foundation.setSelectedIndex(index);
  12157. };
  12158. /**
  12159. * Sets the enabled state to isEnabled for the menu item at the given index.
  12160. * @param index Index of the menu item
  12161. * @param isEnabled The desired enabled state of the menu item.
  12162. */
  12163. MDCMenu.prototype.setEnabled = function (index, isEnabled) {
  12164. this.foundation.setEnabled(index, isEnabled);
  12165. };
  12166. /**
  12167. * @return The item within the menu at the index specified.
  12168. */
  12169. MDCMenu.prototype.getOptionByIndex = function (index) {
  12170. var items = this.items;
  12171. if (index < items.length) {
  12172. return this.items[index];
  12173. } else {
  12174. return null;
  12175. }
  12176. };
  12177. /**
  12178. * @param index A menu item's index.
  12179. * @return The primary text within the menu at the index specified.
  12180. */
  12181. MDCMenu.prototype.getPrimaryTextAtIndex = function (index) {
  12182. var item = this.getOptionByIndex(index);
  12183. if (item && this.list_) {
  12184. return this.list_.getPrimaryText(item) || '';
  12185. }
  12186. return '';
  12187. };
  12188. MDCMenu.prototype.setFixedPosition = function (isFixed) {
  12189. this.menuSurface_.setFixedPosition(isFixed);
  12190. };
  12191. MDCMenu.prototype.setIsHoisted = function (isHoisted) {
  12192. this.menuSurface_.setIsHoisted(isHoisted);
  12193. };
  12194. MDCMenu.prototype.setAbsolutePosition = function (x, y) {
  12195. this.menuSurface_.setAbsolutePosition(x, y);
  12196. };
  12197. /**
  12198. * Sets the element that the menu-surface is anchored to.
  12199. */
  12200. MDCMenu.prototype.setAnchorElement = function (element) {
  12201. this.menuSurface_.anchorElement = element;
  12202. };
  12203. MDCMenu.prototype.getDefaultFoundation = function () {
  12204. var _this = this;
  12205. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  12206. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  12207. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  12208. var adapter = {
  12209. addClassToElementAtIndex: function addClassToElementAtIndex(index, className) {
  12210. var list = _this.items;
  12211. list[index].classList.add(className);
  12212. },
  12213. removeClassFromElementAtIndex: function removeClassFromElementAtIndex(index, className) {
  12214. var list = _this.items;
  12215. list[index].classList.remove(className);
  12216. },
  12217. addAttributeToElementAtIndex: function addAttributeToElementAtIndex(index, attr, value) {
  12218. var list = _this.items;
  12219. list[index].setAttribute(attr, value);
  12220. },
  12221. removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex(index, attr) {
  12222. var list = _this.items;
  12223. list[index].removeAttribute(attr);
  12224. },
  12225. elementContainsClass: function elementContainsClass(element, className) {
  12226. return element.classList.contains(className);
  12227. },
  12228. closeSurface: function closeSurface(skipRestoreFocus) {
  12229. return _this.menuSurface_.close(skipRestoreFocus);
  12230. },
  12231. getElementIndex: function getElementIndex(element) {
  12232. return _this.items.indexOf(element);
  12233. },
  12234. notifySelected: function notifySelected(evtData) {
  12235. return _this.emit(constants_2.strings.SELECTED_EVENT, {
  12236. index: evtData.index,
  12237. item: _this.items[evtData.index]
  12238. });
  12239. },
  12240. getMenuItemCount: function getMenuItemCount() {
  12241. return _this.items.length;
  12242. },
  12243. focusItemAtIndex: function focusItemAtIndex(index) {
  12244. return _this.items[index].focus();
  12245. },
  12246. focusListRoot: function focusListRoot() {
  12247. return _this.root.querySelector(constants_2.strings.LIST_SELECTOR).focus();
  12248. },
  12249. isSelectableItemAtIndex: function isSelectableItemAtIndex(index) {
  12250. return !!ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
  12251. },
  12252. getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex(index) {
  12253. var selectionGroupEl = ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
  12254. var selectedItemEl = selectionGroupEl.querySelector("." + constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
  12255. return selectedItemEl ? _this.items.indexOf(selectedItemEl) : -1;
  12256. }
  12257. };
  12258. // tslint:enable:object-literal-sort-keys
  12259. return new foundation_3.MDCMenuFoundation(adapter);
  12260. };
  12261. return MDCMenu;
  12262. }(component_1.MDCComponent);
  12263. exports.MDCMenu = MDCMenu;
  12264. /***/ }),
  12265. /***/ "./packages/mdc-menu/constants.ts":
  12266. /*!****************************************!*\
  12267. !*** ./packages/mdc-menu/constants.ts ***!
  12268. \****************************************/
  12269. /*! no static exports found */
  12270. /***/ (function(module, exports, __webpack_require__) {
  12271. "use strict";
  12272. /**
  12273. * @license
  12274. * Copyright 2018 Google Inc.
  12275. *
  12276. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12277. * of this software and associated documentation files (the "Software"), to deal
  12278. * in the Software without restriction, including without limitation the rights
  12279. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12280. * copies of the Software, and to permit persons to whom the Software is
  12281. * furnished to do so, subject to the following conditions:
  12282. *
  12283. * The above copyright notice and this permission notice shall be included in
  12284. * all copies or substantial portions of the Software.
  12285. *
  12286. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12287. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12288. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12289. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12290. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12291. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12292. * THE SOFTWARE.
  12293. */
  12294. Object.defineProperty(exports, "__esModule", { value: true });
  12295. var cssClasses = {
  12296. MENU_SELECTED_LIST_ITEM: 'mdc-menu-item--selected',
  12297. MENU_SELECTION_GROUP: 'mdc-menu__selection-group',
  12298. ROOT: 'mdc-menu'
  12299. };
  12300. exports.cssClasses = cssClasses;
  12301. var strings = {
  12302. ARIA_CHECKED_ATTR: 'aria-checked',
  12303. ARIA_DISABLED_ATTR: 'aria-disabled',
  12304. CHECKBOX_SELECTOR: 'input[type="checkbox"]',
  12305. LIST_SELECTOR: '.mdc-list',
  12306. SELECTED_EVENT: 'MDCMenu:selected'
  12307. };
  12308. exports.strings = strings;
  12309. var numbers = {
  12310. FOCUS_ROOT_INDEX: -1
  12311. };
  12312. exports.numbers = numbers;
  12313. var DefaultFocusState;
  12314. (function (DefaultFocusState) {
  12315. DefaultFocusState[DefaultFocusState["NONE"] = 0] = "NONE";
  12316. DefaultFocusState[DefaultFocusState["LIST_ROOT"] = 1] = "LIST_ROOT";
  12317. DefaultFocusState[DefaultFocusState["FIRST_ITEM"] = 2] = "FIRST_ITEM";
  12318. DefaultFocusState[DefaultFocusState["LAST_ITEM"] = 3] = "LAST_ITEM";
  12319. })(DefaultFocusState || (DefaultFocusState = {}));
  12320. exports.DefaultFocusState = DefaultFocusState;
  12321. /***/ }),
  12322. /***/ "./packages/mdc-menu/foundation.ts":
  12323. /*!*****************************************!*\
  12324. !*** ./packages/mdc-menu/foundation.ts ***!
  12325. \*****************************************/
  12326. /*! no static exports found */
  12327. /***/ (function(module, exports, __webpack_require__) {
  12328. "use strict";
  12329. /**
  12330. * @license
  12331. * Copyright 2018 Google Inc.
  12332. *
  12333. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12334. * of this software and associated documentation files (the "Software"), to deal
  12335. * in the Software without restriction, including without limitation the rights
  12336. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12337. * copies of the Software, and to permit persons to whom the Software is
  12338. * furnished to do so, subject to the following conditions:
  12339. *
  12340. * The above copyright notice and this permission notice shall be included in
  12341. * all copies or substantial portions of the Software.
  12342. *
  12343. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12344. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12345. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12346. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12347. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12348. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12349. * THE SOFTWARE.
  12350. */
  12351. var __extends = this && this.__extends || function () {
  12352. var _extendStatics = function extendStatics(d, b) {
  12353. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  12354. d.__proto__ = b;
  12355. } || function (d, b) {
  12356. for (var p in b) {
  12357. if (b.hasOwnProperty(p)) d[p] = b[p];
  12358. }
  12359. };
  12360. return _extendStatics(d, b);
  12361. };
  12362. return function (d, b) {
  12363. _extendStatics(d, b);
  12364. function __() {
  12365. this.constructor = d;
  12366. }
  12367. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12368. };
  12369. }();
  12370. var __assign = this && this.__assign || function () {
  12371. __assign = Object.assign || function (t) {
  12372. for (var s, i = 1, n = arguments.length; i < n; i++) {
  12373. s = arguments[i];
  12374. for (var p in s) {
  12375. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  12376. }
  12377. }
  12378. return t;
  12379. };
  12380. return __assign.apply(this, arguments);
  12381. };
  12382. Object.defineProperty(exports, "__esModule", { value: true });
  12383. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  12384. var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
  12385. var foundation_2 = __webpack_require__(/*! @material/menu-surface/foundation */ "./packages/mdc-menu-surface/foundation.ts");
  12386. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
  12387. var MDCMenuFoundation = /** @class */function (_super) {
  12388. __extends(MDCMenuFoundation, _super);
  12389. function MDCMenuFoundation(adapter) {
  12390. var _this = _super.call(this, __assign(__assign({}, MDCMenuFoundation.defaultAdapter), adapter)) || this;
  12391. _this.closeAnimationEndTimerId_ = 0;
  12392. _this.defaultFocusState_ = constants_2.DefaultFocusState.LIST_ROOT;
  12393. return _this;
  12394. }
  12395. Object.defineProperty(MDCMenuFoundation, "cssClasses", {
  12396. get: function get() {
  12397. return constants_2.cssClasses;
  12398. },
  12399. enumerable: true,
  12400. configurable: true
  12401. });
  12402. Object.defineProperty(MDCMenuFoundation, "strings", {
  12403. get: function get() {
  12404. return constants_2.strings;
  12405. },
  12406. enumerable: true,
  12407. configurable: true
  12408. });
  12409. Object.defineProperty(MDCMenuFoundation, "numbers", {
  12410. get: function get() {
  12411. return constants_2.numbers;
  12412. },
  12413. enumerable: true,
  12414. configurable: true
  12415. });
  12416. Object.defineProperty(MDCMenuFoundation, "defaultAdapter", {
  12417. /**
  12418. * @see {@link MDCMenuAdapter} for typing information on parameters and return types.
  12419. */
  12420. get: function get() {
  12421. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  12422. return {
  12423. addClassToElementAtIndex: function addClassToElementAtIndex() {
  12424. return undefined;
  12425. },
  12426. removeClassFromElementAtIndex: function removeClassFromElementAtIndex() {
  12427. return undefined;
  12428. },
  12429. addAttributeToElementAtIndex: function addAttributeToElementAtIndex() {
  12430. return undefined;
  12431. },
  12432. removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex() {
  12433. return undefined;
  12434. },
  12435. elementContainsClass: function elementContainsClass() {
  12436. return false;
  12437. },
  12438. closeSurface: function closeSurface() {
  12439. return undefined;
  12440. },
  12441. getElementIndex: function getElementIndex() {
  12442. return -1;
  12443. },
  12444. notifySelected: function notifySelected() {
  12445. return undefined;
  12446. },
  12447. getMenuItemCount: function getMenuItemCount() {
  12448. return 0;
  12449. },
  12450. focusItemAtIndex: function focusItemAtIndex() {
  12451. return undefined;
  12452. },
  12453. focusListRoot: function focusListRoot() {
  12454. return undefined;
  12455. },
  12456. getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex() {
  12457. return -1;
  12458. },
  12459. isSelectableItemAtIndex: function isSelectableItemAtIndex() {
  12460. return false;
  12461. }
  12462. };
  12463. // tslint:enable:object-literal-sort-keys
  12464. },
  12465. enumerable: true,
  12466. configurable: true
  12467. });
  12468. MDCMenuFoundation.prototype.destroy = function () {
  12469. if (this.closeAnimationEndTimerId_) {
  12470. clearTimeout(this.closeAnimationEndTimerId_);
  12471. }
  12472. this.adapter.closeSurface();
  12473. };
  12474. MDCMenuFoundation.prototype.handleKeydown = function (evt) {
  12475. var key = evt.key,
  12476. keyCode = evt.keyCode;
  12477. var isTab = key === 'Tab' || keyCode === 9;
  12478. if (isTab) {
  12479. this.adapter.closeSurface( /** skipRestoreFocus */true);
  12480. }
  12481. };
  12482. MDCMenuFoundation.prototype.handleItemAction = function (listItem) {
  12483. var _this = this;
  12484. var index = this.adapter.getElementIndex(listItem);
  12485. if (index < 0) {
  12486. return;
  12487. }
  12488. this.adapter.notifySelected({ index: index });
  12489. this.adapter.closeSurface();
  12490. // Wait for the menu to close before adding/removing classes that affect styles.
  12491. this.closeAnimationEndTimerId_ = setTimeout(function () {
  12492. // Recompute the index in case the menu contents have changed.
  12493. var recomputedIndex = _this.adapter.getElementIndex(listItem);
  12494. if (recomputedIndex >= 0 && _this.adapter.isSelectableItemAtIndex(recomputedIndex)) {
  12495. _this.setSelectedIndex(recomputedIndex);
  12496. }
  12497. }, foundation_2.MDCMenuSurfaceFoundation.numbers.TRANSITION_CLOSE_DURATION);
  12498. };
  12499. MDCMenuFoundation.prototype.handleMenuSurfaceOpened = function () {
  12500. switch (this.defaultFocusState_) {
  12501. case constants_2.DefaultFocusState.FIRST_ITEM:
  12502. this.adapter.focusItemAtIndex(0);
  12503. break;
  12504. case constants_2.DefaultFocusState.LAST_ITEM:
  12505. this.adapter.focusItemAtIndex(this.adapter.getMenuItemCount() - 1);
  12506. break;
  12507. case constants_2.DefaultFocusState.NONE:
  12508. // Do nothing.
  12509. break;
  12510. default:
  12511. this.adapter.focusListRoot();
  12512. break;
  12513. }
  12514. };
  12515. /**
  12516. * Sets default focus state where the menu should focus every time when menu
  12517. * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
  12518. * default.
  12519. */
  12520. MDCMenuFoundation.prototype.setDefaultFocusState = function (focusState) {
  12521. this.defaultFocusState_ = focusState;
  12522. };
  12523. /**
  12524. * Selects the list item at `index` within the menu.
  12525. * @param index Index of list item within the menu.
  12526. */
  12527. MDCMenuFoundation.prototype.setSelectedIndex = function (index) {
  12528. this.validatedIndex_(index);
  12529. if (!this.adapter.isSelectableItemAtIndex(index)) {
  12530. throw new Error('MDCMenuFoundation: No selection group at specified index.');
  12531. }
  12532. var prevSelectedIndex = this.adapter.getSelectedSiblingOfItemAtIndex(index);
  12533. if (prevSelectedIndex >= 0) {
  12534. this.adapter.removeAttributeFromElementAtIndex(prevSelectedIndex, constants_2.strings.ARIA_CHECKED_ATTR);
  12535. this.adapter.removeClassFromElementAtIndex(prevSelectedIndex, constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
  12536. }
  12537. this.adapter.addClassToElementAtIndex(index, constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
  12538. this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_CHECKED_ATTR, 'true');
  12539. };
  12540. /**
  12541. * Sets the enabled state to isEnabled for the menu item at the given index.
  12542. * @param index Index of the menu item
  12543. * @param isEnabled The desired enabled state of the menu item.
  12544. */
  12545. MDCMenuFoundation.prototype.setEnabled = function (index, isEnabled) {
  12546. this.validatedIndex_(index);
  12547. if (isEnabled) {
  12548. this.adapter.removeClassFromElementAtIndex(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  12549. this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_DISABLED_ATTR, 'false');
  12550. } else {
  12551. this.adapter.addClassToElementAtIndex(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  12552. this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_DISABLED_ATTR, 'true');
  12553. }
  12554. };
  12555. MDCMenuFoundation.prototype.validatedIndex_ = function (index) {
  12556. var menuSize = this.adapter.getMenuItemCount();
  12557. var isIndexInRange = index >= 0 && index < menuSize;
  12558. if (!isIndexInRange) {
  12559. throw new Error('MDCMenuFoundation: No list item at specified index.');
  12560. }
  12561. };
  12562. return MDCMenuFoundation;
  12563. }(foundation_1.MDCFoundation);
  12564. exports.MDCMenuFoundation = MDCMenuFoundation;
  12565. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  12566. exports.default = MDCMenuFoundation;
  12567. /***/ }),
  12568. /***/ "./packages/mdc-menu/index.ts":
  12569. /*!************************************!*\
  12570. !*** ./packages/mdc-menu/index.ts ***!
  12571. \************************************/
  12572. /*! no static exports found */
  12573. /***/ (function(module, exports, __webpack_require__) {
  12574. "use strict";
  12575. /**
  12576. * @license
  12577. * Copyright 2019 Google Inc.
  12578. *
  12579. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12580. * of this software and associated documentation files (the "Software"), to deal
  12581. * in the Software without restriction, including without limitation the rights
  12582. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12583. * copies of the Software, and to permit persons to whom the Software is
  12584. * furnished to do so, subject to the following conditions:
  12585. *
  12586. * The above copyright notice and this permission notice shall be included in
  12587. * all copies or substantial portions of the Software.
  12588. *
  12589. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12590. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12591. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12592. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12593. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12594. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12595. * THE SOFTWARE.
  12596. */
  12597. function __export(m) {
  12598. for (var p in m) {
  12599. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  12600. }
  12601. }
  12602. Object.defineProperty(exports, "__esModule", { value: true });
  12603. var constants_1 = __webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts"); // for backward compatibility
  12604. exports.Corner = constants_1.Corner;
  12605. __export(__webpack_require__(/*! ./component */ "./packages/mdc-menu/component.ts"));
  12606. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts"));
  12607. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts"));
  12608. /***/ }),
  12609. /***/ "./packages/mdc-notched-outline/component.ts":
  12610. /*!***************************************************!*\
  12611. !*** ./packages/mdc-notched-outline/component.ts ***!
  12612. \***************************************************/
  12613. /*! no static exports found */
  12614. /***/ (function(module, exports, __webpack_require__) {
  12615. "use strict";
  12616. /**
  12617. * @license
  12618. * Copyright 2017 Google Inc.
  12619. *
  12620. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12621. * of this software and associated documentation files (the "Software"), to deal
  12622. * in the Software without restriction, including without limitation the rights
  12623. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12624. * copies of the Software, and to permit persons to whom the Software is
  12625. * furnished to do so, subject to the following conditions:
  12626. *
  12627. * The above copyright notice and this permission notice shall be included in
  12628. * all copies or substantial portions of the Software.
  12629. *
  12630. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12631. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12632. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12633. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12634. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12635. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12636. * THE SOFTWARE.
  12637. */
  12638. var __extends = this && this.__extends || function () {
  12639. var _extendStatics = function extendStatics(d, b) {
  12640. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  12641. d.__proto__ = b;
  12642. } || function (d, b) {
  12643. for (var p in b) {
  12644. if (b.hasOwnProperty(p)) d[p] = b[p];
  12645. }
  12646. };
  12647. return _extendStatics(d, b);
  12648. };
  12649. return function (d, b) {
  12650. _extendStatics(d, b);
  12651. function __() {
  12652. this.constructor = d;
  12653. }
  12654. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12655. };
  12656. }();
  12657. Object.defineProperty(exports, "__esModule", { value: true });
  12658. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  12659. var foundation_1 = __webpack_require__(/*! @material/floating-label/foundation */ "./packages/mdc-floating-label/foundation.ts");
  12660. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts");
  12661. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-notched-outline/foundation.ts");
  12662. var MDCNotchedOutline = /** @class */function (_super) {
  12663. __extends(MDCNotchedOutline, _super);
  12664. function MDCNotchedOutline() {
  12665. return _super !== null && _super.apply(this, arguments) || this;
  12666. }
  12667. MDCNotchedOutline.attachTo = function (root) {
  12668. return new MDCNotchedOutline(root);
  12669. };
  12670. MDCNotchedOutline.prototype.initialSyncWithDOM = function () {
  12671. this.notchElement_ = this.root.querySelector(constants_1.strings.NOTCH_ELEMENT_SELECTOR);
  12672. var label = this.root.querySelector('.' + foundation_1.MDCFloatingLabelFoundation.cssClasses.ROOT);
  12673. if (label) {
  12674. label.style.transitionDuration = '0s';
  12675. this.root.classList.add(constants_1.cssClasses.OUTLINE_UPGRADED);
  12676. requestAnimationFrame(function () {
  12677. label.style.transitionDuration = '';
  12678. });
  12679. } else {
  12680. this.root.classList.add(constants_1.cssClasses.NO_LABEL);
  12681. }
  12682. };
  12683. /**
  12684. * Updates classes and styles to open the notch to the specified width.
  12685. * @param notchWidth The notch width in the outline.
  12686. */
  12687. MDCNotchedOutline.prototype.notch = function (notchWidth) {
  12688. this.foundation.notch(notchWidth);
  12689. };
  12690. /**
  12691. * Updates classes and styles to close the notch.
  12692. */
  12693. MDCNotchedOutline.prototype.closeNotch = function () {
  12694. this.foundation.closeNotch();
  12695. };
  12696. MDCNotchedOutline.prototype.getDefaultFoundation = function () {
  12697. var _this = this;
  12698. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  12699. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  12700. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  12701. var adapter = {
  12702. addClass: function addClass(className) {
  12703. return _this.root.classList.add(className);
  12704. },
  12705. removeClass: function removeClass(className) {
  12706. return _this.root.classList.remove(className);
  12707. },
  12708. setNotchWidthProperty: function setNotchWidthProperty(width) {
  12709. return _this.notchElement_.style.setProperty('width', width + 'px');
  12710. },
  12711. removeNotchWidthProperty: function removeNotchWidthProperty() {
  12712. return _this.notchElement_.style.removeProperty('width');
  12713. }
  12714. };
  12715. // tslint:enable:object-literal-sort-keys
  12716. return new foundation_2.MDCNotchedOutlineFoundation(adapter);
  12717. };
  12718. return MDCNotchedOutline;
  12719. }(component_1.MDCComponent);
  12720. exports.MDCNotchedOutline = MDCNotchedOutline;
  12721. /***/ }),
  12722. /***/ "./packages/mdc-notched-outline/constants.ts":
  12723. /*!***************************************************!*\
  12724. !*** ./packages/mdc-notched-outline/constants.ts ***!
  12725. \***************************************************/
  12726. /*! no static exports found */
  12727. /***/ (function(module, exports, __webpack_require__) {
  12728. "use strict";
  12729. /**
  12730. * @license
  12731. * Copyright 2018 Google Inc.
  12732. *
  12733. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12734. * of this software and associated documentation files (the "Software"), to deal
  12735. * in the Software without restriction, including without limitation the rights
  12736. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12737. * copies of the Software, and to permit persons to whom the Software is
  12738. * furnished to do so, subject to the following conditions:
  12739. *
  12740. * The above copyright notice and this permission notice shall be included in
  12741. * all copies or substantial portions of the Software.
  12742. *
  12743. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12744. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12745. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12746. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12747. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12748. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12749. * THE SOFTWARE.
  12750. */
  12751. Object.defineProperty(exports, "__esModule", { value: true });
  12752. var strings = {
  12753. NOTCH_ELEMENT_SELECTOR: '.mdc-notched-outline__notch'
  12754. };
  12755. exports.strings = strings;
  12756. var numbers = {
  12757. // This should stay in sync with $mdc-notched-outline-padding * 2.
  12758. NOTCH_ELEMENT_PADDING: 8
  12759. };
  12760. exports.numbers = numbers;
  12761. var cssClasses = {
  12762. NO_LABEL: 'mdc-notched-outline--no-label',
  12763. OUTLINE_NOTCHED: 'mdc-notched-outline--notched',
  12764. OUTLINE_UPGRADED: 'mdc-notched-outline--upgraded'
  12765. };
  12766. exports.cssClasses = cssClasses;
  12767. /***/ }),
  12768. /***/ "./packages/mdc-notched-outline/foundation.ts":
  12769. /*!****************************************************!*\
  12770. !*** ./packages/mdc-notched-outline/foundation.ts ***!
  12771. \****************************************************/
  12772. /*! no static exports found */
  12773. /***/ (function(module, exports, __webpack_require__) {
  12774. "use strict";
  12775. /**
  12776. * @license
  12777. * Copyright 2017 Google Inc.
  12778. *
  12779. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12780. * of this software and associated documentation files (the "Software"), to deal
  12781. * in the Software without restriction, including without limitation the rights
  12782. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12783. * copies of the Software, and to permit persons to whom the Software is
  12784. * furnished to do so, subject to the following conditions:
  12785. *
  12786. * The above copyright notice and this permission notice shall be included in
  12787. * all copies or substantial portions of the Software.
  12788. *
  12789. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12790. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12791. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12792. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12793. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12794. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12795. * THE SOFTWARE.
  12796. */
  12797. var __extends = this && this.__extends || function () {
  12798. var _extendStatics = function extendStatics(d, b) {
  12799. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  12800. d.__proto__ = b;
  12801. } || function (d, b) {
  12802. for (var p in b) {
  12803. if (b.hasOwnProperty(p)) d[p] = b[p];
  12804. }
  12805. };
  12806. return _extendStatics(d, b);
  12807. };
  12808. return function (d, b) {
  12809. _extendStatics(d, b);
  12810. function __() {
  12811. this.constructor = d;
  12812. }
  12813. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12814. };
  12815. }();
  12816. var __assign = this && this.__assign || function () {
  12817. __assign = Object.assign || function (t) {
  12818. for (var s, i = 1, n = arguments.length; i < n; i++) {
  12819. s = arguments[i];
  12820. for (var p in s) {
  12821. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  12822. }
  12823. }
  12824. return t;
  12825. };
  12826. return __assign.apply(this, arguments);
  12827. };
  12828. Object.defineProperty(exports, "__esModule", { value: true });
  12829. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  12830. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts");
  12831. var MDCNotchedOutlineFoundation = /** @class */function (_super) {
  12832. __extends(MDCNotchedOutlineFoundation, _super);
  12833. function MDCNotchedOutlineFoundation(adapter) {
  12834. return _super.call(this, __assign(__assign({}, MDCNotchedOutlineFoundation.defaultAdapter), adapter)) || this;
  12835. }
  12836. Object.defineProperty(MDCNotchedOutlineFoundation, "strings", {
  12837. get: function get() {
  12838. return constants_1.strings;
  12839. },
  12840. enumerable: true,
  12841. configurable: true
  12842. });
  12843. Object.defineProperty(MDCNotchedOutlineFoundation, "cssClasses", {
  12844. get: function get() {
  12845. return constants_1.cssClasses;
  12846. },
  12847. enumerable: true,
  12848. configurable: true
  12849. });
  12850. Object.defineProperty(MDCNotchedOutlineFoundation, "numbers", {
  12851. get: function get() {
  12852. return constants_1.numbers;
  12853. },
  12854. enumerable: true,
  12855. configurable: true
  12856. });
  12857. Object.defineProperty(MDCNotchedOutlineFoundation, "defaultAdapter", {
  12858. /**
  12859. * See {@link MDCNotchedOutlineAdapter} for typing information on parameters and return types.
  12860. */
  12861. get: function get() {
  12862. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  12863. return {
  12864. addClass: function addClass() {
  12865. return undefined;
  12866. },
  12867. removeClass: function removeClass() {
  12868. return undefined;
  12869. },
  12870. setNotchWidthProperty: function setNotchWidthProperty() {
  12871. return undefined;
  12872. },
  12873. removeNotchWidthProperty: function removeNotchWidthProperty() {
  12874. return undefined;
  12875. }
  12876. };
  12877. // tslint:enable:object-literal-sort-keys
  12878. },
  12879. enumerable: true,
  12880. configurable: true
  12881. });
  12882. /**
  12883. * Adds the outline notched selector and updates the notch width calculated based off of notchWidth.
  12884. */
  12885. MDCNotchedOutlineFoundation.prototype.notch = function (notchWidth) {
  12886. var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED;
  12887. if (notchWidth > 0) {
  12888. notchWidth += constants_1.numbers.NOTCH_ELEMENT_PADDING; // Add padding from left/right.
  12889. }
  12890. this.adapter.setNotchWidthProperty(notchWidth);
  12891. this.adapter.addClass(OUTLINE_NOTCHED);
  12892. };
  12893. /**
  12894. * Removes notched outline selector to close the notch in the outline.
  12895. */
  12896. MDCNotchedOutlineFoundation.prototype.closeNotch = function () {
  12897. var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED;
  12898. this.adapter.removeClass(OUTLINE_NOTCHED);
  12899. this.adapter.removeNotchWidthProperty();
  12900. };
  12901. return MDCNotchedOutlineFoundation;
  12902. }(foundation_1.MDCFoundation);
  12903. exports.MDCNotchedOutlineFoundation = MDCNotchedOutlineFoundation;
  12904. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  12905. exports.default = MDCNotchedOutlineFoundation;
  12906. /***/ }),
  12907. /***/ "./packages/mdc-notched-outline/index.ts":
  12908. /*!***********************************************!*\
  12909. !*** ./packages/mdc-notched-outline/index.ts ***!
  12910. \***********************************************/
  12911. /*! no static exports found */
  12912. /***/ (function(module, exports, __webpack_require__) {
  12913. "use strict";
  12914. /**
  12915. * @license
  12916. * Copyright 2019 Google Inc.
  12917. *
  12918. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12919. * of this software and associated documentation files (the "Software"), to deal
  12920. * in the Software without restriction, including without limitation the rights
  12921. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12922. * copies of the Software, and to permit persons to whom the Software is
  12923. * furnished to do so, subject to the following conditions:
  12924. *
  12925. * The above copyright notice and this permission notice shall be included in
  12926. * all copies or substantial portions of the Software.
  12927. *
  12928. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12929. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12930. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12931. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12932. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12933. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12934. * THE SOFTWARE.
  12935. */
  12936. function __export(m) {
  12937. for (var p in m) {
  12938. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  12939. }
  12940. }
  12941. Object.defineProperty(exports, "__esModule", { value: true });
  12942. __export(__webpack_require__(/*! ./component */ "./packages/mdc-notched-outline/component.ts"));
  12943. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts"));
  12944. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-notched-outline/foundation.ts"));
  12945. /***/ }),
  12946. /***/ "./packages/mdc-radio/component.ts":
  12947. /*!*****************************************!*\
  12948. !*** ./packages/mdc-radio/component.ts ***!
  12949. \*****************************************/
  12950. /*! no static exports found */
  12951. /***/ (function(module, exports, __webpack_require__) {
  12952. "use strict";
  12953. /**
  12954. * @license
  12955. * Copyright 2016 Google Inc.
  12956. *
  12957. * Permission is hereby granted, free of charge, to any person obtaining a copy
  12958. * of this software and associated documentation files (the "Software"), to deal
  12959. * in the Software without restriction, including without limitation the rights
  12960. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12961. * copies of the Software, and to permit persons to whom the Software is
  12962. * furnished to do so, subject to the following conditions:
  12963. *
  12964. * The above copyright notice and this permission notice shall be included in
  12965. * all copies or substantial portions of the Software.
  12966. *
  12967. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12968. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12969. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  12970. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  12971. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  12972. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  12973. * THE SOFTWARE.
  12974. */
  12975. var __extends = this && this.__extends || function () {
  12976. var _extendStatics = function extendStatics(d, b) {
  12977. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  12978. d.__proto__ = b;
  12979. } || function (d, b) {
  12980. for (var p in b) {
  12981. if (b.hasOwnProperty(p)) d[p] = b[p];
  12982. }
  12983. };
  12984. return _extendStatics(d, b);
  12985. };
  12986. return function (d, b) {
  12987. _extendStatics(d, b);
  12988. function __() {
  12989. this.constructor = d;
  12990. }
  12991. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12992. };
  12993. }();
  12994. var __assign = this && this.__assign || function () {
  12995. __assign = Object.assign || function (t) {
  12996. for (var s, i = 1, n = arguments.length; i < n; i++) {
  12997. s = arguments[i];
  12998. for (var p in s) {
  12999. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  13000. }
  13001. }
  13002. return t;
  13003. };
  13004. return __assign.apply(this, arguments);
  13005. };
  13006. Object.defineProperty(exports, "__esModule", { value: true });
  13007. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  13008. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  13009. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  13010. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  13011. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-radio/foundation.ts");
  13012. var MDCRadio = /** @class */function (_super) {
  13013. __extends(MDCRadio, _super);
  13014. function MDCRadio() {
  13015. var _this = _super !== null && _super.apply(this, arguments) || this;
  13016. _this.ripple_ = _this.createRipple_();
  13017. return _this;
  13018. }
  13019. MDCRadio.attachTo = function (root) {
  13020. return new MDCRadio(root);
  13021. };
  13022. Object.defineProperty(MDCRadio.prototype, "checked", {
  13023. get: function get() {
  13024. return this.nativeControl_.checked;
  13025. },
  13026. set: function set(checked) {
  13027. this.nativeControl_.checked = checked;
  13028. },
  13029. enumerable: true,
  13030. configurable: true
  13031. });
  13032. Object.defineProperty(MDCRadio.prototype, "disabled", {
  13033. get: function get() {
  13034. return this.nativeControl_.disabled;
  13035. },
  13036. set: function set(disabled) {
  13037. this.foundation.setDisabled(disabled);
  13038. },
  13039. enumerable: true,
  13040. configurable: true
  13041. });
  13042. Object.defineProperty(MDCRadio.prototype, "value", {
  13043. get: function get() {
  13044. return this.nativeControl_.value;
  13045. },
  13046. set: function set(value) {
  13047. this.nativeControl_.value = value;
  13048. },
  13049. enumerable: true,
  13050. configurable: true
  13051. });
  13052. Object.defineProperty(MDCRadio.prototype, "ripple", {
  13053. get: function get() {
  13054. return this.ripple_;
  13055. },
  13056. enumerable: true,
  13057. configurable: true
  13058. });
  13059. MDCRadio.prototype.destroy = function () {
  13060. this.ripple_.destroy();
  13061. _super.prototype.destroy.call(this);
  13062. };
  13063. MDCRadio.prototype.getDefaultFoundation = function () {
  13064. var _this = this;
  13065. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  13066. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  13067. var adapter = {
  13068. addClass: function addClass(className) {
  13069. return _this.root.classList.add(className);
  13070. },
  13071. removeClass: function removeClass(className) {
  13072. return _this.root.classList.remove(className);
  13073. },
  13074. setNativeControlDisabled: function setNativeControlDisabled(disabled) {
  13075. return _this.nativeControl_.disabled = disabled;
  13076. }
  13077. };
  13078. return new foundation_2.MDCRadioFoundation(adapter);
  13079. };
  13080. MDCRadio.prototype.createRipple_ = function () {
  13081. var _this = this;
  13082. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  13083. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  13084. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  13085. var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  13086. return _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
  13087. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  13088. return _this.nativeControl_.removeEventListener(evtType, handler, events_1.applyPassive());
  13089. },
  13090. // Radio buttons technically go "active" whenever there is *any* keyboard interaction.
  13091. // This is not the UI we desire.
  13092. isSurfaceActive: function isSurfaceActive() {
  13093. return false;
  13094. }, isUnbounded: function isUnbounded() {
  13095. return true;
  13096. } });
  13097. // tslint:enable:object-literal-sort-keys
  13098. return new component_2.MDCRipple(this.root, new foundation_1.MDCRippleFoundation(adapter));
  13099. };
  13100. Object.defineProperty(MDCRadio.prototype, "nativeControl_", {
  13101. get: function get() {
  13102. var NATIVE_CONTROL_SELECTOR = foundation_2.MDCRadioFoundation.strings.NATIVE_CONTROL_SELECTOR;
  13103. var el = this.root.querySelector(NATIVE_CONTROL_SELECTOR);
  13104. if (!el) {
  13105. throw new Error("Radio component requires a " + NATIVE_CONTROL_SELECTOR + " element");
  13106. }
  13107. return el;
  13108. },
  13109. enumerable: true,
  13110. configurable: true
  13111. });
  13112. return MDCRadio;
  13113. }(component_1.MDCComponent);
  13114. exports.MDCRadio = MDCRadio;
  13115. /***/ }),
  13116. /***/ "./packages/mdc-radio/constants.ts":
  13117. /*!*****************************************!*\
  13118. !*** ./packages/mdc-radio/constants.ts ***!
  13119. \*****************************************/
  13120. /*! no static exports found */
  13121. /***/ (function(module, exports, __webpack_require__) {
  13122. "use strict";
  13123. /**
  13124. * @license
  13125. * Copyright 2016 Google Inc.
  13126. *
  13127. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13128. * of this software and associated documentation files (the "Software"), to deal
  13129. * in the Software without restriction, including without limitation the rights
  13130. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13131. * copies of the Software, and to permit persons to whom the Software is
  13132. * furnished to do so, subject to the following conditions:
  13133. *
  13134. * The above copyright notice and this permission notice shall be included in
  13135. * all copies or substantial portions of the Software.
  13136. *
  13137. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13138. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13139. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13140. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13141. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13142. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13143. * THE SOFTWARE.
  13144. */
  13145. Object.defineProperty(exports, "__esModule", { value: true });
  13146. var strings = {
  13147. NATIVE_CONTROL_SELECTOR: '.mdc-radio__native-control'
  13148. };
  13149. exports.strings = strings;
  13150. var cssClasses = {
  13151. DISABLED: 'mdc-radio--disabled',
  13152. ROOT: 'mdc-radio'
  13153. };
  13154. exports.cssClasses = cssClasses;
  13155. /***/ }),
  13156. /***/ "./packages/mdc-radio/foundation.ts":
  13157. /*!******************************************!*\
  13158. !*** ./packages/mdc-radio/foundation.ts ***!
  13159. \******************************************/
  13160. /*! no static exports found */
  13161. /***/ (function(module, exports, __webpack_require__) {
  13162. "use strict";
  13163. /**
  13164. * @license
  13165. * Copyright 2016 Google Inc.
  13166. *
  13167. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13168. * of this software and associated documentation files (the "Software"), to deal
  13169. * in the Software without restriction, including without limitation the rights
  13170. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13171. * copies of the Software, and to permit persons to whom the Software is
  13172. * furnished to do so, subject to the following conditions:
  13173. *
  13174. * The above copyright notice and this permission notice shall be included in
  13175. * all copies or substantial portions of the Software.
  13176. *
  13177. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13178. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13179. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13180. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13181. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13182. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13183. * THE SOFTWARE.
  13184. */
  13185. var __extends = this && this.__extends || function () {
  13186. var _extendStatics = function extendStatics(d, b) {
  13187. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  13188. d.__proto__ = b;
  13189. } || function (d, b) {
  13190. for (var p in b) {
  13191. if (b.hasOwnProperty(p)) d[p] = b[p];
  13192. }
  13193. };
  13194. return _extendStatics(d, b);
  13195. };
  13196. return function (d, b) {
  13197. _extendStatics(d, b);
  13198. function __() {
  13199. this.constructor = d;
  13200. }
  13201. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13202. };
  13203. }();
  13204. var __assign = this && this.__assign || function () {
  13205. __assign = Object.assign || function (t) {
  13206. for (var s, i = 1, n = arguments.length; i < n; i++) {
  13207. s = arguments[i];
  13208. for (var p in s) {
  13209. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  13210. }
  13211. }
  13212. return t;
  13213. };
  13214. return __assign.apply(this, arguments);
  13215. };
  13216. Object.defineProperty(exports, "__esModule", { value: true });
  13217. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  13218. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-radio/constants.ts");
  13219. var MDCRadioFoundation = /** @class */function (_super) {
  13220. __extends(MDCRadioFoundation, _super);
  13221. function MDCRadioFoundation(adapter) {
  13222. return _super.call(this, __assign(__assign({}, MDCRadioFoundation.defaultAdapter), adapter)) || this;
  13223. }
  13224. Object.defineProperty(MDCRadioFoundation, "cssClasses", {
  13225. get: function get() {
  13226. return constants_1.cssClasses;
  13227. },
  13228. enumerable: true,
  13229. configurable: true
  13230. });
  13231. Object.defineProperty(MDCRadioFoundation, "strings", {
  13232. get: function get() {
  13233. return constants_1.strings;
  13234. },
  13235. enumerable: true,
  13236. configurable: true
  13237. });
  13238. Object.defineProperty(MDCRadioFoundation, "defaultAdapter", {
  13239. get: function get() {
  13240. return {
  13241. addClass: function addClass() {
  13242. return undefined;
  13243. },
  13244. removeClass: function removeClass() {
  13245. return undefined;
  13246. },
  13247. setNativeControlDisabled: function setNativeControlDisabled() {
  13248. return undefined;
  13249. }
  13250. };
  13251. },
  13252. enumerable: true,
  13253. configurable: true
  13254. });
  13255. MDCRadioFoundation.prototype.setDisabled = function (disabled) {
  13256. var DISABLED = MDCRadioFoundation.cssClasses.DISABLED;
  13257. this.adapter.setNativeControlDisabled(disabled);
  13258. if (disabled) {
  13259. this.adapter.addClass(DISABLED);
  13260. } else {
  13261. this.adapter.removeClass(DISABLED);
  13262. }
  13263. };
  13264. return MDCRadioFoundation;
  13265. }(foundation_1.MDCFoundation);
  13266. exports.MDCRadioFoundation = MDCRadioFoundation;
  13267. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  13268. exports.default = MDCRadioFoundation;
  13269. /***/ }),
  13270. /***/ "./packages/mdc-radio/index.ts":
  13271. /*!*************************************!*\
  13272. !*** ./packages/mdc-radio/index.ts ***!
  13273. \*************************************/
  13274. /*! no static exports found */
  13275. /***/ (function(module, exports, __webpack_require__) {
  13276. "use strict";
  13277. /**
  13278. * @license
  13279. * Copyright 2019 Google Inc.
  13280. *
  13281. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13282. * of this software and associated documentation files (the "Software"), to deal
  13283. * in the Software without restriction, including without limitation the rights
  13284. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13285. * copies of the Software, and to permit persons to whom the Software is
  13286. * furnished to do so, subject to the following conditions:
  13287. *
  13288. * The above copyright notice and this permission notice shall be included in
  13289. * all copies or substantial portions of the Software.
  13290. *
  13291. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13292. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13293. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13294. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13295. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13296. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13297. * THE SOFTWARE.
  13298. */
  13299. function __export(m) {
  13300. for (var p in m) {
  13301. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  13302. }
  13303. }
  13304. Object.defineProperty(exports, "__esModule", { value: true });
  13305. __export(__webpack_require__(/*! ./component */ "./packages/mdc-radio/component.ts"));
  13306. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-radio/constants.ts"));
  13307. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-radio/foundation.ts"));
  13308. /***/ }),
  13309. /***/ "./packages/mdc-ripple/component.ts":
  13310. /*!******************************************!*\
  13311. !*** ./packages/mdc-ripple/component.ts ***!
  13312. \******************************************/
  13313. /*! no static exports found */
  13314. /***/ (function(module, exports, __webpack_require__) {
  13315. "use strict";
  13316. /**
  13317. * @license
  13318. * Copyright 2016 Google Inc.
  13319. *
  13320. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13321. * of this software and associated documentation files (the "Software"), to deal
  13322. * in the Software without restriction, including without limitation the rights
  13323. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13324. * copies of the Software, and to permit persons to whom the Software is
  13325. * furnished to do so, subject to the following conditions:
  13326. *
  13327. * The above copyright notice and this permission notice shall be included in
  13328. * all copies or substantial portions of the Software.
  13329. *
  13330. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13331. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13332. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13333. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13334. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13335. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13336. * THE SOFTWARE.
  13337. */
  13338. var __extends = this && this.__extends || function () {
  13339. var _extendStatics = function extendStatics(d, b) {
  13340. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  13341. d.__proto__ = b;
  13342. } || function (d, b) {
  13343. for (var p in b) {
  13344. if (b.hasOwnProperty(p)) d[p] = b[p];
  13345. }
  13346. };
  13347. return _extendStatics(d, b);
  13348. };
  13349. return function (d, b) {
  13350. _extendStatics(d, b);
  13351. function __() {
  13352. this.constructor = d;
  13353. }
  13354. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13355. };
  13356. }();
  13357. var __importStar = this && this.__importStar || function (mod) {
  13358. if (mod && mod.__esModule) return mod;
  13359. var result = {};
  13360. if (mod != null) for (var k in mod) {
  13361. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  13362. }result["default"] = mod;
  13363. return result;
  13364. };
  13365. Object.defineProperty(exports, "__esModule", { value: true });
  13366. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  13367. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  13368. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  13369. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
  13370. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
  13371. var MDCRipple = /** @class */function (_super) {
  13372. __extends(MDCRipple, _super);
  13373. function MDCRipple() {
  13374. var _this = _super !== null && _super.apply(this, arguments) || this;
  13375. _this.disabled = false;
  13376. return _this;
  13377. }
  13378. MDCRipple.attachTo = function (root, opts) {
  13379. if (opts === void 0) {
  13380. opts = { isUnbounded: undefined };
  13381. }
  13382. var ripple = new MDCRipple(root);
  13383. // Only override unbounded behavior if option is explicitly specified
  13384. if (opts.isUnbounded !== undefined) {
  13385. ripple.unbounded = opts.isUnbounded;
  13386. }
  13387. return ripple;
  13388. };
  13389. MDCRipple.createAdapter = function (instance) {
  13390. return {
  13391. addClass: function addClass(className) {
  13392. return instance.root.classList.add(className);
  13393. },
  13394. browserSupportsCssVars: function browserSupportsCssVars() {
  13395. return util.supportsCssVariables(window);
  13396. },
  13397. computeBoundingRect: function computeBoundingRect() {
  13398. return instance.root.getBoundingClientRect();
  13399. },
  13400. containsEventTarget: function containsEventTarget(target) {
  13401. return instance.root.contains(target);
  13402. },
  13403. deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
  13404. return document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
  13405. },
  13406. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  13407. return instance.root.removeEventListener(evtType, handler, events_1.applyPassive());
  13408. },
  13409. deregisterResizeHandler: function deregisterResizeHandler(handler) {
  13410. return window.removeEventListener('resize', handler);
  13411. },
  13412. getWindowPageOffset: function getWindowPageOffset() {
  13413. return { x: window.pageXOffset, y: window.pageYOffset };
  13414. },
  13415. isSurfaceActive: function isSurfaceActive() {
  13416. return ponyfill_1.matches(instance.root, ':active');
  13417. },
  13418. isSurfaceDisabled: function isSurfaceDisabled() {
  13419. return Boolean(instance.disabled);
  13420. },
  13421. isUnbounded: function isUnbounded() {
  13422. return Boolean(instance.unbounded);
  13423. },
  13424. registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
  13425. return document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
  13426. },
  13427. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  13428. return instance.root.addEventListener(evtType, handler, events_1.applyPassive());
  13429. },
  13430. registerResizeHandler: function registerResizeHandler(handler) {
  13431. return window.addEventListener('resize', handler);
  13432. },
  13433. removeClass: function removeClass(className) {
  13434. return instance.root.classList.remove(className);
  13435. },
  13436. updateCssVariable: function updateCssVariable(varName, value) {
  13437. return instance.root.style.setProperty(varName, value);
  13438. }
  13439. };
  13440. };
  13441. Object.defineProperty(MDCRipple.prototype, "unbounded", {
  13442. get: function get() {
  13443. return Boolean(this.unbounded_);
  13444. },
  13445. set: function set(unbounded) {
  13446. this.unbounded_ = Boolean(unbounded);
  13447. this.setUnbounded_();
  13448. },
  13449. enumerable: true,
  13450. configurable: true
  13451. });
  13452. MDCRipple.prototype.activate = function () {
  13453. this.foundation.activate();
  13454. };
  13455. MDCRipple.prototype.deactivate = function () {
  13456. this.foundation.deactivate();
  13457. };
  13458. MDCRipple.prototype.layout = function () {
  13459. this.foundation.layout();
  13460. };
  13461. MDCRipple.prototype.getDefaultFoundation = function () {
  13462. return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
  13463. };
  13464. MDCRipple.prototype.initialSyncWithDOM = function () {
  13465. var root = this.root;
  13466. this.unbounded = 'mdcRippleIsUnbounded' in root.dataset;
  13467. };
  13468. /**
  13469. * Closure Compiler throws an access control error when directly accessing a
  13470. * protected or private property inside a getter/setter, like unbounded above.
  13471. * By accessing the protected property inside a method, we solve that problem.
  13472. * That's why this function exists.
  13473. */
  13474. MDCRipple.prototype.setUnbounded_ = function () {
  13475. this.foundation.setUnbounded(Boolean(this.unbounded_));
  13476. };
  13477. return MDCRipple;
  13478. }(component_1.MDCComponent);
  13479. exports.MDCRipple = MDCRipple;
  13480. /***/ }),
  13481. /***/ "./packages/mdc-ripple/constants.ts":
  13482. /*!******************************************!*\
  13483. !*** ./packages/mdc-ripple/constants.ts ***!
  13484. \******************************************/
  13485. /*! no static exports found */
  13486. /***/ (function(module, exports, __webpack_require__) {
  13487. "use strict";
  13488. /**
  13489. * @license
  13490. * Copyright 2016 Google Inc.
  13491. *
  13492. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13493. * of this software and associated documentation files (the "Software"), to deal
  13494. * in the Software without restriction, including without limitation the rights
  13495. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13496. * copies of the Software, and to permit persons to whom the Software is
  13497. * furnished to do so, subject to the following conditions:
  13498. *
  13499. * The above copyright notice and this permission notice shall be included in
  13500. * all copies or substantial portions of the Software.
  13501. *
  13502. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13503. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13504. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13505. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13506. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13507. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13508. * THE SOFTWARE.
  13509. */
  13510. Object.defineProperty(exports, "__esModule", { value: true });
  13511. exports.cssClasses = {
  13512. // Ripple is a special case where the "root" component is really a "mixin" of sorts,
  13513. // given that it's an 'upgrade' to an existing component. That being said it is the root
  13514. // CSS class that all other CSS classes derive from.
  13515. BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
  13516. FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
  13517. FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
  13518. ROOT: 'mdc-ripple-upgraded',
  13519. UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
  13520. };
  13521. exports.strings = {
  13522. VAR_FG_SCALE: '--mdc-ripple-fg-scale',
  13523. VAR_FG_SIZE: '--mdc-ripple-fg-size',
  13524. VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
  13525. VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
  13526. VAR_LEFT: '--mdc-ripple-left',
  13527. VAR_TOP: '--mdc-ripple-top'
  13528. };
  13529. exports.numbers = {
  13530. DEACTIVATION_TIMEOUT_MS: 225,
  13531. FG_DEACTIVATION_MS: 150,
  13532. INITIAL_ORIGIN_SCALE: 0.6,
  13533. PADDING: 10,
  13534. TAP_DELAY_MS: 300
  13535. };
  13536. /***/ }),
  13537. /***/ "./packages/mdc-ripple/foundation.ts":
  13538. /*!*******************************************!*\
  13539. !*** ./packages/mdc-ripple/foundation.ts ***!
  13540. \*******************************************/
  13541. /*! no static exports found */
  13542. /***/ (function(module, exports, __webpack_require__) {
  13543. "use strict";
  13544. /**
  13545. * @license
  13546. * Copyright 2016 Google Inc.
  13547. *
  13548. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13549. * of this software and associated documentation files (the "Software"), to deal
  13550. * in the Software without restriction, including without limitation the rights
  13551. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13552. * copies of the Software, and to permit persons to whom the Software is
  13553. * furnished to do so, subject to the following conditions:
  13554. *
  13555. * The above copyright notice and this permission notice shall be included in
  13556. * all copies or substantial portions of the Software.
  13557. *
  13558. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13559. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13560. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13561. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  13562. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  13563. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  13564. * THE SOFTWARE.
  13565. */
  13566. var __extends = this && this.__extends || function () {
  13567. var _extendStatics = function extendStatics(d, b) {
  13568. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  13569. d.__proto__ = b;
  13570. } || function (d, b) {
  13571. for (var p in b) {
  13572. if (b.hasOwnProperty(p)) d[p] = b[p];
  13573. }
  13574. };
  13575. return _extendStatics(d, b);
  13576. };
  13577. return function (d, b) {
  13578. _extendStatics(d, b);
  13579. function __() {
  13580. this.constructor = d;
  13581. }
  13582. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13583. };
  13584. }();
  13585. var __assign = this && this.__assign || function () {
  13586. __assign = Object.assign || function (t) {
  13587. for (var s, i = 1, n = arguments.length; i < n; i++) {
  13588. s = arguments[i];
  13589. for (var p in s) {
  13590. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  13591. }
  13592. }
  13593. return t;
  13594. };
  13595. return __assign.apply(this, arguments);
  13596. };
  13597. Object.defineProperty(exports, "__esModule", { value: true });
  13598. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  13599. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
  13600. var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
  13601. // Activation events registered on the root element of each instance for activation
  13602. var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
  13603. // Deactivation events registered on documentElement when a pointer-related down event occurs
  13604. var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
  13605. // simultaneous nested activations
  13606. var activatedTargets = [];
  13607. var MDCRippleFoundation = /** @class */function (_super) {
  13608. __extends(MDCRippleFoundation, _super);
  13609. function MDCRippleFoundation(adapter) {
  13610. var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
  13611. _this.activationAnimationHasEnded_ = false;
  13612. _this.activationTimer_ = 0;
  13613. _this.fgDeactivationRemovalTimer_ = 0;
  13614. _this.fgScale_ = '0';
  13615. _this.frame_ = { width: 0, height: 0 };
  13616. _this.initialSize_ = 0;
  13617. _this.layoutFrame_ = 0;
  13618. _this.maxRadius_ = 0;
  13619. _this.unboundedCoords_ = { left: 0, top: 0 };
  13620. _this.activationState_ = _this.defaultActivationState_();
  13621. _this.activationTimerCallback_ = function () {
  13622. _this.activationAnimationHasEnded_ = true;
  13623. _this.runDeactivationUXLogicIfReady_();
  13624. };
  13625. _this.activateHandler_ = function (e) {
  13626. return _this.activate_(e);
  13627. };
  13628. _this.deactivateHandler_ = function () {
  13629. return _this.deactivate_();
  13630. };
  13631. _this.focusHandler_ = function () {
  13632. return _this.handleFocus();
  13633. };
  13634. _this.blurHandler_ = function () {
  13635. return _this.handleBlur();
  13636. };
  13637. _this.resizeHandler_ = function () {
  13638. return _this.layout();
  13639. };
  13640. return _this;
  13641. }
  13642. Object.defineProperty(MDCRippleFoundation, "cssClasses", {
  13643. get: function get() {
  13644. return constants_1.cssClasses;
  13645. },
  13646. enumerable: true,
  13647. configurable: true
  13648. });
  13649. Object.defineProperty(MDCRippleFoundation, "strings", {
  13650. get: function get() {
  13651. return constants_1.strings;
  13652. },
  13653. enumerable: true,
  13654. configurable: true
  13655. });
  13656. Object.defineProperty(MDCRippleFoundation, "numbers", {
  13657. get: function get() {
  13658. return constants_1.numbers;
  13659. },
  13660. enumerable: true,
  13661. configurable: true
  13662. });
  13663. Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
  13664. get: function get() {
  13665. return {
  13666. addClass: function addClass() {
  13667. return undefined;
  13668. },
  13669. browserSupportsCssVars: function browserSupportsCssVars() {
  13670. return true;
  13671. },
  13672. computeBoundingRect: function computeBoundingRect() {
  13673. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  13674. },
  13675. containsEventTarget: function containsEventTarget() {
  13676. return true;
  13677. },
  13678. deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
  13679. return undefined;
  13680. },
  13681. deregisterInteractionHandler: function deregisterInteractionHandler() {
  13682. return undefined;
  13683. },
  13684. deregisterResizeHandler: function deregisterResizeHandler() {
  13685. return undefined;
  13686. },
  13687. getWindowPageOffset: function getWindowPageOffset() {
  13688. return { x: 0, y: 0 };
  13689. },
  13690. isSurfaceActive: function isSurfaceActive() {
  13691. return true;
  13692. },
  13693. isSurfaceDisabled: function isSurfaceDisabled() {
  13694. return true;
  13695. },
  13696. isUnbounded: function isUnbounded() {
  13697. return true;
  13698. },
  13699. registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
  13700. return undefined;
  13701. },
  13702. registerInteractionHandler: function registerInteractionHandler() {
  13703. return undefined;
  13704. },
  13705. registerResizeHandler: function registerResizeHandler() {
  13706. return undefined;
  13707. },
  13708. removeClass: function removeClass() {
  13709. return undefined;
  13710. },
  13711. updateCssVariable: function updateCssVariable() {
  13712. return undefined;
  13713. }
  13714. };
  13715. },
  13716. enumerable: true,
  13717. configurable: true
  13718. });
  13719. MDCRippleFoundation.prototype.init = function () {
  13720. var _this = this;
  13721. var supportsPressRipple = this.supportsPressRipple_();
  13722. this.registerRootHandlers_(supportsPressRipple);
  13723. if (supportsPressRipple) {
  13724. var _a = MDCRippleFoundation.cssClasses,
  13725. ROOT_1 = _a.ROOT,
  13726. UNBOUNDED_1 = _a.UNBOUNDED;
  13727. requestAnimationFrame(function () {
  13728. _this.adapter.addClass(ROOT_1);
  13729. if (_this.adapter.isUnbounded()) {
  13730. _this.adapter.addClass(UNBOUNDED_1);
  13731. // Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple
  13732. _this.layoutInternal_();
  13733. }
  13734. });
  13735. }
  13736. };
  13737. MDCRippleFoundation.prototype.destroy = function () {
  13738. var _this = this;
  13739. if (this.supportsPressRipple_()) {
  13740. if (this.activationTimer_) {
  13741. clearTimeout(this.activationTimer_);
  13742. this.activationTimer_ = 0;
  13743. this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
  13744. }
  13745. if (this.fgDeactivationRemovalTimer_) {
  13746. clearTimeout(this.fgDeactivationRemovalTimer_);
  13747. this.fgDeactivationRemovalTimer_ = 0;
  13748. this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
  13749. }
  13750. var _a = MDCRippleFoundation.cssClasses,
  13751. ROOT_2 = _a.ROOT,
  13752. UNBOUNDED_2 = _a.UNBOUNDED;
  13753. requestAnimationFrame(function () {
  13754. _this.adapter.removeClass(ROOT_2);
  13755. _this.adapter.removeClass(UNBOUNDED_2);
  13756. _this.removeCssVars_();
  13757. });
  13758. }
  13759. this.deregisterRootHandlers_();
  13760. this.deregisterDeactivationHandlers_();
  13761. };
  13762. /**
  13763. * @param evt Optional event containing position information.
  13764. */
  13765. MDCRippleFoundation.prototype.activate = function (evt) {
  13766. this.activate_(evt);
  13767. };
  13768. MDCRippleFoundation.prototype.deactivate = function () {
  13769. this.deactivate_();
  13770. };
  13771. MDCRippleFoundation.prototype.layout = function () {
  13772. var _this = this;
  13773. if (this.layoutFrame_) {
  13774. cancelAnimationFrame(this.layoutFrame_);
  13775. }
  13776. this.layoutFrame_ = requestAnimationFrame(function () {
  13777. _this.layoutInternal_();
  13778. _this.layoutFrame_ = 0;
  13779. });
  13780. };
  13781. MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
  13782. var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
  13783. if (unbounded) {
  13784. this.adapter.addClass(UNBOUNDED);
  13785. } else {
  13786. this.adapter.removeClass(UNBOUNDED);
  13787. }
  13788. };
  13789. MDCRippleFoundation.prototype.handleFocus = function () {
  13790. var _this = this;
  13791. requestAnimationFrame(function () {
  13792. return _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  13793. });
  13794. };
  13795. MDCRippleFoundation.prototype.handleBlur = function () {
  13796. var _this = this;
  13797. requestAnimationFrame(function () {
  13798. return _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  13799. });
  13800. };
  13801. /**
  13802. * We compute this property so that we are not querying information about the client
  13803. * until the point in time where the foundation requests it. This prevents scenarios where
  13804. * client-side feature-detection may happen too early, such as when components are rendered on the server
  13805. * and then initialized at mount time on the client.
  13806. */
  13807. MDCRippleFoundation.prototype.supportsPressRipple_ = function () {
  13808. return this.adapter.browserSupportsCssVars();
  13809. };
  13810. MDCRippleFoundation.prototype.defaultActivationState_ = function () {
  13811. return {
  13812. activationEvent: undefined,
  13813. hasDeactivationUXRun: false,
  13814. isActivated: false,
  13815. isProgrammatic: false,
  13816. wasActivatedByPointer: false,
  13817. wasElementMadeActive: false
  13818. };
  13819. };
  13820. /**
  13821. * supportsPressRipple Passed from init to save a redundant function call
  13822. */
  13823. MDCRippleFoundation.prototype.registerRootHandlers_ = function (supportsPressRipple) {
  13824. var _this = this;
  13825. if (supportsPressRipple) {
  13826. ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  13827. _this.adapter.registerInteractionHandler(evtType, _this.activateHandler_);
  13828. });
  13829. if (this.adapter.isUnbounded()) {
  13830. this.adapter.registerResizeHandler(this.resizeHandler_);
  13831. }
  13832. }
  13833. this.adapter.registerInteractionHandler('focus', this.focusHandler_);
  13834. this.adapter.registerInteractionHandler('blur', this.blurHandler_);
  13835. };
  13836. MDCRippleFoundation.prototype.registerDeactivationHandlers_ = function (evt) {
  13837. var _this = this;
  13838. if (evt.type === 'keydown') {
  13839. this.adapter.registerInteractionHandler('keyup', this.deactivateHandler_);
  13840. } else {
  13841. POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  13842. _this.adapter.registerDocumentInteractionHandler(evtType, _this.deactivateHandler_);
  13843. });
  13844. }
  13845. };
  13846. MDCRippleFoundation.prototype.deregisterRootHandlers_ = function () {
  13847. var _this = this;
  13848. ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  13849. _this.adapter.deregisterInteractionHandler(evtType, _this.activateHandler_);
  13850. });
  13851. this.adapter.deregisterInteractionHandler('focus', this.focusHandler_);
  13852. this.adapter.deregisterInteractionHandler('blur', this.blurHandler_);
  13853. if (this.adapter.isUnbounded()) {
  13854. this.adapter.deregisterResizeHandler(this.resizeHandler_);
  13855. }
  13856. };
  13857. MDCRippleFoundation.prototype.deregisterDeactivationHandlers_ = function () {
  13858. var _this = this;
  13859. this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler_);
  13860. POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
  13861. _this.adapter.deregisterDocumentInteractionHandler(evtType, _this.deactivateHandler_);
  13862. });
  13863. };
  13864. MDCRippleFoundation.prototype.removeCssVars_ = function () {
  13865. var _this = this;
  13866. var rippleStrings = MDCRippleFoundation.strings;
  13867. var keys = Object.keys(rippleStrings);
  13868. keys.forEach(function (key) {
  13869. if (key.indexOf('VAR_') === 0) {
  13870. _this.adapter.updateCssVariable(rippleStrings[key], null);
  13871. }
  13872. });
  13873. };
  13874. MDCRippleFoundation.prototype.activate_ = function (evt) {
  13875. var _this = this;
  13876. if (this.adapter.isSurfaceDisabled()) {
  13877. return;
  13878. }
  13879. var activationState = this.activationState_;
  13880. if (activationState.isActivated) {
  13881. return;
  13882. }
  13883. // Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
  13884. var previousActivationEvent = this.previousActivationEvent_;
  13885. var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
  13886. if (isSameInteraction) {
  13887. return;
  13888. }
  13889. activationState.isActivated = true;
  13890. activationState.isProgrammatic = evt === undefined;
  13891. activationState.activationEvent = evt;
  13892. activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
  13893. var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
  13894. return _this.adapter.containsEventTarget(target);
  13895. });
  13896. if (hasActivatedChild) {
  13897. // Immediately reset activation state, while preserving logic that prevents touch follow-on events
  13898. this.resetActivationState_();
  13899. return;
  13900. }
  13901. if (evt !== undefined) {
  13902. activatedTargets.push(evt.target);
  13903. this.registerDeactivationHandlers_(evt);
  13904. }
  13905. activationState.wasElementMadeActive = this.checkElementMadeActive_(evt);
  13906. if (activationState.wasElementMadeActive) {
  13907. this.animateActivation_();
  13908. }
  13909. requestAnimationFrame(function () {
  13910. // Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples
  13911. activatedTargets = [];
  13912. if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
  13913. // If space was pressed, try again within an rAF call to detect :active, because different UAs report
  13914. // active states inconsistently when they're called within event handling code:
  13915. // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
  13916. // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
  13917. // We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS
  13918. // variable is set within a rAF callback for a submit button interaction (#2241).
  13919. activationState.wasElementMadeActive = _this.checkElementMadeActive_(evt);
  13920. if (activationState.wasElementMadeActive) {
  13921. _this.animateActivation_();
  13922. }
  13923. }
  13924. if (!activationState.wasElementMadeActive) {
  13925. // Reset activation state immediately if element was not made active.
  13926. _this.activationState_ = _this.defaultActivationState_();
  13927. }
  13928. });
  13929. };
  13930. MDCRippleFoundation.prototype.checkElementMadeActive_ = function (evt) {
  13931. return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
  13932. };
  13933. MDCRippleFoundation.prototype.animateActivation_ = function () {
  13934. var _this = this;
  13935. var _a = MDCRippleFoundation.strings,
  13936. VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
  13937. VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
  13938. var _b = MDCRippleFoundation.cssClasses,
  13939. FG_DEACTIVATION = _b.FG_DEACTIVATION,
  13940. FG_ACTIVATION = _b.FG_ACTIVATION;
  13941. var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
  13942. this.layoutInternal_();
  13943. var translateStart = '';
  13944. var translateEnd = '';
  13945. if (!this.adapter.isUnbounded()) {
  13946. var _c = this.getFgTranslationCoordinates_(),
  13947. startPoint = _c.startPoint,
  13948. endPoint = _c.endPoint;
  13949. translateStart = startPoint.x + "px, " + startPoint.y + "px";
  13950. translateEnd = endPoint.x + "px, " + endPoint.y + "px";
  13951. }
  13952. this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
  13953. this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
  13954. // Cancel any ongoing activation/deactivation animations
  13955. clearTimeout(this.activationTimer_);
  13956. clearTimeout(this.fgDeactivationRemovalTimer_);
  13957. this.rmBoundedActivationClasses_();
  13958. this.adapter.removeClass(FG_DEACTIVATION);
  13959. // Force layout in order to re-trigger the animation.
  13960. this.adapter.computeBoundingRect();
  13961. this.adapter.addClass(FG_ACTIVATION);
  13962. this.activationTimer_ = setTimeout(function () {
  13963. return _this.activationTimerCallback_();
  13964. }, DEACTIVATION_TIMEOUT_MS);
  13965. };
  13966. MDCRippleFoundation.prototype.getFgTranslationCoordinates_ = function () {
  13967. var _a = this.activationState_,
  13968. activationEvent = _a.activationEvent,
  13969. wasActivatedByPointer = _a.wasActivatedByPointer;
  13970. var startPoint;
  13971. if (wasActivatedByPointer) {
  13972. startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
  13973. } else {
  13974. startPoint = {
  13975. x: this.frame_.width / 2,
  13976. y: this.frame_.height / 2
  13977. };
  13978. }
  13979. // Center the element around the start point.
  13980. startPoint = {
  13981. x: startPoint.x - this.initialSize_ / 2,
  13982. y: startPoint.y - this.initialSize_ / 2
  13983. };
  13984. var endPoint = {
  13985. x: this.frame_.width / 2 - this.initialSize_ / 2,
  13986. y: this.frame_.height / 2 - this.initialSize_ / 2
  13987. };
  13988. return { startPoint: startPoint, endPoint: endPoint };
  13989. };
  13990. MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady_ = function () {
  13991. var _this = this;
  13992. // This method is called both when a pointing device is released, and when the activation animation ends.
  13993. // The deactivation animation should only run after both of those occur.
  13994. var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
  13995. var _a = this.activationState_,
  13996. hasDeactivationUXRun = _a.hasDeactivationUXRun,
  13997. isActivated = _a.isActivated;
  13998. var activationHasEnded = hasDeactivationUXRun || !isActivated;
  13999. if (activationHasEnded && this.activationAnimationHasEnded_) {
  14000. this.rmBoundedActivationClasses_();
  14001. this.adapter.addClass(FG_DEACTIVATION);
  14002. this.fgDeactivationRemovalTimer_ = setTimeout(function () {
  14003. _this.adapter.removeClass(FG_DEACTIVATION);
  14004. }, constants_1.numbers.FG_DEACTIVATION_MS);
  14005. }
  14006. };
  14007. MDCRippleFoundation.prototype.rmBoundedActivationClasses_ = function () {
  14008. var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
  14009. this.adapter.removeClass(FG_ACTIVATION);
  14010. this.activationAnimationHasEnded_ = false;
  14011. this.adapter.computeBoundingRect();
  14012. };
  14013. MDCRippleFoundation.prototype.resetActivationState_ = function () {
  14014. var _this = this;
  14015. this.previousActivationEvent_ = this.activationState_.activationEvent;
  14016. this.activationState_ = this.defaultActivationState_();
  14017. // Touch devices may fire additional events for the same interaction within a short time.
  14018. // Store the previous event until it's safe to assume that subsequent events are for new interactions.
  14019. setTimeout(function () {
  14020. return _this.previousActivationEvent_ = undefined;
  14021. }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
  14022. };
  14023. MDCRippleFoundation.prototype.deactivate_ = function () {
  14024. var _this = this;
  14025. var activationState = this.activationState_;
  14026. // This can happen in scenarios such as when you have a keyup event that blurs the element.
  14027. if (!activationState.isActivated) {
  14028. return;
  14029. }
  14030. var state = __assign({}, activationState);
  14031. if (activationState.isProgrammatic) {
  14032. requestAnimationFrame(function () {
  14033. return _this.animateDeactivation_(state);
  14034. });
  14035. this.resetActivationState_();
  14036. } else {
  14037. this.deregisterDeactivationHandlers_();
  14038. requestAnimationFrame(function () {
  14039. _this.activationState_.hasDeactivationUXRun = true;
  14040. _this.animateDeactivation_(state);
  14041. _this.resetActivationState_();
  14042. });
  14043. }
  14044. };
  14045. MDCRippleFoundation.prototype.animateDeactivation_ = function (_a) {
  14046. var wasActivatedByPointer = _a.wasActivatedByPointer,
  14047. wasElementMadeActive = _a.wasElementMadeActive;
  14048. if (wasActivatedByPointer || wasElementMadeActive) {
  14049. this.runDeactivationUXLogicIfReady_();
  14050. }
  14051. };
  14052. MDCRippleFoundation.prototype.layoutInternal_ = function () {
  14053. var _this = this;
  14054. this.frame_ = this.adapter.computeBoundingRect();
  14055. var maxDim = Math.max(this.frame_.height, this.frame_.width);
  14056. // Surface diameter is treated differently for unbounded vs. bounded ripples.
  14057. // Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately
  14058. // to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically
  14059. // square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter
  14060. // (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via
  14061. // `overflow: hidden`.
  14062. var getBoundedRadius = function getBoundedRadius() {
  14063. var hypotenuse = Math.sqrt(Math.pow(_this.frame_.width, 2) + Math.pow(_this.frame_.height, 2));
  14064. return hypotenuse + MDCRippleFoundation.numbers.PADDING;
  14065. };
  14066. this.maxRadius_ = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
  14067. // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform
  14068. var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
  14069. // Unbounded ripple size should always be even number to equally center align.
  14070. if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
  14071. this.initialSize_ = initialSize - 1;
  14072. } else {
  14073. this.initialSize_ = initialSize;
  14074. }
  14075. this.fgScale_ = "" + this.maxRadius_ / this.initialSize_;
  14076. this.updateLayoutCssVars_();
  14077. };
  14078. MDCRippleFoundation.prototype.updateLayoutCssVars_ = function () {
  14079. var _a = MDCRippleFoundation.strings,
  14080. VAR_FG_SIZE = _a.VAR_FG_SIZE,
  14081. VAR_LEFT = _a.VAR_LEFT,
  14082. VAR_TOP = _a.VAR_TOP,
  14083. VAR_FG_SCALE = _a.VAR_FG_SCALE;
  14084. this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize_ + "px");
  14085. this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale_);
  14086. if (this.adapter.isUnbounded()) {
  14087. this.unboundedCoords_ = {
  14088. left: Math.round(this.frame_.width / 2 - this.initialSize_ / 2),
  14089. top: Math.round(this.frame_.height / 2 - this.initialSize_ / 2)
  14090. };
  14091. this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords_.left + "px");
  14092. this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords_.top + "px");
  14093. }
  14094. };
  14095. return MDCRippleFoundation;
  14096. }(foundation_1.MDCFoundation);
  14097. exports.MDCRippleFoundation = MDCRippleFoundation;
  14098. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  14099. exports.default = MDCRippleFoundation;
  14100. /***/ }),
  14101. /***/ "./packages/mdc-ripple/index.ts":
  14102. /*!**************************************!*\
  14103. !*** ./packages/mdc-ripple/index.ts ***!
  14104. \**************************************/
  14105. /*! no static exports found */
  14106. /***/ (function(module, exports, __webpack_require__) {
  14107. "use strict";
  14108. /**
  14109. * @license
  14110. * Copyright 2019 Google Inc.
  14111. *
  14112. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14113. * of this software and associated documentation files (the "Software"), to deal
  14114. * in the Software without restriction, including without limitation the rights
  14115. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14116. * copies of the Software, and to permit persons to whom the Software is
  14117. * furnished to do so, subject to the following conditions:
  14118. *
  14119. * The above copyright notice and this permission notice shall be included in
  14120. * all copies or substantial portions of the Software.
  14121. *
  14122. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14123. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14124. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14125. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14126. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14127. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14128. * THE SOFTWARE.
  14129. */
  14130. function __export(m) {
  14131. for (var p in m) {
  14132. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  14133. }
  14134. }
  14135. var __importStar = this && this.__importStar || function (mod) {
  14136. if (mod && mod.__esModule) return mod;
  14137. var result = {};
  14138. if (mod != null) for (var k in mod) {
  14139. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  14140. }result["default"] = mod;
  14141. return result;
  14142. };
  14143. Object.defineProperty(exports, "__esModule", { value: true });
  14144. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
  14145. exports.util = util;
  14146. __export(__webpack_require__(/*! ./component */ "./packages/mdc-ripple/component.ts"));
  14147. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts"));
  14148. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts"));
  14149. /***/ }),
  14150. /***/ "./packages/mdc-ripple/util.ts":
  14151. /*!*************************************!*\
  14152. !*** ./packages/mdc-ripple/util.ts ***!
  14153. \*************************************/
  14154. /*! no static exports found */
  14155. /***/ (function(module, exports, __webpack_require__) {
  14156. "use strict";
  14157. Object.defineProperty(exports, "__esModule", { value: true });
  14158. /**
  14159. * Stores result from supportsCssVariables to avoid redundant processing to
  14160. * detect CSS custom variable support.
  14161. */
  14162. var supportsCssVariables_;
  14163. function supportsCssVariables(windowObj, forceRefresh) {
  14164. if (forceRefresh === void 0) {
  14165. forceRefresh = false;
  14166. }
  14167. var CSS = windowObj.CSS;
  14168. var supportsCssVars = supportsCssVariables_;
  14169. if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
  14170. return supportsCssVariables_;
  14171. }
  14172. var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
  14173. if (!supportsFunctionPresent) {
  14174. return false;
  14175. }
  14176. var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
  14177. // See: https://bugs.webkit.org/show_bug.cgi?id=154669
  14178. // See: README section on Safari
  14179. var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
  14180. supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
  14181. if (!forceRefresh) {
  14182. supportsCssVariables_ = supportsCssVars;
  14183. }
  14184. return supportsCssVars;
  14185. }
  14186. exports.supportsCssVariables = supportsCssVariables;
  14187. function getNormalizedEventCoords(evt, pageOffset, clientRect) {
  14188. if (!evt) {
  14189. return { x: 0, y: 0 };
  14190. }
  14191. var x = pageOffset.x,
  14192. y = pageOffset.y;
  14193. var documentX = x + clientRect.left;
  14194. var documentY = y + clientRect.top;
  14195. var normalizedX;
  14196. var normalizedY;
  14197. // Determine touch point relative to the ripple container.
  14198. if (evt.type === 'touchstart') {
  14199. var touchEvent = evt;
  14200. normalizedX = touchEvent.changedTouches[0].pageX - documentX;
  14201. normalizedY = touchEvent.changedTouches[0].pageY - documentY;
  14202. } else {
  14203. var mouseEvent = evt;
  14204. normalizedX = mouseEvent.pageX - documentX;
  14205. normalizedY = mouseEvent.pageY - documentY;
  14206. }
  14207. return { x: normalizedX, y: normalizedY };
  14208. }
  14209. exports.getNormalizedEventCoords = getNormalizedEventCoords;
  14210. /***/ }),
  14211. /***/ "./packages/mdc-segmented-button/index.ts":
  14212. /*!************************************************!*\
  14213. !*** ./packages/mdc-segmented-button/index.ts ***!
  14214. \************************************************/
  14215. /*! no static exports found */
  14216. /***/ (function(module, exports, __webpack_require__) {
  14217. "use strict";
  14218. /**
  14219. * @license
  14220. * Copyright 2020 Google Inc.
  14221. *
  14222. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14223. * of this software and associated documentation files (the "Software"), to deal
  14224. * in the Software without restriction, including without limitation the rights
  14225. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14226. * copies of the Software, and to permit persons to whom the Software is
  14227. * furnished to do so, subject to the following conditions:
  14228. *
  14229. * The above copyright notice and this permission notice shall be included in
  14230. * all copies or substantial portions of the Software.
  14231. *
  14232. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14233. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14234. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14235. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14236. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14237. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14238. * THE SOFTWARE.
  14239. */
  14240. function __export(m) {
  14241. for (var p in m) {
  14242. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  14243. }
  14244. }
  14245. Object.defineProperty(exports, "__esModule", { value: true });
  14246. __export(__webpack_require__(/*! ./segmented-button/index */ "./packages/mdc-segmented-button/segmented-button/index.ts"));
  14247. __export(__webpack_require__(/*! ./segment/index */ "./packages/mdc-segmented-button/segment/index.ts"));
  14248. /***/ }),
  14249. /***/ "./packages/mdc-segmented-button/segment/component.ts":
  14250. /*!************************************************************!*\
  14251. !*** ./packages/mdc-segmented-button/segment/component.ts ***!
  14252. \************************************************************/
  14253. /*! no static exports found */
  14254. /***/ (function(module, exports, __webpack_require__) {
  14255. "use strict";
  14256. /**
  14257. * @license
  14258. * Copyright 2020 Google Inc.
  14259. *
  14260. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14261. * of this software and associated documentation files (the "Software"), to deal
  14262. * in the Software without restriction, including without limitation the rights
  14263. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14264. * copies of the Software, and to permit persons to whom the Software is
  14265. * furnished to do so, subject to the following conditions:
  14266. *
  14267. * The above copyright notice and this permission notice shall be included in
  14268. * all copies or substantial portions of the Software.
  14269. *
  14270. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14271. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14272. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14273. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14274. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14275. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14276. * THE SOFTWARE.
  14277. */
  14278. var __extends = this && this.__extends || function () {
  14279. var _extendStatics = function extendStatics(d, b) {
  14280. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  14281. d.__proto__ = b;
  14282. } || function (d, b) {
  14283. for (var p in b) {
  14284. if (b.hasOwnProperty(p)) d[p] = b[p];
  14285. }
  14286. };
  14287. return _extendStatics(d, b);
  14288. };
  14289. return function (d, b) {
  14290. _extendStatics(d, b);
  14291. function __() {
  14292. this.constructor = d;
  14293. }
  14294. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14295. };
  14296. }();
  14297. var __assign = this && this.__assign || function () {
  14298. __assign = Object.assign || function (t) {
  14299. for (var s, i = 1, n = arguments.length; i < n; i++) {
  14300. s = arguments[i];
  14301. for (var p in s) {
  14302. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  14303. }
  14304. }
  14305. return t;
  14306. };
  14307. return __assign.apply(this, arguments);
  14308. };
  14309. Object.defineProperty(exports, "__esModule", { value: true });
  14310. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  14311. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  14312. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  14313. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segment/constants.ts");
  14314. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segment/foundation.ts");
  14315. /**
  14316. * Implementation of MDCSegmentedButtonSegmentFoundation
  14317. */
  14318. var MDCSegmentedButtonSegment = /** @class */function (_super) {
  14319. __extends(MDCSegmentedButtonSegment, _super);
  14320. function MDCSegmentedButtonSegment() {
  14321. return _super !== null && _super.apply(this, arguments) || this;
  14322. }
  14323. Object.defineProperty(MDCSegmentedButtonSegment.prototype, "ripple", {
  14324. get: function get() {
  14325. return this.rippleComponent;
  14326. },
  14327. enumerable: true,
  14328. configurable: true
  14329. });
  14330. MDCSegmentedButtonSegment.attachTo = function (root) {
  14331. return new MDCSegmentedButtonSegment(root);
  14332. };
  14333. MDCSegmentedButtonSegment.prototype.initialize = function (rippleFactory) {
  14334. var _this = this;
  14335. if (rippleFactory === void 0) {
  14336. rippleFactory = function rippleFactory(el, foundation) {
  14337. return new component_2.MDCRipple(el, foundation);
  14338. };
  14339. }
  14340. var rippleAdapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { computeBoundingRect: function computeBoundingRect() {
  14341. return _this.foundation.getDimensions();
  14342. } });
  14343. this.rippleComponent = rippleFactory(this.root, new foundation_1.MDCRippleFoundation(rippleAdapter));
  14344. };
  14345. MDCSegmentedButtonSegment.prototype.initialSyncWithDOM = function () {
  14346. var _this = this;
  14347. this.handleClick = function () {
  14348. _this.foundation.handleClick();
  14349. };
  14350. this.listen(constants_1.events.CLICK, this.handleClick);
  14351. };
  14352. MDCSegmentedButtonSegment.prototype.destroy = function () {
  14353. this.ripple.destroy();
  14354. this.unlisten(constants_1.events.CLICK, this.handleClick);
  14355. _super.prototype.destroy.call(this);
  14356. };
  14357. MDCSegmentedButtonSegment.prototype.getDefaultFoundation = function () {
  14358. var _this = this;
  14359. // DO NOT INLINE this variable. For backward compatibility, foundations take
  14360. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  14361. // methods, we need a separate, strongly typed adapter variable.
  14362. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  14363. var adapter = {
  14364. isSingleSelect: function isSingleSelect() {
  14365. return _this.isSingleSelect;
  14366. },
  14367. getAttr: function getAttr(attrName) {
  14368. return _this.root.getAttribute(attrName);
  14369. },
  14370. setAttr: function setAttr(attrName, value) {
  14371. _this.root.setAttribute(attrName, value);
  14372. },
  14373. addClass: function addClass(className) {
  14374. _this.root.classList.add(className);
  14375. },
  14376. removeClass: function removeClass(className) {
  14377. _this.root.classList.remove(className);
  14378. },
  14379. hasClass: function hasClass(className) {
  14380. return _this.root.classList.contains(className);
  14381. },
  14382. notifySelectedChange: function notifySelectedChange(selected) {
  14383. _this.emit(constants_1.events.SELECTED, {
  14384. index: _this.index,
  14385. selected: selected,
  14386. segmentId: _this.getSegmentId()
  14387. }, true /* shouldBubble */);
  14388. },
  14389. getRootBoundingClientRect: function getRootBoundingClientRect() {
  14390. return _this.root.getBoundingClientRect();
  14391. }
  14392. };
  14393. return new foundation_2.MDCSegmentedButtonSegmentFoundation(adapter);
  14394. };
  14395. /**
  14396. * Sets segment's index value
  14397. *
  14398. * @param index Segment's index within wrapping segmented button
  14399. */
  14400. MDCSegmentedButtonSegment.prototype.setIndex = function (index) {
  14401. this.index = index;
  14402. };
  14403. /**
  14404. * Sets segment's isSingleSelect value
  14405. *
  14406. * @param isSingleSelect True if wrapping segmented button is single select
  14407. */
  14408. MDCSegmentedButtonSegment.prototype.setIsSingleSelect = function (isSingleSelect) {
  14409. this.isSingleSelect = isSingleSelect;
  14410. };
  14411. /**
  14412. * @return Returns true if segment is currently selected, otherwise returns
  14413. * false
  14414. */
  14415. MDCSegmentedButtonSegment.prototype.isSelected = function () {
  14416. return this.foundation.isSelected();
  14417. };
  14418. /**
  14419. * Sets segment to be selected
  14420. */
  14421. MDCSegmentedButtonSegment.prototype.setSelected = function () {
  14422. this.foundation.setSelected();
  14423. };
  14424. /**
  14425. * Sets segment to be not selected
  14426. */
  14427. MDCSegmentedButtonSegment.prototype.setUnselected = function () {
  14428. this.foundation.setUnselected();
  14429. };
  14430. /**
  14431. * @return Returns segment's segmentId if it was set by client
  14432. */
  14433. MDCSegmentedButtonSegment.prototype.getSegmentId = function () {
  14434. return this.foundation.getSegmentId();
  14435. };
  14436. return MDCSegmentedButtonSegment;
  14437. }(component_1.MDCComponent);
  14438. exports.MDCSegmentedButtonSegment = MDCSegmentedButtonSegment;
  14439. /***/ }),
  14440. /***/ "./packages/mdc-segmented-button/segment/constants.ts":
  14441. /*!************************************************************!*\
  14442. !*** ./packages/mdc-segmented-button/segment/constants.ts ***!
  14443. \************************************************************/
  14444. /*! no static exports found */
  14445. /***/ (function(module, exports, __webpack_require__) {
  14446. "use strict";
  14447. /**
  14448. * @license
  14449. * Copyright 2020 Google Inc.
  14450. *
  14451. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14452. * of this software and associated documentation files (the "Software"), to deal
  14453. * in the Software without restriction, including without limitation the rights
  14454. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14455. * copies of the Software, and to permit persons to whom the Software is
  14456. * furnished to do so, subject to the following conditions:
  14457. *
  14458. * The above copyright notice and this permission notice shall be included in
  14459. * all copies or substantial portions of the Software.
  14460. *
  14461. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14462. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14463. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14464. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14465. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14466. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14467. * THE SOFTWARE.
  14468. */
  14469. Object.defineProperty(exports, "__esModule", { value: true });
  14470. /**
  14471. * Boolean strings for segment
  14472. */
  14473. exports.booleans = {
  14474. TRUE: 'true',
  14475. FALSE: 'false'
  14476. };
  14477. /**
  14478. * Attributes referenced by segment
  14479. */
  14480. exports.attributes = {
  14481. ARIA_CHECKED: 'aria-checked',
  14482. ARIA_PRESSED: 'aria-pressed',
  14483. DATA_SEGMENT_ID: 'data-segment-id'
  14484. };
  14485. /**
  14486. * Events received or emitted by segment
  14487. */
  14488. exports.events = {
  14489. CLICK: 'click',
  14490. SELECTED: 'selected'
  14491. };
  14492. /**
  14493. * Style classes for segment
  14494. */
  14495. exports.cssClasses = {
  14496. SELECTED: 'mdc-segmented-button__segment--selected'
  14497. };
  14498. /***/ }),
  14499. /***/ "./packages/mdc-segmented-button/segment/foundation.ts":
  14500. /*!*************************************************************!*\
  14501. !*** ./packages/mdc-segmented-button/segment/foundation.ts ***!
  14502. \*************************************************************/
  14503. /*! no static exports found */
  14504. /***/ (function(module, exports, __webpack_require__) {
  14505. "use strict";
  14506. /**
  14507. * @license
  14508. * Copyright 2020 Google Inc.
  14509. *
  14510. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14511. * of this software and associated documentation files (the "Software"), to deal
  14512. * in the Software without restriction, including without limitation the rights
  14513. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14514. * copies of the Software, and to permit persons to whom the Software is
  14515. * furnished to do so, subject to the following conditions:
  14516. *
  14517. * The above copyright notice and this permission notice shall be included in
  14518. * all copies or substantial portions of the Software.
  14519. *
  14520. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14521. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14522. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14523. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14524. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14525. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14526. * THE SOFTWARE.
  14527. */
  14528. var __extends = this && this.__extends || function () {
  14529. var _extendStatics = function extendStatics(d, b) {
  14530. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  14531. d.__proto__ = b;
  14532. } || function (d, b) {
  14533. for (var p in b) {
  14534. if (b.hasOwnProperty(p)) d[p] = b[p];
  14535. }
  14536. };
  14537. return _extendStatics(d, b);
  14538. };
  14539. return function (d, b) {
  14540. _extendStatics(d, b);
  14541. function __() {
  14542. this.constructor = d;
  14543. }
  14544. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14545. };
  14546. }();
  14547. var __assign = this && this.__assign || function () {
  14548. __assign = Object.assign || function (t) {
  14549. for (var s, i = 1, n = arguments.length; i < n; i++) {
  14550. s = arguments[i];
  14551. for (var p in s) {
  14552. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  14553. }
  14554. }
  14555. return t;
  14556. };
  14557. return __assign.apply(this, arguments);
  14558. };
  14559. Object.defineProperty(exports, "__esModule", { value: true });
  14560. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  14561. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segment/constants.ts");
  14562. var emptyClientRect = {
  14563. bottom: 0,
  14564. height: 0,
  14565. left: 0,
  14566. right: 0,
  14567. top: 0,
  14568. width: 0
  14569. };
  14570. var MDCSegmentedButtonSegmentFoundation = /** @class */function (_super) {
  14571. __extends(MDCSegmentedButtonSegmentFoundation, _super);
  14572. function MDCSegmentedButtonSegmentFoundation(adapter) {
  14573. return _super.call(this, __assign(__assign({}, MDCSegmentedButtonSegmentFoundation.defaultAdapter), adapter)) || this;
  14574. }
  14575. Object.defineProperty(MDCSegmentedButtonSegmentFoundation, "defaultAdapter", {
  14576. get: function get() {
  14577. return {
  14578. isSingleSelect: function isSingleSelect() {
  14579. return false;
  14580. }, getAttr: function getAttr() {
  14581. return '';
  14582. }, setAttr: function setAttr() {
  14583. return undefined;
  14584. },
  14585. addClass: function addClass() {
  14586. return undefined;
  14587. }, removeClass: function removeClass() {
  14588. return undefined;
  14589. },
  14590. hasClass: function hasClass() {
  14591. return false;
  14592. },
  14593. notifySelectedChange: function notifySelectedChange() {
  14594. return undefined;
  14595. },
  14596. getRootBoundingClientRect: function getRootBoundingClientRect() {
  14597. return emptyClientRect;
  14598. }
  14599. };
  14600. },
  14601. enumerable: true,
  14602. configurable: true
  14603. });
  14604. /**
  14605. * @return Returns true if segment is currently selected, otherwise returns
  14606. * false
  14607. */
  14608. MDCSegmentedButtonSegmentFoundation.prototype.isSelected = function () {
  14609. return this.adapter.hasClass(constants_1.cssClasses.SELECTED);
  14610. };
  14611. /**
  14612. * Sets segment to be selected
  14613. */
  14614. MDCSegmentedButtonSegmentFoundation.prototype.setSelected = function () {
  14615. this.adapter.addClass(constants_1.cssClasses.SELECTED);
  14616. this.setAriaAttr(constants_1.booleans.TRUE);
  14617. };
  14618. /**
  14619. * Sets segment to be not selected
  14620. */
  14621. MDCSegmentedButtonSegmentFoundation.prototype.setUnselected = function () {
  14622. this.adapter.removeClass(constants_1.cssClasses.SELECTED);
  14623. this.setAriaAttr(constants_1.booleans.FALSE);
  14624. };
  14625. /**
  14626. * @return Returns segment's segmentId if it was set by client
  14627. */
  14628. MDCSegmentedButtonSegmentFoundation.prototype.getSegmentId = function () {
  14629. var _a;
  14630. return (_a = this.adapter.getAttr(constants_1.attributes.DATA_SEGMENT_ID)) !== null && _a !== void 0 ? _a : undefined;
  14631. };
  14632. /**
  14633. * Called when segment is clicked. If the wrapping segmented button is single
  14634. * select, doesn't allow segment to be set to not selected. Otherwise, toggles
  14635. * segment's selected status. Finally, emits event to wrapping segmented
  14636. * button.
  14637. *
  14638. * @event selected With detail - SegmentDetail
  14639. */
  14640. MDCSegmentedButtonSegmentFoundation.prototype.handleClick = function () {
  14641. if (this.adapter.isSingleSelect()) {
  14642. this.setSelected();
  14643. } else {
  14644. this.toggleSelection();
  14645. }
  14646. this.adapter.notifySelectedChange(this.isSelected());
  14647. };
  14648. /**
  14649. * @return Returns bounding rectangle for ripple effect
  14650. */
  14651. MDCSegmentedButtonSegmentFoundation.prototype.getDimensions = function () {
  14652. return this.adapter.getRootBoundingClientRect();
  14653. };
  14654. /**
  14655. * Sets segment from not selected to selected, or selected to not selected
  14656. */
  14657. MDCSegmentedButtonSegmentFoundation.prototype.toggleSelection = function () {
  14658. if (this.isSelected()) {
  14659. this.setUnselected();
  14660. } else {
  14661. this.setSelected();
  14662. }
  14663. };
  14664. /**
  14665. * Sets appropriate aria attribute, based on wrapping segmented button's
  14666. * single selected value, to new value
  14667. *
  14668. * @param value Value that represents selected status
  14669. */
  14670. MDCSegmentedButtonSegmentFoundation.prototype.setAriaAttr = function (value) {
  14671. if (this.adapter.isSingleSelect()) {
  14672. this.adapter.setAttr(constants_1.attributes.ARIA_CHECKED, value);
  14673. } else {
  14674. this.adapter.setAttr(constants_1.attributes.ARIA_PRESSED, value);
  14675. }
  14676. };
  14677. return MDCSegmentedButtonSegmentFoundation;
  14678. }(foundation_1.MDCFoundation);
  14679. exports.MDCSegmentedButtonSegmentFoundation = MDCSegmentedButtonSegmentFoundation;
  14680. /***/ }),
  14681. /***/ "./packages/mdc-segmented-button/segment/index.ts":
  14682. /*!********************************************************!*\
  14683. !*** ./packages/mdc-segmented-button/segment/index.ts ***!
  14684. \********************************************************/
  14685. /*! no static exports found */
  14686. /***/ (function(module, exports, __webpack_require__) {
  14687. "use strict";
  14688. /**
  14689. * @license
  14690. * Copyright 2020 Google Inc.
  14691. *
  14692. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14693. * of this software and associated documentation files (the "Software"), to deal
  14694. * in the Software without restriction, including without limitation the rights
  14695. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14696. * copies of the Software, and to permit persons to whom the Software is
  14697. * furnished to do so, subject to the following conditions:
  14698. *
  14699. * The above copyright notice and this permission notice shall be included in
  14700. * all copies or substantial portions of the Software.
  14701. *
  14702. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14703. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14704. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14705. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14706. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14707. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14708. * THE SOFTWARE.
  14709. */
  14710. function __export(m) {
  14711. for (var p in m) {
  14712. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  14713. }
  14714. }
  14715. Object.defineProperty(exports, "__esModule", { value: true });
  14716. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segment/foundation.ts"));
  14717. __export(__webpack_require__(/*! ./component */ "./packages/mdc-segmented-button/segment/component.ts"));
  14718. /***/ }),
  14719. /***/ "./packages/mdc-segmented-button/segmented-button/component.ts":
  14720. /*!*********************************************************************!*\
  14721. !*** ./packages/mdc-segmented-button/segmented-button/component.ts ***!
  14722. \*********************************************************************/
  14723. /*! no static exports found */
  14724. /***/ (function(module, exports, __webpack_require__) {
  14725. "use strict";
  14726. /**
  14727. * @license
  14728. * Copyright 2020 Google Inc.
  14729. *
  14730. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14731. * of this software and associated documentation files (the "Software"), to deal
  14732. * in the Software without restriction, including without limitation the rights
  14733. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14734. * copies of the Software, and to permit persons to whom the Software is
  14735. * furnished to do so, subject to the following conditions:
  14736. *
  14737. * The above copyright notice and this permission notice shall be included in
  14738. * all copies or substantial portions of the Software.
  14739. *
  14740. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14741. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14742. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14743. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14744. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14745. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14746. * THE SOFTWARE.
  14747. */
  14748. var __extends = this && this.__extends || function () {
  14749. var _extendStatics = function extendStatics(d, b) {
  14750. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  14751. d.__proto__ = b;
  14752. } || function (d, b) {
  14753. for (var p in b) {
  14754. if (b.hasOwnProperty(p)) d[p] = b[p];
  14755. }
  14756. };
  14757. return _extendStatics(d, b);
  14758. };
  14759. return function (d, b) {
  14760. _extendStatics(d, b);
  14761. function __() {
  14762. this.constructor = d;
  14763. }
  14764. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14765. };
  14766. }();
  14767. Object.defineProperty(exports, "__esModule", { value: true });
  14768. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  14769. var component_2 = __webpack_require__(/*! ../segment/component */ "./packages/mdc-segmented-button/segment/component.ts");
  14770. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segmented-button/constants.ts");
  14771. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segmented-button/foundation.ts");
  14772. // TODO(b/152410470): Remove trailing underscores from private properties
  14773. // tslint:disable:strip-private-property-underscore
  14774. var MDCSegmentedButton = /** @class */function (_super) {
  14775. __extends(MDCSegmentedButton, _super);
  14776. function MDCSegmentedButton() {
  14777. return _super !== null && _super.apply(this, arguments) || this;
  14778. }
  14779. MDCSegmentedButton.attachTo = function (root) {
  14780. return new MDCSegmentedButton(root);
  14781. };
  14782. Object.defineProperty(MDCSegmentedButton.prototype, "segments", {
  14783. get: function get() {
  14784. return this.segments_.slice();
  14785. },
  14786. enumerable: true,
  14787. configurable: true
  14788. });
  14789. // initialSyncWithDOM
  14790. MDCSegmentedButton.prototype.initialize = function (segmentFactory) {
  14791. if (segmentFactory === void 0) {
  14792. segmentFactory = function segmentFactory(el) {
  14793. return new component_2.MDCSegmentedButtonSegment(el);
  14794. };
  14795. }
  14796. this.segmentFactory = segmentFactory;
  14797. this.segments_ = this.instantiateSegments(this.segmentFactory);
  14798. };
  14799. /**
  14800. * @param segmentFactory Factory to create new child segments
  14801. * @return Returns list of child segments found in DOM
  14802. */
  14803. MDCSegmentedButton.prototype.instantiateSegments = function (segmentFactory) {
  14804. var segmentElements = [].slice.call(this.root.querySelectorAll(constants_1.selectors.SEGMENT));
  14805. return segmentElements.map(function (el) {
  14806. return segmentFactory(el);
  14807. });
  14808. };
  14809. MDCSegmentedButton.prototype.initialSyncWithDOM = function () {
  14810. var _this = this;
  14811. this.handleSelected = function (event) {
  14812. _this.foundation.handleSelected(event.detail);
  14813. };
  14814. this.listen(constants_1.events.SELECTED, this.handleSelected);
  14815. var isSingleSelect = this.foundation.isSingleSelect();
  14816. this.segments_.forEach(function (segment, index) {
  14817. segment.setIndex(index);
  14818. segment.setIsSingleSelect(isSingleSelect);
  14819. });
  14820. var selectedSegments = this.segments_.filter(function (segment) {
  14821. return segment.isSelected();
  14822. });
  14823. if (isSingleSelect && selectedSegments.length == 0 && this.segments_.length > 0) {
  14824. throw new Error('No segment selected in singleSelect mdc-segmented-button');
  14825. } else if (isSingleSelect && selectedSegments.length > 1) {
  14826. throw new Error('Multiple segments selected in singleSelect mdc-segmented-button');
  14827. }
  14828. };
  14829. MDCSegmentedButton.prototype.destroy = function () {
  14830. this.segments_.forEach(function (segment) {
  14831. segment.destroy();
  14832. });
  14833. this.unlisten(constants_1.events.SELECTED, this.handleSelected);
  14834. _super.prototype.destroy.call(this);
  14835. };
  14836. MDCSegmentedButton.prototype.getDefaultFoundation = function () {
  14837. var _this = this;
  14838. var adapter = {
  14839. hasClass: function hasClass(className) {
  14840. return _this.root.classList.contains(className);
  14841. },
  14842. getSegments: function getSegments() {
  14843. return _this.mappedSegments();
  14844. },
  14845. selectSegment: function selectSegment(indexOrSegmentId) {
  14846. var segmentDetail = _this.mappedSegments().find(function (_segmentDetail) {
  14847. return _segmentDetail.index === indexOrSegmentId || _segmentDetail.segmentId === indexOrSegmentId;
  14848. });
  14849. if (segmentDetail) {
  14850. _this.segments_[segmentDetail.index].setSelected();
  14851. }
  14852. },
  14853. unselectSegment: function unselectSegment(indexOrSegmentId) {
  14854. var segmentDetail = _this.mappedSegments().find(function (_segmentDetail) {
  14855. return _segmentDetail.index === indexOrSegmentId || _segmentDetail.segmentId === indexOrSegmentId;
  14856. });
  14857. if (segmentDetail) {
  14858. _this.segments_[segmentDetail.index].setUnselected();
  14859. }
  14860. },
  14861. notifySelectedChange: function notifySelectedChange(detail) {
  14862. _this.emit(constants_1.events.CHANGE, detail, true /* shouldBubble */);
  14863. }
  14864. };
  14865. return new foundation_1.MDCSegmentedButtonFoundation(adapter);
  14866. };
  14867. /**
  14868. * @return Returns readonly list of selected child segments as SegmentDetails
  14869. */
  14870. MDCSegmentedButton.prototype.getSelectedSegments = function () {
  14871. return this.foundation.getSelectedSegments();
  14872. };
  14873. /**
  14874. * Sets identified segment to be selected
  14875. *
  14876. * @param indexOrSegmentId Number index or string segmentId that identifies
  14877. * child segment
  14878. */
  14879. MDCSegmentedButton.prototype.selectSegment = function (indexOrSegmentId) {
  14880. this.foundation.selectSegment(indexOrSegmentId);
  14881. };
  14882. /**
  14883. * Sets identified segment to be not selected
  14884. *
  14885. * @param indexOrSegmentId Number index or string segmentId that identifies
  14886. * child segment
  14887. */
  14888. MDCSegmentedButton.prototype.unselectSegment = function (indexOrSegmentId) {
  14889. this.foundation.unselectSegment(indexOrSegmentId);
  14890. };
  14891. /**
  14892. * @param indexOrSegmentId Number index or string segmentId that identifies
  14893. * child segment
  14894. * @return Returns true if identified child segment is currently selected,
  14895. * otherwise returns false
  14896. */
  14897. MDCSegmentedButton.prototype.isSegmentSelected = function (indexOrSegmentId) {
  14898. return this.foundation.isSegmentSelected(indexOrSegmentId);
  14899. };
  14900. /**
  14901. * @return Returns child segments mapped to readonly SegmentDetail list
  14902. */
  14903. MDCSegmentedButton.prototype.mappedSegments = function () {
  14904. return this.segments_.map(function (segment, index) {
  14905. return {
  14906. index: index,
  14907. selected: segment.isSelected(),
  14908. segmentId: segment.getSegmentId()
  14909. };
  14910. });
  14911. };
  14912. return MDCSegmentedButton;
  14913. }(component_1.MDCComponent);
  14914. exports.MDCSegmentedButton = MDCSegmentedButton;
  14915. /***/ }),
  14916. /***/ "./packages/mdc-segmented-button/segmented-button/constants.ts":
  14917. /*!*********************************************************************!*\
  14918. !*** ./packages/mdc-segmented-button/segmented-button/constants.ts ***!
  14919. \*********************************************************************/
  14920. /*! no static exports found */
  14921. /***/ (function(module, exports, __webpack_require__) {
  14922. "use strict";
  14923. /**
  14924. * @license
  14925. * Copyright 2020 Google Inc.
  14926. *
  14927. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14928. * of this software and associated documentation files (the "Software"), to deal
  14929. * in the Software without restriction, including without limitation the rights
  14930. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14931. * copies of the Software, and to permit persons to whom the Software is
  14932. * furnished to do so, subject to the following conditions:
  14933. *
  14934. * The above copyright notice and this permission notice shall be included in
  14935. * all copies or substantial portions of the Software.
  14936. *
  14937. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14938. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14939. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14940. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14941. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14942. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14943. * THE SOFTWARE.
  14944. */
  14945. Object.defineProperty(exports, "__esModule", { value: true });
  14946. /**
  14947. * Selectors used by segmented-button
  14948. */
  14949. exports.selectors = {
  14950. SEGMENT: '.mdc-segmented-button__segment'
  14951. };
  14952. /**
  14953. * Events received or emitted by segmented-button
  14954. */
  14955. exports.events = {
  14956. SELECTED: 'selected',
  14957. CHANGE: 'change'
  14958. };
  14959. /**
  14960. * Style classes for segmented-button
  14961. */
  14962. exports.cssClasses = {
  14963. SINGLE_SELECT: 'mdc-segmented-button--single-select'
  14964. };
  14965. /***/ }),
  14966. /***/ "./packages/mdc-segmented-button/segmented-button/foundation.ts":
  14967. /*!**********************************************************************!*\
  14968. !*** ./packages/mdc-segmented-button/segmented-button/foundation.ts ***!
  14969. \**********************************************************************/
  14970. /*! no static exports found */
  14971. /***/ (function(module, exports, __webpack_require__) {
  14972. "use strict";
  14973. /**
  14974. * @license
  14975. * Copyright 2020 Google Inc.
  14976. *
  14977. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14978. * of this software and associated documentation files (the "Software"), to deal
  14979. * in the Software without restriction, including without limitation the rights
  14980. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14981. * copies of the Software, and to permit persons to whom the Software is
  14982. * furnished to do so, subject to the following conditions:
  14983. *
  14984. * The above copyright notice and this permission notice shall be included in
  14985. * all copies or substantial portions of the Software.
  14986. *
  14987. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14988. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14989. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14990. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  14991. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  14992. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  14993. * THE SOFTWARE.
  14994. */
  14995. var __extends = this && this.__extends || function () {
  14996. var _extendStatics = function extendStatics(d, b) {
  14997. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  14998. d.__proto__ = b;
  14999. } || function (d, b) {
  15000. for (var p in b) {
  15001. if (b.hasOwnProperty(p)) d[p] = b[p];
  15002. }
  15003. };
  15004. return _extendStatics(d, b);
  15005. };
  15006. return function (d, b) {
  15007. _extendStatics(d, b);
  15008. function __() {
  15009. this.constructor = d;
  15010. }
  15011. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15012. };
  15013. }();
  15014. var __assign = this && this.__assign || function () {
  15015. __assign = Object.assign || function (t) {
  15016. for (var s, i = 1, n = arguments.length; i < n; i++) {
  15017. s = arguments[i];
  15018. for (var p in s) {
  15019. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  15020. }
  15021. }
  15022. return t;
  15023. };
  15024. return __assign.apply(this, arguments);
  15025. };
  15026. var __values = this && this.__values || function (o) {
  15027. var s = typeof Symbol === "function" && Symbol.iterator,
  15028. m = s && o[s],
  15029. i = 0;
  15030. if (m) return m.call(o);
  15031. if (o && typeof o.length === "number") return {
  15032. next: function next() {
  15033. if (o && i >= o.length) o = void 0;
  15034. return { value: o && o[i++], done: !o };
  15035. }
  15036. };
  15037. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  15038. };
  15039. Object.defineProperty(exports, "__esModule", { value: true });
  15040. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  15041. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segmented-button/constants.ts");
  15042. var MDCSegmentedButtonFoundation = /** @class */function (_super) {
  15043. __extends(MDCSegmentedButtonFoundation, _super);
  15044. function MDCSegmentedButtonFoundation(adapter) {
  15045. return _super.call(this, __assign(__assign({}, MDCSegmentedButtonFoundation.defaultAdapter), adapter)) || this;
  15046. }
  15047. Object.defineProperty(MDCSegmentedButtonFoundation, "defaultAdapter", {
  15048. get: function get() {
  15049. return {
  15050. hasClass: function hasClass() {
  15051. return false;
  15052. }, getSegments: function getSegments() {
  15053. return [];
  15054. },
  15055. selectSegment: function selectSegment() {
  15056. return undefined;
  15057. },
  15058. unselectSegment: function unselectSegment() {
  15059. return undefined;
  15060. },
  15061. notifySelectedChange: function notifySelectedChange() {
  15062. return undefined;
  15063. }
  15064. };
  15065. },
  15066. enumerable: true,
  15067. configurable: true
  15068. });
  15069. /**
  15070. * Sets identified child segment to be selected
  15071. *
  15072. * @param indexOrSegmentId Number index or string segmentId that identifies
  15073. * child segment
  15074. */
  15075. MDCSegmentedButtonFoundation.prototype.selectSegment = function (indexOrSegmentId) {
  15076. this.adapter.selectSegment(indexOrSegmentId);
  15077. };
  15078. /**
  15079. * Sets identified child segment to be not selected
  15080. *
  15081. * @param indexOrSegmentId Number index or string segmentId that identifies
  15082. * child segment
  15083. */
  15084. MDCSegmentedButtonFoundation.prototype.unselectSegment = function (indexOrSegmentId) {
  15085. this.adapter.unselectSegment(indexOrSegmentId);
  15086. };
  15087. /**
  15088. * @return Returns currently selected child segments as readonly list of
  15089. * SegmentDetails
  15090. */
  15091. MDCSegmentedButtonFoundation.prototype.getSelectedSegments = function () {
  15092. return this.adapter.getSegments().filter(function (segmentDetail) {
  15093. return segmentDetail.selected;
  15094. });
  15095. };
  15096. /**
  15097. * @param indexOrSegmentId Number index or string segmentId that identifies
  15098. * child segment
  15099. * @return Returns true if identified child segment is currently selected,
  15100. * otherwise returns false
  15101. */
  15102. MDCSegmentedButtonFoundation.prototype.isSegmentSelected = function (indexOrSegmentId) {
  15103. return this.adapter.getSegments().some(function (segmentDetail) {
  15104. return (segmentDetail.index === indexOrSegmentId || segmentDetail.segmentId === indexOrSegmentId) && segmentDetail.selected;
  15105. });
  15106. };
  15107. /**
  15108. * @return Returns true if segmented button is single select, otherwise
  15109. * returns false
  15110. */
  15111. MDCSegmentedButtonFoundation.prototype.isSingleSelect = function () {
  15112. return this.adapter.hasClass(constants_1.cssClasses.SINGLE_SELECT);
  15113. };
  15114. /**
  15115. * Called when child segment's selected status may have changed. If segmented
  15116. * button is single select, unselects all child segments other than identified
  15117. * child segment. Finally, emits event to client.
  15118. *
  15119. * @param detail Child segment affected represented as SegmentDetail
  15120. * @event change With detail - SegmentDetail
  15121. */
  15122. MDCSegmentedButtonFoundation.prototype.handleSelected = function (detail) {
  15123. if (this.isSingleSelect()) {
  15124. this.unselectPrevSelected(detail.index);
  15125. }
  15126. this.adapter.notifySelectedChange(detail);
  15127. };
  15128. /**
  15129. * Sets all child segments to be not selected except for child segment
  15130. * identified by index
  15131. *
  15132. * @param index Index of child segment to not unselect
  15133. */
  15134. MDCSegmentedButtonFoundation.prototype.unselectPrevSelected = function (index) {
  15135. var e_1, _a;
  15136. try {
  15137. for (var _b = __values(this.getSelectedSegments()), _c = _b.next(); !_c.done; _c = _b.next()) {
  15138. var selectedSegment = _c.value;
  15139. if (selectedSegment.index !== index) {
  15140. this.unselectSegment(selectedSegment.index);
  15141. }
  15142. }
  15143. } catch (e_1_1) {
  15144. e_1 = { error: e_1_1 };
  15145. } finally {
  15146. try {
  15147. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  15148. } finally {
  15149. if (e_1) throw e_1.error;
  15150. }
  15151. }
  15152. };
  15153. return MDCSegmentedButtonFoundation;
  15154. }(foundation_1.MDCFoundation);
  15155. exports.MDCSegmentedButtonFoundation = MDCSegmentedButtonFoundation;
  15156. /***/ }),
  15157. /***/ "./packages/mdc-segmented-button/segmented-button/index.ts":
  15158. /*!*****************************************************************!*\
  15159. !*** ./packages/mdc-segmented-button/segmented-button/index.ts ***!
  15160. \*****************************************************************/
  15161. /*! no static exports found */
  15162. /***/ (function(module, exports, __webpack_require__) {
  15163. "use strict";
  15164. /**
  15165. * @license
  15166. * Copyright 2020 Google Inc.
  15167. *
  15168. * Permission is hereby granted, free of charge, to any person obtaining a copy
  15169. * of this software and associated documentation files (the "Software"), to deal
  15170. * in the Software without restriction, including without limitation the rights
  15171. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15172. * copies of the Software, and to permit persons to whom the Software is
  15173. * furnished to do so, subject to the following conditions:
  15174. *
  15175. * The above copyright notice and this permission notice shall be included in
  15176. * all copies or substantial portions of the Software.
  15177. *
  15178. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15179. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15180. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15181. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15182. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15183. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  15184. * THE SOFTWARE.
  15185. */
  15186. function __export(m) {
  15187. for (var p in m) {
  15188. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  15189. }
  15190. }
  15191. Object.defineProperty(exports, "__esModule", { value: true });
  15192. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segmented-button/foundation.ts"));
  15193. __export(__webpack_require__(/*! ./component */ "./packages/mdc-segmented-button/segmented-button/component.ts"));
  15194. /***/ }),
  15195. /***/ "./packages/mdc-select/component.ts":
  15196. /*!******************************************!*\
  15197. !*** ./packages/mdc-select/component.ts ***!
  15198. \******************************************/
  15199. /*! no static exports found */
  15200. /***/ (function(module, exports, __webpack_require__) {
  15201. "use strict";
  15202. /**
  15203. * @license
  15204. * Copyright 2016 Google Inc.
  15205. *
  15206. * Permission is hereby granted, free of charge, to any person obtaining a copy
  15207. * of this software and associated documentation files (the "Software"), to deal
  15208. * in the Software without restriction, including without limitation the rights
  15209. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15210. * copies of the Software, and to permit persons to whom the Software is
  15211. * furnished to do so, subject to the following conditions:
  15212. *
  15213. * The above copyright notice and this permission notice shall be included in
  15214. * all copies or substantial portions of the Software.
  15215. *
  15216. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15217. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15218. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15219. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15220. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15221. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  15222. * THE SOFTWARE.
  15223. */
  15224. var __extends = this && this.__extends || function () {
  15225. var _extendStatics = function extendStatics(d, b) {
  15226. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  15227. d.__proto__ = b;
  15228. } || function (d, b) {
  15229. for (var p in b) {
  15230. if (b.hasOwnProperty(p)) d[p] = b[p];
  15231. }
  15232. };
  15233. return _extendStatics(d, b);
  15234. };
  15235. return function (d, b) {
  15236. _extendStatics(d, b);
  15237. function __() {
  15238. this.constructor = d;
  15239. }
  15240. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15241. };
  15242. }();
  15243. var __assign = this && this.__assign || function () {
  15244. __assign = Object.assign || function (t) {
  15245. for (var s, i = 1, n = arguments.length; i < n; i++) {
  15246. s = arguments[i];
  15247. for (var p in s) {
  15248. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  15249. }
  15250. }
  15251. return t;
  15252. };
  15253. return __assign.apply(this, arguments);
  15254. };
  15255. var __importStar = this && this.__importStar || function (mod) {
  15256. if (mod && mod.__esModule) return mod;
  15257. var result = {};
  15258. if (mod != null) for (var k in mod) {
  15259. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  15260. }result["default"] = mod;
  15261. return result;
  15262. };
  15263. Object.defineProperty(exports, "__esModule", { value: true });
  15264. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  15265. var component_2 = __webpack_require__(/*! @material/floating-label/component */ "./packages/mdc-floating-label/component.ts");
  15266. var component_3 = __webpack_require__(/*! @material/line-ripple/component */ "./packages/mdc-line-ripple/component.ts");
  15267. var menuSurfaceConstants = __importStar(__webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts"));
  15268. var component_4 = __webpack_require__(/*! @material/menu/component */ "./packages/mdc-menu/component.ts");
  15269. var menuConstants = __importStar(__webpack_require__(/*! @material/menu/constants */ "./packages/mdc-menu/constants.ts"));
  15270. var component_5 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
  15271. var component_6 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  15272. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  15273. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
  15274. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts");
  15275. var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-select/helper-text/component.ts");
  15276. var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-select/icon/component.ts");
  15277. var MDCSelect = /** @class */function (_super) {
  15278. __extends(MDCSelect, _super);
  15279. function MDCSelect() {
  15280. return _super !== null && _super.apply(this, arguments) || this;
  15281. }
  15282. MDCSelect.attachTo = function (root) {
  15283. return new MDCSelect(root);
  15284. };
  15285. MDCSelect.prototype.initialize = function (labelFactory, lineRippleFactory, outlineFactory, menuFactory, iconFactory, helperTextFactory) {
  15286. if (labelFactory === void 0) {
  15287. labelFactory = function labelFactory(el) {
  15288. return new component_2.MDCFloatingLabel(el);
  15289. };
  15290. }
  15291. if (lineRippleFactory === void 0) {
  15292. lineRippleFactory = function lineRippleFactory(el) {
  15293. return new component_3.MDCLineRipple(el);
  15294. };
  15295. }
  15296. if (outlineFactory === void 0) {
  15297. outlineFactory = function outlineFactory(el) {
  15298. return new component_5.MDCNotchedOutline(el);
  15299. };
  15300. }
  15301. if (menuFactory === void 0) {
  15302. menuFactory = function menuFactory(el) {
  15303. return new component_4.MDCMenu(el);
  15304. };
  15305. }
  15306. if (iconFactory === void 0) {
  15307. iconFactory = function iconFactory(el) {
  15308. return new component_8.MDCSelectIcon(el);
  15309. };
  15310. }
  15311. if (helperTextFactory === void 0) {
  15312. helperTextFactory = function helperTextFactory(el) {
  15313. return new component_7.MDCSelectHelperText(el);
  15314. };
  15315. }
  15316. this.selectAnchor = this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
  15317. this.selectedText = this.root.querySelector(constants_1.strings.SELECTED_TEXT_SELECTOR);
  15318. this.hiddenInput = this.root.querySelector(constants_1.strings.HIDDEN_INPUT_SELECTOR);
  15319. if (!this.selectedText) {
  15320. throw new Error('MDCSelect: Missing required element: The following selector must be present: ' + ("'" + constants_1.strings.SELECTED_TEXT_SELECTOR + "'"));
  15321. }
  15322. if (this.selectAnchor.hasAttribute(constants_1.strings.ARIA_CONTROLS)) {
  15323. var helperTextElement = document.getElementById(this.selectAnchor.getAttribute(constants_1.strings.ARIA_CONTROLS));
  15324. if (helperTextElement) {
  15325. this.helperText = helperTextFactory(helperTextElement);
  15326. }
  15327. }
  15328. this.menuSetup(menuFactory);
  15329. var labelElement = this.root.querySelector(constants_1.strings.LABEL_SELECTOR);
  15330. this.label = labelElement ? labelFactory(labelElement) : null;
  15331. var lineRippleElement = this.root.querySelector(constants_1.strings.LINE_RIPPLE_SELECTOR);
  15332. this.lineRipple = lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
  15333. var outlineElement = this.root.querySelector(constants_1.strings.OUTLINE_SELECTOR);
  15334. this.outline = outlineElement ? outlineFactory(outlineElement) : null;
  15335. var leadingIcon = this.root.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
  15336. if (leadingIcon) {
  15337. this.leadingIcon = iconFactory(leadingIcon);
  15338. }
  15339. if (!this.root.classList.contains(constants_1.cssClasses.OUTLINED)) {
  15340. this.ripple = this.createRipple();
  15341. }
  15342. };
  15343. /**
  15344. * Initializes the select's event listeners and internal state based
  15345. * on the environment's state.
  15346. */
  15347. MDCSelect.prototype.initialSyncWithDOM = function () {
  15348. var _this = this;
  15349. this.handleFocus = function () {
  15350. _this.foundation.handleFocus();
  15351. };
  15352. this.handleBlur = function () {
  15353. _this.foundation.handleBlur();
  15354. };
  15355. this.handleClick = function (evt) {
  15356. _this.selectAnchor.focus();
  15357. _this.foundation.handleClick(_this.getNormalizedXCoordinate(evt));
  15358. };
  15359. this.handleKeydown = function (evt) {
  15360. _this.foundation.handleKeydown(evt);
  15361. };
  15362. this.handleMenuItemAction = function (evt) {
  15363. _this.foundation.handleMenuItemAction(evt.detail.index);
  15364. };
  15365. this.handleMenuOpened = function () {
  15366. _this.foundation.handleMenuOpened();
  15367. };
  15368. this.handleMenuClosed = function () {
  15369. _this.foundation.handleMenuClosed();
  15370. };
  15371. this.selectAnchor.addEventListener('focus', this.handleFocus);
  15372. this.selectAnchor.addEventListener('blur', this.handleBlur);
  15373. this.selectAnchor.addEventListener('click', this.handleClick);
  15374. this.selectAnchor.addEventListener('keydown', this.handleKeydown);
  15375. this.menu.listen(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
  15376. this.menu.listen(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
  15377. this.menu.listen(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
  15378. if (this.hiddenInput) {
  15379. if (this.hiddenInput.value) {
  15380. // If the hidden input already has a value, use it to restore the
  15381. // select's value. This can happen e.g. if the user goes back or (in
  15382. // some browsers) refreshes the page.
  15383. this.foundation.setValue(this.hiddenInput.value, /** skipNotify */true);
  15384. this.foundation.layout();
  15385. return;
  15386. }
  15387. this.hiddenInput.value = this.value;
  15388. }
  15389. };
  15390. MDCSelect.prototype.destroy = function () {
  15391. this.selectAnchor.removeEventListener('focus', this.handleFocus);
  15392. this.selectAnchor.removeEventListener('blur', this.handleBlur);
  15393. this.selectAnchor.removeEventListener('keydown', this.handleKeydown);
  15394. this.selectAnchor.removeEventListener('click', this.handleClick);
  15395. this.menu.unlisten(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
  15396. this.menu.unlisten(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
  15397. this.menu.unlisten(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
  15398. this.menu.destroy();
  15399. if (this.ripple) {
  15400. this.ripple.destroy();
  15401. }
  15402. if (this.outline) {
  15403. this.outline.destroy();
  15404. }
  15405. if (this.leadingIcon) {
  15406. this.leadingIcon.destroy();
  15407. }
  15408. if (this.helperText) {
  15409. this.helperText.destroy();
  15410. }
  15411. _super.prototype.destroy.call(this);
  15412. };
  15413. Object.defineProperty(MDCSelect.prototype, "value", {
  15414. get: function get() {
  15415. return this.foundation.getValue();
  15416. },
  15417. set: function set(value) {
  15418. this.foundation.setValue(value);
  15419. },
  15420. enumerable: true,
  15421. configurable: true
  15422. });
  15423. Object.defineProperty(MDCSelect.prototype, "selectedIndex", {
  15424. get: function get() {
  15425. return this.foundation.getSelectedIndex();
  15426. },
  15427. set: function set(selectedIndex) {
  15428. this.foundation.setSelectedIndex(selectedIndex, /** closeMenu */true);
  15429. },
  15430. enumerable: true,
  15431. configurable: true
  15432. });
  15433. Object.defineProperty(MDCSelect.prototype, "disabled", {
  15434. get: function get() {
  15435. return this.foundation.getDisabled();
  15436. },
  15437. set: function set(disabled) {
  15438. this.foundation.setDisabled(disabled);
  15439. if (this.hiddenInput) {
  15440. this.hiddenInput.disabled = disabled;
  15441. }
  15442. },
  15443. enumerable: true,
  15444. configurable: true
  15445. });
  15446. Object.defineProperty(MDCSelect.prototype, "leadingIconAriaLabel", {
  15447. set: function set(label) {
  15448. this.foundation.setLeadingIconAriaLabel(label);
  15449. },
  15450. enumerable: true,
  15451. configurable: true
  15452. });
  15453. Object.defineProperty(MDCSelect.prototype, "leadingIconContent", {
  15454. /**
  15455. * Sets the text content of the leading icon.
  15456. */
  15457. set: function set(content) {
  15458. this.foundation.setLeadingIconContent(content);
  15459. },
  15460. enumerable: true,
  15461. configurable: true
  15462. });
  15463. Object.defineProperty(MDCSelect.prototype, "helperTextContent", {
  15464. /**
  15465. * Sets the text content of the helper text.
  15466. */
  15467. set: function set(content) {
  15468. this.foundation.setHelperTextContent(content);
  15469. },
  15470. enumerable: true,
  15471. configurable: true
  15472. });
  15473. Object.defineProperty(MDCSelect.prototype, "useDefaultValidation", {
  15474. /**
  15475. * Enables or disables the default validation scheme where a required select
  15476. * must be non-empty. Set to false for custom validation.
  15477. * @param useDefaultValidation Set this to false to ignore default
  15478. * validation scheme.
  15479. */
  15480. set: function set(useDefaultValidation) {
  15481. this.foundation.setUseDefaultValidation(useDefaultValidation);
  15482. },
  15483. enumerable: true,
  15484. configurable: true
  15485. });
  15486. Object.defineProperty(MDCSelect.prototype, "valid", {
  15487. /**
  15488. * Checks if the select is in a valid state.
  15489. */
  15490. get: function get() {
  15491. return this.foundation.isValid();
  15492. },
  15493. /**
  15494. * Sets the current invalid state of the select.
  15495. */
  15496. set: function set(isValid) {
  15497. this.foundation.setValid(isValid);
  15498. },
  15499. enumerable: true,
  15500. configurable: true
  15501. });
  15502. Object.defineProperty(MDCSelect.prototype, "required", {
  15503. /**
  15504. * Returns whether the select is required.
  15505. */
  15506. get: function get() {
  15507. return this.foundation.getRequired();
  15508. },
  15509. /**
  15510. * Sets the control to the required state.
  15511. */
  15512. set: function set(isRequired) {
  15513. this.foundation.setRequired(isRequired);
  15514. },
  15515. enumerable: true,
  15516. configurable: true
  15517. });
  15518. /**
  15519. * Re-calculates if the notched outline should be notched and if the label
  15520. * should float.
  15521. */
  15522. MDCSelect.prototype.layout = function () {
  15523. this.foundation.layout();
  15524. };
  15525. /**
  15526. * Synchronizes the list of options with the state of the foundation. Call
  15527. * this whenever menu options are dynamically updated.
  15528. */
  15529. MDCSelect.prototype.layoutOptions = function () {
  15530. this.foundation.layoutOptions();
  15531. this.menu.layout();
  15532. // Update cached menuItemValues for adapter.
  15533. this.menuItemValues = this.menu.items.map(function (el) {
  15534. return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
  15535. });
  15536. if (this.hiddenInput) {
  15537. this.hiddenInput.value = this.value;
  15538. }
  15539. };
  15540. MDCSelect.prototype.getDefaultFoundation = function () {
  15541. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  15542. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  15543. var adapter = __assign(__assign(__assign(__assign({}, this.getSelectAdapterMethods()), this.getCommonAdapterMethods()), this.getOutlineAdapterMethods()), this.getLabelAdapterMethods());
  15544. return new foundation_2.MDCSelectFoundation(adapter, this.getFoundationMap());
  15545. };
  15546. /**
  15547. * Handles setup for the menu.
  15548. */
  15549. MDCSelect.prototype.menuSetup = function (menuFactory) {
  15550. this.menuElement = this.root.querySelector(constants_1.strings.MENU_SELECTOR);
  15551. this.menu = menuFactory(this.menuElement);
  15552. this.menu.hasTypeahead = true;
  15553. this.menu.singleSelection = true;
  15554. this.menuItemValues = this.menu.items.map(function (el) {
  15555. return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
  15556. });
  15557. };
  15558. MDCSelect.prototype.createRipple = function () {
  15559. var _this = this;
  15560. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  15561. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  15562. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15563. var adapter = __assign(__assign({}, component_6.MDCRipple.createAdapter({ root: this.selectAnchor })), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  15564. _this.selectAnchor.addEventListener(evtType, handler);
  15565. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  15566. _this.selectAnchor.removeEventListener(evtType, handler);
  15567. } });
  15568. // tslint:enable:object-literal-sort-keys
  15569. return new component_6.MDCRipple(this.selectAnchor, new foundation_1.MDCRippleFoundation(adapter));
  15570. };
  15571. MDCSelect.prototype.getSelectAdapterMethods = function () {
  15572. var _this = this;
  15573. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15574. return {
  15575. getMenuItemAttr: function getMenuItemAttr(menuItem, attr) {
  15576. return menuItem.getAttribute(attr);
  15577. },
  15578. setSelectedText: function setSelectedText(text) {
  15579. _this.selectedText.textContent = text;
  15580. },
  15581. isSelectAnchorFocused: function isSelectAnchorFocused() {
  15582. return document.activeElement === _this.selectAnchor;
  15583. },
  15584. getSelectAnchorAttr: function getSelectAnchorAttr(attr) {
  15585. return _this.selectAnchor.getAttribute(attr);
  15586. },
  15587. setSelectAnchorAttr: function setSelectAnchorAttr(attr, value) {
  15588. _this.selectAnchor.setAttribute(attr, value);
  15589. },
  15590. removeSelectAnchorAttr: function removeSelectAnchorAttr(attr) {
  15591. _this.selectAnchor.removeAttribute(attr);
  15592. },
  15593. addMenuClass: function addMenuClass(className) {
  15594. _this.menuElement.classList.add(className);
  15595. },
  15596. removeMenuClass: function removeMenuClass(className) {
  15597. _this.menuElement.classList.remove(className);
  15598. },
  15599. openMenu: function openMenu() {
  15600. _this.menu.open = true;
  15601. },
  15602. closeMenu: function closeMenu() {
  15603. _this.menu.open = false;
  15604. },
  15605. getAnchorElement: function getAnchorElement() {
  15606. return _this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
  15607. },
  15608. setMenuAnchorElement: function setMenuAnchorElement(anchorEl) {
  15609. _this.menu.setAnchorElement(anchorEl);
  15610. },
  15611. setMenuAnchorCorner: function setMenuAnchorCorner(anchorCorner) {
  15612. _this.menu.setAnchorCorner(anchorCorner);
  15613. },
  15614. setMenuWrapFocus: function setMenuWrapFocus(wrapFocus) {
  15615. _this.menu.wrapFocus = wrapFocus;
  15616. },
  15617. getSelectedIndex: function getSelectedIndex() {
  15618. var index = _this.menu.selectedIndex;
  15619. return index instanceof Array ? index[0] : index;
  15620. },
  15621. setSelectedIndex: function setSelectedIndex(index) {
  15622. _this.menu.selectedIndex = index;
  15623. },
  15624. focusMenuItemAtIndex: function focusMenuItemAtIndex(index) {
  15625. _this.menu.items[index].focus();
  15626. },
  15627. getMenuItemCount: function getMenuItemCount() {
  15628. return _this.menu.items.length;
  15629. },
  15630. // Cache menu item values. layoutOptions() updates this cache.
  15631. getMenuItemValues: function getMenuItemValues() {
  15632. return _this.menuItemValues;
  15633. },
  15634. getMenuItemTextAtIndex: function getMenuItemTextAtIndex(index) {
  15635. return _this.menu.getPrimaryTextAtIndex(index);
  15636. },
  15637. isTypeaheadInProgress: function isTypeaheadInProgress() {
  15638. return _this.menu.typeaheadInProgress;
  15639. },
  15640. typeaheadMatchItem: function typeaheadMatchItem(nextChar, startingIndex) {
  15641. return _this.menu.typeaheadMatchItem(nextChar, startingIndex);
  15642. }
  15643. };
  15644. // tslint:enable:object-literal-sort-keys
  15645. };
  15646. MDCSelect.prototype.getCommonAdapterMethods = function () {
  15647. var _this = this;
  15648. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15649. return {
  15650. addClass: function addClass(className) {
  15651. _this.root.classList.add(className);
  15652. },
  15653. removeClass: function removeClass(className) {
  15654. _this.root.classList.remove(className);
  15655. },
  15656. hasClass: function hasClass(className) {
  15657. return _this.root.classList.contains(className);
  15658. },
  15659. setRippleCenter: function setRippleCenter(normalizedX) {
  15660. _this.lineRipple && _this.lineRipple.setRippleCenter(normalizedX);
  15661. },
  15662. activateBottomLine: function activateBottomLine() {
  15663. _this.lineRipple && _this.lineRipple.activate();
  15664. },
  15665. deactivateBottomLine: function deactivateBottomLine() {
  15666. _this.lineRipple && _this.lineRipple.deactivate();
  15667. },
  15668. notifyChange: function notifyChange(value) {
  15669. var index = _this.selectedIndex;
  15670. _this.emit(constants_1.strings.CHANGE_EVENT, { value: value, index: index }, true /* shouldBubble */);
  15671. if (_this.hiddenInput) {
  15672. _this.hiddenInput.value = value;
  15673. }
  15674. }
  15675. };
  15676. // tslint:enable:object-literal-sort-keys
  15677. };
  15678. MDCSelect.prototype.getOutlineAdapterMethods = 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. hasOutline: function hasOutline() {
  15683. return Boolean(_this.outline);
  15684. },
  15685. notchOutline: function notchOutline(labelWidth) {
  15686. _this.outline && _this.outline.notch(labelWidth);
  15687. },
  15688. closeOutline: function closeOutline() {
  15689. _this.outline && _this.outline.closeNotch();
  15690. }
  15691. };
  15692. // tslint:enable:object-literal-sort-keys
  15693. };
  15694. MDCSelect.prototype.getLabelAdapterMethods = function () {
  15695. var _this = this;
  15696. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15697. return {
  15698. hasLabel: function hasLabel() {
  15699. return !!_this.label;
  15700. },
  15701. floatLabel: function floatLabel(shouldFloat) {
  15702. _this.label && _this.label.float(shouldFloat);
  15703. },
  15704. getLabelWidth: function getLabelWidth() {
  15705. return _this.label ? _this.label.getWidth() : 0;
  15706. },
  15707. setLabelRequired: function setLabelRequired(isRequired) {
  15708. _this.label && _this.label.setRequired(isRequired);
  15709. }
  15710. };
  15711. // tslint:enable:object-literal-sort-keys
  15712. };
  15713. /**
  15714. * Calculates where the line ripple should start based on the x coordinate within the component.
  15715. */
  15716. MDCSelect.prototype.getNormalizedXCoordinate = function (evt) {
  15717. var targetClientRect = evt.target.getBoundingClientRect();
  15718. var xCoordinate = this.isTouchEvent(evt) ? evt.touches[0].clientX : evt.clientX;
  15719. return xCoordinate - targetClientRect.left;
  15720. };
  15721. MDCSelect.prototype.isTouchEvent = function (evt) {
  15722. return Boolean(evt.touches);
  15723. };
  15724. /**
  15725. * Returns a map of all subcomponents to subfoundations.
  15726. */
  15727. MDCSelect.prototype.getFoundationMap = function () {
  15728. return {
  15729. helperText: this.helperText ? this.helperText.foundationForSelect : undefined,
  15730. leadingIcon: this.leadingIcon ? this.leadingIcon.foundationForSelect : undefined
  15731. };
  15732. };
  15733. return MDCSelect;
  15734. }(component_1.MDCComponent);
  15735. exports.MDCSelect = MDCSelect;
  15736. /***/ }),
  15737. /***/ "./packages/mdc-select/constants.ts":
  15738. /*!******************************************!*\
  15739. !*** ./packages/mdc-select/constants.ts ***!
  15740. \******************************************/
  15741. /*! no static exports found */
  15742. /***/ (function(module, exports, __webpack_require__) {
  15743. "use strict";
  15744. /**
  15745. * @license
  15746. * Copyright 2016 Google Inc.
  15747. *
  15748. * Permission is hereby granted, free of charge, to any person obtaining a copy
  15749. * of this software and associated documentation files (the "Software"), to deal
  15750. * in the Software without restriction, including without limitation the rights
  15751. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15752. * copies of the Software, and to permit persons to whom the Software is
  15753. * furnished to do so, subject to the following conditions:
  15754. *
  15755. * The above copyright notice and this permission notice shall be included in
  15756. * all copies or substantial portions of the Software.
  15757. *
  15758. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15759. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15760. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15761. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15762. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15763. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  15764. * THE SOFTWARE.
  15765. */
  15766. Object.defineProperty(exports, "__esModule", { value: true });
  15767. var cssClasses = {
  15768. ACTIVATED: 'mdc-select--activated',
  15769. DISABLED: 'mdc-select--disabled',
  15770. FOCUSED: 'mdc-select--focused',
  15771. INVALID: 'mdc-select--invalid',
  15772. MENU_INVALID: 'mdc-select__menu--invalid',
  15773. OUTLINED: 'mdc-select--outlined',
  15774. REQUIRED: 'mdc-select--required',
  15775. ROOT: 'mdc-select',
  15776. WITH_LEADING_ICON: 'mdc-select--with-leading-icon'
  15777. };
  15778. exports.cssClasses = cssClasses;
  15779. var strings = {
  15780. ARIA_CONTROLS: 'aria-controls',
  15781. ARIA_DESCRIBEDBY: 'aria-describedby',
  15782. ARIA_SELECTED_ATTR: 'aria-selected',
  15783. CHANGE_EVENT: 'MDCSelect:change',
  15784. HIDDEN_INPUT_SELECTOR: 'input[type="hidden"]',
  15785. LABEL_SELECTOR: '.mdc-floating-label',
  15786. LEADING_ICON_SELECTOR: '.mdc-select__icon',
  15787. LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
  15788. MENU_SELECTOR: '.mdc-select__menu',
  15789. OUTLINE_SELECTOR: '.mdc-notched-outline',
  15790. SELECTED_TEXT_SELECTOR: '.mdc-select__selected-text',
  15791. SELECT_ANCHOR_SELECTOR: '.mdc-select__anchor',
  15792. VALUE_ATTR: 'data-value'
  15793. };
  15794. exports.strings = strings;
  15795. var numbers = {
  15796. LABEL_SCALE: 0.75,
  15797. UNSET_INDEX: -1,
  15798. CLICK_DEBOUNCE_TIMEOUT_MS: 330
  15799. };
  15800. exports.numbers = numbers;
  15801. /***/ }),
  15802. /***/ "./packages/mdc-select/foundation.ts":
  15803. /*!*******************************************!*\
  15804. !*** ./packages/mdc-select/foundation.ts ***!
  15805. \*******************************************/
  15806. /*! no static exports found */
  15807. /***/ (function(module, exports, __webpack_require__) {
  15808. "use strict";
  15809. /**
  15810. * @license
  15811. * Copyright 2016 Google Inc.
  15812. *
  15813. * Permission is hereby granted, free of charge, to any person obtaining a copy
  15814. * of this software and associated documentation files (the "Software"), to deal
  15815. * in the Software without restriction, including without limitation the rights
  15816. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  15817. * copies of the Software, and to permit persons to whom the Software is
  15818. * furnished to do so, subject to the following conditions:
  15819. *
  15820. * The above copyright notice and this permission notice shall be included in
  15821. * all copies or substantial portions of the Software.
  15822. *
  15823. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15824. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15825. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15826. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15827. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  15828. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  15829. * THE SOFTWARE.
  15830. */
  15831. var __extends = this && this.__extends || function () {
  15832. var _extendStatics = function extendStatics(d, b) {
  15833. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  15834. d.__proto__ = b;
  15835. } || function (d, b) {
  15836. for (var p in b) {
  15837. if (b.hasOwnProperty(p)) d[p] = b[p];
  15838. }
  15839. };
  15840. return _extendStatics(d, b);
  15841. };
  15842. return function (d, b) {
  15843. _extendStatics(d, b);
  15844. function __() {
  15845. this.constructor = d;
  15846. }
  15847. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15848. };
  15849. }();
  15850. var __assign = this && this.__assign || function () {
  15851. __assign = Object.assign || function (t) {
  15852. for (var s, i = 1, n = arguments.length; i < n; i++) {
  15853. s = arguments[i];
  15854. for (var p in s) {
  15855. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  15856. }
  15857. }
  15858. return t;
  15859. };
  15860. return __assign.apply(this, arguments);
  15861. };
  15862. Object.defineProperty(exports, "__esModule", { value: true });
  15863. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  15864. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  15865. var constants_1 = __webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts");
  15866. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
  15867. var MDCSelectFoundation = /** @class */function (_super) {
  15868. __extends(MDCSelectFoundation, _super);
  15869. /* istanbul ignore next: optional argument is not a branch statement */
  15870. /**
  15871. * @param adapter
  15872. * @param foundationMap Map from subcomponent names to their subfoundations.
  15873. */
  15874. function MDCSelectFoundation(adapter, foundationMap) {
  15875. if (foundationMap === void 0) {
  15876. foundationMap = {};
  15877. }
  15878. var _this = _super.call(this, __assign(__assign({}, MDCSelectFoundation.defaultAdapter), adapter)) || this;
  15879. // Disabled state
  15880. _this.disabled = false;
  15881. // isMenuOpen is used to track the state of the menu by listening to the
  15882. // MDCMenuSurface:closed event For reference, menu.open will return false if
  15883. // the menu is still closing, but isMenuOpen returns false only after the menu
  15884. // has closed
  15885. _this.isMenuOpen = false;
  15886. // By default, select is invalid if it is required but no value is selected.
  15887. _this.useDefaultValidation = true;
  15888. _this.customValidity = true;
  15889. _this.lastSelectedIndex = constants_2.numbers.UNSET_INDEX;
  15890. _this.clickDebounceTimeout = 0;
  15891. _this.recentlyClicked = false;
  15892. _this.leadingIcon = foundationMap.leadingIcon;
  15893. _this.helperText = foundationMap.helperText;
  15894. return _this;
  15895. }
  15896. Object.defineProperty(MDCSelectFoundation, "cssClasses", {
  15897. get: function get() {
  15898. return constants_2.cssClasses;
  15899. },
  15900. enumerable: true,
  15901. configurable: true
  15902. });
  15903. Object.defineProperty(MDCSelectFoundation, "numbers", {
  15904. get: function get() {
  15905. return constants_2.numbers;
  15906. },
  15907. enumerable: true,
  15908. configurable: true
  15909. });
  15910. Object.defineProperty(MDCSelectFoundation, "strings", {
  15911. get: function get() {
  15912. return constants_2.strings;
  15913. },
  15914. enumerable: true,
  15915. configurable: true
  15916. });
  15917. Object.defineProperty(MDCSelectFoundation, "defaultAdapter", {
  15918. /**
  15919. * See {@link MDCSelectAdapter} for typing information on parameters and return types.
  15920. */
  15921. get: function get() {
  15922. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  15923. return {
  15924. addClass: function addClass() {
  15925. return undefined;
  15926. },
  15927. removeClass: function removeClass() {
  15928. return undefined;
  15929. },
  15930. hasClass: function hasClass() {
  15931. return false;
  15932. },
  15933. activateBottomLine: function activateBottomLine() {
  15934. return undefined;
  15935. },
  15936. deactivateBottomLine: function deactivateBottomLine() {
  15937. return undefined;
  15938. },
  15939. getSelectedIndex: function getSelectedIndex() {
  15940. return -1;
  15941. },
  15942. setSelectedIndex: function setSelectedIndex() {
  15943. return undefined;
  15944. },
  15945. hasLabel: function hasLabel() {
  15946. return false;
  15947. },
  15948. floatLabel: function floatLabel() {
  15949. return undefined;
  15950. },
  15951. getLabelWidth: function getLabelWidth() {
  15952. return 0;
  15953. },
  15954. setLabelRequired: function setLabelRequired() {
  15955. return undefined;
  15956. },
  15957. hasOutline: function hasOutline() {
  15958. return false;
  15959. },
  15960. notchOutline: function notchOutline() {
  15961. return undefined;
  15962. },
  15963. closeOutline: function closeOutline() {
  15964. return undefined;
  15965. },
  15966. setRippleCenter: function setRippleCenter() {
  15967. return undefined;
  15968. },
  15969. notifyChange: function notifyChange() {
  15970. return undefined;
  15971. },
  15972. setSelectedText: function setSelectedText() {
  15973. return undefined;
  15974. },
  15975. isSelectAnchorFocused: function isSelectAnchorFocused() {
  15976. return false;
  15977. },
  15978. getSelectAnchorAttr: function getSelectAnchorAttr() {
  15979. return '';
  15980. },
  15981. setSelectAnchorAttr: function setSelectAnchorAttr() {
  15982. return undefined;
  15983. },
  15984. removeSelectAnchorAttr: function removeSelectAnchorAttr() {
  15985. return undefined;
  15986. },
  15987. addMenuClass: function addMenuClass() {
  15988. return undefined;
  15989. },
  15990. removeMenuClass: function removeMenuClass() {
  15991. return undefined;
  15992. },
  15993. openMenu: function openMenu() {
  15994. return undefined;
  15995. },
  15996. closeMenu: function closeMenu() {
  15997. return undefined;
  15998. },
  15999. getAnchorElement: function getAnchorElement() {
  16000. return null;
  16001. },
  16002. setMenuAnchorElement: function setMenuAnchorElement() {
  16003. return undefined;
  16004. },
  16005. setMenuAnchorCorner: function setMenuAnchorCorner() {
  16006. return undefined;
  16007. },
  16008. setMenuWrapFocus: function setMenuWrapFocus() {
  16009. return undefined;
  16010. },
  16011. focusMenuItemAtIndex: function focusMenuItemAtIndex() {
  16012. return undefined;
  16013. },
  16014. getMenuItemCount: function getMenuItemCount() {
  16015. return 0;
  16016. },
  16017. getMenuItemValues: function getMenuItemValues() {
  16018. return [];
  16019. },
  16020. getMenuItemTextAtIndex: function getMenuItemTextAtIndex() {
  16021. return '';
  16022. },
  16023. isTypeaheadInProgress: function isTypeaheadInProgress() {
  16024. return false;
  16025. },
  16026. typeaheadMatchItem: function typeaheadMatchItem() {
  16027. return -1;
  16028. }
  16029. };
  16030. // tslint:enable:object-literal-sort-keys
  16031. },
  16032. enumerable: true,
  16033. configurable: true
  16034. });
  16035. /** Returns the index of the currently selected menu item, or -1 if none. */
  16036. MDCSelectFoundation.prototype.getSelectedIndex = function () {
  16037. return this.adapter.getSelectedIndex();
  16038. };
  16039. MDCSelectFoundation.prototype.setSelectedIndex = function (index, closeMenu, skipNotify) {
  16040. if (closeMenu === void 0) {
  16041. closeMenu = false;
  16042. }
  16043. if (skipNotify === void 0) {
  16044. skipNotify = false;
  16045. }
  16046. if (index >= this.adapter.getMenuItemCount()) {
  16047. return;
  16048. }
  16049. if (index === constants_2.numbers.UNSET_INDEX) {
  16050. this.adapter.setSelectedText('');
  16051. } else {
  16052. this.adapter.setSelectedText(this.adapter.getMenuItemTextAtIndex(index).trim());
  16053. }
  16054. this.adapter.setSelectedIndex(index);
  16055. if (closeMenu) {
  16056. this.adapter.closeMenu();
  16057. }
  16058. if (!skipNotify && this.lastSelectedIndex !== index) {
  16059. this.handleChange();
  16060. }
  16061. this.lastSelectedIndex = index;
  16062. };
  16063. MDCSelectFoundation.prototype.setValue = function (value, skipNotify) {
  16064. if (skipNotify === void 0) {
  16065. skipNotify = false;
  16066. }
  16067. var index = this.adapter.getMenuItemValues().indexOf(value);
  16068. this.setSelectedIndex(index, /** closeMenu */false, skipNotify);
  16069. };
  16070. MDCSelectFoundation.prototype.getValue = function () {
  16071. var index = this.adapter.getSelectedIndex();
  16072. var menuItemValues = this.adapter.getMenuItemValues();
  16073. return index !== constants_2.numbers.UNSET_INDEX ? menuItemValues[index] : '';
  16074. };
  16075. MDCSelectFoundation.prototype.getDisabled = function () {
  16076. return this.disabled;
  16077. };
  16078. MDCSelectFoundation.prototype.setDisabled = function (isDisabled) {
  16079. this.disabled = isDisabled;
  16080. if (this.disabled) {
  16081. this.adapter.addClass(constants_2.cssClasses.DISABLED);
  16082. this.adapter.closeMenu();
  16083. } else {
  16084. this.adapter.removeClass(constants_2.cssClasses.DISABLED);
  16085. }
  16086. if (this.leadingIcon) {
  16087. this.leadingIcon.setDisabled(this.disabled);
  16088. }
  16089. if (this.disabled) {
  16090. // Prevent click events from focusing select. Simply pointer-events: none
  16091. // is not enough since screenreader clicks may bypass this.
  16092. this.adapter.removeSelectAnchorAttr('tabindex');
  16093. } else {
  16094. this.adapter.setSelectAnchorAttr('tabindex', '0');
  16095. }
  16096. this.adapter.setSelectAnchorAttr('aria-disabled', this.disabled.toString());
  16097. };
  16098. /** Opens the menu. */
  16099. MDCSelectFoundation.prototype.openMenu = function () {
  16100. this.adapter.addClass(constants_2.cssClasses.ACTIVATED);
  16101. this.adapter.openMenu();
  16102. this.isMenuOpen = true;
  16103. this.adapter.setSelectAnchorAttr('aria-expanded', 'true');
  16104. };
  16105. /**
  16106. * @param content Sets the content of the helper text.
  16107. */
  16108. MDCSelectFoundation.prototype.setHelperTextContent = function (content) {
  16109. if (this.helperText) {
  16110. this.helperText.setContent(content);
  16111. }
  16112. };
  16113. /**
  16114. * Re-calculates if the notched outline should be notched and if the label
  16115. * should float.
  16116. */
  16117. MDCSelectFoundation.prototype.layout = function () {
  16118. if (this.adapter.hasLabel()) {
  16119. var optionHasValue = this.getValue().length > 0;
  16120. var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
  16121. var shouldFloatAndNotch = optionHasValue || isFocused;
  16122. var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
  16123. this.notchOutline(shouldFloatAndNotch);
  16124. this.adapter.floatLabel(shouldFloatAndNotch);
  16125. this.adapter.setLabelRequired(isRequired);
  16126. }
  16127. };
  16128. /**
  16129. * Synchronizes the list of options with the state of the foundation. Call
  16130. * this whenever menu options are dynamically updated.
  16131. */
  16132. MDCSelectFoundation.prototype.layoutOptions = function () {
  16133. var menuItemValues = this.adapter.getMenuItemValues();
  16134. var selectedIndex = menuItemValues.indexOf(this.getValue());
  16135. this.setSelectedIndex(selectedIndex, /** closeMenu */false, /** skipNotify */true);
  16136. };
  16137. MDCSelectFoundation.prototype.handleMenuOpened = function () {
  16138. if (this.adapter.getMenuItemValues().length === 0) {
  16139. return;
  16140. }
  16141. // Menu should open to the last selected element, should open to first menu item otherwise.
  16142. var selectedIndex = this.getSelectedIndex();
  16143. var focusItemIndex = selectedIndex >= 0 ? selectedIndex : 0;
  16144. this.adapter.focusMenuItemAtIndex(focusItemIndex);
  16145. };
  16146. MDCSelectFoundation.prototype.handleMenuClosed = function () {
  16147. this.adapter.removeClass(constants_2.cssClasses.ACTIVATED);
  16148. this.isMenuOpen = false;
  16149. this.adapter.setSelectAnchorAttr('aria-expanded', 'false');
  16150. // Unfocus the select if menu is closed without a selection
  16151. if (!this.adapter.isSelectAnchorFocused()) {
  16152. this.blur();
  16153. }
  16154. };
  16155. /**
  16156. * Handles value changes, via change event or programmatic updates.
  16157. */
  16158. MDCSelectFoundation.prototype.handleChange = function () {
  16159. this.layout();
  16160. this.adapter.notifyChange(this.getValue());
  16161. var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
  16162. if (isRequired && this.useDefaultValidation) {
  16163. this.setValid(this.isValid());
  16164. }
  16165. };
  16166. MDCSelectFoundation.prototype.handleMenuItemAction = function (index) {
  16167. this.setSelectedIndex(index, /** closeMenu */true);
  16168. };
  16169. /**
  16170. * Handles focus events from select element.
  16171. */
  16172. MDCSelectFoundation.prototype.handleFocus = function () {
  16173. this.adapter.addClass(constants_2.cssClasses.FOCUSED);
  16174. this.layout();
  16175. this.adapter.activateBottomLine();
  16176. };
  16177. /**
  16178. * Handles blur events from select element.
  16179. */
  16180. MDCSelectFoundation.prototype.handleBlur = function () {
  16181. if (this.isMenuOpen) {
  16182. return;
  16183. }
  16184. this.blur();
  16185. };
  16186. MDCSelectFoundation.prototype.handleClick = function (normalizedX) {
  16187. if (this.disabled || this.recentlyClicked) {
  16188. return;
  16189. }
  16190. this.setClickDebounceTimeout();
  16191. if (this.isMenuOpen) {
  16192. this.adapter.closeMenu();
  16193. return;
  16194. }
  16195. this.adapter.setRippleCenter(normalizedX);
  16196. this.openMenu();
  16197. };
  16198. /**
  16199. * Handles keydown events on select element. Depending on the type of
  16200. * character typed, does typeahead matching or opens menu.
  16201. */
  16202. MDCSelectFoundation.prototype.handleKeydown = function (event) {
  16203. if (this.isMenuOpen || !this.adapter.hasClass(constants_2.cssClasses.FOCUSED)) {
  16204. return;
  16205. }
  16206. var isEnter = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ENTER;
  16207. var isSpace = keyboard_1.normalizeKey(event) === keyboard_1.KEY.SPACEBAR;
  16208. var arrowUp = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_UP;
  16209. var arrowDown = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_DOWN;
  16210. // Typeahead
  16211. if (!isSpace && event.key && event.key.length === 1 || isSpace && this.adapter.isTypeaheadInProgress()) {
  16212. var key = isSpace ? ' ' : event.key;
  16213. var typeaheadNextIndex = this.adapter.typeaheadMatchItem(key, this.getSelectedIndex());
  16214. if (typeaheadNextIndex >= 0) {
  16215. this.setSelectedIndex(typeaheadNextIndex);
  16216. }
  16217. event.preventDefault();
  16218. return;
  16219. }
  16220. if (!isEnter && !isSpace && !arrowUp && !arrowDown) {
  16221. return;
  16222. }
  16223. // Increment/decrement index as necessary and open menu.
  16224. if (arrowUp && this.getSelectedIndex() > 0) {
  16225. this.setSelectedIndex(this.getSelectedIndex() - 1);
  16226. } else if (arrowDown && this.getSelectedIndex() < this.adapter.getMenuItemCount() - 1) {
  16227. this.setSelectedIndex(this.getSelectedIndex() + 1);
  16228. }
  16229. this.openMenu();
  16230. event.preventDefault();
  16231. };
  16232. /**
  16233. * Opens/closes the notched outline.
  16234. */
  16235. MDCSelectFoundation.prototype.notchOutline = function (openNotch) {
  16236. if (!this.adapter.hasOutline()) {
  16237. return;
  16238. }
  16239. var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
  16240. if (openNotch) {
  16241. var labelScale = constants_2.numbers.LABEL_SCALE;
  16242. var labelWidth = this.adapter.getLabelWidth() * labelScale;
  16243. this.adapter.notchOutline(labelWidth);
  16244. } else if (!isFocused) {
  16245. this.adapter.closeOutline();
  16246. }
  16247. };
  16248. /**
  16249. * Sets the aria label of the leading icon.
  16250. */
  16251. MDCSelectFoundation.prototype.setLeadingIconAriaLabel = function (label) {
  16252. if (this.leadingIcon) {
  16253. this.leadingIcon.setAriaLabel(label);
  16254. }
  16255. };
  16256. /**
  16257. * Sets the text content of the leading icon.
  16258. */
  16259. MDCSelectFoundation.prototype.setLeadingIconContent = function (content) {
  16260. if (this.leadingIcon) {
  16261. this.leadingIcon.setContent(content);
  16262. }
  16263. };
  16264. MDCSelectFoundation.prototype.setUseDefaultValidation = function (useDefaultValidation) {
  16265. this.useDefaultValidation = useDefaultValidation;
  16266. };
  16267. MDCSelectFoundation.prototype.setValid = function (isValid) {
  16268. if (!this.useDefaultValidation) {
  16269. this.customValidity = isValid;
  16270. }
  16271. this.adapter.setSelectAnchorAttr('aria-invalid', (!isValid).toString());
  16272. if (isValid) {
  16273. this.adapter.removeClass(constants_2.cssClasses.INVALID);
  16274. this.adapter.removeMenuClass(constants_2.cssClasses.MENU_INVALID);
  16275. } else {
  16276. this.adapter.addClass(constants_2.cssClasses.INVALID);
  16277. this.adapter.addMenuClass(constants_2.cssClasses.MENU_INVALID);
  16278. }
  16279. this.syncHelperTextValidity(isValid);
  16280. };
  16281. MDCSelectFoundation.prototype.isValid = function () {
  16282. if (this.useDefaultValidation && this.adapter.hasClass(constants_2.cssClasses.REQUIRED) && !this.adapter.hasClass(constants_2.cssClasses.DISABLED)) {
  16283. // See notes for required attribute under https://www.w3.org/TR/html52/sec-forms.html#the-select-element
  16284. // TL;DR: Invalid if no index is selected, or if the first index is selected and has an empty value.
  16285. return this.getSelectedIndex() !== constants_2.numbers.UNSET_INDEX && (this.getSelectedIndex() !== 0 || Boolean(this.getValue()));
  16286. }
  16287. return this.customValidity;
  16288. };
  16289. MDCSelectFoundation.prototype.setRequired = function (isRequired) {
  16290. if (isRequired) {
  16291. this.adapter.addClass(constants_2.cssClasses.REQUIRED);
  16292. } else {
  16293. this.adapter.removeClass(constants_2.cssClasses.REQUIRED);
  16294. }
  16295. this.adapter.setSelectAnchorAttr('aria-required', isRequired.toString());
  16296. this.adapter.setLabelRequired(isRequired);
  16297. };
  16298. MDCSelectFoundation.prototype.getRequired = function () {
  16299. return this.adapter.getSelectAnchorAttr('aria-required') === 'true';
  16300. };
  16301. MDCSelectFoundation.prototype.init = function () {
  16302. var anchorEl = this.adapter.getAnchorElement();
  16303. if (anchorEl) {
  16304. this.adapter.setMenuAnchorElement(anchorEl);
  16305. this.adapter.setMenuAnchorCorner(constants_1.Corner.BOTTOM_START);
  16306. }
  16307. this.adapter.setMenuWrapFocus(false);
  16308. this.setDisabled(this.adapter.hasClass(constants_2.cssClasses.DISABLED));
  16309. this.syncHelperTextValidity(!this.adapter.hasClass(constants_2.cssClasses.INVALID));
  16310. this.layout();
  16311. this.layoutOptions();
  16312. };
  16313. /**
  16314. * Unfocuses the select component.
  16315. */
  16316. MDCSelectFoundation.prototype.blur = function () {
  16317. this.adapter.removeClass(constants_2.cssClasses.FOCUSED);
  16318. this.layout();
  16319. this.adapter.deactivateBottomLine();
  16320. var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
  16321. if (isRequired && this.useDefaultValidation) {
  16322. this.setValid(this.isValid());
  16323. }
  16324. };
  16325. MDCSelectFoundation.prototype.syncHelperTextValidity = function (isValid) {
  16326. if (!this.helperText) {
  16327. return;
  16328. }
  16329. this.helperText.setValidity(isValid);
  16330. var helperTextVisible = this.helperText.isVisible();
  16331. var helperTextId = this.helperText.getId();
  16332. if (helperTextVisible && helperTextId) {
  16333. this.adapter.setSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY, helperTextId);
  16334. } else {
  16335. // Needed because screenreaders will read labels pointed to by
  16336. // `aria-describedby` even if they are `aria-hidden`.
  16337. this.adapter.removeSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY);
  16338. }
  16339. };
  16340. MDCSelectFoundation.prototype.setClickDebounceTimeout = function () {
  16341. var _this = this;
  16342. clearTimeout(this.clickDebounceTimeout);
  16343. this.clickDebounceTimeout = setTimeout(function () {
  16344. _this.recentlyClicked = false;
  16345. }, constants_2.numbers.CLICK_DEBOUNCE_TIMEOUT_MS);
  16346. this.recentlyClicked = true;
  16347. };
  16348. return MDCSelectFoundation;
  16349. }(foundation_1.MDCFoundation);
  16350. exports.MDCSelectFoundation = MDCSelectFoundation;
  16351. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  16352. exports.default = MDCSelectFoundation;
  16353. /***/ }),
  16354. /***/ "./packages/mdc-select/helper-text/component.ts":
  16355. /*!******************************************************!*\
  16356. !*** ./packages/mdc-select/helper-text/component.ts ***!
  16357. \******************************************************/
  16358. /*! no static exports found */
  16359. /***/ (function(module, exports, __webpack_require__) {
  16360. "use strict";
  16361. /**
  16362. * @license
  16363. * Copyright 2018 Google Inc.
  16364. *
  16365. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16366. * of this software and associated documentation files (the "Software"), to deal
  16367. * in the Software without restriction, including without limitation the rights
  16368. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16369. * copies of the Software, and to permit persons to whom the Software is
  16370. * furnished to do so, subject to the following conditions:
  16371. *
  16372. * The above copyright notice and this permission notice shall be included in
  16373. * all copies or substantial portions of the Software.
  16374. *
  16375. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16376. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16377. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16378. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16379. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16380. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16381. * THE SOFTWARE.
  16382. */
  16383. var __extends = this && this.__extends || function () {
  16384. var _extendStatics = function extendStatics(d, b) {
  16385. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  16386. d.__proto__ = b;
  16387. } || function (d, b) {
  16388. for (var p in b) {
  16389. if (b.hasOwnProperty(p)) d[p] = b[p];
  16390. }
  16391. };
  16392. return _extendStatics(d, b);
  16393. };
  16394. return function (d, b) {
  16395. _extendStatics(d, b);
  16396. function __() {
  16397. this.constructor = d;
  16398. }
  16399. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16400. };
  16401. }();
  16402. Object.defineProperty(exports, "__esModule", { value: true });
  16403. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  16404. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts");
  16405. var MDCSelectHelperText = /** @class */function (_super) {
  16406. __extends(MDCSelectHelperText, _super);
  16407. function MDCSelectHelperText() {
  16408. return _super !== null && _super.apply(this, arguments) || this;
  16409. }
  16410. MDCSelectHelperText.attachTo = function (root) {
  16411. return new MDCSelectHelperText(root);
  16412. };
  16413. Object.defineProperty(MDCSelectHelperText.prototype, "foundationForSelect", {
  16414. // Provided for access by MDCSelect component
  16415. get: function get() {
  16416. return this.foundation;
  16417. },
  16418. enumerable: true,
  16419. configurable: true
  16420. });
  16421. MDCSelectHelperText.prototype.getDefaultFoundation = function () {
  16422. var _this = this;
  16423. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  16424. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  16425. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  16426. var adapter = {
  16427. addClass: function addClass(className) {
  16428. return _this.root.classList.add(className);
  16429. },
  16430. removeClass: function removeClass(className) {
  16431. return _this.root.classList.remove(className);
  16432. },
  16433. hasClass: function hasClass(className) {
  16434. return _this.root.classList.contains(className);
  16435. },
  16436. getAttr: function getAttr(attr) {
  16437. return _this.root.getAttribute(attr);
  16438. },
  16439. setAttr: function setAttr(attr, value) {
  16440. return _this.root.setAttribute(attr, value);
  16441. },
  16442. removeAttr: function removeAttr(attr) {
  16443. return _this.root.removeAttribute(attr);
  16444. },
  16445. setContent: function setContent(content) {
  16446. _this.root.textContent = content;
  16447. }
  16448. };
  16449. // tslint:enable:object-literal-sort-keys
  16450. return new foundation_1.MDCSelectHelperTextFoundation(adapter);
  16451. };
  16452. return MDCSelectHelperText;
  16453. }(component_1.MDCComponent);
  16454. exports.MDCSelectHelperText = MDCSelectHelperText;
  16455. /***/ }),
  16456. /***/ "./packages/mdc-select/helper-text/constants.ts":
  16457. /*!******************************************************!*\
  16458. !*** ./packages/mdc-select/helper-text/constants.ts ***!
  16459. \******************************************************/
  16460. /*! no static exports found */
  16461. /***/ (function(module, exports, __webpack_require__) {
  16462. "use strict";
  16463. /**
  16464. * @license
  16465. * Copyright 2018 Google Inc.
  16466. *
  16467. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16468. * of this software and associated documentation files (the "Software"), to deal
  16469. * in the Software without restriction, including without limitation the rights
  16470. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16471. * copies of the Software, and to permit persons to whom the Software is
  16472. * furnished to do so, subject to the following conditions:
  16473. *
  16474. * The above copyright notice and this permission notice shall be included in
  16475. * all copies or substantial portions of the Software.
  16476. *
  16477. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16478. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16479. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16480. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16481. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16482. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16483. * THE SOFTWARE.
  16484. */
  16485. Object.defineProperty(exports, "__esModule", { value: true });
  16486. var strings = {
  16487. ARIA_HIDDEN: 'aria-hidden',
  16488. ROLE: 'role'
  16489. };
  16490. exports.strings = strings;
  16491. var cssClasses = {
  16492. HELPER_TEXT_VALIDATION_MSG: 'mdc-select-helper-text--validation-msg',
  16493. HELPER_TEXT_VALIDATION_MSG_PERSISTENT: 'mdc-select-helper-text--validation-msg-persistent'
  16494. };
  16495. exports.cssClasses = cssClasses;
  16496. /***/ }),
  16497. /***/ "./packages/mdc-select/helper-text/foundation.ts":
  16498. /*!*******************************************************!*\
  16499. !*** ./packages/mdc-select/helper-text/foundation.ts ***!
  16500. \*******************************************************/
  16501. /*! no static exports found */
  16502. /***/ (function(module, exports, __webpack_require__) {
  16503. "use strict";
  16504. /**
  16505. * @license
  16506. * Copyright 2018 Google Inc.
  16507. *
  16508. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16509. * of this software and associated documentation files (the "Software"), to deal
  16510. * in the Software without restriction, including without limitation the rights
  16511. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16512. * copies of the Software, and to permit persons to whom the Software is
  16513. * furnished to do so, subject to the following conditions:
  16514. *
  16515. * The above copyright notice and this permission notice shall be included in
  16516. * all copies or substantial portions of the Software.
  16517. *
  16518. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16519. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16520. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16521. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16522. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16523. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16524. * THE SOFTWARE.
  16525. */
  16526. var __extends = this && this.__extends || function () {
  16527. var _extendStatics = function extendStatics(d, b) {
  16528. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  16529. d.__proto__ = b;
  16530. } || function (d, b) {
  16531. for (var p in b) {
  16532. if (b.hasOwnProperty(p)) d[p] = b[p];
  16533. }
  16534. };
  16535. return _extendStatics(d, b);
  16536. };
  16537. return function (d, b) {
  16538. _extendStatics(d, b);
  16539. function __() {
  16540. this.constructor = d;
  16541. }
  16542. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16543. };
  16544. }();
  16545. var __assign = this && this.__assign || function () {
  16546. __assign = Object.assign || function (t) {
  16547. for (var s, i = 1, n = arguments.length; i < n; i++) {
  16548. s = arguments[i];
  16549. for (var p in s) {
  16550. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  16551. }
  16552. }
  16553. return t;
  16554. };
  16555. return __assign.apply(this, arguments);
  16556. };
  16557. Object.defineProperty(exports, "__esModule", { value: true });
  16558. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  16559. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
  16560. var MDCSelectHelperTextFoundation = /** @class */function (_super) {
  16561. __extends(MDCSelectHelperTextFoundation, _super);
  16562. function MDCSelectHelperTextFoundation(adapter) {
  16563. return _super.call(this, __assign(__assign({}, MDCSelectHelperTextFoundation.defaultAdapter), adapter)) || this;
  16564. }
  16565. Object.defineProperty(MDCSelectHelperTextFoundation, "cssClasses", {
  16566. get: function get() {
  16567. return constants_1.cssClasses;
  16568. },
  16569. enumerable: true,
  16570. configurable: true
  16571. });
  16572. Object.defineProperty(MDCSelectHelperTextFoundation, "strings", {
  16573. get: function get() {
  16574. return constants_1.strings;
  16575. },
  16576. enumerable: true,
  16577. configurable: true
  16578. });
  16579. Object.defineProperty(MDCSelectHelperTextFoundation, "defaultAdapter", {
  16580. /**
  16581. * See {@link MDCSelectHelperTextAdapter} for typing information on parameters and return types.
  16582. */
  16583. get: function get() {
  16584. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  16585. return {
  16586. addClass: function addClass() {
  16587. return undefined;
  16588. },
  16589. removeClass: function removeClass() {
  16590. return undefined;
  16591. },
  16592. hasClass: function hasClass() {
  16593. return false;
  16594. },
  16595. setAttr: function setAttr() {
  16596. return undefined;
  16597. },
  16598. getAttr: function getAttr() {
  16599. return null;
  16600. },
  16601. removeAttr: function removeAttr() {
  16602. return undefined;
  16603. },
  16604. setContent: function setContent() {
  16605. return undefined;
  16606. }
  16607. };
  16608. // tslint:enable:object-literal-sort-keys
  16609. },
  16610. enumerable: true,
  16611. configurable: true
  16612. });
  16613. /**
  16614. * @return The ID of the helper text, or null if none is set.
  16615. */
  16616. MDCSelectHelperTextFoundation.prototype.getId = function () {
  16617. return this.adapter.getAttr('id');
  16618. };
  16619. /**
  16620. * @return Whether the helper text is currently visible.
  16621. */
  16622. MDCSelectHelperTextFoundation.prototype.isVisible = function () {
  16623. return this.adapter.getAttr(constants_1.strings.ARIA_HIDDEN) !== 'true';
  16624. };
  16625. /**
  16626. * Sets the content of the helper text field.
  16627. */
  16628. MDCSelectHelperTextFoundation.prototype.setContent = function (content) {
  16629. this.adapter.setContent(content);
  16630. };
  16631. /**
  16632. * Sets the helper text to act as a validation message.
  16633. * By default, validation messages are hidden when the select is valid and
  16634. * visible when the select is invalid.
  16635. *
  16636. * @param isValidation True to make the helper text act as an error validation
  16637. * message.
  16638. */
  16639. MDCSelectHelperTextFoundation.prototype.setValidation = function (isValidation) {
  16640. if (isValidation) {
  16641. this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  16642. } else {
  16643. this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  16644. }
  16645. };
  16646. /**
  16647. * Sets the persistency of the validation helper text.
  16648. * This keeps the validation message visible even if the select is valid,
  16649. * though it will be displayed in the normal (grey) color.
  16650. */
  16651. MDCSelectHelperTextFoundation.prototype.setValidationMsgPersistent = function (isPersistent) {
  16652. if (isPersistent) {
  16653. this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
  16654. } else {
  16655. this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
  16656. }
  16657. };
  16658. /**
  16659. * When acting as a validation message, shows/hides the helper text and
  16660. * triggers alerts as necessary based on the select's validity.
  16661. */
  16662. MDCSelectHelperTextFoundation.prototype.setValidity = function (selectIsValid) {
  16663. var isValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  16664. if (!isValidationMsg) {
  16665. // Non-validating helper-text is always displayed and does not participate
  16666. // in validation logic.
  16667. return;
  16668. }
  16669. var isPersistentValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
  16670. // Validating helper text is displayed if select is invalid, unless it is
  16671. // set as persistent, in which case it always displays.
  16672. var msgShouldDisplay = !selectIsValid || isPersistentValidationMsg;
  16673. if (msgShouldDisplay) {
  16674. this.showToScreenReader();
  16675. // In addition to displaying, also trigger an alert if the select
  16676. // has become invalid.
  16677. if (!selectIsValid) {
  16678. this.adapter.setAttr(constants_1.strings.ROLE, 'alert');
  16679. } else {
  16680. this.adapter.removeAttr(constants_1.strings.ROLE);
  16681. }
  16682. return;
  16683. }
  16684. // Hide everything.
  16685. this.adapter.removeAttr(constants_1.strings.ROLE);
  16686. this.hide();
  16687. };
  16688. /**
  16689. * Makes the helper text visible to screen readers.
  16690. */
  16691. MDCSelectHelperTextFoundation.prototype.showToScreenReader = function () {
  16692. this.adapter.removeAttr(constants_1.strings.ARIA_HIDDEN);
  16693. };
  16694. /**
  16695. * Hides the help text from screen readers.
  16696. */
  16697. MDCSelectHelperTextFoundation.prototype.hide = function () {
  16698. this.adapter.setAttr(constants_1.strings.ARIA_HIDDEN, 'true');
  16699. };
  16700. return MDCSelectHelperTextFoundation;
  16701. }(foundation_1.MDCFoundation);
  16702. exports.MDCSelectHelperTextFoundation = MDCSelectHelperTextFoundation;
  16703. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  16704. exports.default = MDCSelectHelperTextFoundation;
  16705. /***/ }),
  16706. /***/ "./packages/mdc-select/helper-text/index.ts":
  16707. /*!**************************************************!*\
  16708. !*** ./packages/mdc-select/helper-text/index.ts ***!
  16709. \**************************************************/
  16710. /*! no static exports found */
  16711. /***/ (function(module, exports, __webpack_require__) {
  16712. "use strict";
  16713. /**
  16714. * @license
  16715. * Copyright 2019 Google Inc.
  16716. *
  16717. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16718. * of this software and associated documentation files (the "Software"), to deal
  16719. * in the Software without restriction, including without limitation the rights
  16720. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16721. * copies of the Software, and to permit persons to whom the Software is
  16722. * furnished to do so, subject to the following conditions:
  16723. *
  16724. * The above copyright notice and this permission notice shall be included in
  16725. * all copies or substantial portions of the Software.
  16726. *
  16727. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16728. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16729. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16730. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16731. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16732. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16733. * THE SOFTWARE.
  16734. */
  16735. function __export(m) {
  16736. for (var p in m) {
  16737. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  16738. }
  16739. }
  16740. Object.defineProperty(exports, "__esModule", { value: true });
  16741. __export(__webpack_require__(/*! ./component */ "./packages/mdc-select/helper-text/component.ts"));
  16742. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts"));
  16743. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
  16744. exports.helperTextCssClasses = constants_1.cssClasses;
  16745. exports.helperTextStrings = constants_1.strings;
  16746. /***/ }),
  16747. /***/ "./packages/mdc-select/icon/component.ts":
  16748. /*!***********************************************!*\
  16749. !*** ./packages/mdc-select/icon/component.ts ***!
  16750. \***********************************************/
  16751. /*! no static exports found */
  16752. /***/ (function(module, exports, __webpack_require__) {
  16753. "use strict";
  16754. /**
  16755. * @license
  16756. * Copyright 2018 Google Inc.
  16757. *
  16758. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16759. * of this software and associated documentation files (the "Software"), to deal
  16760. * in the Software without restriction, including without limitation the rights
  16761. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16762. * copies of the Software, and to permit persons to whom the Software is
  16763. * furnished to do so, subject to the following conditions:
  16764. *
  16765. * The above copyright notice and this permission notice shall be included in
  16766. * all copies or substantial portions of the Software.
  16767. *
  16768. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16769. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16770. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16771. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16772. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16773. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16774. * THE SOFTWARE.
  16775. */
  16776. var __extends = this && this.__extends || function () {
  16777. var _extendStatics = function extendStatics(d, b) {
  16778. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  16779. d.__proto__ = b;
  16780. } || function (d, b) {
  16781. for (var p in b) {
  16782. if (b.hasOwnProperty(p)) d[p] = b[p];
  16783. }
  16784. };
  16785. return _extendStatics(d, b);
  16786. };
  16787. return function (d, b) {
  16788. _extendStatics(d, b);
  16789. function __() {
  16790. this.constructor = d;
  16791. }
  16792. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16793. };
  16794. }();
  16795. Object.defineProperty(exports, "__esModule", { value: true });
  16796. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  16797. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts");
  16798. var MDCSelectIcon = /** @class */function (_super) {
  16799. __extends(MDCSelectIcon, _super);
  16800. function MDCSelectIcon() {
  16801. return _super !== null && _super.apply(this, arguments) || this;
  16802. }
  16803. MDCSelectIcon.attachTo = function (root) {
  16804. return new MDCSelectIcon(root);
  16805. };
  16806. Object.defineProperty(MDCSelectIcon.prototype, "foundationForSelect", {
  16807. // Provided for access by MDCSelect component
  16808. get: function get() {
  16809. return this.foundation;
  16810. },
  16811. enumerable: true,
  16812. configurable: true
  16813. });
  16814. MDCSelectIcon.prototype.getDefaultFoundation = function () {
  16815. var _this = this;
  16816. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  16817. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  16818. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  16819. var adapter = {
  16820. getAttr: function getAttr(attr) {
  16821. return _this.root.getAttribute(attr);
  16822. },
  16823. setAttr: function setAttr(attr, value) {
  16824. return _this.root.setAttribute(attr, value);
  16825. },
  16826. removeAttr: function removeAttr(attr) {
  16827. return _this.root.removeAttribute(attr);
  16828. },
  16829. setContent: function setContent(content) {
  16830. _this.root.textContent = content;
  16831. },
  16832. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  16833. return _this.listen(evtType, handler);
  16834. },
  16835. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  16836. return _this.unlisten(evtType, handler);
  16837. },
  16838. notifyIconAction: function notifyIconAction() {
  16839. return _this.emit(foundation_1.MDCSelectIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */);
  16840. }
  16841. };
  16842. // tslint:enable:object-literal-sort-keys
  16843. return new foundation_1.MDCSelectIconFoundation(adapter);
  16844. };
  16845. return MDCSelectIcon;
  16846. }(component_1.MDCComponent);
  16847. exports.MDCSelectIcon = MDCSelectIcon;
  16848. /***/ }),
  16849. /***/ "./packages/mdc-select/icon/constants.ts":
  16850. /*!***********************************************!*\
  16851. !*** ./packages/mdc-select/icon/constants.ts ***!
  16852. \***********************************************/
  16853. /*! no static exports found */
  16854. /***/ (function(module, exports, __webpack_require__) {
  16855. "use strict";
  16856. /**
  16857. * @license
  16858. * Copyright 2018 Google Inc.
  16859. *
  16860. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16861. * of this software and associated documentation files (the "Software"), to deal
  16862. * in the Software without restriction, including without limitation the rights
  16863. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16864. * copies of the Software, and to permit persons to whom the Software is
  16865. * furnished to do so, subject to the following conditions:
  16866. *
  16867. * The above copyright notice and this permission notice shall be included in
  16868. * all copies or substantial portions of the Software.
  16869. *
  16870. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16871. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16872. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16873. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16874. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16875. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16876. * THE SOFTWARE.
  16877. */
  16878. Object.defineProperty(exports, "__esModule", { value: true });
  16879. var strings = {
  16880. ICON_EVENT: 'MDCSelect:icon',
  16881. ICON_ROLE: 'button'
  16882. };
  16883. exports.strings = strings;
  16884. /***/ }),
  16885. /***/ "./packages/mdc-select/icon/foundation.ts":
  16886. /*!************************************************!*\
  16887. !*** ./packages/mdc-select/icon/foundation.ts ***!
  16888. \************************************************/
  16889. /*! no static exports found */
  16890. /***/ (function(module, exports, __webpack_require__) {
  16891. "use strict";
  16892. /**
  16893. * @license
  16894. * Copyright 2018 Google Inc.
  16895. *
  16896. * Permission is hereby granted, free of charge, to any person obtaining a copy
  16897. * of this software and associated documentation files (the "Software"), to deal
  16898. * in the Software without restriction, including without limitation the rights
  16899. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16900. * copies of the Software, and to permit persons to whom the Software is
  16901. * furnished to do so, subject to the following conditions:
  16902. *
  16903. * The above copyright notice and this permission notice shall be included in
  16904. * all copies or substantial portions of the Software.
  16905. *
  16906. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16907. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16908. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16909. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16910. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16911. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  16912. * THE SOFTWARE.
  16913. */
  16914. var __extends = this && this.__extends || function () {
  16915. var _extendStatics = function extendStatics(d, b) {
  16916. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  16917. d.__proto__ = b;
  16918. } || function (d, b) {
  16919. for (var p in b) {
  16920. if (b.hasOwnProperty(p)) d[p] = b[p];
  16921. }
  16922. };
  16923. return _extendStatics(d, b);
  16924. };
  16925. return function (d, b) {
  16926. _extendStatics(d, b);
  16927. function __() {
  16928. this.constructor = d;
  16929. }
  16930. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  16931. };
  16932. }();
  16933. var __assign = this && this.__assign || function () {
  16934. __assign = Object.assign || function (t) {
  16935. for (var s, i = 1, n = arguments.length; i < n; i++) {
  16936. s = arguments[i];
  16937. for (var p in s) {
  16938. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  16939. }
  16940. }
  16941. return t;
  16942. };
  16943. return __assign.apply(this, arguments);
  16944. };
  16945. Object.defineProperty(exports, "__esModule", { value: true });
  16946. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  16947. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
  16948. var INTERACTION_EVENTS = ['click', 'keydown'];
  16949. var MDCSelectIconFoundation = /** @class */function (_super) {
  16950. __extends(MDCSelectIconFoundation, _super);
  16951. function MDCSelectIconFoundation(adapter) {
  16952. var _this = _super.call(this, __assign(__assign({}, MDCSelectIconFoundation.defaultAdapter), adapter)) || this;
  16953. _this.savedTabIndex_ = null;
  16954. _this.interactionHandler_ = function (evt) {
  16955. return _this.handleInteraction(evt);
  16956. };
  16957. return _this;
  16958. }
  16959. Object.defineProperty(MDCSelectIconFoundation, "strings", {
  16960. get: function get() {
  16961. return constants_1.strings;
  16962. },
  16963. enumerable: true,
  16964. configurable: true
  16965. });
  16966. Object.defineProperty(MDCSelectIconFoundation, "defaultAdapter", {
  16967. /**
  16968. * See {@link MDCSelectIconAdapter} for typing information on parameters and return types.
  16969. */
  16970. get: function get() {
  16971. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  16972. return {
  16973. getAttr: function getAttr() {
  16974. return null;
  16975. },
  16976. setAttr: function setAttr() {
  16977. return undefined;
  16978. },
  16979. removeAttr: function removeAttr() {
  16980. return undefined;
  16981. },
  16982. setContent: function setContent() {
  16983. return undefined;
  16984. },
  16985. registerInteractionHandler: function registerInteractionHandler() {
  16986. return undefined;
  16987. },
  16988. deregisterInteractionHandler: function deregisterInteractionHandler() {
  16989. return undefined;
  16990. },
  16991. notifyIconAction: function notifyIconAction() {
  16992. return undefined;
  16993. }
  16994. };
  16995. // tslint:enable:object-literal-sort-keys
  16996. },
  16997. enumerable: true,
  16998. configurable: true
  16999. });
  17000. MDCSelectIconFoundation.prototype.init = function () {
  17001. var _this = this;
  17002. this.savedTabIndex_ = this.adapter.getAttr('tabindex');
  17003. INTERACTION_EVENTS.forEach(function (evtType) {
  17004. _this.adapter.registerInteractionHandler(evtType, _this.interactionHandler_);
  17005. });
  17006. };
  17007. MDCSelectIconFoundation.prototype.destroy = function () {
  17008. var _this = this;
  17009. INTERACTION_EVENTS.forEach(function (evtType) {
  17010. _this.adapter.deregisterInteractionHandler(evtType, _this.interactionHandler_);
  17011. });
  17012. };
  17013. MDCSelectIconFoundation.prototype.setDisabled = function (disabled) {
  17014. if (!this.savedTabIndex_) {
  17015. return;
  17016. }
  17017. if (disabled) {
  17018. this.adapter.setAttr('tabindex', '-1');
  17019. this.adapter.removeAttr('role');
  17020. } else {
  17021. this.adapter.setAttr('tabindex', this.savedTabIndex_);
  17022. this.adapter.setAttr('role', constants_1.strings.ICON_ROLE);
  17023. }
  17024. };
  17025. MDCSelectIconFoundation.prototype.setAriaLabel = function (label) {
  17026. this.adapter.setAttr('aria-label', label);
  17027. };
  17028. MDCSelectIconFoundation.prototype.setContent = function (content) {
  17029. this.adapter.setContent(content);
  17030. };
  17031. MDCSelectIconFoundation.prototype.handleInteraction = function (evt) {
  17032. var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
  17033. if (evt.type === 'click' || isEnterKey) {
  17034. this.adapter.notifyIconAction();
  17035. }
  17036. };
  17037. return MDCSelectIconFoundation;
  17038. }(foundation_1.MDCFoundation);
  17039. exports.MDCSelectIconFoundation = MDCSelectIconFoundation;
  17040. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  17041. exports.default = MDCSelectIconFoundation;
  17042. /***/ }),
  17043. /***/ "./packages/mdc-select/icon/index.ts":
  17044. /*!*******************************************!*\
  17045. !*** ./packages/mdc-select/icon/index.ts ***!
  17046. \*******************************************/
  17047. /*! no static exports found */
  17048. /***/ (function(module, exports, __webpack_require__) {
  17049. "use strict";
  17050. /**
  17051. * @license
  17052. * Copyright 2019 Google Inc.
  17053. *
  17054. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17055. * of this software and associated documentation files (the "Software"), to deal
  17056. * in the Software without restriction, including without limitation the rights
  17057. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17058. * copies of the Software, and to permit persons to whom the Software is
  17059. * furnished to do so, subject to the following conditions:
  17060. *
  17061. * The above copyright notice and this permission notice shall be included in
  17062. * all copies or substantial portions of the Software.
  17063. *
  17064. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17065. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17066. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17067. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17068. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17069. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17070. * THE SOFTWARE.
  17071. */
  17072. function __export(m) {
  17073. for (var p in m) {
  17074. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  17075. }
  17076. }
  17077. Object.defineProperty(exports, "__esModule", { value: true });
  17078. __export(__webpack_require__(/*! ./component */ "./packages/mdc-select/icon/component.ts"));
  17079. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts"));
  17080. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
  17081. exports.iconStrings = constants_1.strings;
  17082. /***/ }),
  17083. /***/ "./packages/mdc-select/index.ts":
  17084. /*!**************************************!*\
  17085. !*** ./packages/mdc-select/index.ts ***!
  17086. \**************************************/
  17087. /*! no static exports found */
  17088. /***/ (function(module, exports, __webpack_require__) {
  17089. "use strict";
  17090. /**
  17091. * @license
  17092. * Copyright 2019 Google Inc.
  17093. *
  17094. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17095. * of this software and associated documentation files (the "Software"), to deal
  17096. * in the Software without restriction, including without limitation the rights
  17097. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17098. * copies of the Software, and to permit persons to whom the Software is
  17099. * furnished to do so, subject to the following conditions:
  17100. *
  17101. * The above copyright notice and this permission notice shall be included in
  17102. * all copies or substantial portions of the Software.
  17103. *
  17104. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17105. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17106. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17107. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17108. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17109. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17110. * THE SOFTWARE.
  17111. */
  17112. function __export(m) {
  17113. for (var p in m) {
  17114. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  17115. }
  17116. }
  17117. Object.defineProperty(exports, "__esModule", { value: true });
  17118. __export(__webpack_require__(/*! ./component */ "./packages/mdc-select/component.ts"));
  17119. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts"));
  17120. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts"));
  17121. __export(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-select/helper-text/index.ts"));
  17122. __export(__webpack_require__(/*! ./icon/index */ "./packages/mdc-select/icon/index.ts"));
  17123. /***/ }),
  17124. /***/ "./packages/mdc-slider/component.ts":
  17125. /*!******************************************!*\
  17126. !*** ./packages/mdc-slider/component.ts ***!
  17127. \******************************************/
  17128. /*! no static exports found */
  17129. /***/ (function(module, exports, __webpack_require__) {
  17130. "use strict";
  17131. /**
  17132. * @license
  17133. * Copyright 2020 Google Inc.
  17134. *
  17135. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17136. * of this software and associated documentation files (the "Software"), to deal
  17137. * in the Software without restriction, including without limitation the rights
  17138. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17139. * copies of the Software, and to permit persons to whom the Software is
  17140. * furnished to do so, subject to the following conditions:
  17141. *
  17142. * The above copyright notice and this permission notice shall be included in
  17143. * all copies or substantial portions of the Software.
  17144. *
  17145. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17146. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17147. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17148. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17149. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17150. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17151. * THE SOFTWARE.
  17152. */
  17153. var __extends = this && this.__extends || function () {
  17154. var _extendStatics = function extendStatics(d, b) {
  17155. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  17156. d.__proto__ = b;
  17157. } || function (d, b) {
  17158. for (var p in b) {
  17159. if (b.hasOwnProperty(p)) d[p] = b[p];
  17160. }
  17161. };
  17162. return _extendStatics(d, b);
  17163. };
  17164. return function (d, b) {
  17165. _extendStatics(d, b);
  17166. function __() {
  17167. this.constructor = d;
  17168. }
  17169. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17170. };
  17171. }();
  17172. var __assign = this && this.__assign || function () {
  17173. __assign = Object.assign || function (t) {
  17174. for (var s, i = 1, n = arguments.length; i < n; i++) {
  17175. s = arguments[i];
  17176. for (var p in s) {
  17177. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  17178. }
  17179. }
  17180. return t;
  17181. };
  17182. return __assign.apply(this, arguments);
  17183. };
  17184. Object.defineProperty(exports, "__esModule", { value: true });
  17185. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  17186. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  17187. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  17188. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  17189. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  17190. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
  17191. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts");
  17192. var types_1 = __webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts");
  17193. /** Vanilla JS implementation of slider component. */
  17194. var MDCSlider = /** @class */function (_super) {
  17195. __extends(MDCSlider, _super);
  17196. function MDCSlider() {
  17197. var _this = _super !== null && _super.apply(this, arguments) || this;
  17198. _this.skipInitialUIUpdate = false;
  17199. // Function that maps a slider value to the value of the `aria-valuetext`
  17200. // attribute on the thumb element.
  17201. _this.valueToAriaValueTextFn = null;
  17202. return _this;
  17203. }
  17204. MDCSlider.attachTo = function (root, options) {
  17205. if (options === void 0) {
  17206. options = {};
  17207. }
  17208. return new MDCSlider(root, undefined, options);
  17209. };
  17210. MDCSlider.prototype.getDefaultFoundation = function () {
  17211. var _this = this;
  17212. // tslint:disable:object-literal-sort-keys Methods should be in the same
  17213. // order as the adapter interface.
  17214. var adapter = {
  17215. hasClass: function hasClass(className) {
  17216. return _this.root.classList.contains(className);
  17217. },
  17218. addClass: function addClass(className) {
  17219. _this.root.classList.add(className);
  17220. },
  17221. removeClass: function removeClass(className) {
  17222. _this.root.classList.remove(className);
  17223. },
  17224. addThumbClass: function addThumbClass(className, thumb) {
  17225. _this.getThumbEl(thumb).classList.add(className);
  17226. },
  17227. removeThumbClass: function removeThumbClass(className, thumb) {
  17228. _this.getThumbEl(thumb).classList.remove(className);
  17229. },
  17230. getAttribute: function getAttribute(attribute) {
  17231. return _this.root.getAttribute(attribute);
  17232. },
  17233. getInputValue: function getInputValue(thumb) {
  17234. return _this.getInput(thumb).value;
  17235. },
  17236. setInputValue: function setInputValue(value, thumb) {
  17237. _this.getInput(thumb).value = value;
  17238. },
  17239. getInputAttribute: function getInputAttribute(attribute, thumb) {
  17240. return _this.getInput(thumb).getAttribute(attribute);
  17241. },
  17242. setInputAttribute: function setInputAttribute(attribute, value, thumb) {
  17243. _this.getInput(thumb).setAttribute(attribute, value);
  17244. },
  17245. removeInputAttribute: function removeInputAttribute(attribute, thumb) {
  17246. _this.getInput(thumb).removeAttribute(attribute);
  17247. },
  17248. focusInput: function focusInput(thumb) {
  17249. _this.getInput(thumb).focus();
  17250. },
  17251. isInputFocused: function isInputFocused(thumb) {
  17252. return _this.getInput(thumb) === document.activeElement;
  17253. },
  17254. getThumbKnobWidth: function getThumbKnobWidth(thumb) {
  17255. return _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.THUMB_KNOB).getBoundingClientRect().width;
  17256. },
  17257. getThumbBoundingClientRect: function getThumbBoundingClientRect(thumb) {
  17258. return _this.getThumbEl(thumb).getBoundingClientRect();
  17259. },
  17260. getBoundingClientRect: function getBoundingClientRect() {
  17261. return _this.root.getBoundingClientRect();
  17262. },
  17263. isRTL: function isRTL() {
  17264. return getComputedStyle(_this.root).direction === 'rtl';
  17265. },
  17266. setThumbStyleProperty: function setThumbStyleProperty(propertyName, value, thumb) {
  17267. _this.getThumbEl(thumb).style.setProperty(propertyName, value);
  17268. },
  17269. removeThumbStyleProperty: function removeThumbStyleProperty(propertyName, thumb) {
  17270. _this.getThumbEl(thumb).style.removeProperty(propertyName);
  17271. },
  17272. setTrackActiveStyleProperty: function setTrackActiveStyleProperty(propertyName, value) {
  17273. _this.trackActive.style.setProperty(propertyName, value);
  17274. },
  17275. removeTrackActiveStyleProperty: function removeTrackActiveStyleProperty(propertyName) {
  17276. _this.trackActive.style.removeProperty(propertyName);
  17277. },
  17278. setValueIndicatorText: function setValueIndicatorText(value, thumb) {
  17279. var valueIndicatorEl = _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.VALUE_INDICATOR_TEXT);
  17280. valueIndicatorEl.textContent = String(value);
  17281. },
  17282. getValueToAriaValueTextFn: function getValueToAriaValueTextFn() {
  17283. return _this.valueToAriaValueTextFn;
  17284. },
  17285. updateTickMarks: function updateTickMarks(tickMarks) {
  17286. var tickMarksContainer = _this.root.querySelector("." + constants_1.cssClasses.TICK_MARKS_CONTAINER);
  17287. if (!tickMarksContainer) {
  17288. tickMarksContainer = document.createElement('div');
  17289. tickMarksContainer.classList.add(constants_1.cssClasses.TICK_MARKS_CONTAINER);
  17290. var track = _this.root.querySelector("." + constants_1.cssClasses.TRACK);
  17291. track.appendChild(tickMarksContainer);
  17292. }
  17293. if (tickMarks.length !== tickMarksContainer.children.length) {
  17294. tickMarksContainer.innerHTML = '';
  17295. _this.addTickMarks(tickMarksContainer, tickMarks);
  17296. } else {
  17297. _this.updateTickMarks(tickMarksContainer, tickMarks);
  17298. }
  17299. },
  17300. setPointerCapture: function setPointerCapture(pointerId) {
  17301. _this.root.setPointerCapture(pointerId);
  17302. },
  17303. emitChangeEvent: function emitChangeEvent(value, thumb) {
  17304. _this.emit(constants_1.events.CHANGE, { value: value, thumb: thumb });
  17305. },
  17306. emitInputEvent: function emitInputEvent(value, thumb) {
  17307. _this.emit(constants_1.events.INPUT, { value: value, thumb: thumb });
  17308. },
  17309. emitDragStartEvent: function emitDragStartEvent(_, thumb) {
  17310. // Emitting event is not yet implemented. See issue:
  17311. // https://github.com/material-components/material-components-web/issues/6448
  17312. _this.getRipple(thumb).activate();
  17313. },
  17314. emitDragEndEvent: function emitDragEndEvent(_, thumb) {
  17315. // Emitting event is not yet implemented. See issue:
  17316. // https://github.com/material-components/material-components-web/issues/6448
  17317. _this.getRipple(thumb).deactivate();
  17318. },
  17319. registerEventHandler: function registerEventHandler(evtType, handler) {
  17320. _this.listen(evtType, handler);
  17321. },
  17322. deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
  17323. _this.unlisten(evtType, handler);
  17324. },
  17325. registerThumbEventHandler: function registerThumbEventHandler(thumb, evtType, handler) {
  17326. _this.getThumbEl(thumb).addEventListener(evtType, handler);
  17327. },
  17328. deregisterThumbEventHandler: function deregisterThumbEventHandler(thumb, evtType, handler) {
  17329. _this.getThumbEl(thumb).removeEventListener(evtType, handler);
  17330. },
  17331. registerInputEventHandler: function registerInputEventHandler(thumb, evtType, handler) {
  17332. _this.getInput(thumb).addEventListener(evtType, handler);
  17333. },
  17334. deregisterInputEventHandler: function deregisterInputEventHandler(thumb, evtType, handler) {
  17335. _this.getInput(thumb).removeEventListener(evtType, handler);
  17336. },
  17337. registerBodyEventHandler: function registerBodyEventHandler(evtType, handler) {
  17338. document.body.addEventListener(evtType, handler);
  17339. },
  17340. deregisterBodyEventHandler: function deregisterBodyEventHandler(evtType, handler) {
  17341. document.body.removeEventListener(evtType, handler);
  17342. },
  17343. registerWindowEventHandler: function registerWindowEventHandler(evtType, handler) {
  17344. window.addEventListener(evtType, handler);
  17345. },
  17346. deregisterWindowEventHandler: function deregisterWindowEventHandler(evtType, handler) {
  17347. window.removeEventListener(evtType, handler);
  17348. }
  17349. };
  17350. return new foundation_2.MDCSliderFoundation(adapter);
  17351. };
  17352. /**
  17353. * Initializes component, with the following options:
  17354. * - `skipInitialUIUpdate`: Whether to skip updating the UI when initially
  17355. * syncing with the DOM. This should be enabled when the slider position
  17356. * is set before component initialization.
  17357. */
  17358. MDCSlider.prototype.initialize = function (_a) {
  17359. var skipInitialUIUpdate = (_a === void 0 ? {} : _a).skipInitialUIUpdate;
  17360. this.inputs = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.INPUT));
  17361. this.thumbs = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.THUMB));
  17362. this.trackActive = this.root.querySelector("." + constants_1.cssClasses.TRACK_ACTIVE);
  17363. this.ripples = this.createRipples();
  17364. if (skipInitialUIUpdate) {
  17365. this.skipInitialUIUpdate = true;
  17366. }
  17367. };
  17368. MDCSlider.prototype.initialSyncWithDOM = function () {
  17369. this.foundation.layout({ skipUpdateUI: this.skipInitialUIUpdate });
  17370. };
  17371. /** Redraws UI based on DOM (e.g. element dimensions, RTL). */
  17372. MDCSlider.prototype.layout = function () {
  17373. this.foundation.layout();
  17374. };
  17375. MDCSlider.prototype.getValueStart = function () {
  17376. return this.foundation.getValueStart();
  17377. };
  17378. MDCSlider.prototype.setValueStart = function (valueStart) {
  17379. this.foundation.setValueStart(valueStart);
  17380. };
  17381. MDCSlider.prototype.getValue = function () {
  17382. return this.foundation.getValue();
  17383. };
  17384. MDCSlider.prototype.setValue = function (value) {
  17385. this.foundation.setValue(value);
  17386. };
  17387. /** @return Slider disabled state. */
  17388. MDCSlider.prototype.getDisabled = function () {
  17389. return this.foundation.getDisabled();
  17390. };
  17391. /** Sets slider disabled state. */
  17392. MDCSlider.prototype.setDisabled = function (disabled) {
  17393. this.foundation.setDisabled(disabled);
  17394. };
  17395. /**
  17396. * Sets a function that maps the slider value to the value of the
  17397. * `aria-valuetext` attribute on the thumb element.
  17398. */
  17399. MDCSlider.prototype.setValueToAriaValueTextFn = function (mapFn) {
  17400. this.valueToAriaValueTextFn = mapFn;
  17401. };
  17402. MDCSlider.prototype.getThumbEl = function (thumb) {
  17403. return thumb === types_1.Thumb.END ? this.thumbs[this.thumbs.length - 1] : this.thumbs[0];
  17404. };
  17405. MDCSlider.prototype.getInput = function (thumb) {
  17406. return thumb === types_1.Thumb.END ? this.inputs[this.inputs.length - 1] : this.inputs[0];
  17407. };
  17408. MDCSlider.prototype.getRipple = function (thumb) {
  17409. return thumb === types_1.Thumb.END ? this.ripples[this.ripples.length - 1] : this.ripples[0];
  17410. };
  17411. /** Adds tick mark elements to the given container. */
  17412. MDCSlider.prototype.addTickMarks = function (tickMarkContainer, tickMarks) {
  17413. var fragment = document.createDocumentFragment();
  17414. for (var i = 0; i < tickMarks.length; i++) {
  17415. var div = document.createElement('div');
  17416. var tickMarkClass = tickMarks[i] === types_1.TickMark.ACTIVE ? constants_1.cssClasses.TICK_MARK_ACTIVE : constants_1.cssClasses.TICK_MARK_INACTIVE;
  17417. div.classList.add(tickMarkClass);
  17418. fragment.appendChild(div);
  17419. }
  17420. tickMarkContainer.appendChild(fragment);
  17421. };
  17422. /** Updates tick mark elements' classes in the given container. */
  17423. MDCSlider.prototype.updateTickMarks = function (tickMarkContainer, tickMarks) {
  17424. var tickMarkEls = Array.from(tickMarkContainer.children);
  17425. for (var i = 0; i < tickMarkEls.length; i++) {
  17426. if (tickMarks[i] === types_1.TickMark.ACTIVE) {
  17427. tickMarkEls[i].classList.add(constants_1.cssClasses.TICK_MARK_ACTIVE);
  17428. tickMarkEls[i].classList.remove(constants_1.cssClasses.TICK_MARK_INACTIVE);
  17429. } else {
  17430. tickMarkEls[i].classList.add(constants_1.cssClasses.TICK_MARK_INACTIVE);
  17431. tickMarkEls[i].classList.remove(constants_1.cssClasses.TICK_MARK_ACTIVE);
  17432. }
  17433. }
  17434. };
  17435. /** Initializes thumb ripples. */
  17436. MDCSlider.prototype.createRipples = function () {
  17437. var ripples = [];
  17438. var rippleSurfaces = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.THUMB));
  17439. var _loop_1 = function _loop_1(i) {
  17440. var rippleSurface = rippleSurfaces[i];
  17441. // Use the corresponding input as the focus source for the ripple (i.e.
  17442. // when the input is focused, the ripple is in the focused state).
  17443. var input = this_1.inputs[i];
  17444. var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this_1)), { addClass: function addClass(className) {
  17445. rippleSurface.classList.add(className);
  17446. }, computeBoundingRect: function computeBoundingRect() {
  17447. return rippleSurface.getBoundingClientRect();
  17448. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  17449. input.removeEventListener(evtType, handler);
  17450. }, isSurfaceActive: function isSurfaceActive() {
  17451. return ponyfill_1.matches(input, ':active');
  17452. }, isUnbounded: function isUnbounded() {
  17453. return true;
  17454. }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  17455. input.addEventListener(evtType, handler, events_1.applyPassive());
  17456. }, removeClass: function removeClass(className) {
  17457. rippleSurface.classList.remove(className);
  17458. }, updateCssVariable: function updateCssVariable(varName, value) {
  17459. rippleSurface.style.setProperty(varName, value);
  17460. } });
  17461. var ripple = new component_2.MDCRipple(rippleSurface, new foundation_1.MDCRippleFoundation(adapter));
  17462. ripple.unbounded = true;
  17463. ripples.push(ripple);
  17464. };
  17465. var this_1 = this;
  17466. for (var i = 0; i < rippleSurfaces.length; i++) {
  17467. _loop_1(i);
  17468. }
  17469. return ripples;
  17470. };
  17471. return MDCSlider;
  17472. }(component_1.MDCComponent);
  17473. exports.MDCSlider = MDCSlider;
  17474. /***/ }),
  17475. /***/ "./packages/mdc-slider/constants.ts":
  17476. /*!******************************************!*\
  17477. !*** ./packages/mdc-slider/constants.ts ***!
  17478. \******************************************/
  17479. /*! no static exports found */
  17480. /***/ (function(module, exports, __webpack_require__) {
  17481. "use strict";
  17482. /**
  17483. * @license
  17484. * Copyright 2020 Google Inc.
  17485. *
  17486. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17487. * of this software and associated documentation files (the "Software"), to deal
  17488. * in the Software without restriction, including without limitation the rights
  17489. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17490. * copies of the Software, and to permit persons to whom the Software is
  17491. * furnished to do so, subject to the following conditions:
  17492. *
  17493. * The above copyright notice and this permission notice shall be included in
  17494. * all copies or substantial portions of the Software.
  17495. *
  17496. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17497. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17498. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17499. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17500. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17501. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17502. * THE SOFTWARE.
  17503. */
  17504. Object.defineProperty(exports, "__esModule", { value: true });
  17505. /** Slider element classes. */
  17506. exports.cssClasses = {
  17507. DISABLED: 'mdc-slider--disabled',
  17508. DISCRETE: 'mdc-slider--discrete',
  17509. INPUT: 'mdc-slider__input',
  17510. RANGE: 'mdc-slider--range',
  17511. THUMB: 'mdc-slider__thumb',
  17512. THUMB_KNOB: 'mdc-slider__thumb-knob',
  17513. // Class added to the top thumb (for overlapping thumbs in range slider).
  17514. THUMB_TOP: 'mdc-slider__thumb--top',
  17515. THUMB_WITH_INDICATOR: 'mdc-slider__thumb--with-indicator',
  17516. TICK_MARKS: 'mdc-slider--tick-marks',
  17517. TICK_MARKS_CONTAINER: 'mdc-slider__tick-marks',
  17518. TICK_MARK_ACTIVE: 'mdc-slider__tick-mark--active',
  17519. TICK_MARK_INACTIVE: 'mdc-slider__tick-mark--inactive',
  17520. TRACK: 'mdc-slider__track',
  17521. // The active track fill element that will be scaled as the value changes.
  17522. TRACK_ACTIVE: 'mdc-slider__track--active_fill',
  17523. VALUE_INDICATOR_TEXT: 'mdc-slider__value-indicator-text'
  17524. };
  17525. /** Slider numbers. */
  17526. exports.numbers = {
  17527. // Default step size.
  17528. STEP_SIZE: 1,
  17529. // Minimum absolute difference between clientX of move event / down event
  17530. // for which to update thumb, in the case of overlapping thumbs.
  17531. // This is needed to reduce chances of choosing the thumb based on
  17532. // pointer jitter.
  17533. THUMB_UPDATE_MIN_PX: 5
  17534. };
  17535. /** Slider attributes. */
  17536. exports.attributes = {
  17537. ARIA_DISABLED: 'aria-disabled',
  17538. ARIA_VALUEMAX: 'aria-valuemax',
  17539. ARIA_VALUEMIN: 'aria-valuemin',
  17540. ARIA_VALUENOW: 'aria-valuenow',
  17541. ARIA_VALUETEXT: 'aria-valuetext',
  17542. INPUT_DISABLED: 'disabled',
  17543. INPUT_MIN: 'min',
  17544. INPUT_MAX: 'max',
  17545. INPUT_VALUE: 'value',
  17546. INPUT_STEP: 'step'
  17547. };
  17548. /** Slider events. */
  17549. exports.events = {
  17550. CHANGE: 'MDCSlider:change',
  17551. INPUT: 'MDCSlider:input'
  17552. };
  17553. /***/ }),
  17554. /***/ "./packages/mdc-slider/foundation.ts":
  17555. /*!*******************************************!*\
  17556. !*** ./packages/mdc-slider/foundation.ts ***!
  17557. \*******************************************/
  17558. /*! no static exports found */
  17559. /***/ (function(module, exports, __webpack_require__) {
  17560. "use strict";
  17561. /**
  17562. * @license
  17563. * Copyright 2020 Google Inc.
  17564. *
  17565. * Permission is hereby granted, free of charge, to any person obtaining a copy
  17566. * of this software and associated documentation files (the "Software"), to deal
  17567. * in the Software without restriction, including without limitation the rights
  17568. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17569. * copies of the Software, and to permit persons to whom the Software is
  17570. * furnished to do so, subject to the following conditions:
  17571. *
  17572. * The above copyright notice and this permission notice shall be included in
  17573. * all copies or substantial portions of the Software.
  17574. *
  17575. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17576. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17577. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17578. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17579. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17580. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17581. * THE SOFTWARE.
  17582. */
  17583. var __extends = this && this.__extends || function () {
  17584. var _extendStatics = function extendStatics(d, b) {
  17585. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  17586. d.__proto__ = b;
  17587. } || function (d, b) {
  17588. for (var p in b) {
  17589. if (b.hasOwnProperty(p)) d[p] = b[p];
  17590. }
  17591. };
  17592. return _extendStatics(d, b);
  17593. };
  17594. return function (d, b) {
  17595. _extendStatics(d, b);
  17596. function __() {
  17597. this.constructor = d;
  17598. }
  17599. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  17600. };
  17601. }();
  17602. var __assign = this && this.__assign || function () {
  17603. __assign = Object.assign || function (t) {
  17604. for (var s, i = 1, n = arguments.length; i < n; i++) {
  17605. s = arguments[i];
  17606. for (var p in s) {
  17607. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  17608. }
  17609. }
  17610. return t;
  17611. };
  17612. return __assign.apply(this, arguments);
  17613. };
  17614. Object.defineProperty(exports, "__esModule", { value: true });
  17615. var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
  17616. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  17617. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
  17618. var types_1 = __webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts");
  17619. // Accessing `window` without a `typeof` check will throw on Node environments.
  17620. var HAS_WINDOW = typeof window !== 'undefined';
  17621. /**
  17622. * Foundation class for slider. Responsibilities include:
  17623. * - Updating slider values (internal state and DOM updates) based on client
  17624. * 'x' position.
  17625. * - Updating DOM after slider property updates (e.g. min, max).
  17626. */
  17627. var MDCSliderFoundation = /** @class */function (_super) {
  17628. __extends(MDCSliderFoundation, _super);
  17629. function MDCSliderFoundation(adapter) {
  17630. var _this = _super.call(this, __assign(__assign({}, MDCSliderFoundation.defaultAdapter), adapter)) || this;
  17631. // Whether the initial styles (to position the thumb, before component
  17632. // initialization) have been removed.
  17633. _this.initialStylesRemoved = false;
  17634. _this.isDisabled = false;
  17635. _this.isDiscrete = false;
  17636. _this.step = constants_1.numbers.STEP_SIZE;
  17637. _this.hasTickMarks = false;
  17638. // The following properties are only set for range sliders.
  17639. _this.isRange = false;
  17640. // Tracks the thumb being moved across a slider pointer interaction (down,
  17641. // move event).
  17642. _this.thumb = null;
  17643. // `clientX` from the most recent down event. Used in subsequent move
  17644. // events to determine which thumb to move (in the case of
  17645. // overlapping thumbs).
  17646. _this.downEventClientX = null;
  17647. // Width of the start thumb knob.
  17648. _this.startThumbKnobWidth = 0;
  17649. // Width of the end thumb knob.
  17650. _this.endThumbKnobWidth = 0;
  17651. return _this;
  17652. }
  17653. Object.defineProperty(MDCSliderFoundation, "defaultAdapter", {
  17654. get: function get() {
  17655. // tslint:disable:object-literal-sort-keys Methods should be in the same
  17656. // order as the adapter interface.
  17657. return {
  17658. hasClass: function hasClass() {
  17659. return false;
  17660. },
  17661. addClass: function addClass() {
  17662. return undefined;
  17663. },
  17664. removeClass: function removeClass() {
  17665. return undefined;
  17666. },
  17667. addThumbClass: function addThumbClass() {
  17668. return undefined;
  17669. },
  17670. removeThumbClass: function removeThumbClass() {
  17671. return undefined;
  17672. },
  17673. getAttribute: function getAttribute() {
  17674. return null;
  17675. },
  17676. getInputValue: function getInputValue() {
  17677. return '';
  17678. },
  17679. setInputValue: function setInputValue() {
  17680. return undefined;
  17681. },
  17682. getInputAttribute: function getInputAttribute() {
  17683. return null;
  17684. },
  17685. setInputAttribute: function setInputAttribute() {
  17686. return null;
  17687. },
  17688. removeInputAttribute: function removeInputAttribute() {
  17689. return null;
  17690. },
  17691. focusInput: function focusInput() {
  17692. return undefined;
  17693. },
  17694. isInputFocused: function isInputFocused() {
  17695. return false;
  17696. },
  17697. getThumbKnobWidth: function getThumbKnobWidth() {
  17698. return 0;
  17699. },
  17700. getThumbBoundingClientRect: function getThumbBoundingClientRect() {
  17701. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  17702. },
  17703. getBoundingClientRect: function getBoundingClientRect() {
  17704. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  17705. },
  17706. isRTL: function isRTL() {
  17707. return false;
  17708. },
  17709. setThumbStyleProperty: function setThumbStyleProperty() {
  17710. return undefined;
  17711. },
  17712. removeThumbStyleProperty: function removeThumbStyleProperty() {
  17713. return undefined;
  17714. },
  17715. setTrackActiveStyleProperty: function setTrackActiveStyleProperty() {
  17716. return undefined;
  17717. },
  17718. removeTrackActiveStyleProperty: function removeTrackActiveStyleProperty() {
  17719. return undefined;
  17720. },
  17721. setValueIndicatorText: function setValueIndicatorText() {
  17722. return undefined;
  17723. },
  17724. getValueToAriaValueTextFn: function getValueToAriaValueTextFn() {
  17725. return null;
  17726. },
  17727. updateTickMarks: function updateTickMarks() {
  17728. return undefined;
  17729. },
  17730. setPointerCapture: function setPointerCapture() {
  17731. return undefined;
  17732. },
  17733. emitChangeEvent: function emitChangeEvent() {
  17734. return undefined;
  17735. },
  17736. emitInputEvent: function emitInputEvent() {
  17737. return undefined;
  17738. },
  17739. emitDragStartEvent: function emitDragStartEvent() {
  17740. return undefined;
  17741. },
  17742. emitDragEndEvent: function emitDragEndEvent() {
  17743. return undefined;
  17744. },
  17745. registerEventHandler: function registerEventHandler() {
  17746. return undefined;
  17747. },
  17748. deregisterEventHandler: function deregisterEventHandler() {
  17749. return undefined;
  17750. },
  17751. registerThumbEventHandler: function registerThumbEventHandler() {
  17752. return undefined;
  17753. },
  17754. deregisterThumbEventHandler: function deregisterThumbEventHandler() {
  17755. return undefined;
  17756. },
  17757. registerInputEventHandler: function registerInputEventHandler() {
  17758. return undefined;
  17759. },
  17760. deregisterInputEventHandler: function deregisterInputEventHandler() {
  17761. return undefined;
  17762. },
  17763. registerBodyEventHandler: function registerBodyEventHandler() {
  17764. return undefined;
  17765. },
  17766. deregisterBodyEventHandler: function deregisterBodyEventHandler() {
  17767. return undefined;
  17768. },
  17769. registerWindowEventHandler: function registerWindowEventHandler() {
  17770. return undefined;
  17771. },
  17772. deregisterWindowEventHandler: function deregisterWindowEventHandler() {
  17773. return undefined;
  17774. }
  17775. };
  17776. // tslint:enable:object-literal-sort-keys
  17777. },
  17778. enumerable: true,
  17779. configurable: true
  17780. });
  17781. MDCSliderFoundation.prototype.init = function () {
  17782. var _this = this;
  17783. this.isDisabled = this.adapter.hasClass(constants_1.cssClasses.DISABLED);
  17784. this.isDiscrete = this.adapter.hasClass(constants_1.cssClasses.DISCRETE);
  17785. this.hasTickMarks = this.adapter.hasClass(constants_1.cssClasses.TICK_MARKS);
  17786. this.isRange = this.adapter.hasClass(constants_1.cssClasses.RANGE);
  17787. 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);
  17788. var max = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_MAX, types_1.Thumb.END), constants_1.attributes.INPUT_MAX);
  17789. var value = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_VALUE, types_1.Thumb.END), constants_1.attributes.INPUT_VALUE);
  17790. var valueStart = this.isRange ? this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_VALUE, types_1.Thumb.START), constants_1.attributes.INPUT_VALUE) : min;
  17791. this.validateProperties({ min: min, max: max, value: value, valueStart: valueStart });
  17792. this.min = min;
  17793. this.max = max;
  17794. this.value = value;
  17795. this.valueStart = valueStart;
  17796. this.valueBeforeDownEvent = value;
  17797. this.valueStartBeforeDownEvent = valueStart;
  17798. var stepAttr = this.adapter.getInputAttribute(constants_1.attributes.INPUT_STEP, types_1.Thumb.END);
  17799. if (stepAttr) {
  17800. this.step = this.convertAttributeValueToNumber(stepAttr, constants_1.attributes.INPUT_STEP);
  17801. }
  17802. if (this.step <= 0) {
  17803. throw new Error("MDCSliderFoundation: step must be a positive number. " + ("Current step: " + this.step));
  17804. }
  17805. this.mousedownOrTouchstartListener = this.handleMousedownOrTouchstart.bind(this);
  17806. this.moveListener = this.handleMove.bind(this);
  17807. this.pointerdownListener = this.handlePointerdown.bind(this);
  17808. this.pointerupListener = this.handlePointerup.bind(this);
  17809. this.thumbMouseenterListener = this.handleThumbMouseenter.bind(this);
  17810. this.thumbMouseleaveListener = this.handleThumbMouseleave.bind(this);
  17811. this.inputStartChangeListener = function () {
  17812. _this.handleInputChange(types_1.Thumb.START);
  17813. };
  17814. this.inputEndChangeListener = function () {
  17815. _this.handleInputChange(types_1.Thumb.END);
  17816. };
  17817. this.inputStartFocusListener = function () {
  17818. _this.handleInputFocus(types_1.Thumb.START);
  17819. };
  17820. this.inputEndFocusListener = function () {
  17821. _this.handleInputFocus(types_1.Thumb.END);
  17822. };
  17823. this.inputStartBlurListener = function () {
  17824. _this.handleInputBlur(types_1.Thumb.START);
  17825. };
  17826. this.inputEndBlurListener = function () {
  17827. _this.handleInputBlur(types_1.Thumb.END);
  17828. };
  17829. this.resizeListener = this.handleResize.bind(this);
  17830. this.registerEventHandlers();
  17831. };
  17832. MDCSliderFoundation.prototype.destroy = function () {
  17833. this.deregisterEventHandlers();
  17834. };
  17835. MDCSliderFoundation.prototype.getMin = function () {
  17836. return this.min;
  17837. };
  17838. MDCSliderFoundation.prototype.getMax = function () {
  17839. return this.max;
  17840. };
  17841. /**
  17842. * - For single point sliders, returns the thumb value.
  17843. * - For range (two-thumb) sliders, returns the end thumb's value.
  17844. */
  17845. MDCSliderFoundation.prototype.getValue = function () {
  17846. return this.value;
  17847. };
  17848. /**
  17849. * - For single point sliders, sets the thumb value.
  17850. * - For range (two-thumb) sliders, sets the end thumb's value.
  17851. */
  17852. MDCSliderFoundation.prototype.setValue = function (value) {
  17853. if (this.isRange && value < this.valueStart) {
  17854. throw new Error("end thumb value (" + value + ") must be >= start thumb " + ("value (" + this.valueStart + ")"));
  17855. }
  17856. this.updateValue(value, types_1.Thumb.END);
  17857. };
  17858. /**
  17859. * Only applicable for range sliders.
  17860. * @return The start thumb's value.
  17861. */
  17862. MDCSliderFoundation.prototype.getValueStart = function () {
  17863. if (!this.isRange) {
  17864. throw new Error('`valueStart` is only applicable for range sliders.');
  17865. }
  17866. return this.valueStart;
  17867. };
  17868. /**
  17869. * Only applicable for range sliders. Sets the start thumb's value.
  17870. */
  17871. MDCSliderFoundation.prototype.setValueStart = function (valueStart) {
  17872. if (!this.isRange) {
  17873. throw new Error('`valueStart` is only applicable for range sliders.');
  17874. }
  17875. if (this.isRange && valueStart > this.value) {
  17876. throw new Error("start thumb value (" + valueStart + ") must be <= end thumb " + ("value (" + this.value + ")"));
  17877. }
  17878. this.updateValue(valueStart, types_1.Thumb.START);
  17879. };
  17880. MDCSliderFoundation.prototype.getStep = function () {
  17881. return this.step;
  17882. };
  17883. MDCSliderFoundation.prototype.getDisabled = function () {
  17884. return this.isDisabled;
  17885. };
  17886. /**
  17887. * Sets disabled state, including updating styles and thumb tabindex.
  17888. */
  17889. MDCSliderFoundation.prototype.setDisabled = function (disabled) {
  17890. this.isDisabled = disabled;
  17891. if (disabled) {
  17892. this.adapter.addClass(constants_1.cssClasses.DISABLED);
  17893. if (this.isRange) {
  17894. this.adapter.setInputAttribute(constants_1.attributes.INPUT_DISABLED, '', types_1.Thumb.START);
  17895. }
  17896. this.adapter.setInputAttribute(constants_1.attributes.INPUT_DISABLED, '', types_1.Thumb.END);
  17897. } else {
  17898. this.adapter.removeClass(constants_1.cssClasses.DISABLED);
  17899. if (this.isRange) {
  17900. this.adapter.removeInputAttribute(constants_1.attributes.INPUT_DISABLED, types_1.Thumb.START);
  17901. }
  17902. this.adapter.removeInputAttribute(constants_1.attributes.INPUT_DISABLED, types_1.Thumb.END);
  17903. }
  17904. };
  17905. /** @return Whether the slider is a range slider. */
  17906. MDCSliderFoundation.prototype.getIsRange = function () {
  17907. return this.isRange;
  17908. };
  17909. /**
  17910. * - Syncs slider boundingClientRect with the current DOM.
  17911. * - Updates UI based on internal state.
  17912. */
  17913. MDCSliderFoundation.prototype.layout = function (_a) {
  17914. var skipUpdateUI = (_a === void 0 ? {} : _a).skipUpdateUI;
  17915. this.rect = this.adapter.getBoundingClientRect();
  17916. if (this.isRange) {
  17917. this.startThumbKnobWidth = this.adapter.getThumbKnobWidth(types_1.Thumb.START);
  17918. this.endThumbKnobWidth = this.adapter.getThumbKnobWidth(types_1.Thumb.END);
  17919. }
  17920. if (!skipUpdateUI) {
  17921. this.updateUI();
  17922. }
  17923. };
  17924. /** Handles resize events on the window. */
  17925. MDCSliderFoundation.prototype.handleResize = function () {
  17926. this.layout();
  17927. };
  17928. /**
  17929. * Handles pointer down events on the slider root element.
  17930. */
  17931. MDCSliderFoundation.prototype.handleDown = function (event) {
  17932. if (this.isDisabled) return;
  17933. this.valueStartBeforeDownEvent = this.valueStart;
  17934. this.valueBeforeDownEvent = this.value;
  17935. var clientX = event.clientX != null ? event.clientX : event.targetTouches[0].clientX;
  17936. this.downEventClientX = clientX;
  17937. var value = this.mapClientXOnSliderScale(clientX);
  17938. this.thumb = this.getThumbFromDownEvent(clientX, value);
  17939. if (this.thumb === null) return;
  17940. this.handleDragStart(event, value, this.thumb);
  17941. // Presses within the range do not invoke slider updates.
  17942. var newValueInCurrentRange = this.isRange && value >= this.valueStart && value <= this.value;
  17943. if (newValueInCurrentRange) return;
  17944. this.updateValue(value, this.thumb, { emitInputEvent: true });
  17945. };
  17946. /**
  17947. * Handles pointer move events on the slider root element.
  17948. */
  17949. MDCSliderFoundation.prototype.handleMove = function (event) {
  17950. if (this.isDisabled) return;
  17951. // Prevent scrolling.
  17952. event.preventDefault();
  17953. var clientX = event.clientX != null ? event.clientX : event.targetTouches[0].clientX;
  17954. var dragAlreadyStarted = this.thumb != null;
  17955. this.thumb = this.getThumbFromMoveEvent(clientX);
  17956. if (this.thumb === null) return;
  17957. var value = this.mapClientXOnSliderScale(clientX);
  17958. if (!dragAlreadyStarted) {
  17959. this.handleDragStart(event, value, this.thumb);
  17960. this.adapter.emitDragStartEvent(value, this.thumb);
  17961. }
  17962. this.updateValue(value, this.thumb, { emitInputEvent: true });
  17963. };
  17964. /**
  17965. * Handles pointer up events on the slider root element.
  17966. */
  17967. MDCSliderFoundation.prototype.handleUp = function () {
  17968. if (this.isDisabled || this.thumb === null) return;
  17969. var oldValue = this.thumb === types_1.Thumb.START ? this.valueStartBeforeDownEvent : this.valueBeforeDownEvent;
  17970. var newValue = this.thumb === types_1.Thumb.START ? this.valueStart : this.value;
  17971. if (oldValue !== newValue) {
  17972. this.adapter.emitChangeEvent(newValue, this.thumb);
  17973. }
  17974. this.adapter.emitDragEndEvent(newValue, this.thumb);
  17975. this.thumb = null;
  17976. };
  17977. /**
  17978. * For range, discrete slider, shows the value indicator on both thumbs.
  17979. */
  17980. MDCSliderFoundation.prototype.handleThumbMouseenter = function () {
  17981. if (!this.isDiscrete || !this.isRange) return;
  17982. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.START);
  17983. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.END);
  17984. };
  17985. /**
  17986. * For range, discrete slider, hides the value indicator on both thumbs.
  17987. */
  17988. MDCSliderFoundation.prototype.handleThumbMouseleave = function () {
  17989. if (!this.isDiscrete || !this.isRange) return;
  17990. if (this.adapter.isInputFocused(types_1.Thumb.START) || this.adapter.isInputFocused(types_1.Thumb.END)) {
  17991. // Leave value indicator shown if either input is focused.
  17992. return;
  17993. }
  17994. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.START);
  17995. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.END);
  17996. };
  17997. MDCSliderFoundation.prototype.handleMousedownOrTouchstart = function (event) {
  17998. var _this = this;
  17999. var moveEventType = event.type === 'mousedown' ? 'mousemove' : 'touchmove';
  18000. // After a down event on the slider root, listen for move events on
  18001. // body (so the slider value is updated for events outside of the
  18002. // slider root).
  18003. this.adapter.registerBodyEventHandler(moveEventType, this.moveListener);
  18004. var upHandler = function upHandler() {
  18005. _this.handleUp();
  18006. // Once the drag is finished (up event on body), remove the move
  18007. // handler.
  18008. _this.adapter.deregisterBodyEventHandler(moveEventType, _this.moveListener);
  18009. // Also stop listening for subsequent up events.
  18010. _this.adapter.deregisterEventHandler('mouseup', upHandler);
  18011. _this.adapter.deregisterEventHandler('touchend', upHandler);
  18012. };
  18013. this.adapter.registerBodyEventHandler('mouseup', upHandler);
  18014. this.adapter.registerBodyEventHandler('touchend', upHandler);
  18015. this.handleDown(event);
  18016. };
  18017. MDCSliderFoundation.prototype.handlePointerdown = function (event) {
  18018. this.adapter.setPointerCapture(event.pointerId);
  18019. this.adapter.registerEventHandler('pointermove', this.moveListener);
  18020. this.handleDown(event);
  18021. };
  18022. /**
  18023. * Handles input `change` event by setting internal slider value to match
  18024. * input's new value.
  18025. */
  18026. MDCSliderFoundation.prototype.handleInputChange = function (thumb) {
  18027. var value = Number(this.adapter.getInputValue(thumb));
  18028. if (thumb === types_1.Thumb.START) {
  18029. this.setValueStart(value);
  18030. } else {
  18031. this.setValue(value);
  18032. }
  18033. };
  18034. /** Shows value indicator on thumb(s). */
  18035. MDCSliderFoundation.prototype.handleInputFocus = function (thumb) {
  18036. if (!this.isDiscrete) return;
  18037. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, thumb);
  18038. if (this.isRange) {
  18039. var otherThumb = thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START;
  18040. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, otherThumb);
  18041. }
  18042. };
  18043. /** Removes value indicator from thumb(s). */
  18044. MDCSliderFoundation.prototype.handleInputBlur = function (thumb) {
  18045. if (!this.isDiscrete) return;
  18046. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, thumb);
  18047. if (this.isRange) {
  18048. var otherThumb = thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START;
  18049. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, otherThumb);
  18050. }
  18051. };
  18052. /**
  18053. * Emits custom dragStart event, along with focusing the underlying input.
  18054. */
  18055. MDCSliderFoundation.prototype.handleDragStart = function (event, value, thumb) {
  18056. this.adapter.focusInput(thumb);
  18057. // Prevent the input (that we just focused) from losing focus.
  18058. event.preventDefault();
  18059. this.adapter.emitDragStartEvent(value, thumb);
  18060. };
  18061. /**
  18062. * @return The thumb to be moved based on initial down event.
  18063. */
  18064. MDCSliderFoundation.prototype.getThumbFromDownEvent = function (clientX, value) {
  18065. // For single point slider, thumb to be moved is always the END (only)
  18066. // thumb.
  18067. if (!this.isRange) return types_1.Thumb.END;
  18068. // Check if event press point is in the bounds of any thumb.
  18069. var thumbStartRect = this.adapter.getThumbBoundingClientRect(types_1.Thumb.START);
  18070. var thumbEndRect = this.adapter.getThumbBoundingClientRect(types_1.Thumb.END);
  18071. var inThumbStartBounds = clientX >= thumbStartRect.left && clientX <= thumbStartRect.right;
  18072. var inThumbEndBounds = clientX >= thumbEndRect.left && clientX <= thumbEndRect.right;
  18073. if (inThumbStartBounds && inThumbEndBounds) {
  18074. // Thumbs overlapping. Thumb to be moved cannot be determined yet.
  18075. return null;
  18076. }
  18077. // If press is in bounds for either thumb on down event, that's the thumb
  18078. // to be moved.
  18079. if (inThumbStartBounds) {
  18080. return types_1.Thumb.START;
  18081. }
  18082. if (inThumbEndBounds) {
  18083. return types_1.Thumb.END;
  18084. }
  18085. // Otherwise, if press occurred outside of the range, return either start
  18086. // or end thumb based on which the press is closer to.
  18087. if (value < this.valueStart) {
  18088. return types_1.Thumb.START;
  18089. }
  18090. if (value > this.value) {
  18091. return types_1.Thumb.END;
  18092. }
  18093. return null;
  18094. };
  18095. /**
  18096. * @return The thumb to be moved based on move event (based on drag
  18097. * direction from original down event). Only applicable if thumbs
  18098. * were overlapping in the down event.
  18099. */
  18100. MDCSliderFoundation.prototype.getThumbFromMoveEvent = function (clientX) {
  18101. // Thumb has already been chosen.
  18102. if (this.thumb !== null) return this.thumb;
  18103. if (this.downEventClientX === null) {
  18104. throw new Error('`downEventClientX` is null after move event.');
  18105. }
  18106. var moveDistanceUnderThreshold = Math.abs(this.downEventClientX - clientX) < constants_1.numbers.THUMB_UPDATE_MIN_PX;
  18107. if (moveDistanceUnderThreshold) return this.thumb;
  18108. var draggedThumbToLeft = clientX < this.downEventClientX;
  18109. if (draggedThumbToLeft) {
  18110. return this.adapter.isRTL() ? types_1.Thumb.END : types_1.Thumb.START;
  18111. } else {
  18112. return this.adapter.isRTL() ? types_1.Thumb.START : types_1.Thumb.END;
  18113. }
  18114. };
  18115. /**
  18116. * Updates UI based on internal state.
  18117. * @param thumb Thumb whose value is being updated. If undefined, UI is
  18118. * updated for both thumbs based on current internal state.
  18119. */
  18120. MDCSliderFoundation.prototype.updateUI = function (thumb) {
  18121. this.updateThumbAndInputAttributes(thumb);
  18122. this.updateThumbAndTrackUI(thumb);
  18123. this.updateValueIndicatorUI(thumb);
  18124. this.updateTickMarksUI();
  18125. };
  18126. /**
  18127. * Updates thumb and input attributes based on current value.
  18128. * @param thumb Thumb whose aria attributes to update.
  18129. */
  18130. MDCSliderFoundation.prototype.updateThumbAndInputAttributes = function (thumb) {
  18131. if (!thumb) return;
  18132. var value = this.isRange && thumb === types_1.Thumb.START ? this.valueStart : this.value;
  18133. var valueStr = String(value);
  18134. this.adapter.setInputAttribute(constants_1.attributes.INPUT_VALUE, valueStr, thumb);
  18135. if (this.isRange && thumb === types_1.Thumb.START) {
  18136. this.adapter.setInputAttribute(constants_1.attributes.INPUT_MIN, valueStr, types_1.Thumb.END);
  18137. } else if (this.isRange && thumb === types_1.Thumb.END) {
  18138. this.adapter.setInputAttribute(constants_1.attributes.INPUT_MAX, valueStr, types_1.Thumb.START);
  18139. }
  18140. // Sync attribute with property.
  18141. if (this.adapter.getInputValue(thumb) !== valueStr) {
  18142. this.adapter.setInputValue(valueStr, thumb);
  18143. }
  18144. var valueToAriaValueTextFn = this.adapter.getValueToAriaValueTextFn();
  18145. if (valueToAriaValueTextFn) {
  18146. this.adapter.setInputAttribute(constants_1.attributes.ARIA_VALUETEXT, valueToAriaValueTextFn(value), thumb);
  18147. }
  18148. };
  18149. /**
  18150. * Updates value indicator UI based on current value.
  18151. * @param thumb Thumb whose value indicator to update. If undefined, all
  18152. * thumbs' value indicators are updated.
  18153. */
  18154. MDCSliderFoundation.prototype.updateValueIndicatorUI = function (thumb) {
  18155. if (!this.isDiscrete) return;
  18156. var value = this.isRange && thumb === types_1.Thumb.START ? this.valueStart : this.value;
  18157. this.adapter.setValueIndicatorText(value, thumb === types_1.Thumb.START ? types_1.Thumb.START : types_1.Thumb.END);
  18158. if (!thumb && this.isRange) {
  18159. this.adapter.setValueIndicatorText(this.valueStart, types_1.Thumb.START);
  18160. }
  18161. };
  18162. /**
  18163. * Updates tick marks UI within slider, based on current min, max, and step.
  18164. */
  18165. MDCSliderFoundation.prototype.updateTickMarksUI = function () {
  18166. if (!this.isDiscrete || !this.hasTickMarks) return;
  18167. var numTickMarksInactiveStart = (this.valueStart - this.min) / this.step;
  18168. var numTickMarksActive = (this.value - this.valueStart) / this.step + 1;
  18169. var numTickMarksInactiveEnd = (this.max - this.value) / this.step;
  18170. var tickMarksInactiveStart = Array.from({ length: numTickMarksInactiveStart }).fill(types_1.TickMark.INACTIVE);
  18171. var tickMarksActive = Array.from({ length: numTickMarksActive }).fill(types_1.TickMark.ACTIVE);
  18172. var tickMarksInactiveEnd = Array.from({ length: numTickMarksInactiveEnd }).fill(types_1.TickMark.INACTIVE);
  18173. this.adapter.updateTickMarks(tickMarksInactiveStart.concat(tickMarksActive).concat(tickMarksInactiveEnd));
  18174. };
  18175. /** Maps clientX to a value on the slider scale. */
  18176. MDCSliderFoundation.prototype.mapClientXOnSliderScale = function (clientX) {
  18177. var xPos = clientX - this.rect.left;
  18178. var pctComplete = xPos / this.rect.width;
  18179. if (this.adapter.isRTL()) {
  18180. pctComplete = 1 - pctComplete;
  18181. }
  18182. // Fit the percentage complete between the range [min,max]
  18183. // by remapping from [0, 1] to [min, min+(max-min)].
  18184. var value = this.min + pctComplete * (this.max - this.min);
  18185. if (value === this.max || value === this.min) {
  18186. return value;
  18187. }
  18188. return this.quantize(value);
  18189. };
  18190. /**
  18191. * Updates slider value (internal state and UI) based on the given value.
  18192. */
  18193. MDCSliderFoundation.prototype.updateValue = function (value, thumb, _a) {
  18194. var _b = _a === void 0 ? {} : _a,
  18195. emitInputEvent = _b.emitInputEvent,
  18196. emitChangeEvent = _b.emitChangeEvent;
  18197. value = this.clampValue(value, thumb);
  18198. if (this.isRange && thumb === types_1.Thumb.START) {
  18199. // Exit early if current value is the same as the new value.
  18200. if (this.valueStart === value) return;
  18201. this.valueStart = value;
  18202. } else {
  18203. // Exit early if current value is the same as the new value.
  18204. if (this.value === value) return;
  18205. this.value = value;
  18206. }
  18207. this.updateUI(thumb);
  18208. if (emitInputEvent) {
  18209. this.adapter.emitInputEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
  18210. }
  18211. if (emitChangeEvent) {
  18212. this.adapter.emitChangeEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
  18213. }
  18214. };
  18215. /** Calculates the quantized value based on step value. */
  18216. MDCSliderFoundation.prototype.quantize = function (value) {
  18217. var numSteps = Math.round(value / this.step);
  18218. return numSteps * this.step;
  18219. };
  18220. /**
  18221. * Clamps the given value for the given thumb based on slider properties:
  18222. * - Restricts value within [min, max].
  18223. * - If range slider, clamp start value <= end value, and
  18224. * end value >= start value.
  18225. */
  18226. MDCSliderFoundation.prototype.clampValue = function (value, thumb) {
  18227. // Clamp value to [min, max] range.
  18228. value = Math.min(Math.max(value, this.min), this.max);
  18229. var thumbStartMovedPastThumbEnd = this.isRange && thumb === types_1.Thumb.START && value > this.value;
  18230. if (thumbStartMovedPastThumbEnd) {
  18231. return this.value;
  18232. }
  18233. var thumbEndMovedPastThumbStart = this.isRange && thumb === types_1.Thumb.END && value < this.valueStart;
  18234. if (thumbEndMovedPastThumbStart) {
  18235. return this.valueStart;
  18236. }
  18237. return value;
  18238. };
  18239. /**
  18240. * Updates the active track and thumb style properties to reflect current
  18241. * value.
  18242. */
  18243. MDCSliderFoundation.prototype.updateThumbAndTrackUI = function (thumb) {
  18244. var _this = this;
  18245. var _a = this,
  18246. max = _a.max,
  18247. min = _a.min;
  18248. var pctComplete = (this.value - this.valueStart) / (max - min);
  18249. var rangePx = pctComplete * this.rect.width;
  18250. var isRtl = this.adapter.isRTL();
  18251. var transformProp = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
  18252. if (this.isRange) {
  18253. var thumbLeftPos_1 = this.adapter.isRTL() ? (max - this.value) / (max - min) * this.rect.width : (this.valueStart - min) / (max - min) * this.rect.width;
  18254. var thumbRightPos_1 = thumbLeftPos_1 + rangePx;
  18255. requestAnimationFrame(function () {
  18256. // Set active track styles, accounting for animation direction by
  18257. // setting `transform-origin`.
  18258. var trackAnimatesFromRight = !isRtl && thumb === types_1.Thumb.START || isRtl && thumb !== types_1.Thumb.START;
  18259. if (trackAnimatesFromRight) {
  18260. _this.adapter.setTrackActiveStyleProperty('transform-origin', 'right');
  18261. _this.adapter.setTrackActiveStyleProperty('left', 'unset');
  18262. _this.adapter.setTrackActiveStyleProperty('right', _this.rect.width - thumbRightPos_1 + "px");
  18263. } else {
  18264. _this.adapter.setTrackActiveStyleProperty('transform-origin', 'left');
  18265. _this.adapter.setTrackActiveStyleProperty('right', 'unset');
  18266. _this.adapter.setTrackActiveStyleProperty('left', thumbLeftPos_1 + "px");
  18267. }
  18268. _this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
  18269. // Set thumb styles.
  18270. var thumbStartPos = isRtl ? thumbRightPos_1 : thumbLeftPos_1;
  18271. var thumbEndPos = _this.adapter.isRTL() ? thumbLeftPos_1 : thumbRightPos_1;
  18272. if (thumb === types_1.Thumb.START || !thumb || !_this.initialStylesRemoved) {
  18273. _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", types_1.Thumb.START);
  18274. }
  18275. if (thumb === types_1.Thumb.END || !thumb || !_this.initialStylesRemoved) {
  18276. _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbEndPos + "px)", types_1.Thumb.END);
  18277. }
  18278. _this.removeInitialStyles(isRtl);
  18279. _this.updateOverlappingThumbsUI(thumbStartPos, thumbEndPos, thumb);
  18280. });
  18281. } else {
  18282. requestAnimationFrame(function () {
  18283. var thumbStartPos = isRtl ? _this.rect.width - rangePx : rangePx;
  18284. _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", types_1.Thumb.END);
  18285. _this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
  18286. _this.removeInitialStyles(isRtl);
  18287. });
  18288. }
  18289. };
  18290. /**
  18291. * Removes initial inline styles if not already removed. `left:<...>%`
  18292. * inline styles can be added to position the thumb correctly before JS
  18293. * initialization. However, they need to be removed before the JS starts
  18294. * positioning the thumb. This is because the JS uses
  18295. * `transform:translateX(<...>)px` (for performance reasons) to position
  18296. * the thumb (which is not possible for initial styles since we need the
  18297. * bounding rect measurements).
  18298. */
  18299. MDCSliderFoundation.prototype.removeInitialStyles = function (isRtl) {
  18300. if (this.initialStylesRemoved) return;
  18301. // Remove thumb position properties that were added for initial render.
  18302. var position = isRtl ? 'right' : 'left';
  18303. this.adapter.removeThumbStyleProperty(position, types_1.Thumb.END);
  18304. if (this.isRange) {
  18305. this.adapter.removeThumbStyleProperty(position, types_1.Thumb.START);
  18306. }
  18307. this.initialStylesRemoved = true;
  18308. this.resetTrackAndThumbAnimation();
  18309. };
  18310. /**
  18311. * Resets track/thumb animation to prevent animation when adding
  18312. * `transform` styles to thumb initially.
  18313. */
  18314. MDCSliderFoundation.prototype.resetTrackAndThumbAnimation = function () {
  18315. var _this = this;
  18316. if (!this.isDiscrete) return;
  18317. // Set transition properties to default (no animation), so that the
  18318. // newly added `transform` styles do not animate thumb/track from
  18319. // their default positions.
  18320. var transitionProp = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transition') : 'transition';
  18321. var transitionDefault = 'all 0s ease 0s';
  18322. this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, types_1.Thumb.END);
  18323. if (this.isRange) {
  18324. this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, types_1.Thumb.START);
  18325. }
  18326. this.adapter.setTrackActiveStyleProperty(transitionProp, transitionDefault);
  18327. // In the next frame, remove the transition inline styles we just
  18328. // added, such that any animations added in the CSS can now take effect.
  18329. requestAnimationFrame(function () {
  18330. _this.adapter.removeThumbStyleProperty(transitionProp, types_1.Thumb.END);
  18331. _this.adapter.removeTrackActiveStyleProperty(transitionProp);
  18332. if (_this.isRange) {
  18333. _this.adapter.removeThumbStyleProperty(transitionProp, types_1.Thumb.START);
  18334. }
  18335. });
  18336. };
  18337. /**
  18338. * Adds THUMB_TOP class to active thumb if thumb knobs overlap; otherwise
  18339. * removes THUMB_TOP class from both thumbs.
  18340. * @param thumb Thumb that is active (being moved).
  18341. */
  18342. MDCSliderFoundation.prototype.updateOverlappingThumbsUI = function (thumbStartPos, thumbEndPos, thumb) {
  18343. var thumbsOverlap = false;
  18344. if (this.adapter.isRTL()) {
  18345. var startThumbLeftEdge = thumbStartPos - this.startThumbKnobWidth / 2;
  18346. var endThumbRightEdge = thumbEndPos + this.endThumbKnobWidth / 2;
  18347. thumbsOverlap = endThumbRightEdge >= startThumbLeftEdge;
  18348. } else {
  18349. var startThumbRightEdge = thumbStartPos + this.startThumbKnobWidth / 2;
  18350. var endThumbLeftEdge = thumbEndPos - this.endThumbKnobWidth / 2;
  18351. thumbsOverlap = startThumbRightEdge >= endThumbLeftEdge;
  18352. }
  18353. if (thumbsOverlap) {
  18354. this.adapter.addThumbClass(constants_1.cssClasses.THUMB_TOP,
  18355. // If no thumb was dragged (in the case of initial layout), end
  18356. // thumb is on top by default.
  18357. thumb || types_1.Thumb.END);
  18358. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START);
  18359. } else {
  18360. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, types_1.Thumb.START);
  18361. this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, types_1.Thumb.END);
  18362. }
  18363. };
  18364. /**
  18365. * Converts attribute value to a number, e.g. '100' => 100. Throws errors
  18366. * for invalid values.
  18367. * @param attributeValue Attribute value, e.g. 100.
  18368. * @param attributeName Attribute name, e.g. `aria-valuemax`.
  18369. */
  18370. MDCSliderFoundation.prototype.convertAttributeValueToNumber = function (attributeValue, attributeName) {
  18371. if (attributeValue === null) {
  18372. throw new Error("MDCSliderFoundation: `" + attributeName + "` must be non-null.");
  18373. }
  18374. var value = Number(attributeValue);
  18375. if (isNaN(value)) {
  18376. throw new Error("MDCSliderFoundation: `" + attributeName + "` value is " + ("`" + attributeValue + "`, but must be a number."));
  18377. }
  18378. return value;
  18379. };
  18380. /** Checks that the given properties are valid slider values. */
  18381. MDCSliderFoundation.prototype.validateProperties = function (_a) {
  18382. var min = _a.min,
  18383. max = _a.max,
  18384. value = _a.value,
  18385. valueStart = _a.valueStart;
  18386. if (min >= max) {
  18387. throw new Error("MDCSliderFoundation: min must be strictly less than max. " + ("Current: [min: " + min + ", max: " + max + "]"));
  18388. }
  18389. if (this.isRange) {
  18390. if (value < min || value > max || valueStart < min || valueStart > max) {
  18391. throw new Error("MDCSliderFoundation: values must be in [min, max] range. " + ("Current values: [start value: " + valueStart + ", end value: " + value + "]"));
  18392. }
  18393. if (valueStart > value) {
  18394. throw new Error("MDCSliderFoundation: start value must be <= end value. " + ("Current values: [start value: " + valueStart + ", end value: " + value + "]"));
  18395. }
  18396. } else {
  18397. // Single point slider.
  18398. if (value < min || value > max) {
  18399. throw new Error("MDCSliderFoundation: value must be in [min, max] range. " + ("Current value: " + value));
  18400. }
  18401. }
  18402. };
  18403. MDCSliderFoundation.prototype.registerEventHandlers = function () {
  18404. this.adapter.registerWindowEventHandler('resize', this.resizeListener);
  18405. if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
  18406. // If supported, use pointer events API with #setPointerCapture.
  18407. this.adapter.registerEventHandler('pointerdown', this.pointerdownListener);
  18408. this.adapter.registerEventHandler('pointerup', this.pointerupListener);
  18409. } else {
  18410. // Otherwise, fall back to mousedown/touchstart events.
  18411. this.adapter.registerEventHandler('mousedown', this.mousedownOrTouchstartListener);
  18412. this.adapter.registerEventHandler('touchstart', this.mousedownOrTouchstartListener);
  18413. }
  18414. if (this.isRange) {
  18415. this.adapter.registerThumbEventHandler(types_1.Thumb.START, 'mouseenter', this.thumbMouseenterListener);
  18416. this.adapter.registerThumbEventHandler(types_1.Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
  18417. this.adapter.registerInputEventHandler(types_1.Thumb.START, 'change', this.inputStartChangeListener);
  18418. this.adapter.registerInputEventHandler(types_1.Thumb.START, 'focus', this.inputStartFocusListener);
  18419. this.adapter.registerInputEventHandler(types_1.Thumb.START, 'blur', this.inputStartBlurListener);
  18420. }
  18421. this.adapter.registerThumbEventHandler(types_1.Thumb.END, 'mouseenter', this.thumbMouseenterListener);
  18422. this.adapter.registerThumbEventHandler(types_1.Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
  18423. this.adapter.registerInputEventHandler(types_1.Thumb.END, 'change', this.inputEndChangeListener);
  18424. this.adapter.registerInputEventHandler(types_1.Thumb.END, 'focus', this.inputEndFocusListener);
  18425. this.adapter.registerInputEventHandler(types_1.Thumb.END, 'blur', this.inputEndBlurListener);
  18426. };
  18427. MDCSliderFoundation.prototype.deregisterEventHandlers = function () {
  18428. this.adapter.deregisterWindowEventHandler('resize', this.resizeListener);
  18429. if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
  18430. this.adapter.deregisterEventHandler('pointerdown', this.pointerdownListener);
  18431. this.adapter.deregisterEventHandler('pointerup', this.pointerupListener);
  18432. } else {
  18433. this.adapter.deregisterEventHandler('mousedown', this.mousedownOrTouchstartListener);
  18434. this.adapter.deregisterEventHandler('touchstart', this.mousedownOrTouchstartListener);
  18435. }
  18436. if (this.isRange) {
  18437. this.adapter.deregisterThumbEventHandler(types_1.Thumb.START, 'mouseenter', this.thumbMouseenterListener);
  18438. this.adapter.deregisterThumbEventHandler(types_1.Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
  18439. this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'change', this.inputStartChangeListener);
  18440. this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'focus', this.inputStartFocusListener);
  18441. this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'blur', this.inputStartBlurListener);
  18442. }
  18443. this.adapter.deregisterThumbEventHandler(types_1.Thumb.END, 'mouseenter', this.thumbMouseenterListener);
  18444. this.adapter.deregisterThumbEventHandler(types_1.Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
  18445. this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'change', this.inputEndChangeListener);
  18446. this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'focus', this.inputEndFocusListener);
  18447. this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'blur', this.inputEndBlurListener);
  18448. };
  18449. MDCSliderFoundation.prototype.handlePointerup = function () {
  18450. this.handleUp();
  18451. this.adapter.deregisterEventHandler('pointermove', this.moveListener);
  18452. };
  18453. MDCSliderFoundation.SUPPORTS_POINTER_EVENTS = HAS_WINDOW && Boolean(window.PointerEvent) &&
  18454. // #setPointerCapture is buggy on iOS, so we can't use pointer events
  18455. // until the following bug is fixed:
  18456. // https://bugs.webkit.org/show_bug.cgi?id=220196
  18457. !isIOS();
  18458. return MDCSliderFoundation;
  18459. }(foundation_1.MDCFoundation);
  18460. exports.MDCSliderFoundation = MDCSliderFoundation;
  18461. function isIOS() {
  18462. // Source:
  18463. // https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
  18464. return ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform)
  18465. // iPad on iOS 13 detection
  18466. || navigator.userAgent.includes('Mac') && 'ontouchend' in document;
  18467. }
  18468. /***/ }),
  18469. /***/ "./packages/mdc-slider/index.ts":
  18470. /*!**************************************!*\
  18471. !*** ./packages/mdc-slider/index.ts ***!
  18472. \**************************************/
  18473. /*! no static exports found */
  18474. /***/ (function(module, exports, __webpack_require__) {
  18475. "use strict";
  18476. /**
  18477. * @license
  18478. * Copyright 2020 Google Inc.
  18479. *
  18480. * Permission is hereby granted, free of charge, to any person obtaining a copy
  18481. * of this software and associated documentation files (the "Software"), to deal
  18482. * in the Software without restriction, including without limitation the rights
  18483. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18484. * copies of the Software, and to permit persons to whom the Software is
  18485. * furnished to do so, subject to the following conditions:
  18486. *
  18487. * The above copyright notice and this permission notice shall be included in
  18488. * all copies or substantial portions of the Software.
  18489. *
  18490. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18491. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18492. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18493. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18494. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18495. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18496. * THE SOFTWARE.
  18497. */
  18498. function __export(m) {
  18499. for (var p in m) {
  18500. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  18501. }
  18502. }
  18503. Object.defineProperty(exports, "__esModule", { value: true });
  18504. __export(__webpack_require__(/*! ./component */ "./packages/mdc-slider/component.ts"));
  18505. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts"));
  18506. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts"));
  18507. __export(__webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts"));
  18508. /***/ }),
  18509. /***/ "./packages/mdc-slider/types.ts":
  18510. /*!**************************************!*\
  18511. !*** ./packages/mdc-slider/types.ts ***!
  18512. \**************************************/
  18513. /*! no static exports found */
  18514. /***/ (function(module, exports, __webpack_require__) {
  18515. "use strict";
  18516. /**
  18517. * @license
  18518. * Copyright 2020 Google Inc.
  18519. *
  18520. * Permission is hereby granted, free of charge, to any person obtaining a copy
  18521. * of this software and associated documentation files (the "Software"), to deal
  18522. * in the Software without restriction, including without limitation the rights
  18523. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18524. * copies of the Software, and to permit persons to whom the Software is
  18525. * furnished to do so, subject to the following conditions:
  18526. *
  18527. * The above copyright notice and this permission notice shall be included in
  18528. * all copies or substantial portions of the Software.
  18529. *
  18530. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18531. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18532. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18533. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18534. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18535. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18536. * THE SOFTWARE.
  18537. */
  18538. Object.defineProperty(exports, "__esModule", { value: true });
  18539. /** Tick mark enum, for discrete sliders. */
  18540. var TickMark;
  18541. (function (TickMark) {
  18542. TickMark[TickMark["ACTIVE"] = 0] = "ACTIVE";
  18543. TickMark[TickMark["INACTIVE"] = 1] = "INACTIVE";
  18544. })(TickMark = exports.TickMark || (exports.TickMark = {}));
  18545. /**
  18546. * Thumb types: range slider has two thumbs (START, END) whereas single point
  18547. * slider only has one thumb (END).
  18548. */
  18549. var Thumb;
  18550. (function (Thumb) {
  18551. // Thumb at start of slider (e.g. in LTR mode, left thumb on range slider).
  18552. Thumb[Thumb["START"] = 1] = "START";
  18553. // Thumb at end of slider (e.g. in LTR mode, right thumb on range slider,
  18554. // or only thumb on single point slider).
  18555. Thumb[Thumb["END"] = 2] = "END";
  18556. })(Thumb = exports.Thumb || (exports.Thumb = {}));
  18557. /***/ }),
  18558. /***/ "./packages/mdc-snackbar/component.ts":
  18559. /*!********************************************!*\
  18560. !*** ./packages/mdc-snackbar/component.ts ***!
  18561. \********************************************/
  18562. /*! no static exports found */
  18563. /***/ (function(module, exports, __webpack_require__) {
  18564. "use strict";
  18565. /**
  18566. * @license
  18567. * Copyright 2018 Google Inc.
  18568. *
  18569. * Permission is hereby granted, free of charge, to any person obtaining a copy
  18570. * of this software and associated documentation files (the "Software"), to deal
  18571. * in the Software without restriction, including without limitation the rights
  18572. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18573. * copies of the Software, and to permit persons to whom the Software is
  18574. * furnished to do so, subject to the following conditions:
  18575. *
  18576. * The above copyright notice and this permission notice shall be included in
  18577. * all copies or substantial portions of the Software.
  18578. *
  18579. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18580. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18581. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18582. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18583. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18584. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18585. * THE SOFTWARE.
  18586. */
  18587. var __extends = this && this.__extends || function () {
  18588. var _extendStatics = function extendStatics(d, b) {
  18589. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  18590. d.__proto__ = b;
  18591. } || function (d, b) {
  18592. for (var p in b) {
  18593. if (b.hasOwnProperty(p)) d[p] = b[p];
  18594. }
  18595. };
  18596. return _extendStatics(d, b);
  18597. };
  18598. return function (d, b) {
  18599. _extendStatics(d, b);
  18600. function __() {
  18601. this.constructor = d;
  18602. }
  18603. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  18604. };
  18605. }();
  18606. var __importStar = this && this.__importStar || function (mod) {
  18607. if (mod && mod.__esModule) return mod;
  18608. var result = {};
  18609. if (mod != null) for (var k in mod) {
  18610. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  18611. }result["default"] = mod;
  18612. return result;
  18613. };
  18614. Object.defineProperty(exports, "__esModule", { value: true });
  18615. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  18616. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  18617. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
  18618. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts");
  18619. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
  18620. var SURFACE_SELECTOR = constants_1.strings.SURFACE_SELECTOR,
  18621. LABEL_SELECTOR = constants_1.strings.LABEL_SELECTOR,
  18622. ACTION_SELECTOR = constants_1.strings.ACTION_SELECTOR,
  18623. DISMISS_SELECTOR = constants_1.strings.DISMISS_SELECTOR,
  18624. OPENING_EVENT = constants_1.strings.OPENING_EVENT,
  18625. OPENED_EVENT = constants_1.strings.OPENED_EVENT,
  18626. CLOSING_EVENT = constants_1.strings.CLOSING_EVENT,
  18627. CLOSED_EVENT = constants_1.strings.CLOSED_EVENT;
  18628. var MDCSnackbar = /** @class */function (_super) {
  18629. __extends(MDCSnackbar, _super);
  18630. function MDCSnackbar() {
  18631. return _super !== null && _super.apply(this, arguments) || this;
  18632. }
  18633. MDCSnackbar.attachTo = function (root) {
  18634. return new MDCSnackbar(root);
  18635. };
  18636. MDCSnackbar.prototype.initialize = function (announcerFactory) {
  18637. if (announcerFactory === void 0) {
  18638. announcerFactory = function announcerFactory() {
  18639. return util.announce;
  18640. };
  18641. }
  18642. this.announce_ = announcerFactory();
  18643. };
  18644. MDCSnackbar.prototype.initialSyncWithDOM = function () {
  18645. var _this = this;
  18646. this.surfaceEl_ = this.root.querySelector(SURFACE_SELECTOR);
  18647. this.labelEl_ = this.root.querySelector(LABEL_SELECTOR);
  18648. this.actionEl_ = this.root.querySelector(ACTION_SELECTOR);
  18649. this.handleKeyDown_ = function (evt) {
  18650. return _this.foundation.handleKeyDown(evt);
  18651. };
  18652. this.handleSurfaceClick_ = function (evt) {
  18653. var target = evt.target;
  18654. if (_this.isActionButton_(target)) {
  18655. _this.foundation.handleActionButtonClick(evt);
  18656. } else if (_this.isActionIcon_(target)) {
  18657. _this.foundation.handleActionIconClick(evt);
  18658. }
  18659. };
  18660. this.registerKeyDownHandler_(this.handleKeyDown_);
  18661. this.registerSurfaceClickHandler_(this.handleSurfaceClick_);
  18662. };
  18663. MDCSnackbar.prototype.destroy = function () {
  18664. _super.prototype.destroy.call(this);
  18665. this.deregisterKeyDownHandler_(this.handleKeyDown_);
  18666. this.deregisterSurfaceClickHandler_(this.handleSurfaceClick_);
  18667. };
  18668. MDCSnackbar.prototype.open = function () {
  18669. this.foundation.open();
  18670. };
  18671. /**
  18672. * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
  18673. * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
  18674. * client-specific values may also be used if desired.
  18675. */
  18676. MDCSnackbar.prototype.close = function (reason) {
  18677. if (reason === void 0) {
  18678. reason = '';
  18679. }
  18680. this.foundation.close(reason);
  18681. };
  18682. MDCSnackbar.prototype.getDefaultFoundation = function () {
  18683. var _this = this;
  18684. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  18685. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  18686. var adapter = {
  18687. addClass: function addClass(className) {
  18688. return _this.root.classList.add(className);
  18689. },
  18690. announce: function announce() {
  18691. return _this.announce_(_this.labelEl_);
  18692. },
  18693. notifyClosed: function notifyClosed(reason) {
  18694. return _this.emit(CLOSED_EVENT, reason ? { reason: reason } : {});
  18695. },
  18696. notifyClosing: function notifyClosing(reason) {
  18697. return _this.emit(CLOSING_EVENT, reason ? { reason: reason } : {});
  18698. },
  18699. notifyOpened: function notifyOpened() {
  18700. return _this.emit(OPENED_EVENT, {});
  18701. },
  18702. notifyOpening: function notifyOpening() {
  18703. return _this.emit(OPENING_EVENT, {});
  18704. },
  18705. removeClass: function removeClass(className) {
  18706. return _this.root.classList.remove(className);
  18707. }
  18708. };
  18709. return new foundation_1.MDCSnackbarFoundation(adapter);
  18710. };
  18711. Object.defineProperty(MDCSnackbar.prototype, "timeoutMs", {
  18712. get: function get() {
  18713. return this.foundation.getTimeoutMs();
  18714. },
  18715. set: function set(timeoutMs) {
  18716. this.foundation.setTimeoutMs(timeoutMs);
  18717. },
  18718. enumerable: true,
  18719. configurable: true
  18720. });
  18721. Object.defineProperty(MDCSnackbar.prototype, "closeOnEscape", {
  18722. get: function get() {
  18723. return this.foundation.getCloseOnEscape();
  18724. },
  18725. set: function set(closeOnEscape) {
  18726. this.foundation.setCloseOnEscape(closeOnEscape);
  18727. },
  18728. enumerable: true,
  18729. configurable: true
  18730. });
  18731. Object.defineProperty(MDCSnackbar.prototype, "isOpen", {
  18732. get: function get() {
  18733. return this.foundation.isOpen();
  18734. },
  18735. enumerable: true,
  18736. configurable: true
  18737. });
  18738. Object.defineProperty(MDCSnackbar.prototype, "labelText", {
  18739. get: function get() {
  18740. // This property only returns null if the node is a document, DOCTYPE, or notation.
  18741. // On Element nodes, it always returns a string.
  18742. return this.labelEl_.textContent;
  18743. },
  18744. set: function set(labelText) {
  18745. this.labelEl_.textContent = labelText;
  18746. },
  18747. enumerable: true,
  18748. configurable: true
  18749. });
  18750. Object.defineProperty(MDCSnackbar.prototype, "actionButtonText", {
  18751. get: function get() {
  18752. return this.actionEl_.textContent;
  18753. },
  18754. set: function set(actionButtonText) {
  18755. this.actionEl_.textContent = actionButtonText;
  18756. },
  18757. enumerable: true,
  18758. configurable: true
  18759. });
  18760. MDCSnackbar.prototype.registerKeyDownHandler_ = function (handler) {
  18761. this.listen('keydown', handler);
  18762. };
  18763. MDCSnackbar.prototype.deregisterKeyDownHandler_ = function (handler) {
  18764. this.unlisten('keydown', handler);
  18765. };
  18766. MDCSnackbar.prototype.registerSurfaceClickHandler_ = function (handler) {
  18767. this.surfaceEl_.addEventListener('click', handler);
  18768. };
  18769. MDCSnackbar.prototype.deregisterSurfaceClickHandler_ = function (handler) {
  18770. this.surfaceEl_.removeEventListener('click', handler);
  18771. };
  18772. MDCSnackbar.prototype.isActionButton_ = function (target) {
  18773. return Boolean(ponyfill_1.closest(target, ACTION_SELECTOR));
  18774. };
  18775. MDCSnackbar.prototype.isActionIcon_ = function (target) {
  18776. return Boolean(ponyfill_1.closest(target, DISMISS_SELECTOR));
  18777. };
  18778. return MDCSnackbar;
  18779. }(component_1.MDCComponent);
  18780. exports.MDCSnackbar = MDCSnackbar;
  18781. /***/ }),
  18782. /***/ "./packages/mdc-snackbar/constants.ts":
  18783. /*!********************************************!*\
  18784. !*** ./packages/mdc-snackbar/constants.ts ***!
  18785. \********************************************/
  18786. /*! no static exports found */
  18787. /***/ (function(module, exports, __webpack_require__) {
  18788. "use strict";
  18789. /**
  18790. * @license
  18791. * Copyright 2018 Google Inc.
  18792. *
  18793. * Permission is hereby granted, free of charge, to any person obtaining a copy
  18794. * of this software and associated documentation files (the "Software"), to deal
  18795. * in the Software without restriction, including without limitation the rights
  18796. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18797. * copies of the Software, and to permit persons to whom the Software is
  18798. * furnished to do so, subject to the following conditions:
  18799. *
  18800. * The above copyright notice and this permission notice shall be included in
  18801. * all copies or substantial portions of the Software.
  18802. *
  18803. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18804. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18805. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18806. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18807. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18808. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18809. * THE SOFTWARE.
  18810. */
  18811. Object.defineProperty(exports, "__esModule", { value: true });
  18812. var cssClasses = {
  18813. CLOSING: 'mdc-snackbar--closing',
  18814. OPEN: 'mdc-snackbar--open',
  18815. OPENING: 'mdc-snackbar--opening'
  18816. };
  18817. exports.cssClasses = cssClasses;
  18818. var strings = {
  18819. ACTION_SELECTOR: '.mdc-snackbar__action',
  18820. ARIA_LIVE_LABEL_TEXT_ATTR: 'data-mdc-snackbar-label-text',
  18821. CLOSED_EVENT: 'MDCSnackbar:closed',
  18822. CLOSING_EVENT: 'MDCSnackbar:closing',
  18823. DISMISS_SELECTOR: '.mdc-snackbar__dismiss',
  18824. LABEL_SELECTOR: '.mdc-snackbar__label',
  18825. OPENED_EVENT: 'MDCSnackbar:opened',
  18826. OPENING_EVENT: 'MDCSnackbar:opening',
  18827. REASON_ACTION: 'action',
  18828. REASON_DISMISS: 'dismiss',
  18829. SURFACE_SELECTOR: '.mdc-snackbar__surface'
  18830. };
  18831. exports.strings = strings;
  18832. var numbers = {
  18833. DEFAULT_AUTO_DISMISS_TIMEOUT_MS: 5000,
  18834. INDETERMINATE: -1,
  18835. MAX_AUTO_DISMISS_TIMEOUT_MS: 10000,
  18836. MIN_AUTO_DISMISS_TIMEOUT_MS: 4000,
  18837. // These variables need to be kept in sync with the values in _variables.scss.
  18838. SNACKBAR_ANIMATION_CLOSE_TIME_MS: 75,
  18839. SNACKBAR_ANIMATION_OPEN_TIME_MS: 150,
  18840. /**
  18841. * Number of milliseconds to wait between temporarily clearing the label text
  18842. * in the DOM and subsequently restoring it. This is necessary to force IE 11
  18843. * to pick up the `aria-live` content change and announce it to the user.
  18844. */
  18845. ARIA_LIVE_DELAY_MS: 1000
  18846. };
  18847. exports.numbers = numbers;
  18848. /***/ }),
  18849. /***/ "./packages/mdc-snackbar/foundation.ts":
  18850. /*!*********************************************!*\
  18851. !*** ./packages/mdc-snackbar/foundation.ts ***!
  18852. \*********************************************/
  18853. /*! no static exports found */
  18854. /***/ (function(module, exports, __webpack_require__) {
  18855. "use strict";
  18856. /**
  18857. * @license
  18858. * Copyright 2018 Google Inc.
  18859. *
  18860. * Permission is hereby granted, free of charge, to any person obtaining a copy
  18861. * of this software and associated documentation files (the "Software"), to deal
  18862. * in the Software without restriction, including without limitation the rights
  18863. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  18864. * copies of the Software, and to permit persons to whom the Software is
  18865. * furnished to do so, subject to the following conditions:
  18866. *
  18867. * The above copyright notice and this permission notice shall be included in
  18868. * all copies or substantial portions of the Software.
  18869. *
  18870. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18871. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18872. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18873. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18874. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18875. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18876. * THE SOFTWARE.
  18877. */
  18878. var __extends = this && this.__extends || function () {
  18879. var _extendStatics = function extendStatics(d, b) {
  18880. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  18881. d.__proto__ = b;
  18882. } || function (d, b) {
  18883. for (var p in b) {
  18884. if (b.hasOwnProperty(p)) d[p] = b[p];
  18885. }
  18886. };
  18887. return _extendStatics(d, b);
  18888. };
  18889. return function (d, b) {
  18890. _extendStatics(d, b);
  18891. function __() {
  18892. this.constructor = d;
  18893. }
  18894. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  18895. };
  18896. }();
  18897. var __assign = this && this.__assign || function () {
  18898. __assign = Object.assign || function (t) {
  18899. for (var s, i = 1, n = arguments.length; i < n; i++) {
  18900. s = arguments[i];
  18901. for (var p in s) {
  18902. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  18903. }
  18904. }
  18905. return t;
  18906. };
  18907. return __assign.apply(this, arguments);
  18908. };
  18909. Object.defineProperty(exports, "__esModule", { value: true });
  18910. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  18911. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
  18912. var OPENING = constants_1.cssClasses.OPENING,
  18913. OPEN = constants_1.cssClasses.OPEN,
  18914. CLOSING = constants_1.cssClasses.CLOSING;
  18915. var REASON_ACTION = constants_1.strings.REASON_ACTION,
  18916. REASON_DISMISS = constants_1.strings.REASON_DISMISS;
  18917. var MDCSnackbarFoundation = /** @class */function (_super) {
  18918. __extends(MDCSnackbarFoundation, _super);
  18919. function MDCSnackbarFoundation(adapter) {
  18920. var _this = _super.call(this, __assign(__assign({}, MDCSnackbarFoundation.defaultAdapter), adapter)) || this;
  18921. _this.isOpen_ = false;
  18922. _this.animationFrame_ = 0;
  18923. _this.animationTimer_ = 0;
  18924. _this.autoDismissTimer_ = 0;
  18925. _this.autoDismissTimeoutMs_ = constants_1.numbers.DEFAULT_AUTO_DISMISS_TIMEOUT_MS;
  18926. _this.closeOnEscape_ = true;
  18927. return _this;
  18928. }
  18929. Object.defineProperty(MDCSnackbarFoundation, "cssClasses", {
  18930. get: function get() {
  18931. return constants_1.cssClasses;
  18932. },
  18933. enumerable: true,
  18934. configurable: true
  18935. });
  18936. Object.defineProperty(MDCSnackbarFoundation, "strings", {
  18937. get: function get() {
  18938. return constants_1.strings;
  18939. },
  18940. enumerable: true,
  18941. configurable: true
  18942. });
  18943. Object.defineProperty(MDCSnackbarFoundation, "numbers", {
  18944. get: function get() {
  18945. return constants_1.numbers;
  18946. },
  18947. enumerable: true,
  18948. configurable: true
  18949. });
  18950. Object.defineProperty(MDCSnackbarFoundation, "defaultAdapter", {
  18951. get: function get() {
  18952. return {
  18953. addClass: function addClass() {
  18954. return undefined;
  18955. },
  18956. announce: function announce() {
  18957. return undefined;
  18958. },
  18959. notifyClosed: function notifyClosed() {
  18960. return undefined;
  18961. },
  18962. notifyClosing: function notifyClosing() {
  18963. return undefined;
  18964. },
  18965. notifyOpened: function notifyOpened() {
  18966. return undefined;
  18967. },
  18968. notifyOpening: function notifyOpening() {
  18969. return undefined;
  18970. },
  18971. removeClass: function removeClass() {
  18972. return undefined;
  18973. }
  18974. };
  18975. },
  18976. enumerable: true,
  18977. configurable: true
  18978. });
  18979. MDCSnackbarFoundation.prototype.destroy = function () {
  18980. this.clearAutoDismissTimer_();
  18981. cancelAnimationFrame(this.animationFrame_);
  18982. this.animationFrame_ = 0;
  18983. clearTimeout(this.animationTimer_);
  18984. this.animationTimer_ = 0;
  18985. this.adapter.removeClass(OPENING);
  18986. this.adapter.removeClass(OPEN);
  18987. this.adapter.removeClass(CLOSING);
  18988. };
  18989. MDCSnackbarFoundation.prototype.open = function () {
  18990. var _this = this;
  18991. this.clearAutoDismissTimer_();
  18992. this.isOpen_ = true;
  18993. this.adapter.notifyOpening();
  18994. this.adapter.removeClass(CLOSING);
  18995. this.adapter.addClass(OPENING);
  18996. this.adapter.announce();
  18997. // Wait a frame once display is no longer "none", to establish basis for animation
  18998. this.runNextAnimationFrame_(function () {
  18999. _this.adapter.addClass(OPEN);
  19000. _this.animationTimer_ = setTimeout(function () {
  19001. var timeoutMs = _this.getTimeoutMs();
  19002. _this.handleAnimationTimerEnd_();
  19003. _this.adapter.notifyOpened();
  19004. if (timeoutMs !== constants_1.numbers.INDETERMINATE) {
  19005. _this.autoDismissTimer_ = setTimeout(function () {
  19006. _this.close(REASON_DISMISS);
  19007. }, timeoutMs);
  19008. }
  19009. }, constants_1.numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS);
  19010. });
  19011. };
  19012. /**
  19013. * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
  19014. * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
  19015. * client-specific values may also be used if desired.
  19016. */
  19017. MDCSnackbarFoundation.prototype.close = function (reason) {
  19018. var _this = this;
  19019. if (reason === void 0) {
  19020. reason = '';
  19021. }
  19022. if (!this.isOpen_) {
  19023. // Avoid redundant close calls (and events), e.g. repeated interactions as the snackbar is animating closed
  19024. return;
  19025. }
  19026. cancelAnimationFrame(this.animationFrame_);
  19027. this.animationFrame_ = 0;
  19028. this.clearAutoDismissTimer_();
  19029. this.isOpen_ = false;
  19030. this.adapter.notifyClosing(reason);
  19031. this.adapter.addClass(constants_1.cssClasses.CLOSING);
  19032. this.adapter.removeClass(constants_1.cssClasses.OPEN);
  19033. this.adapter.removeClass(constants_1.cssClasses.OPENING);
  19034. clearTimeout(this.animationTimer_);
  19035. this.animationTimer_ = setTimeout(function () {
  19036. _this.handleAnimationTimerEnd_();
  19037. _this.adapter.notifyClosed(reason);
  19038. }, constants_1.numbers.SNACKBAR_ANIMATION_CLOSE_TIME_MS);
  19039. };
  19040. MDCSnackbarFoundation.prototype.isOpen = function () {
  19041. return this.isOpen_;
  19042. };
  19043. MDCSnackbarFoundation.prototype.getTimeoutMs = function () {
  19044. return this.autoDismissTimeoutMs_;
  19045. };
  19046. MDCSnackbarFoundation.prototype.setTimeoutMs = function (timeoutMs) {
  19047. // Use shorter variable names to make the code more readable
  19048. var minValue = constants_1.numbers.MIN_AUTO_DISMISS_TIMEOUT_MS;
  19049. var maxValue = constants_1.numbers.MAX_AUTO_DISMISS_TIMEOUT_MS;
  19050. var indeterminateValue = constants_1.numbers.INDETERMINATE;
  19051. if (timeoutMs === constants_1.numbers.INDETERMINATE || timeoutMs <= maxValue && timeoutMs >= minValue) {
  19052. this.autoDismissTimeoutMs_ = timeoutMs;
  19053. } else {
  19054. throw new Error("\n timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + "\n (or " + indeterminateValue + " to disable), but got '" + timeoutMs + "'");
  19055. }
  19056. };
  19057. MDCSnackbarFoundation.prototype.getCloseOnEscape = function () {
  19058. return this.closeOnEscape_;
  19059. };
  19060. MDCSnackbarFoundation.prototype.setCloseOnEscape = function (closeOnEscape) {
  19061. this.closeOnEscape_ = closeOnEscape;
  19062. };
  19063. MDCSnackbarFoundation.prototype.handleKeyDown = function (evt) {
  19064. var isEscapeKey = evt.key === 'Escape' || evt.keyCode === 27;
  19065. if (isEscapeKey && this.getCloseOnEscape()) {
  19066. this.close(REASON_DISMISS);
  19067. }
  19068. };
  19069. MDCSnackbarFoundation.prototype.handleActionButtonClick = function (_evt) {
  19070. this.close(REASON_ACTION);
  19071. };
  19072. MDCSnackbarFoundation.prototype.handleActionIconClick = function (_evt) {
  19073. this.close(REASON_DISMISS);
  19074. };
  19075. MDCSnackbarFoundation.prototype.clearAutoDismissTimer_ = function () {
  19076. clearTimeout(this.autoDismissTimer_);
  19077. this.autoDismissTimer_ = 0;
  19078. };
  19079. MDCSnackbarFoundation.prototype.handleAnimationTimerEnd_ = function () {
  19080. this.animationTimer_ = 0;
  19081. this.adapter.removeClass(constants_1.cssClasses.OPENING);
  19082. this.adapter.removeClass(constants_1.cssClasses.CLOSING);
  19083. };
  19084. /**
  19085. * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
  19086. */
  19087. MDCSnackbarFoundation.prototype.runNextAnimationFrame_ = function (callback) {
  19088. var _this = this;
  19089. cancelAnimationFrame(this.animationFrame_);
  19090. this.animationFrame_ = requestAnimationFrame(function () {
  19091. _this.animationFrame_ = 0;
  19092. clearTimeout(_this.animationTimer_);
  19093. _this.animationTimer_ = setTimeout(callback, 0);
  19094. });
  19095. };
  19096. return MDCSnackbarFoundation;
  19097. }(foundation_1.MDCFoundation);
  19098. exports.MDCSnackbarFoundation = MDCSnackbarFoundation;
  19099. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  19100. exports.default = MDCSnackbarFoundation;
  19101. /***/ }),
  19102. /***/ "./packages/mdc-snackbar/index.ts":
  19103. /*!****************************************!*\
  19104. !*** ./packages/mdc-snackbar/index.ts ***!
  19105. \****************************************/
  19106. /*! no static exports found */
  19107. /***/ (function(module, exports, __webpack_require__) {
  19108. "use strict";
  19109. /**
  19110. * @license
  19111. * Copyright 2019 Google Inc.
  19112. *
  19113. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19114. * of this software and associated documentation files (the "Software"), to deal
  19115. * in the Software without restriction, including without limitation the rights
  19116. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19117. * copies of the Software, and to permit persons to whom the Software is
  19118. * furnished to do so, subject to the following conditions:
  19119. *
  19120. * The above copyright notice and this permission notice shall be included in
  19121. * all copies or substantial portions of the Software.
  19122. *
  19123. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19124. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19125. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19126. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19127. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19128. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19129. * THE SOFTWARE.
  19130. */
  19131. function __export(m) {
  19132. for (var p in m) {
  19133. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  19134. }
  19135. }
  19136. var __importStar = this && this.__importStar || function (mod) {
  19137. if (mod && mod.__esModule) return mod;
  19138. var result = {};
  19139. if (mod != null) for (var k in mod) {
  19140. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  19141. }result["default"] = mod;
  19142. return result;
  19143. };
  19144. Object.defineProperty(exports, "__esModule", { value: true });
  19145. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
  19146. exports.util = util;
  19147. __export(__webpack_require__(/*! ./component */ "./packages/mdc-snackbar/component.ts"));
  19148. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts"));
  19149. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts"));
  19150. /***/ }),
  19151. /***/ "./packages/mdc-snackbar/util.ts":
  19152. /*!***************************************!*\
  19153. !*** ./packages/mdc-snackbar/util.ts ***!
  19154. \***************************************/
  19155. /*! no static exports found */
  19156. /***/ (function(module, exports, __webpack_require__) {
  19157. "use strict";
  19158. /**
  19159. * @license
  19160. * Copyright 2018 Google Inc.
  19161. *
  19162. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19163. * of this software and associated documentation files (the "Software"), to deal
  19164. * in the Software without restriction, including without limitation the rights
  19165. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19166. * copies of the Software, and to permit persons to whom the Software is
  19167. * furnished to do so, subject to the following conditions:
  19168. *
  19169. * The above copyright notice and this permission notice shall be included in
  19170. * all copies or substantial portions of the Software.
  19171. *
  19172. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19173. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19174. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19175. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19176. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19177. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19178. * THE SOFTWARE.
  19179. */
  19180. Object.defineProperty(exports, "__esModule", { value: true });
  19181. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
  19182. var ARIA_LIVE_DELAY_MS = constants_1.numbers.ARIA_LIVE_DELAY_MS;
  19183. var ARIA_LIVE_LABEL_TEXT_ATTR = constants_1.strings.ARIA_LIVE_LABEL_TEXT_ATTR;
  19184. function announce(ariaEl, labelEl) {
  19185. if (labelEl === void 0) {
  19186. labelEl = ariaEl;
  19187. }
  19188. var priority = ariaEl.getAttribute('aria-live');
  19189. // Trim text to ignore `&nbsp;` (see below).
  19190. // textContent is only null if the node is a document, DOCTYPE, or notation.
  19191. var labelText = labelEl.textContent.trim();
  19192. if (!labelText || !priority) {
  19193. return;
  19194. }
  19195. // Temporarily disable `aria-live` to prevent JAWS+Firefox from announcing the message twice.
  19196. ariaEl.setAttribute('aria-live', 'off');
  19197. // Temporarily clear `textContent` to force a DOM mutation event that will be detected by screen readers.
  19198. // `aria-live` elements are only announced when the element's `textContent` *changes*, so snackbars
  19199. // sent to the browser in the initial HTML response won't be read unless we clear the element's `textContent` first.
  19200. // Similarly, displaying the same snackbar message twice in a row doesn't trigger a DOM mutation event,
  19201. // so screen readers won't announce the second message unless we first clear `textContent`.
  19202. //
  19203. // We have to clear the label text two different ways to make it work in all browsers and screen readers:
  19204. //
  19205. // 1. `textContent = ''` is required for IE11 + JAWS
  19206. // 2. `innerHTML = '&nbsp;'` is required for Chrome + JAWS and NVDA
  19207. //
  19208. // All other browser/screen reader combinations support both methods.
  19209. //
  19210. // The wrapper `<span>` visually hides the space character so that it doesn't cause jank when added/removed.
  19211. // N.B.: Setting `position: absolute`, `opacity: 0`, or `height: 0` prevents Chrome from detecting the DOM change.
  19212. //
  19213. // This technique has been tested in:
  19214. //
  19215. // * JAWS 2019:
  19216. // - Chrome 70
  19217. // - Firefox 60 (ESR)
  19218. // - IE 11
  19219. // * NVDA 2018:
  19220. // - Chrome 70
  19221. // - Firefox 60 (ESR)
  19222. // - IE 11
  19223. // * ChromeVox 53
  19224. labelEl.textContent = '';
  19225. labelEl.innerHTML = '<span style="display: inline-block; width: 0; height: 1px;">&nbsp;</span>';
  19226. // Prevent visual jank by temporarily displaying the label text in the ::before pseudo-element.
  19227. // CSS generated content is normally announced by screen readers
  19228. // (except in IE 11; see https://tink.uk/accessibility-support-for-css-generated-content/);
  19229. // however, `aria-live` is turned off, so this DOM update will be ignored by screen readers.
  19230. labelEl.setAttribute(ARIA_LIVE_LABEL_TEXT_ATTR, labelText);
  19231. setTimeout(function () {
  19232. // Allow screen readers to announce changes to the DOM again.
  19233. ariaEl.setAttribute('aria-live', priority);
  19234. // Remove the message from the ::before pseudo-element.
  19235. labelEl.removeAttribute(ARIA_LIVE_LABEL_TEXT_ATTR);
  19236. // Restore the original label text, which will be announced by screen readers.
  19237. labelEl.textContent = labelText;
  19238. }, ARIA_LIVE_DELAY_MS);
  19239. }
  19240. exports.announce = announce;
  19241. /***/ }),
  19242. /***/ "./packages/mdc-switch/component.ts":
  19243. /*!******************************************!*\
  19244. !*** ./packages/mdc-switch/component.ts ***!
  19245. \******************************************/
  19246. /*! no static exports found */
  19247. /***/ (function(module, exports, __webpack_require__) {
  19248. "use strict";
  19249. /**
  19250. * @license
  19251. * Copyright 2018 Google Inc.
  19252. *
  19253. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19254. * of this software and associated documentation files (the "Software"), to deal
  19255. * in the Software without restriction, including without limitation the rights
  19256. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19257. * copies of the Software, and to permit persons to whom the Software is
  19258. * furnished to do so, subject to the following conditions:
  19259. *
  19260. * The above copyright notice and this permission notice shall be included in
  19261. * all copies or substantial portions of the Software.
  19262. *
  19263. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19264. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19265. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19266. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19267. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19268. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19269. * THE SOFTWARE.
  19270. */
  19271. var __extends = this && this.__extends || function () {
  19272. var _extendStatics = function extendStatics(d, b) {
  19273. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  19274. d.__proto__ = b;
  19275. } || function (d, b) {
  19276. for (var p in b) {
  19277. if (b.hasOwnProperty(p)) d[p] = b[p];
  19278. }
  19279. };
  19280. return _extendStatics(d, b);
  19281. };
  19282. return function (d, b) {
  19283. _extendStatics(d, b);
  19284. function __() {
  19285. this.constructor = d;
  19286. }
  19287. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19288. };
  19289. }();
  19290. var __assign = this && this.__assign || function () {
  19291. __assign = Object.assign || function (t) {
  19292. for (var s, i = 1, n = arguments.length; i < n; i++) {
  19293. s = arguments[i];
  19294. for (var p in s) {
  19295. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  19296. }
  19297. }
  19298. return t;
  19299. };
  19300. return __assign.apply(this, arguments);
  19301. };
  19302. var __read = this && this.__read || function (o, n) {
  19303. var m = typeof Symbol === "function" && o[Symbol.iterator];
  19304. if (!m) return o;
  19305. var i = m.call(o),
  19306. r,
  19307. ar = [],
  19308. e;
  19309. try {
  19310. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  19311. ar.push(r.value);
  19312. }
  19313. } catch (error) {
  19314. e = { error: error };
  19315. } finally {
  19316. try {
  19317. if (r && !r.done && (m = i["return"])) m.call(i);
  19318. } finally {
  19319. if (e) throw e.error;
  19320. }
  19321. }
  19322. return ar;
  19323. };
  19324. var __spread = this && this.__spread || function () {
  19325. for (var ar = [], i = 0; i < arguments.length; i++) {
  19326. ar = ar.concat(__read(arguments[i]));
  19327. }return ar;
  19328. };
  19329. Object.defineProperty(exports, "__esModule", { value: true });
  19330. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  19331. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  19332. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  19333. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  19334. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  19335. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-switch/foundation.ts");
  19336. var MDCSwitch = /** @class */function (_super) {
  19337. __extends(MDCSwitch, _super);
  19338. function MDCSwitch() {
  19339. var _this = _super !== null && _super.apply(this, arguments) || this;
  19340. _this.ripple_ = _this.createRipple_();
  19341. return _this;
  19342. }
  19343. MDCSwitch.attachTo = function (root) {
  19344. return new MDCSwitch(root);
  19345. };
  19346. MDCSwitch.prototype.destroy = function () {
  19347. _super.prototype.destroy.call(this);
  19348. this.ripple_.destroy();
  19349. this.nativeControl_.removeEventListener('change', this.changeHandler_);
  19350. };
  19351. MDCSwitch.prototype.initialSyncWithDOM = function () {
  19352. var _this = this;
  19353. this.changeHandler_ = function () {
  19354. var _a;
  19355. var args = [];
  19356. for (var _i = 0; _i < arguments.length; _i++) {
  19357. args[_i] = arguments[_i];
  19358. }
  19359. return (_a = _this.foundation).handleChange.apply(_a, __spread(args));
  19360. };
  19361. this.nativeControl_.addEventListener('change', this.changeHandler_);
  19362. // Sometimes the checked state of the input element is saved in the history.
  19363. // The switch styling should match the checked state of the input element.
  19364. // Do an initial sync between the native control and the foundation.
  19365. this.checked = this.checked;
  19366. };
  19367. MDCSwitch.prototype.getDefaultFoundation = function () {
  19368. var _this = this;
  19369. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  19370. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  19371. var adapter = {
  19372. addClass: function addClass(className) {
  19373. return _this.root.classList.add(className);
  19374. },
  19375. removeClass: function removeClass(className) {
  19376. return _this.root.classList.remove(className);
  19377. },
  19378. setNativeControlChecked: function setNativeControlChecked(checked) {
  19379. return _this.nativeControl_.checked = checked;
  19380. },
  19381. setNativeControlDisabled: function setNativeControlDisabled(disabled) {
  19382. return _this.nativeControl_.disabled = disabled;
  19383. },
  19384. setNativeControlAttr: function setNativeControlAttr(attr, value) {
  19385. return _this.nativeControl_.setAttribute(attr, value);
  19386. }
  19387. };
  19388. return new foundation_2.MDCSwitchFoundation(adapter);
  19389. };
  19390. Object.defineProperty(MDCSwitch.prototype, "ripple", {
  19391. get: function get() {
  19392. return this.ripple_;
  19393. },
  19394. enumerable: true,
  19395. configurable: true
  19396. });
  19397. Object.defineProperty(MDCSwitch.prototype, "checked", {
  19398. get: function get() {
  19399. return this.nativeControl_.checked;
  19400. },
  19401. set: function set(checked) {
  19402. this.foundation.setChecked(checked);
  19403. },
  19404. enumerable: true,
  19405. configurable: true
  19406. });
  19407. Object.defineProperty(MDCSwitch.prototype, "disabled", {
  19408. get: function get() {
  19409. return this.nativeControl_.disabled;
  19410. },
  19411. set: function set(disabled) {
  19412. this.foundation.setDisabled(disabled);
  19413. },
  19414. enumerable: true,
  19415. configurable: true
  19416. });
  19417. MDCSwitch.prototype.createRipple_ = function () {
  19418. var _this = this;
  19419. var RIPPLE_SURFACE_SELECTOR = foundation_2.MDCSwitchFoundation.strings.RIPPLE_SURFACE_SELECTOR;
  19420. var rippleSurface = this.root.querySelector(RIPPLE_SURFACE_SELECTOR);
  19421. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  19422. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  19423. var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { addClass: function addClass(className) {
  19424. return rippleSurface.classList.add(className);
  19425. }, computeBoundingRect: function computeBoundingRect() {
  19426. return rippleSurface.getBoundingClientRect();
  19427. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  19428. _this.nativeControl_.removeEventListener(evtType, handler, events_1.applyPassive());
  19429. }, isSurfaceActive: function isSurfaceActive() {
  19430. return ponyfill_1.matches(_this.nativeControl_, ':active');
  19431. }, isUnbounded: function isUnbounded() {
  19432. return true;
  19433. }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  19434. _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
  19435. }, removeClass: function removeClass(className) {
  19436. rippleSurface.classList.remove(className);
  19437. }, updateCssVariable: function updateCssVariable(varName, value) {
  19438. rippleSurface.style.setProperty(varName, value);
  19439. } });
  19440. return new component_2.MDCRipple(this.root, new foundation_1.MDCRippleFoundation(adapter));
  19441. };
  19442. Object.defineProperty(MDCSwitch.prototype, "nativeControl_", {
  19443. get: function get() {
  19444. var NATIVE_CONTROL_SELECTOR = foundation_2.MDCSwitchFoundation.strings.NATIVE_CONTROL_SELECTOR;
  19445. return this.root.querySelector(NATIVE_CONTROL_SELECTOR);
  19446. },
  19447. enumerable: true,
  19448. configurable: true
  19449. });
  19450. return MDCSwitch;
  19451. }(component_1.MDCComponent);
  19452. exports.MDCSwitch = MDCSwitch;
  19453. /***/ }),
  19454. /***/ "./packages/mdc-switch/constants.ts":
  19455. /*!******************************************!*\
  19456. !*** ./packages/mdc-switch/constants.ts ***!
  19457. \******************************************/
  19458. /*! no static exports found */
  19459. /***/ (function(module, exports, __webpack_require__) {
  19460. "use strict";
  19461. /**
  19462. * @license
  19463. * Copyright 2018 Google Inc.
  19464. *
  19465. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19466. * of this software and associated documentation files (the "Software"), to deal
  19467. * in the Software without restriction, including without limitation the rights
  19468. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19469. * copies of the Software, and to permit persons to whom the Software is
  19470. * furnished to do so, subject to the following conditions:
  19471. *
  19472. * The above copyright notice and this permission notice shall be included in
  19473. * all copies or substantial portions of the Software.
  19474. *
  19475. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19476. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19477. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19478. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19479. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19480. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19481. * THE SOFTWARE.
  19482. */
  19483. Object.defineProperty(exports, "__esModule", { value: true });
  19484. /** CSS classes used by the switch. */
  19485. var cssClasses = {
  19486. /** Class used for a switch that is in the "checked" (on) position. */
  19487. CHECKED: 'mdc-switch--checked',
  19488. /** Class used for a switch that is disabled. */
  19489. DISABLED: 'mdc-switch--disabled'
  19490. };
  19491. exports.cssClasses = cssClasses;
  19492. /** String constants used by the switch. */
  19493. var strings = {
  19494. /** Aria attribute for checked or unchecked state of switch */
  19495. ARIA_CHECKED_ATTR: 'aria-checked',
  19496. /** A CSS selector used to locate the native HTML control for the switch. */
  19497. NATIVE_CONTROL_SELECTOR: '.mdc-switch__native-control',
  19498. /** A CSS selector used to locate the ripple surface element for the switch. */
  19499. RIPPLE_SURFACE_SELECTOR: '.mdc-switch__thumb-underlay'
  19500. };
  19501. exports.strings = strings;
  19502. /***/ }),
  19503. /***/ "./packages/mdc-switch/foundation.ts":
  19504. /*!*******************************************!*\
  19505. !*** ./packages/mdc-switch/foundation.ts ***!
  19506. \*******************************************/
  19507. /*! no static exports found */
  19508. /***/ (function(module, exports, __webpack_require__) {
  19509. "use strict";
  19510. /**
  19511. * @license
  19512. * Copyright 2018 Google Inc.
  19513. *
  19514. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19515. * of this software and associated documentation files (the "Software"), to deal
  19516. * in the Software without restriction, including without limitation the rights
  19517. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19518. * copies of the Software, and to permit persons to whom the Software is
  19519. * furnished to do so, subject to the following conditions:
  19520. *
  19521. * The above copyright notice and this permission notice shall be included in
  19522. * all copies or substantial portions of the Software.
  19523. *
  19524. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19525. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19526. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19527. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19528. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19529. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19530. * THE SOFTWARE.
  19531. */
  19532. var __extends = this && this.__extends || function () {
  19533. var _extendStatics = function extendStatics(d, b) {
  19534. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  19535. d.__proto__ = b;
  19536. } || function (d, b) {
  19537. for (var p in b) {
  19538. if (b.hasOwnProperty(p)) d[p] = b[p];
  19539. }
  19540. };
  19541. return _extendStatics(d, b);
  19542. };
  19543. return function (d, b) {
  19544. _extendStatics(d, b);
  19545. function __() {
  19546. this.constructor = d;
  19547. }
  19548. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19549. };
  19550. }();
  19551. var __assign = this && this.__assign || function () {
  19552. __assign = Object.assign || function (t) {
  19553. for (var s, i = 1, n = arguments.length; i < n; i++) {
  19554. s = arguments[i];
  19555. for (var p in s) {
  19556. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  19557. }
  19558. }
  19559. return t;
  19560. };
  19561. return __assign.apply(this, arguments);
  19562. };
  19563. Object.defineProperty(exports, "__esModule", { value: true });
  19564. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  19565. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts");
  19566. var MDCSwitchFoundation = /** @class */function (_super) {
  19567. __extends(MDCSwitchFoundation, _super);
  19568. function MDCSwitchFoundation(adapter) {
  19569. return _super.call(this, __assign(__assign({}, MDCSwitchFoundation.defaultAdapter), adapter)) || this;
  19570. }
  19571. Object.defineProperty(MDCSwitchFoundation, "strings", {
  19572. /** The string constants used by the switch. */
  19573. get: function get() {
  19574. return constants_1.strings;
  19575. },
  19576. enumerable: true,
  19577. configurable: true
  19578. });
  19579. Object.defineProperty(MDCSwitchFoundation, "cssClasses", {
  19580. /** The CSS classes used by the switch. */
  19581. get: function get() {
  19582. return constants_1.cssClasses;
  19583. },
  19584. enumerable: true,
  19585. configurable: true
  19586. });
  19587. Object.defineProperty(MDCSwitchFoundation, "defaultAdapter", {
  19588. /** The default Adapter for the switch. */
  19589. get: function get() {
  19590. return {
  19591. addClass: function addClass() {
  19592. return undefined;
  19593. },
  19594. removeClass: function removeClass() {
  19595. return undefined;
  19596. },
  19597. setNativeControlChecked: function setNativeControlChecked() {
  19598. return undefined;
  19599. },
  19600. setNativeControlDisabled: function setNativeControlDisabled() {
  19601. return undefined;
  19602. },
  19603. setNativeControlAttr: function setNativeControlAttr() {
  19604. return undefined;
  19605. }
  19606. };
  19607. },
  19608. enumerable: true,
  19609. configurable: true
  19610. });
  19611. /** Sets the checked state of the switch. */
  19612. MDCSwitchFoundation.prototype.setChecked = function (checked) {
  19613. this.adapter.setNativeControlChecked(checked);
  19614. this.updateAriaChecked_(checked);
  19615. this.updateCheckedStyling_(checked);
  19616. };
  19617. /** Sets the disabled state of the switch. */
  19618. MDCSwitchFoundation.prototype.setDisabled = function (disabled) {
  19619. this.adapter.setNativeControlDisabled(disabled);
  19620. if (disabled) {
  19621. this.adapter.addClass(constants_1.cssClasses.DISABLED);
  19622. } else {
  19623. this.adapter.removeClass(constants_1.cssClasses.DISABLED);
  19624. }
  19625. };
  19626. /** Handles the change event for the switch native control. */
  19627. MDCSwitchFoundation.prototype.handleChange = function (evt) {
  19628. var nativeControl = evt.target;
  19629. this.updateAriaChecked_(nativeControl.checked);
  19630. this.updateCheckedStyling_(nativeControl.checked);
  19631. };
  19632. /** Updates the styling of the switch based on its checked state. */
  19633. MDCSwitchFoundation.prototype.updateCheckedStyling_ = function (checked) {
  19634. if (checked) {
  19635. this.adapter.addClass(constants_1.cssClasses.CHECKED);
  19636. } else {
  19637. this.adapter.removeClass(constants_1.cssClasses.CHECKED);
  19638. }
  19639. };
  19640. MDCSwitchFoundation.prototype.updateAriaChecked_ = function (checked) {
  19641. this.adapter.setNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR, "" + !!checked);
  19642. };
  19643. return MDCSwitchFoundation;
  19644. }(foundation_1.MDCFoundation);
  19645. exports.MDCSwitchFoundation = MDCSwitchFoundation;
  19646. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  19647. exports.default = MDCSwitchFoundation;
  19648. /***/ }),
  19649. /***/ "./packages/mdc-switch/index.ts":
  19650. /*!**************************************!*\
  19651. !*** ./packages/mdc-switch/index.ts ***!
  19652. \**************************************/
  19653. /*! no static exports found */
  19654. /***/ (function(module, exports, __webpack_require__) {
  19655. "use strict";
  19656. /**
  19657. * @license
  19658. * Copyright 2019 Google Inc.
  19659. *
  19660. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19661. * of this software and associated documentation files (the "Software"), to deal
  19662. * in the Software without restriction, including without limitation the rights
  19663. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19664. * copies of the Software, and to permit persons to whom the Software is
  19665. * furnished to do so, subject to the following conditions:
  19666. *
  19667. * The above copyright notice and this permission notice shall be included in
  19668. * all copies or substantial portions of the Software.
  19669. *
  19670. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19671. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19672. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19673. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19674. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19675. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19676. * THE SOFTWARE.
  19677. */
  19678. function __export(m) {
  19679. for (var p in m) {
  19680. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  19681. }
  19682. }
  19683. Object.defineProperty(exports, "__esModule", { value: true });
  19684. __export(__webpack_require__(/*! ./component */ "./packages/mdc-switch/component.ts"));
  19685. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts"));
  19686. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-switch/foundation.ts"));
  19687. /***/ }),
  19688. /***/ "./packages/mdc-tab-bar/component.ts":
  19689. /*!*******************************************!*\
  19690. !*** ./packages/mdc-tab-bar/component.ts ***!
  19691. \*******************************************/
  19692. /*! no static exports found */
  19693. /***/ (function(module, exports, __webpack_require__) {
  19694. "use strict";
  19695. /**
  19696. * @license
  19697. * Copyright 2018 Google Inc.
  19698. *
  19699. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19700. * of this software and associated documentation files (the "Software"), to deal
  19701. * in the Software without restriction, including without limitation the rights
  19702. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19703. * copies of the Software, and to permit persons to whom the Software is
  19704. * furnished to do so, subject to the following conditions:
  19705. *
  19706. * The above copyright notice and this permission notice shall be included in
  19707. * all copies or substantial portions of the Software.
  19708. *
  19709. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19710. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19711. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19712. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19713. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19714. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19715. * THE SOFTWARE.
  19716. */
  19717. var __extends = this && this.__extends || function () {
  19718. var _extendStatics = function extendStatics(d, b) {
  19719. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  19720. d.__proto__ = b;
  19721. } || function (d, b) {
  19722. for (var p in b) {
  19723. if (b.hasOwnProperty(p)) d[p] = b[p];
  19724. }
  19725. };
  19726. return _extendStatics(d, b);
  19727. };
  19728. return function (d, b) {
  19729. _extendStatics(d, b);
  19730. function __() {
  19731. this.constructor = d;
  19732. }
  19733. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  19734. };
  19735. }();
  19736. Object.defineProperty(exports, "__esModule", { value: true });
  19737. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  19738. var component_2 = __webpack_require__(/*! @material/tab-scroller/component */ "./packages/mdc-tab-scroller/component.ts");
  19739. var component_3 = __webpack_require__(/*! @material/tab/component */ "./packages/mdc-tab/component.ts");
  19740. var foundation_1 = __webpack_require__(/*! @material/tab/foundation */ "./packages/mdc-tab/foundation.ts");
  19741. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-bar/foundation.ts");
  19742. var strings = foundation_2.MDCTabBarFoundation.strings;
  19743. var tabIdCounter = 0;
  19744. var MDCTabBar = /** @class */function (_super) {
  19745. __extends(MDCTabBar, _super);
  19746. function MDCTabBar() {
  19747. return _super !== null && _super.apply(this, arguments) || this;
  19748. }
  19749. MDCTabBar.attachTo = function (root) {
  19750. return new MDCTabBar(root);
  19751. };
  19752. Object.defineProperty(MDCTabBar.prototype, "focusOnActivate", {
  19753. set: function set(focusOnActivate) {
  19754. this.tabList_.forEach(function (tab) {
  19755. return tab.focusOnActivate = focusOnActivate;
  19756. });
  19757. },
  19758. enumerable: true,
  19759. configurable: true
  19760. });
  19761. Object.defineProperty(MDCTabBar.prototype, "useAutomaticActivation", {
  19762. set: function set(useAutomaticActivation) {
  19763. this.foundation.setUseAutomaticActivation(useAutomaticActivation);
  19764. },
  19765. enumerable: true,
  19766. configurable: true
  19767. });
  19768. MDCTabBar.prototype.initialize = function (tabFactory, tabScrollerFactory) {
  19769. if (tabFactory === void 0) {
  19770. tabFactory = function tabFactory(el) {
  19771. return new component_3.MDCTab(el);
  19772. };
  19773. }
  19774. if (tabScrollerFactory === void 0) {
  19775. tabScrollerFactory = function tabScrollerFactory(el) {
  19776. return new component_2.MDCTabScroller(el);
  19777. };
  19778. }
  19779. this.tabList_ = this.instantiateTabs_(tabFactory);
  19780. this.tabScroller_ = this.instantiateTabScroller_(tabScrollerFactory);
  19781. };
  19782. MDCTabBar.prototype.initialSyncWithDOM = function () {
  19783. var _this = this;
  19784. this.handleTabInteraction_ = function (evt) {
  19785. return _this.foundation.handleTabInteraction(evt);
  19786. };
  19787. this.handleKeyDown_ = function (evt) {
  19788. return _this.foundation.handleKeyDown(evt);
  19789. };
  19790. this.listen(foundation_1.MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_);
  19791. this.listen('keydown', this.handleKeyDown_);
  19792. for (var i = 0; i < this.tabList_.length; i++) {
  19793. if (this.tabList_[i].active) {
  19794. this.scrollIntoView(i);
  19795. break;
  19796. }
  19797. }
  19798. };
  19799. MDCTabBar.prototype.destroy = function () {
  19800. _super.prototype.destroy.call(this);
  19801. this.unlisten(foundation_1.MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_);
  19802. this.unlisten('keydown', this.handleKeyDown_);
  19803. this.tabList_.forEach(function (tab) {
  19804. return tab.destroy();
  19805. });
  19806. if (this.tabScroller_) {
  19807. this.tabScroller_.destroy();
  19808. }
  19809. };
  19810. MDCTabBar.prototype.getDefaultFoundation = function () {
  19811. var _this = this;
  19812. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  19813. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  19814. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  19815. var adapter = {
  19816. scrollTo: function scrollTo(scrollX) {
  19817. return _this.tabScroller_.scrollTo(scrollX);
  19818. },
  19819. incrementScroll: function incrementScroll(scrollXIncrement) {
  19820. return _this.tabScroller_.incrementScroll(scrollXIncrement);
  19821. },
  19822. getScrollPosition: function getScrollPosition() {
  19823. return _this.tabScroller_.getScrollPosition();
  19824. },
  19825. getScrollContentWidth: function getScrollContentWidth() {
  19826. return _this.tabScroller_.getScrollContentWidth();
  19827. },
  19828. getOffsetWidth: function getOffsetWidth() {
  19829. return _this.root.offsetWidth;
  19830. },
  19831. isRTL: function isRTL() {
  19832. return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
  19833. },
  19834. setActiveTab: function setActiveTab(index) {
  19835. return _this.foundation.activateTab(index);
  19836. },
  19837. activateTabAtIndex: function activateTabAtIndex(index, clientRect) {
  19838. return _this.tabList_[index].activate(clientRect);
  19839. },
  19840. deactivateTabAtIndex: function deactivateTabAtIndex(index) {
  19841. return _this.tabList_[index].deactivate();
  19842. },
  19843. focusTabAtIndex: function focusTabAtIndex(index) {
  19844. return _this.tabList_[index].focus();
  19845. },
  19846. getTabIndicatorClientRectAtIndex: function getTabIndicatorClientRectAtIndex(index) {
  19847. return _this.tabList_[index].computeIndicatorClientRect();
  19848. },
  19849. getTabDimensionsAtIndex: function getTabDimensionsAtIndex(index) {
  19850. return _this.tabList_[index].computeDimensions();
  19851. },
  19852. getPreviousActiveTabIndex: function getPreviousActiveTabIndex() {
  19853. for (var i = 0; i < _this.tabList_.length; i++) {
  19854. if (_this.tabList_[i].active) {
  19855. return i;
  19856. }
  19857. }
  19858. return -1;
  19859. },
  19860. getFocusedTabIndex: function getFocusedTabIndex() {
  19861. var tabElements = _this.getTabElements_();
  19862. var activeElement = document.activeElement;
  19863. return tabElements.indexOf(activeElement);
  19864. },
  19865. getIndexOfTabById: function getIndexOfTabById(id) {
  19866. for (var i = 0; i < _this.tabList_.length; i++) {
  19867. if (_this.tabList_[i].id === id) {
  19868. return i;
  19869. }
  19870. }
  19871. return -1;
  19872. },
  19873. getTabListLength: function getTabListLength() {
  19874. return _this.tabList_.length;
  19875. },
  19876. notifyTabActivated: function notifyTabActivated(index) {
  19877. return _this.emit(strings.TAB_ACTIVATED_EVENT, { index: index }, true);
  19878. }
  19879. };
  19880. // tslint:enable:object-literal-sort-keys
  19881. return new foundation_2.MDCTabBarFoundation(adapter);
  19882. };
  19883. /**
  19884. * Activates the tab at the given index
  19885. * @param index The index of the tab
  19886. */
  19887. MDCTabBar.prototype.activateTab = function (index) {
  19888. this.foundation.activateTab(index);
  19889. };
  19890. /**
  19891. * Scrolls the tab at the given index into view
  19892. * @param index THe index of the tab
  19893. */
  19894. MDCTabBar.prototype.scrollIntoView = function (index) {
  19895. this.foundation.scrollIntoView(index);
  19896. };
  19897. /**
  19898. * Returns all the tab elements in a nice clean array
  19899. */
  19900. MDCTabBar.prototype.getTabElements_ = function () {
  19901. return [].slice.call(this.root.querySelectorAll(strings.TAB_SELECTOR));
  19902. };
  19903. /**
  19904. * Instantiates tab components on all child tab elements
  19905. */
  19906. MDCTabBar.prototype.instantiateTabs_ = function (tabFactory) {
  19907. return this.getTabElements_().map(function (el) {
  19908. el.id = el.id || "mdc-tab-" + ++tabIdCounter;
  19909. return tabFactory(el);
  19910. });
  19911. };
  19912. /**
  19913. * Instantiates tab scroller component on the child tab scroller element
  19914. */
  19915. MDCTabBar.prototype.instantiateTabScroller_ = function (tabScrollerFactory) {
  19916. var tabScrollerElement = this.root.querySelector(strings.TAB_SCROLLER_SELECTOR);
  19917. if (tabScrollerElement) {
  19918. return tabScrollerFactory(tabScrollerElement);
  19919. }
  19920. return null;
  19921. };
  19922. return MDCTabBar;
  19923. }(component_1.MDCComponent);
  19924. exports.MDCTabBar = MDCTabBar;
  19925. /***/ }),
  19926. /***/ "./packages/mdc-tab-bar/constants.ts":
  19927. /*!*******************************************!*\
  19928. !*** ./packages/mdc-tab-bar/constants.ts ***!
  19929. \*******************************************/
  19930. /*! no static exports found */
  19931. /***/ (function(module, exports, __webpack_require__) {
  19932. "use strict";
  19933. /**
  19934. * @license
  19935. * Copyright 2018 Google Inc.
  19936. *
  19937. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19938. * of this software and associated documentation files (the "Software"), to deal
  19939. * in the Software without restriction, including without limitation the rights
  19940. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19941. * copies of the Software, and to permit persons to whom the Software is
  19942. * furnished to do so, subject to the following conditions:
  19943. *
  19944. * The above copyright notice and this permission notice shall be included in
  19945. * all copies or substantial portions of the Software.
  19946. *
  19947. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19948. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19949. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19950. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19951. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19952. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19953. * THE SOFTWARE.
  19954. */
  19955. Object.defineProperty(exports, "__esModule", { value: true });
  19956. var strings = {
  19957. ARROW_LEFT_KEY: 'ArrowLeft',
  19958. ARROW_RIGHT_KEY: 'ArrowRight',
  19959. END_KEY: 'End',
  19960. ENTER_KEY: 'Enter',
  19961. HOME_KEY: 'Home',
  19962. SPACE_KEY: 'Space',
  19963. TAB_ACTIVATED_EVENT: 'MDCTabBar:activated',
  19964. TAB_SCROLLER_SELECTOR: '.mdc-tab-scroller',
  19965. TAB_SELECTOR: '.mdc-tab'
  19966. };
  19967. exports.strings = strings;
  19968. var numbers = {
  19969. ARROW_LEFT_KEYCODE: 37,
  19970. ARROW_RIGHT_KEYCODE: 39,
  19971. END_KEYCODE: 35,
  19972. ENTER_KEYCODE: 13,
  19973. EXTRA_SCROLL_AMOUNT: 20,
  19974. HOME_KEYCODE: 36,
  19975. SPACE_KEYCODE: 32
  19976. };
  19977. exports.numbers = numbers;
  19978. /***/ }),
  19979. /***/ "./packages/mdc-tab-bar/foundation.ts":
  19980. /*!********************************************!*\
  19981. !*** ./packages/mdc-tab-bar/foundation.ts ***!
  19982. \********************************************/
  19983. /*! no static exports found */
  19984. /***/ (function(module, exports, __webpack_require__) {
  19985. "use strict";
  19986. /**
  19987. * @license
  19988. * Copyright 2018 Google Inc.
  19989. *
  19990. * Permission is hereby granted, free of charge, to any person obtaining a copy
  19991. * of this software and associated documentation files (the "Software"), to deal
  19992. * in the Software without restriction, including without limitation the rights
  19993. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19994. * copies of the Software, and to permit persons to whom the Software is
  19995. * furnished to do so, subject to the following conditions:
  19996. *
  19997. * The above copyright notice and this permission notice shall be included in
  19998. * all copies or substantial portions of the Software.
  19999. *
  20000. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20001. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20002. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20003. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20004. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20005. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20006. * THE SOFTWARE.
  20007. */
  20008. var __extends = this && this.__extends || function () {
  20009. var _extendStatics = function extendStatics(d, b) {
  20010. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20011. d.__proto__ = b;
  20012. } || function (d, b) {
  20013. for (var p in b) {
  20014. if (b.hasOwnProperty(p)) d[p] = b[p];
  20015. }
  20016. };
  20017. return _extendStatics(d, b);
  20018. };
  20019. return function (d, b) {
  20020. _extendStatics(d, b);
  20021. function __() {
  20022. this.constructor = d;
  20023. }
  20024. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20025. };
  20026. }();
  20027. var __assign = this && this.__assign || function () {
  20028. __assign = Object.assign || function (t) {
  20029. for (var s, i = 1, n = arguments.length; i < n; i++) {
  20030. s = arguments[i];
  20031. for (var p in s) {
  20032. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  20033. }
  20034. }
  20035. return t;
  20036. };
  20037. return __assign.apply(this, arguments);
  20038. };
  20039. Object.defineProperty(exports, "__esModule", { value: true });
  20040. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  20041. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-bar/constants.ts");
  20042. var ACCEPTABLE_KEYS = new Set();
  20043. // IE11 has no support for new Set with iterable so we need to initialize this by hand
  20044. ACCEPTABLE_KEYS.add(constants_1.strings.ARROW_LEFT_KEY);
  20045. ACCEPTABLE_KEYS.add(constants_1.strings.ARROW_RIGHT_KEY);
  20046. ACCEPTABLE_KEYS.add(constants_1.strings.END_KEY);
  20047. ACCEPTABLE_KEYS.add(constants_1.strings.HOME_KEY);
  20048. ACCEPTABLE_KEYS.add(constants_1.strings.ENTER_KEY);
  20049. ACCEPTABLE_KEYS.add(constants_1.strings.SPACE_KEY);
  20050. var KEYCODE_MAP = new Map();
  20051. // IE11 has no support for new Map with iterable so we need to initialize this by hand
  20052. KEYCODE_MAP.set(constants_1.numbers.ARROW_LEFT_KEYCODE, constants_1.strings.ARROW_LEFT_KEY);
  20053. KEYCODE_MAP.set(constants_1.numbers.ARROW_RIGHT_KEYCODE, constants_1.strings.ARROW_RIGHT_KEY);
  20054. KEYCODE_MAP.set(constants_1.numbers.END_KEYCODE, constants_1.strings.END_KEY);
  20055. KEYCODE_MAP.set(constants_1.numbers.HOME_KEYCODE, constants_1.strings.HOME_KEY);
  20056. KEYCODE_MAP.set(constants_1.numbers.ENTER_KEYCODE, constants_1.strings.ENTER_KEY);
  20057. KEYCODE_MAP.set(constants_1.numbers.SPACE_KEYCODE, constants_1.strings.SPACE_KEY);
  20058. var MDCTabBarFoundation = /** @class */function (_super) {
  20059. __extends(MDCTabBarFoundation, _super);
  20060. function MDCTabBarFoundation(adapter) {
  20061. var _this = _super.call(this, __assign(__assign({}, MDCTabBarFoundation.defaultAdapter), adapter)) || this;
  20062. _this.useAutomaticActivation_ = false;
  20063. return _this;
  20064. }
  20065. Object.defineProperty(MDCTabBarFoundation, "strings", {
  20066. get: function get() {
  20067. return constants_1.strings;
  20068. },
  20069. enumerable: true,
  20070. configurable: true
  20071. });
  20072. Object.defineProperty(MDCTabBarFoundation, "numbers", {
  20073. get: function get() {
  20074. return constants_1.numbers;
  20075. },
  20076. enumerable: true,
  20077. configurable: true
  20078. });
  20079. Object.defineProperty(MDCTabBarFoundation, "defaultAdapter", {
  20080. get: function get() {
  20081. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  20082. return {
  20083. scrollTo: function scrollTo() {
  20084. return undefined;
  20085. },
  20086. incrementScroll: function incrementScroll() {
  20087. return undefined;
  20088. },
  20089. getScrollPosition: function getScrollPosition() {
  20090. return 0;
  20091. },
  20092. getScrollContentWidth: function getScrollContentWidth() {
  20093. return 0;
  20094. },
  20095. getOffsetWidth: function getOffsetWidth() {
  20096. return 0;
  20097. },
  20098. isRTL: function isRTL() {
  20099. return false;
  20100. },
  20101. setActiveTab: function setActiveTab() {
  20102. return undefined;
  20103. },
  20104. activateTabAtIndex: function activateTabAtIndex() {
  20105. return undefined;
  20106. },
  20107. deactivateTabAtIndex: function deactivateTabAtIndex() {
  20108. return undefined;
  20109. },
  20110. focusTabAtIndex: function focusTabAtIndex() {
  20111. return undefined;
  20112. },
  20113. getTabIndicatorClientRectAtIndex: function getTabIndicatorClientRectAtIndex() {
  20114. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  20115. },
  20116. getTabDimensionsAtIndex: function getTabDimensionsAtIndex() {
  20117. return { rootLeft: 0, rootRight: 0, contentLeft: 0, contentRight: 0 };
  20118. },
  20119. getPreviousActiveTabIndex: function getPreviousActiveTabIndex() {
  20120. return -1;
  20121. },
  20122. getFocusedTabIndex: function getFocusedTabIndex() {
  20123. return -1;
  20124. },
  20125. getIndexOfTabById: function getIndexOfTabById() {
  20126. return -1;
  20127. },
  20128. getTabListLength: function getTabListLength() {
  20129. return 0;
  20130. },
  20131. notifyTabActivated: function notifyTabActivated() {
  20132. return undefined;
  20133. }
  20134. };
  20135. // tslint:enable:object-literal-sort-keys
  20136. },
  20137. enumerable: true,
  20138. configurable: true
  20139. });
  20140. /**
  20141. * Switches between automatic and manual activation modes.
  20142. * See https://www.w3.org/TR/wai-aria-practices/#tabpanel for examples.
  20143. */
  20144. MDCTabBarFoundation.prototype.setUseAutomaticActivation = function (useAutomaticActivation) {
  20145. this.useAutomaticActivation_ = useAutomaticActivation;
  20146. };
  20147. MDCTabBarFoundation.prototype.activateTab = function (index) {
  20148. var previousActiveIndex = this.adapter.getPreviousActiveTabIndex();
  20149. if (!this.indexIsInRange_(index) || index === previousActiveIndex) {
  20150. return;
  20151. }
  20152. var previousClientRect;
  20153. if (previousActiveIndex !== -1) {
  20154. this.adapter.deactivateTabAtIndex(previousActiveIndex);
  20155. previousClientRect = this.adapter.getTabIndicatorClientRectAtIndex(previousActiveIndex);
  20156. }
  20157. this.adapter.activateTabAtIndex(index, previousClientRect);
  20158. this.scrollIntoView(index);
  20159. this.adapter.notifyTabActivated(index);
  20160. };
  20161. MDCTabBarFoundation.prototype.handleKeyDown = function (evt) {
  20162. // Get the key from the event
  20163. var key = this.getKeyFromEvent_(evt);
  20164. // Early exit if the event key isn't one of the keyboard navigation keys
  20165. if (key === undefined) {
  20166. return;
  20167. }
  20168. // Prevent default behavior for movement keys, but not for activation keys, since :active is used to apply ripple
  20169. if (!this.isActivationKey_(key)) {
  20170. evt.preventDefault();
  20171. }
  20172. if (this.useAutomaticActivation_) {
  20173. if (this.isActivationKey_(key)) {
  20174. return;
  20175. }
  20176. var index = this.determineTargetFromKey_(this.adapter.getPreviousActiveTabIndex(), key);
  20177. this.adapter.setActiveTab(index);
  20178. this.scrollIntoView(index);
  20179. } else {
  20180. var focusedTabIndex = this.adapter.getFocusedTabIndex();
  20181. if (this.isActivationKey_(key)) {
  20182. this.adapter.setActiveTab(focusedTabIndex);
  20183. } else {
  20184. var index = this.determineTargetFromKey_(focusedTabIndex, key);
  20185. this.adapter.focusTabAtIndex(index);
  20186. this.scrollIntoView(index);
  20187. }
  20188. }
  20189. };
  20190. /**
  20191. * Handles the MDCTab:interacted event
  20192. */
  20193. MDCTabBarFoundation.prototype.handleTabInteraction = function (evt) {
  20194. this.adapter.setActiveTab(this.adapter.getIndexOfTabById(evt.detail.tabId));
  20195. };
  20196. /**
  20197. * Scrolls the tab at the given index into view
  20198. * @param index The tab index to make visible
  20199. */
  20200. MDCTabBarFoundation.prototype.scrollIntoView = function (index) {
  20201. // Early exit if the index is out of range
  20202. if (!this.indexIsInRange_(index)) {
  20203. return;
  20204. }
  20205. // Always scroll to 0 if scrolling to the 0th index
  20206. if (index === 0) {
  20207. return this.adapter.scrollTo(0);
  20208. }
  20209. // Always scroll to the max value if scrolling to the Nth index
  20210. // MDCTabScroller.scrollTo() will never scroll past the max possible value
  20211. if (index === this.adapter.getTabListLength() - 1) {
  20212. return this.adapter.scrollTo(this.adapter.getScrollContentWidth());
  20213. }
  20214. if (this.isRTL_()) {
  20215. return this.scrollIntoViewRTL_(index);
  20216. }
  20217. this.scrollIntoView_(index);
  20218. };
  20219. /**
  20220. * Private method for determining the index of the destination tab based on what key was pressed
  20221. * @param origin The original index from which to determine the destination
  20222. * @param key The name of the key
  20223. */
  20224. MDCTabBarFoundation.prototype.determineTargetFromKey_ = function (origin, key) {
  20225. var isRTL = this.isRTL_();
  20226. var maxIndex = this.adapter.getTabListLength() - 1;
  20227. var shouldGoToEnd = key === constants_1.strings.END_KEY;
  20228. var shouldDecrement = key === constants_1.strings.ARROW_LEFT_KEY && !isRTL || key === constants_1.strings.ARROW_RIGHT_KEY && isRTL;
  20229. var shouldIncrement = key === constants_1.strings.ARROW_RIGHT_KEY && !isRTL || key === constants_1.strings.ARROW_LEFT_KEY && isRTL;
  20230. var index = origin;
  20231. if (shouldGoToEnd) {
  20232. index = maxIndex;
  20233. } else if (shouldDecrement) {
  20234. index -= 1;
  20235. } else if (shouldIncrement) {
  20236. index += 1;
  20237. } else {
  20238. index = 0;
  20239. }
  20240. if (index < 0) {
  20241. index = maxIndex;
  20242. } else if (index > maxIndex) {
  20243. index = 0;
  20244. }
  20245. return index;
  20246. };
  20247. /**
  20248. * Calculates the scroll increment that will make the tab at the given index visible
  20249. * @param index The index of the tab
  20250. * @param nextIndex The index of the next tab
  20251. * @param scrollPosition The current scroll position
  20252. * @param barWidth The width of the Tab Bar
  20253. */
  20254. MDCTabBarFoundation.prototype.calculateScrollIncrement_ = function (index, nextIndex, scrollPosition, barWidth) {
  20255. var nextTabDimensions = this.adapter.getTabDimensionsAtIndex(nextIndex);
  20256. var relativeContentLeft = nextTabDimensions.contentLeft - scrollPosition - barWidth;
  20257. var relativeContentRight = nextTabDimensions.contentRight - scrollPosition;
  20258. var leftIncrement = relativeContentRight - constants_1.numbers.EXTRA_SCROLL_AMOUNT;
  20259. var rightIncrement = relativeContentLeft + constants_1.numbers.EXTRA_SCROLL_AMOUNT;
  20260. if (nextIndex < index) {
  20261. return Math.min(leftIncrement, 0);
  20262. }
  20263. return Math.max(rightIncrement, 0);
  20264. };
  20265. /**
  20266. * Calculates the scroll increment that will make the tab at the given index visible in RTL
  20267. * @param index The index of the tab
  20268. * @param nextIndex The index of the next tab
  20269. * @param scrollPosition The current scroll position
  20270. * @param barWidth The width of the Tab Bar
  20271. * @param scrollContentWidth The width of the scroll content
  20272. */
  20273. MDCTabBarFoundation.prototype.calculateScrollIncrementRTL_ = function (index, nextIndex, scrollPosition, barWidth, scrollContentWidth) {
  20274. var nextTabDimensions = this.adapter.getTabDimensionsAtIndex(nextIndex);
  20275. var relativeContentLeft = scrollContentWidth - nextTabDimensions.contentLeft - scrollPosition;
  20276. var relativeContentRight = scrollContentWidth - nextTabDimensions.contentRight - scrollPosition - barWidth;
  20277. var leftIncrement = relativeContentRight + constants_1.numbers.EXTRA_SCROLL_AMOUNT;
  20278. var rightIncrement = relativeContentLeft - constants_1.numbers.EXTRA_SCROLL_AMOUNT;
  20279. if (nextIndex > index) {
  20280. return Math.max(leftIncrement, 0);
  20281. }
  20282. return Math.min(rightIncrement, 0);
  20283. };
  20284. /**
  20285. * Determines the index of the adjacent tab closest to either edge of the Tab Bar
  20286. * @param index The index of the tab
  20287. * @param tabDimensions The dimensions of the tab
  20288. * @param scrollPosition The current scroll position
  20289. * @param barWidth The width of the tab bar
  20290. */
  20291. MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdge_ = function (index, tabDimensions, scrollPosition, barWidth) {
  20292. /**
  20293. * Tabs are laid out in the Tab Scroller like this:
  20294. *
  20295. * Scroll Position
  20296. * +---+
  20297. * | | Bar Width
  20298. * | +-----------------------------------+
  20299. * | | |
  20300. * | V V
  20301. * | +-----------------------------------+
  20302. * V | Tab Scroller |
  20303. * +------------+--------------+-------------------+
  20304. * | Tab | Tab | Tab |
  20305. * +------------+--------------+-------------------+
  20306. * | |
  20307. * +-----------------------------------+
  20308. *
  20309. * To determine the next adjacent index, we look at the Tab root left and
  20310. * Tab root right, both relative to the scroll position. If the Tab root
  20311. * left is less than 0, then we know it's out of view to the left. If the
  20312. * Tab root right minus the bar width is greater than 0, we know the Tab is
  20313. * out of view to the right. From there, we either increment or decrement
  20314. * the index.
  20315. */
  20316. var relativeRootLeft = tabDimensions.rootLeft - scrollPosition;
  20317. var relativeRootRight = tabDimensions.rootRight - scrollPosition - barWidth;
  20318. var relativeRootDelta = relativeRootLeft + relativeRootRight;
  20319. var leftEdgeIsCloser = relativeRootLeft < 0 || relativeRootDelta < 0;
  20320. var rightEdgeIsCloser = relativeRootRight > 0 || relativeRootDelta > 0;
  20321. if (leftEdgeIsCloser) {
  20322. return index - 1;
  20323. }
  20324. if (rightEdgeIsCloser) {
  20325. return index + 1;
  20326. }
  20327. return -1;
  20328. };
  20329. /**
  20330. * Determines the index of the adjacent tab closest to either edge of the Tab Bar in RTL
  20331. * @param index The index of the tab
  20332. * @param tabDimensions The dimensions of the tab
  20333. * @param scrollPosition The current scroll position
  20334. * @param barWidth The width of the tab bar
  20335. * @param scrollContentWidth The width of the scroller content
  20336. */
  20337. MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdgeRTL_ = function (index, tabDimensions, scrollPosition, barWidth, scrollContentWidth) {
  20338. var rootLeft = scrollContentWidth - tabDimensions.rootLeft - barWidth - scrollPosition;
  20339. var rootRight = scrollContentWidth - tabDimensions.rootRight - scrollPosition;
  20340. var rootDelta = rootLeft + rootRight;
  20341. var leftEdgeIsCloser = rootLeft > 0 || rootDelta > 0;
  20342. var rightEdgeIsCloser = rootRight < 0 || rootDelta < 0;
  20343. if (leftEdgeIsCloser) {
  20344. return index + 1;
  20345. }
  20346. if (rightEdgeIsCloser) {
  20347. return index - 1;
  20348. }
  20349. return -1;
  20350. };
  20351. /**
  20352. * Returns the key associated with a keydown event
  20353. * @param evt The keydown event
  20354. */
  20355. MDCTabBarFoundation.prototype.getKeyFromEvent_ = function (evt) {
  20356. if (ACCEPTABLE_KEYS.has(evt.key)) {
  20357. return evt.key;
  20358. }
  20359. return KEYCODE_MAP.get(evt.keyCode);
  20360. };
  20361. MDCTabBarFoundation.prototype.isActivationKey_ = function (key) {
  20362. return key === constants_1.strings.SPACE_KEY || key === constants_1.strings.ENTER_KEY;
  20363. };
  20364. /**
  20365. * Returns whether a given index is inclusively between the ends
  20366. * @param index The index to test
  20367. */
  20368. MDCTabBarFoundation.prototype.indexIsInRange_ = function (index) {
  20369. return index >= 0 && index < this.adapter.getTabListLength();
  20370. };
  20371. /**
  20372. * Returns the view's RTL property
  20373. */
  20374. MDCTabBarFoundation.prototype.isRTL_ = function () {
  20375. return this.adapter.isRTL();
  20376. };
  20377. /**
  20378. * Scrolls the tab at the given index into view for left-to-right user agents.
  20379. * @param index The index of the tab to scroll into view
  20380. */
  20381. MDCTabBarFoundation.prototype.scrollIntoView_ = function (index) {
  20382. var scrollPosition = this.adapter.getScrollPosition();
  20383. var barWidth = this.adapter.getOffsetWidth();
  20384. var tabDimensions = this.adapter.getTabDimensionsAtIndex(index);
  20385. var nextIndex = this.findAdjacentTabIndexClosestToEdge_(index, tabDimensions, scrollPosition, barWidth);
  20386. if (!this.indexIsInRange_(nextIndex)) {
  20387. return;
  20388. }
  20389. var scrollIncrement = this.calculateScrollIncrement_(index, nextIndex, scrollPosition, barWidth);
  20390. this.adapter.incrementScroll(scrollIncrement);
  20391. };
  20392. /**
  20393. * Scrolls the tab at the given index into view in RTL
  20394. * @param index The tab index to make visible
  20395. */
  20396. MDCTabBarFoundation.prototype.scrollIntoViewRTL_ = function (index) {
  20397. var scrollPosition = this.adapter.getScrollPosition();
  20398. var barWidth = this.adapter.getOffsetWidth();
  20399. var tabDimensions = this.adapter.getTabDimensionsAtIndex(index);
  20400. var scrollWidth = this.adapter.getScrollContentWidth();
  20401. var nextIndex = this.findAdjacentTabIndexClosestToEdgeRTL_(index, tabDimensions, scrollPosition, barWidth, scrollWidth);
  20402. if (!this.indexIsInRange_(nextIndex)) {
  20403. return;
  20404. }
  20405. var scrollIncrement = this.calculateScrollIncrementRTL_(index, nextIndex, scrollPosition, barWidth, scrollWidth);
  20406. this.adapter.incrementScroll(scrollIncrement);
  20407. };
  20408. return MDCTabBarFoundation;
  20409. }(foundation_1.MDCFoundation);
  20410. exports.MDCTabBarFoundation = MDCTabBarFoundation;
  20411. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  20412. exports.default = MDCTabBarFoundation;
  20413. /***/ }),
  20414. /***/ "./packages/mdc-tab-bar/index.ts":
  20415. /*!***************************************!*\
  20416. !*** ./packages/mdc-tab-bar/index.ts ***!
  20417. \***************************************/
  20418. /*! no static exports found */
  20419. /***/ (function(module, exports, __webpack_require__) {
  20420. "use strict";
  20421. /**
  20422. * @license
  20423. * Copyright 2019 Google Inc.
  20424. *
  20425. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20426. * of this software and associated documentation files (the "Software"), to deal
  20427. * in the Software without restriction, including without limitation the rights
  20428. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20429. * copies of the Software, and to permit persons to whom the Software is
  20430. * furnished to do so, subject to the following conditions:
  20431. *
  20432. * The above copyright notice and this permission notice shall be included in
  20433. * all copies or substantial portions of the Software.
  20434. *
  20435. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20436. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20437. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20438. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20439. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20440. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20441. * THE SOFTWARE.
  20442. */
  20443. function __export(m) {
  20444. for (var p in m) {
  20445. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  20446. }
  20447. }
  20448. Object.defineProperty(exports, "__esModule", { value: true });
  20449. __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab-bar/component.ts"));
  20450. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-bar/constants.ts"));
  20451. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-bar/foundation.ts"));
  20452. /***/ }),
  20453. /***/ "./packages/mdc-tab-indicator/component.ts":
  20454. /*!*************************************************!*\
  20455. !*** ./packages/mdc-tab-indicator/component.ts ***!
  20456. \*************************************************/
  20457. /*! no static exports found */
  20458. /***/ (function(module, exports, __webpack_require__) {
  20459. "use strict";
  20460. /**
  20461. * @license
  20462. * Copyright 2018 Google Inc.
  20463. *
  20464. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20465. * of this software and associated documentation files (the "Software"), to deal
  20466. * in the Software without restriction, including without limitation the rights
  20467. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20468. * copies of the Software, and to permit persons to whom the Software is
  20469. * furnished to do so, subject to the following conditions:
  20470. *
  20471. * The above copyright notice and this permission notice shall be included in
  20472. * all copies or substantial portions of the Software.
  20473. *
  20474. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20475. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20476. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20477. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20478. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20479. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20480. * THE SOFTWARE.
  20481. */
  20482. var __extends = this && this.__extends || function () {
  20483. var _extendStatics = function extendStatics(d, b) {
  20484. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20485. d.__proto__ = b;
  20486. } || function (d, b) {
  20487. for (var p in b) {
  20488. if (b.hasOwnProperty(p)) d[p] = b[p];
  20489. }
  20490. };
  20491. return _extendStatics(d, b);
  20492. };
  20493. return function (d, b) {
  20494. _extendStatics(d, b);
  20495. function __() {
  20496. this.constructor = d;
  20497. }
  20498. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20499. };
  20500. }();
  20501. Object.defineProperty(exports, "__esModule", { value: true });
  20502. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  20503. var fading_foundation_1 = __webpack_require__(/*! ./fading-foundation */ "./packages/mdc-tab-indicator/fading-foundation.ts");
  20504. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
  20505. var sliding_foundation_1 = __webpack_require__(/*! ./sliding-foundation */ "./packages/mdc-tab-indicator/sliding-foundation.ts");
  20506. var MDCTabIndicator = /** @class */function (_super) {
  20507. __extends(MDCTabIndicator, _super);
  20508. function MDCTabIndicator() {
  20509. return _super !== null && _super.apply(this, arguments) || this;
  20510. }
  20511. MDCTabIndicator.attachTo = function (root) {
  20512. return new MDCTabIndicator(root);
  20513. };
  20514. MDCTabIndicator.prototype.initialize = function () {
  20515. this.content_ = this.root.querySelector(foundation_1.MDCTabIndicatorFoundation.strings.CONTENT_SELECTOR);
  20516. };
  20517. MDCTabIndicator.prototype.computeContentClientRect = function () {
  20518. return this.foundation.computeContentClientRect();
  20519. };
  20520. MDCTabIndicator.prototype.getDefaultFoundation = function () {
  20521. var _this = this;
  20522. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  20523. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  20524. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  20525. var adapter = {
  20526. addClass: function addClass(className) {
  20527. return _this.root.classList.add(className);
  20528. },
  20529. removeClass: function removeClass(className) {
  20530. return _this.root.classList.remove(className);
  20531. },
  20532. computeContentClientRect: function computeContentClientRect() {
  20533. return _this.content_.getBoundingClientRect();
  20534. },
  20535. setContentStyleProperty: function setContentStyleProperty(prop, value) {
  20536. return _this.content_.style.setProperty(prop, value);
  20537. }
  20538. };
  20539. // tslint:enable:object-literal-sort-keys
  20540. if (this.root.classList.contains(foundation_1.MDCTabIndicatorFoundation.cssClasses.FADE)) {
  20541. return new fading_foundation_1.MDCFadingTabIndicatorFoundation(adapter);
  20542. }
  20543. // Default to the sliding indicator
  20544. return new sliding_foundation_1.MDCSlidingTabIndicatorFoundation(adapter);
  20545. };
  20546. MDCTabIndicator.prototype.activate = function (previousIndicatorClientRect) {
  20547. this.foundation.activate(previousIndicatorClientRect);
  20548. };
  20549. MDCTabIndicator.prototype.deactivate = function () {
  20550. this.foundation.deactivate();
  20551. };
  20552. return MDCTabIndicator;
  20553. }(component_1.MDCComponent);
  20554. exports.MDCTabIndicator = MDCTabIndicator;
  20555. /***/ }),
  20556. /***/ "./packages/mdc-tab-indicator/constants.ts":
  20557. /*!*************************************************!*\
  20558. !*** ./packages/mdc-tab-indicator/constants.ts ***!
  20559. \*************************************************/
  20560. /*! no static exports found */
  20561. /***/ (function(module, exports, __webpack_require__) {
  20562. "use strict";
  20563. /**
  20564. * @license
  20565. * Copyright 2018 Google Inc.
  20566. *
  20567. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20568. * of this software and associated documentation files (the "Software"), to deal
  20569. * in the Software without restriction, including without limitation the rights
  20570. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20571. * copies of the Software, and to permit persons to whom the Software is
  20572. * furnished to do so, subject to the following conditions:
  20573. *
  20574. * The above copyright notice and this permission notice shall be included in
  20575. * all copies or substantial portions of the Software.
  20576. *
  20577. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20578. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20579. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20580. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20581. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20582. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20583. * THE SOFTWARE.
  20584. */
  20585. Object.defineProperty(exports, "__esModule", { value: true });
  20586. var cssClasses = {
  20587. ACTIVE: 'mdc-tab-indicator--active',
  20588. FADE: 'mdc-tab-indicator--fade',
  20589. NO_TRANSITION: 'mdc-tab-indicator--no-transition'
  20590. };
  20591. exports.cssClasses = cssClasses;
  20592. var strings = {
  20593. CONTENT_SELECTOR: '.mdc-tab-indicator__content'
  20594. };
  20595. exports.strings = strings;
  20596. /***/ }),
  20597. /***/ "./packages/mdc-tab-indicator/fading-foundation.ts":
  20598. /*!*********************************************************!*\
  20599. !*** ./packages/mdc-tab-indicator/fading-foundation.ts ***!
  20600. \*********************************************************/
  20601. /*! no static exports found */
  20602. /***/ (function(module, exports, __webpack_require__) {
  20603. "use strict";
  20604. /**
  20605. * @license
  20606. * Copyright 2018 Google Inc.
  20607. *
  20608. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20609. * of this software and associated documentation files (the "Software"), to deal
  20610. * in the Software without restriction, including without limitation the rights
  20611. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20612. * copies of the Software, and to permit persons to whom the Software is
  20613. * furnished to do so, subject to the following conditions:
  20614. *
  20615. * The above copyright notice and this permission notice shall be included in
  20616. * all copies or substantial portions of the Software.
  20617. *
  20618. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20619. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20620. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20621. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20622. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20623. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20624. * THE SOFTWARE.
  20625. */
  20626. var __extends = this && this.__extends || function () {
  20627. var _extendStatics = function extendStatics(d, b) {
  20628. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20629. d.__proto__ = b;
  20630. } || function (d, b) {
  20631. for (var p in b) {
  20632. if (b.hasOwnProperty(p)) d[p] = b[p];
  20633. }
  20634. };
  20635. return _extendStatics(d, b);
  20636. };
  20637. return function (d, b) {
  20638. _extendStatics(d, b);
  20639. function __() {
  20640. this.constructor = d;
  20641. }
  20642. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20643. };
  20644. }();
  20645. Object.defineProperty(exports, "__esModule", { value: true });
  20646. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
  20647. /* istanbul ignore next: subclass is not a branch statement */
  20648. var MDCFadingTabIndicatorFoundation = /** @class */function (_super) {
  20649. __extends(MDCFadingTabIndicatorFoundation, _super);
  20650. function MDCFadingTabIndicatorFoundation() {
  20651. return _super !== null && _super.apply(this, arguments) || this;
  20652. }
  20653. MDCFadingTabIndicatorFoundation.prototype.activate = function () {
  20654. this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
  20655. };
  20656. MDCFadingTabIndicatorFoundation.prototype.deactivate = function () {
  20657. this.adapter.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
  20658. };
  20659. return MDCFadingTabIndicatorFoundation;
  20660. }(foundation_1.MDCTabIndicatorFoundation);
  20661. exports.MDCFadingTabIndicatorFoundation = MDCFadingTabIndicatorFoundation;
  20662. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  20663. exports.default = MDCFadingTabIndicatorFoundation;
  20664. /***/ }),
  20665. /***/ "./packages/mdc-tab-indicator/foundation.ts":
  20666. /*!**************************************************!*\
  20667. !*** ./packages/mdc-tab-indicator/foundation.ts ***!
  20668. \**************************************************/
  20669. /*! no static exports found */
  20670. /***/ (function(module, exports, __webpack_require__) {
  20671. "use strict";
  20672. /**
  20673. * @license
  20674. * Copyright 2018 Google Inc.
  20675. *
  20676. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20677. * of this software and associated documentation files (the "Software"), to deal
  20678. * in the Software without restriction, including without limitation the rights
  20679. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20680. * copies of the Software, and to permit persons to whom the Software is
  20681. * furnished to do so, subject to the following conditions:
  20682. *
  20683. * The above copyright notice and this permission notice shall be included in
  20684. * all copies or substantial portions of the Software.
  20685. *
  20686. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20687. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20688. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20689. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20690. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20691. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20692. * THE SOFTWARE.
  20693. */
  20694. var __extends = this && this.__extends || function () {
  20695. var _extendStatics = function extendStatics(d, b) {
  20696. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20697. d.__proto__ = b;
  20698. } || function (d, b) {
  20699. for (var p in b) {
  20700. if (b.hasOwnProperty(p)) d[p] = b[p];
  20701. }
  20702. };
  20703. return _extendStatics(d, b);
  20704. };
  20705. return function (d, b) {
  20706. _extendStatics(d, b);
  20707. function __() {
  20708. this.constructor = d;
  20709. }
  20710. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20711. };
  20712. }();
  20713. var __assign = this && this.__assign || function () {
  20714. __assign = Object.assign || function (t) {
  20715. for (var s, i = 1, n = arguments.length; i < n; i++) {
  20716. s = arguments[i];
  20717. for (var p in s) {
  20718. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  20719. }
  20720. }
  20721. return t;
  20722. };
  20723. return __assign.apply(this, arguments);
  20724. };
  20725. Object.defineProperty(exports, "__esModule", { value: true });
  20726. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  20727. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-indicator/constants.ts");
  20728. var MDCTabIndicatorFoundation = /** @class */function (_super) {
  20729. __extends(MDCTabIndicatorFoundation, _super);
  20730. function MDCTabIndicatorFoundation(adapter) {
  20731. return _super.call(this, __assign(__assign({}, MDCTabIndicatorFoundation.defaultAdapter), adapter)) || this;
  20732. }
  20733. Object.defineProperty(MDCTabIndicatorFoundation, "cssClasses", {
  20734. get: function get() {
  20735. return constants_1.cssClasses;
  20736. },
  20737. enumerable: true,
  20738. configurable: true
  20739. });
  20740. Object.defineProperty(MDCTabIndicatorFoundation, "strings", {
  20741. get: function get() {
  20742. return constants_1.strings;
  20743. },
  20744. enumerable: true,
  20745. configurable: true
  20746. });
  20747. Object.defineProperty(MDCTabIndicatorFoundation, "defaultAdapter", {
  20748. get: function get() {
  20749. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  20750. return {
  20751. addClass: function addClass() {
  20752. return undefined;
  20753. },
  20754. removeClass: function removeClass() {
  20755. return undefined;
  20756. },
  20757. computeContentClientRect: function computeContentClientRect() {
  20758. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  20759. },
  20760. setContentStyleProperty: function setContentStyleProperty() {
  20761. return undefined;
  20762. }
  20763. };
  20764. // tslint:enable:object-literal-sort-keys
  20765. },
  20766. enumerable: true,
  20767. configurable: true
  20768. });
  20769. MDCTabIndicatorFoundation.prototype.computeContentClientRect = function () {
  20770. return this.adapter.computeContentClientRect();
  20771. };
  20772. return MDCTabIndicatorFoundation;
  20773. }(foundation_1.MDCFoundation);
  20774. exports.MDCTabIndicatorFoundation = MDCTabIndicatorFoundation;
  20775. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  20776. exports.default = MDCTabIndicatorFoundation;
  20777. /***/ }),
  20778. /***/ "./packages/mdc-tab-indicator/index.ts":
  20779. /*!*********************************************!*\
  20780. !*** ./packages/mdc-tab-indicator/index.ts ***!
  20781. \*********************************************/
  20782. /*! no static exports found */
  20783. /***/ (function(module, exports, __webpack_require__) {
  20784. "use strict";
  20785. /**
  20786. * @license
  20787. * Copyright 2019 Google Inc.
  20788. *
  20789. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20790. * of this software and associated documentation files (the "Software"), to deal
  20791. * in the Software without restriction, including without limitation the rights
  20792. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20793. * copies of the Software, and to permit persons to whom the Software is
  20794. * furnished to do so, subject to the following conditions:
  20795. *
  20796. * The above copyright notice and this permission notice shall be included in
  20797. * all copies or substantial portions of the Software.
  20798. *
  20799. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20800. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20801. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20802. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20803. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20804. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20805. * THE SOFTWARE.
  20806. */
  20807. function __export(m) {
  20808. for (var p in m) {
  20809. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  20810. }
  20811. }
  20812. Object.defineProperty(exports, "__esModule", { value: true });
  20813. __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab-indicator/component.ts"));
  20814. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-indicator/constants.ts"));
  20815. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts"));
  20816. __export(__webpack_require__(/*! ./fading-foundation */ "./packages/mdc-tab-indicator/fading-foundation.ts"));
  20817. __export(__webpack_require__(/*! ./sliding-foundation */ "./packages/mdc-tab-indicator/sliding-foundation.ts"));
  20818. /***/ }),
  20819. /***/ "./packages/mdc-tab-indicator/sliding-foundation.ts":
  20820. /*!**********************************************************!*\
  20821. !*** ./packages/mdc-tab-indicator/sliding-foundation.ts ***!
  20822. \**********************************************************/
  20823. /*! no static exports found */
  20824. /***/ (function(module, exports, __webpack_require__) {
  20825. "use strict";
  20826. /**
  20827. * @license
  20828. * Copyright 2018 Google Inc.
  20829. *
  20830. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20831. * of this software and associated documentation files (the "Software"), to deal
  20832. * in the Software without restriction, including without limitation the rights
  20833. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20834. * copies of the Software, and to permit persons to whom the Software is
  20835. * furnished to do so, subject to the following conditions:
  20836. *
  20837. * The above copyright notice and this permission notice shall be included in
  20838. * all copies or substantial portions of the Software.
  20839. *
  20840. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20841. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20842. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20843. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20844. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20845. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20846. * THE SOFTWARE.
  20847. */
  20848. var __extends = this && this.__extends || function () {
  20849. var _extendStatics = function extendStatics(d, b) {
  20850. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20851. d.__proto__ = b;
  20852. } || function (d, b) {
  20853. for (var p in b) {
  20854. if (b.hasOwnProperty(p)) d[p] = b[p];
  20855. }
  20856. };
  20857. return _extendStatics(d, b);
  20858. };
  20859. return function (d, b) {
  20860. _extendStatics(d, b);
  20861. function __() {
  20862. this.constructor = d;
  20863. }
  20864. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20865. };
  20866. }();
  20867. Object.defineProperty(exports, "__esModule", { value: true });
  20868. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
  20869. /* istanbul ignore next: subclass is not a branch statement */
  20870. var MDCSlidingTabIndicatorFoundation = /** @class */function (_super) {
  20871. __extends(MDCSlidingTabIndicatorFoundation, _super);
  20872. function MDCSlidingTabIndicatorFoundation() {
  20873. return _super !== null && _super.apply(this, arguments) || this;
  20874. }
  20875. MDCSlidingTabIndicatorFoundation.prototype.activate = function (previousIndicatorClientRect) {
  20876. // Early exit if no indicator is present to handle cases where an indicator
  20877. // may be activated without a prior indicator state
  20878. if (!previousIndicatorClientRect) {
  20879. this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
  20880. return;
  20881. }
  20882. // This animation uses the FLIP approach. You can read more about it at the link below:
  20883. // https://aerotwist.com/blog/flip-your-animations/
  20884. // Calculate the dimensions based on the dimensions of the previous indicator
  20885. var currentClientRect = this.computeContentClientRect();
  20886. var widthDelta = previousIndicatorClientRect.width / currentClientRect.width;
  20887. var xPosition = previousIndicatorClientRect.left - currentClientRect.left;
  20888. this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION);
  20889. this.adapter.setContentStyleProperty('transform', "translateX(" + xPosition + "px) scaleX(" + widthDelta + ")");
  20890. // Force repaint before updating classes and transform to ensure the transform properly takes effect
  20891. this.computeContentClientRect();
  20892. this.adapter.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION);
  20893. this.adapter.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
  20894. this.adapter.setContentStyleProperty('transform', '');
  20895. };
  20896. MDCSlidingTabIndicatorFoundation.prototype.deactivate = function () {
  20897. this.adapter.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
  20898. };
  20899. return MDCSlidingTabIndicatorFoundation;
  20900. }(foundation_1.MDCTabIndicatorFoundation);
  20901. exports.MDCSlidingTabIndicatorFoundation = MDCSlidingTabIndicatorFoundation;
  20902. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  20903. exports.default = MDCSlidingTabIndicatorFoundation;
  20904. /***/ }),
  20905. /***/ "./packages/mdc-tab-scroller/component.ts":
  20906. /*!************************************************!*\
  20907. !*** ./packages/mdc-tab-scroller/component.ts ***!
  20908. \************************************************/
  20909. /*! no static exports found */
  20910. /***/ (function(module, exports, __webpack_require__) {
  20911. "use strict";
  20912. /**
  20913. * @license
  20914. * Copyright 2018 Google Inc.
  20915. *
  20916. * Permission is hereby granted, free of charge, to any person obtaining a copy
  20917. * of this software and associated documentation files (the "Software"), to deal
  20918. * in the Software without restriction, including without limitation the rights
  20919. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  20920. * copies of the Software, and to permit persons to whom the Software is
  20921. * furnished to do so, subject to the following conditions:
  20922. *
  20923. * The above copyright notice and this permission notice shall be included in
  20924. * all copies or substantial portions of the Software.
  20925. *
  20926. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20927. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20928. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20929. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20930. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20931. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20932. * THE SOFTWARE.
  20933. */
  20934. var __extends = this && this.__extends || function () {
  20935. var _extendStatics = function extendStatics(d, b) {
  20936. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  20937. d.__proto__ = b;
  20938. } || function (d, b) {
  20939. for (var p in b) {
  20940. if (b.hasOwnProperty(p)) d[p] = b[p];
  20941. }
  20942. };
  20943. return _extendStatics(d, b);
  20944. };
  20945. return function (d, b) {
  20946. _extendStatics(d, b);
  20947. function __() {
  20948. this.constructor = d;
  20949. }
  20950. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  20951. };
  20952. }();
  20953. var __importStar = this && this.__importStar || function (mod) {
  20954. if (mod && mod.__esModule) return mod;
  20955. var result = {};
  20956. if (mod != null) for (var k in mod) {
  20957. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  20958. }result["default"] = mod;
  20959. return result;
  20960. };
  20961. Object.defineProperty(exports, "__esModule", { value: true });
  20962. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  20963. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  20964. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  20965. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-scroller/foundation.ts");
  20966. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-tab-scroller/util.ts"));
  20967. var MDCTabScroller = /** @class */function (_super) {
  20968. __extends(MDCTabScroller, _super);
  20969. function MDCTabScroller() {
  20970. return _super !== null && _super.apply(this, arguments) || this;
  20971. }
  20972. MDCTabScroller.attachTo = function (root) {
  20973. return new MDCTabScroller(root);
  20974. };
  20975. MDCTabScroller.prototype.initialize = function () {
  20976. this.area_ = this.root.querySelector(foundation_1.MDCTabScrollerFoundation.strings.AREA_SELECTOR);
  20977. this.content_ = this.root.querySelector(foundation_1.MDCTabScrollerFoundation.strings.CONTENT_SELECTOR);
  20978. };
  20979. MDCTabScroller.prototype.initialSyncWithDOM = function () {
  20980. var _this = this;
  20981. this.handleInteraction_ = function () {
  20982. return _this.foundation.handleInteraction();
  20983. };
  20984. this.handleTransitionEnd_ = function (evt) {
  20985. return _this.foundation.handleTransitionEnd(evt);
  20986. };
  20987. this.area_.addEventListener('wheel', this.handleInteraction_, events_1.applyPassive());
  20988. this.area_.addEventListener('touchstart', this.handleInteraction_, events_1.applyPassive());
  20989. this.area_.addEventListener('pointerdown', this.handleInteraction_, events_1.applyPassive());
  20990. this.area_.addEventListener('mousedown', this.handleInteraction_, events_1.applyPassive());
  20991. this.area_.addEventListener('keydown', this.handleInteraction_, events_1.applyPassive());
  20992. this.content_.addEventListener('transitionend', this.handleTransitionEnd_);
  20993. };
  20994. MDCTabScroller.prototype.destroy = function () {
  20995. _super.prototype.destroy.call(this);
  20996. this.area_.removeEventListener('wheel', this.handleInteraction_, events_1.applyPassive());
  20997. this.area_.removeEventListener('touchstart', this.handleInteraction_, events_1.applyPassive());
  20998. this.area_.removeEventListener('pointerdown', this.handleInteraction_, events_1.applyPassive());
  20999. this.area_.removeEventListener('mousedown', this.handleInteraction_, events_1.applyPassive());
  21000. this.area_.removeEventListener('keydown', this.handleInteraction_, events_1.applyPassive());
  21001. this.content_.removeEventListener('transitionend', this.handleTransitionEnd_);
  21002. };
  21003. MDCTabScroller.prototype.getDefaultFoundation = function () {
  21004. var _this = this;
  21005. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  21006. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  21007. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  21008. var adapter = {
  21009. eventTargetMatchesSelector: function eventTargetMatchesSelector(evtTarget, selector) {
  21010. return ponyfill_1.matches(evtTarget, selector);
  21011. },
  21012. addClass: function addClass(className) {
  21013. return _this.root.classList.add(className);
  21014. },
  21015. removeClass: function removeClass(className) {
  21016. return _this.root.classList.remove(className);
  21017. },
  21018. addScrollAreaClass: function addScrollAreaClass(className) {
  21019. return _this.area_.classList.add(className);
  21020. },
  21021. setScrollAreaStyleProperty: function setScrollAreaStyleProperty(prop, value) {
  21022. return _this.area_.style.setProperty(prop, value);
  21023. },
  21024. setScrollContentStyleProperty: function setScrollContentStyleProperty(prop, value) {
  21025. return _this.content_.style.setProperty(prop, value);
  21026. },
  21027. getScrollContentStyleValue: function getScrollContentStyleValue(propName) {
  21028. return window.getComputedStyle(_this.content_).getPropertyValue(propName);
  21029. },
  21030. setScrollAreaScrollLeft: function setScrollAreaScrollLeft(scrollX) {
  21031. return _this.area_.scrollLeft = scrollX;
  21032. },
  21033. getScrollAreaScrollLeft: function getScrollAreaScrollLeft() {
  21034. return _this.area_.scrollLeft;
  21035. },
  21036. getScrollContentOffsetWidth: function getScrollContentOffsetWidth() {
  21037. return _this.content_.offsetWidth;
  21038. },
  21039. getScrollAreaOffsetWidth: function getScrollAreaOffsetWidth() {
  21040. return _this.area_.offsetWidth;
  21041. },
  21042. computeScrollAreaClientRect: function computeScrollAreaClientRect() {
  21043. return _this.area_.getBoundingClientRect();
  21044. },
  21045. computeScrollContentClientRect: function computeScrollContentClientRect() {
  21046. return _this.content_.getBoundingClientRect();
  21047. },
  21048. computeHorizontalScrollbarHeight: function computeHorizontalScrollbarHeight() {
  21049. return util.computeHorizontalScrollbarHeight(document);
  21050. }
  21051. };
  21052. // tslint:enable:object-literal-sort-keys
  21053. return new foundation_1.MDCTabScrollerFoundation(adapter);
  21054. };
  21055. /**
  21056. * Returns the current visual scroll position
  21057. */
  21058. MDCTabScroller.prototype.getScrollPosition = function () {
  21059. return this.foundation.getScrollPosition();
  21060. };
  21061. /**
  21062. * Returns the width of the scroll content
  21063. */
  21064. MDCTabScroller.prototype.getScrollContentWidth = function () {
  21065. return this.content_.offsetWidth;
  21066. };
  21067. /**
  21068. * Increments the scroll value by the given amount
  21069. * @param scrollXIncrement The pixel value by which to increment the scroll value
  21070. */
  21071. MDCTabScroller.prototype.incrementScroll = function (scrollXIncrement) {
  21072. this.foundation.incrementScroll(scrollXIncrement);
  21073. };
  21074. /**
  21075. * Scrolls to the given pixel position
  21076. * @param scrollX The pixel value to scroll to
  21077. */
  21078. MDCTabScroller.prototype.scrollTo = function (scrollX) {
  21079. this.foundation.scrollTo(scrollX);
  21080. };
  21081. return MDCTabScroller;
  21082. }(component_1.MDCComponent);
  21083. exports.MDCTabScroller = MDCTabScroller;
  21084. /***/ }),
  21085. /***/ "./packages/mdc-tab-scroller/constants.ts":
  21086. /*!************************************************!*\
  21087. !*** ./packages/mdc-tab-scroller/constants.ts ***!
  21088. \************************************************/
  21089. /*! no static exports found */
  21090. /***/ (function(module, exports, __webpack_require__) {
  21091. "use strict";
  21092. /**
  21093. * @license
  21094. * Copyright 2018 Google Inc.
  21095. *
  21096. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21097. * of this software and associated documentation files (the "Software"), to deal
  21098. * in the Software without restriction, including without limitation the rights
  21099. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21100. * copies of the Software, and to permit persons to whom the Software is
  21101. * furnished to do so, subject to the following conditions:
  21102. *
  21103. * The above copyright notice and this permission notice shall be included in
  21104. * all copies or substantial portions of the Software.
  21105. *
  21106. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21107. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21108. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21109. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21110. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21111. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21112. * THE SOFTWARE.
  21113. */
  21114. Object.defineProperty(exports, "__esModule", { value: true });
  21115. var cssClasses = {
  21116. ANIMATING: 'mdc-tab-scroller--animating',
  21117. SCROLL_AREA_SCROLL: 'mdc-tab-scroller__scroll-area--scroll',
  21118. SCROLL_TEST: 'mdc-tab-scroller__test'
  21119. };
  21120. exports.cssClasses = cssClasses;
  21121. var strings = {
  21122. AREA_SELECTOR: '.mdc-tab-scroller__scroll-area',
  21123. CONTENT_SELECTOR: '.mdc-tab-scroller__scroll-content'
  21124. };
  21125. exports.strings = strings;
  21126. /***/ }),
  21127. /***/ "./packages/mdc-tab-scroller/foundation.ts":
  21128. /*!*************************************************!*\
  21129. !*** ./packages/mdc-tab-scroller/foundation.ts ***!
  21130. \*************************************************/
  21131. /*! no static exports found */
  21132. /***/ (function(module, exports, __webpack_require__) {
  21133. "use strict";
  21134. /**
  21135. * @license
  21136. * Copyright 2018 Google Inc.
  21137. *
  21138. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21139. * of this software and associated documentation files (the "Software"), to deal
  21140. * in the Software without restriction, including without limitation the rights
  21141. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21142. * copies of the Software, and to permit persons to whom the Software is
  21143. * furnished to do so, subject to the following conditions:
  21144. *
  21145. * The above copyright notice and this permission notice shall be included in
  21146. * all copies or substantial portions of the Software.
  21147. *
  21148. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21149. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21150. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21151. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21152. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21153. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21154. * THE SOFTWARE.
  21155. */
  21156. var __extends = this && this.__extends || function () {
  21157. var _extendStatics = function extendStatics(d, b) {
  21158. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  21159. d.__proto__ = b;
  21160. } || function (d, b) {
  21161. for (var p in b) {
  21162. if (b.hasOwnProperty(p)) d[p] = b[p];
  21163. }
  21164. };
  21165. return _extendStatics(d, b);
  21166. };
  21167. return function (d, b) {
  21168. _extendStatics(d, b);
  21169. function __() {
  21170. this.constructor = d;
  21171. }
  21172. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21173. };
  21174. }();
  21175. var __assign = this && this.__assign || function () {
  21176. __assign = Object.assign || function (t) {
  21177. for (var s, i = 1, n = arguments.length; i < n; i++) {
  21178. s = arguments[i];
  21179. for (var p in s) {
  21180. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  21181. }
  21182. }
  21183. return t;
  21184. };
  21185. return __assign.apply(this, arguments);
  21186. };
  21187. var __read = this && this.__read || function (o, n) {
  21188. var m = typeof Symbol === "function" && o[Symbol.iterator];
  21189. if (!m) return o;
  21190. var i = m.call(o),
  21191. r,
  21192. ar = [],
  21193. e;
  21194. try {
  21195. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  21196. ar.push(r.value);
  21197. }
  21198. } catch (error) {
  21199. e = { error: error };
  21200. } finally {
  21201. try {
  21202. if (r && !r.done && (m = i["return"])) m.call(i);
  21203. } finally {
  21204. if (e) throw e.error;
  21205. }
  21206. }
  21207. return ar;
  21208. };
  21209. Object.defineProperty(exports, "__esModule", { value: true });
  21210. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  21211. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts");
  21212. var rtl_default_scroller_1 = __webpack_require__(/*! ./rtl-default-scroller */ "./packages/mdc-tab-scroller/rtl-default-scroller.ts");
  21213. var rtl_negative_scroller_1 = __webpack_require__(/*! ./rtl-negative-scroller */ "./packages/mdc-tab-scroller/rtl-negative-scroller.ts");
  21214. var rtl_reverse_scroller_1 = __webpack_require__(/*! ./rtl-reverse-scroller */ "./packages/mdc-tab-scroller/rtl-reverse-scroller.ts");
  21215. var MDCTabScrollerFoundation = /** @class */function (_super) {
  21216. __extends(MDCTabScrollerFoundation, _super);
  21217. function MDCTabScrollerFoundation(adapter) {
  21218. var _this = _super.call(this, __assign(__assign({}, MDCTabScrollerFoundation.defaultAdapter), adapter)) || this;
  21219. /**
  21220. * Controls whether we should handle the transitionend and interaction events during the animation.
  21221. */
  21222. _this.isAnimating_ = false;
  21223. return _this;
  21224. }
  21225. Object.defineProperty(MDCTabScrollerFoundation, "cssClasses", {
  21226. get: function get() {
  21227. return constants_1.cssClasses;
  21228. },
  21229. enumerable: true,
  21230. configurable: true
  21231. });
  21232. Object.defineProperty(MDCTabScrollerFoundation, "strings", {
  21233. get: function get() {
  21234. return constants_1.strings;
  21235. },
  21236. enumerable: true,
  21237. configurable: true
  21238. });
  21239. Object.defineProperty(MDCTabScrollerFoundation, "defaultAdapter", {
  21240. get: function get() {
  21241. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  21242. return {
  21243. eventTargetMatchesSelector: function eventTargetMatchesSelector() {
  21244. return false;
  21245. },
  21246. addClass: function addClass() {
  21247. return undefined;
  21248. },
  21249. removeClass: function removeClass() {
  21250. return undefined;
  21251. },
  21252. addScrollAreaClass: function addScrollAreaClass() {
  21253. return undefined;
  21254. },
  21255. setScrollAreaStyleProperty: function setScrollAreaStyleProperty() {
  21256. return undefined;
  21257. },
  21258. setScrollContentStyleProperty: function setScrollContentStyleProperty() {
  21259. return undefined;
  21260. },
  21261. getScrollContentStyleValue: function getScrollContentStyleValue() {
  21262. return '';
  21263. },
  21264. setScrollAreaScrollLeft: function setScrollAreaScrollLeft() {
  21265. return undefined;
  21266. },
  21267. getScrollAreaScrollLeft: function getScrollAreaScrollLeft() {
  21268. return 0;
  21269. },
  21270. getScrollContentOffsetWidth: function getScrollContentOffsetWidth() {
  21271. return 0;
  21272. },
  21273. getScrollAreaOffsetWidth: function getScrollAreaOffsetWidth() {
  21274. return 0;
  21275. },
  21276. computeScrollAreaClientRect: function computeScrollAreaClientRect() {
  21277. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  21278. },
  21279. computeScrollContentClientRect: function computeScrollContentClientRect() {
  21280. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  21281. },
  21282. computeHorizontalScrollbarHeight: function computeHorizontalScrollbarHeight() {
  21283. return 0;
  21284. }
  21285. };
  21286. // tslint:enable:object-literal-sort-keys
  21287. },
  21288. enumerable: true,
  21289. configurable: true
  21290. });
  21291. MDCTabScrollerFoundation.prototype.init = function () {
  21292. // Compute horizontal scrollbar height on scroller with overflow initially hidden, then update overflow to scroll
  21293. // and immediately adjust bottom margin to avoid the scrollbar initially appearing before JS runs.
  21294. var horizontalScrollbarHeight = this.adapter.computeHorizontalScrollbarHeight();
  21295. this.adapter.setScrollAreaStyleProperty('margin-bottom', -horizontalScrollbarHeight + 'px');
  21296. this.adapter.addScrollAreaClass(MDCTabScrollerFoundation.cssClasses.SCROLL_AREA_SCROLL);
  21297. };
  21298. /**
  21299. * Computes the current visual scroll position
  21300. */
  21301. MDCTabScrollerFoundation.prototype.getScrollPosition = function () {
  21302. if (this.isRTL_()) {
  21303. return this.computeCurrentScrollPositionRTL_();
  21304. }
  21305. var currentTranslateX = this.calculateCurrentTranslateX_();
  21306. var scrollLeft = this.adapter.getScrollAreaScrollLeft();
  21307. return scrollLeft - currentTranslateX;
  21308. };
  21309. /**
  21310. * Handles interaction events that occur during transition
  21311. */
  21312. MDCTabScrollerFoundation.prototype.handleInteraction = function () {
  21313. // Early exit if we aren't animating
  21314. if (!this.isAnimating_) {
  21315. return;
  21316. }
  21317. // Prevent other event listeners from handling this event
  21318. this.stopScrollAnimation_();
  21319. };
  21320. /**
  21321. * Handles the transitionend event
  21322. */
  21323. MDCTabScrollerFoundation.prototype.handleTransitionEnd = function (evt) {
  21324. // Early exit if we aren't animating or the event was triggered by a different element.
  21325. var evtTarget = evt.target;
  21326. if (!this.isAnimating_ || !this.adapter.eventTargetMatchesSelector(evtTarget, MDCTabScrollerFoundation.strings.CONTENT_SELECTOR)) {
  21327. return;
  21328. }
  21329. this.isAnimating_ = false;
  21330. this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
  21331. };
  21332. /**
  21333. * Increment the scroll value by the scrollXIncrement using animation.
  21334. * @param scrollXIncrement The value by which to increment the scroll position
  21335. */
  21336. MDCTabScrollerFoundation.prototype.incrementScroll = function (scrollXIncrement) {
  21337. // Early exit for non-operational increment values
  21338. if (scrollXIncrement === 0) {
  21339. return;
  21340. }
  21341. this.animate_(this.getIncrementScrollOperation_(scrollXIncrement));
  21342. };
  21343. /**
  21344. * Increment the scroll value by the scrollXIncrement without animation.
  21345. * @param scrollXIncrement The value by which to increment the scroll position
  21346. */
  21347. MDCTabScrollerFoundation.prototype.incrementScrollImmediate = function (scrollXIncrement) {
  21348. // Early exit for non-operational increment values
  21349. if (scrollXIncrement === 0) {
  21350. return;
  21351. }
  21352. var operation = this.getIncrementScrollOperation_(scrollXIncrement);
  21353. if (operation.scrollDelta === 0) {
  21354. return;
  21355. }
  21356. this.stopScrollAnimation_();
  21357. this.adapter.setScrollAreaScrollLeft(operation.finalScrollPosition);
  21358. };
  21359. /**
  21360. * Scrolls to the given scrollX value
  21361. */
  21362. MDCTabScrollerFoundation.prototype.scrollTo = function (scrollX) {
  21363. if (this.isRTL_()) {
  21364. return this.scrollToRTL_(scrollX);
  21365. }
  21366. this.scrollTo_(scrollX);
  21367. };
  21368. /**
  21369. * @return Browser-specific {@link MDCTabScrollerRTL} instance.
  21370. */
  21371. MDCTabScrollerFoundation.prototype.getRTLScroller = function () {
  21372. if (!this.rtlScrollerInstance_) {
  21373. this.rtlScrollerInstance_ = this.rtlScrollerFactory_();
  21374. }
  21375. return this.rtlScrollerInstance_;
  21376. };
  21377. /**
  21378. * @return translateX value from a CSS matrix transform function string.
  21379. */
  21380. MDCTabScrollerFoundation.prototype.calculateCurrentTranslateX_ = function () {
  21381. var transformValue = this.adapter.getScrollContentStyleValue('transform');
  21382. // Early exit if no transform is present
  21383. if (transformValue === 'none') {
  21384. return 0;
  21385. }
  21386. // The transform value comes back as a matrix transformation in the form
  21387. // of `matrix(a, b, c, d, tx, ty)`. We only care about tx (translateX) so
  21388. // we're going to grab all the parenthesized values, strip out tx, and
  21389. // parse it.
  21390. var match = /\((.+?)\)/.exec(transformValue);
  21391. if (!match) {
  21392. return 0;
  21393. }
  21394. var matrixParams = match[1];
  21395. // tslint:disable-next-line:ban-ts-ignore "Unused vars" should be a linter warning, not a compiler error.
  21396. // @ts-ignore These unused variables should retain their semantic names for clarity.
  21397. var _a = __read(matrixParams.split(','), 6),
  21398. a = _a[0],
  21399. b = _a[1],
  21400. c = _a[2],
  21401. d = _a[3],
  21402. tx = _a[4],
  21403. ty = _a[5];
  21404. return parseFloat(tx); // tslint:disable-line:ban
  21405. };
  21406. /**
  21407. * Calculates a safe scroll value that is > 0 and < the max scroll value
  21408. * @param scrollX The distance to scroll
  21409. */
  21410. MDCTabScrollerFoundation.prototype.clampScrollValue_ = function (scrollX) {
  21411. var edges = this.calculateScrollEdges_();
  21412. return Math.min(Math.max(edges.left, scrollX), edges.right);
  21413. };
  21414. MDCTabScrollerFoundation.prototype.computeCurrentScrollPositionRTL_ = function () {
  21415. var translateX = this.calculateCurrentTranslateX_();
  21416. return this.getRTLScroller().getScrollPositionRTL(translateX);
  21417. };
  21418. MDCTabScrollerFoundation.prototype.calculateScrollEdges_ = function () {
  21419. var contentWidth = this.adapter.getScrollContentOffsetWidth();
  21420. var rootWidth = this.adapter.getScrollAreaOffsetWidth();
  21421. return {
  21422. left: 0,
  21423. right: contentWidth - rootWidth
  21424. };
  21425. };
  21426. /**
  21427. * Internal scroll method
  21428. * @param scrollX The new scroll position
  21429. */
  21430. MDCTabScrollerFoundation.prototype.scrollTo_ = function (scrollX) {
  21431. var currentScrollX = this.getScrollPosition();
  21432. var safeScrollX = this.clampScrollValue_(scrollX);
  21433. var scrollDelta = safeScrollX - currentScrollX;
  21434. this.animate_({
  21435. finalScrollPosition: safeScrollX,
  21436. scrollDelta: scrollDelta
  21437. });
  21438. };
  21439. /**
  21440. * Internal RTL scroll method
  21441. * @param scrollX The new scroll position
  21442. */
  21443. MDCTabScrollerFoundation.prototype.scrollToRTL_ = function (scrollX) {
  21444. var animation = this.getRTLScroller().scrollToRTL(scrollX);
  21445. this.animate_(animation);
  21446. };
  21447. /**
  21448. * Internal method to compute the increment scroll operation values.
  21449. * @param scrollX The desired scroll position increment
  21450. * @return MDCTabScrollerAnimation with the sanitized values for performing the scroll operation.
  21451. */
  21452. MDCTabScrollerFoundation.prototype.getIncrementScrollOperation_ = function (scrollX) {
  21453. if (this.isRTL_()) {
  21454. return this.getRTLScroller().incrementScrollRTL(scrollX);
  21455. }
  21456. var currentScrollX = this.getScrollPosition();
  21457. var targetScrollX = scrollX + currentScrollX;
  21458. var safeScrollX = this.clampScrollValue_(targetScrollX);
  21459. var scrollDelta = safeScrollX - currentScrollX;
  21460. return {
  21461. finalScrollPosition: safeScrollX,
  21462. scrollDelta: scrollDelta
  21463. };
  21464. };
  21465. /**
  21466. * Animates the tab scrolling
  21467. * @param animation The animation to apply
  21468. */
  21469. MDCTabScrollerFoundation.prototype.animate_ = function (animation) {
  21470. var _this = this;
  21471. // Early exit if translateX is 0, which means there's no animation to perform
  21472. if (animation.scrollDelta === 0) {
  21473. return;
  21474. }
  21475. this.stopScrollAnimation_();
  21476. // This animation uses the FLIP approach.
  21477. // Read more here: https://aerotwist.com/blog/flip-your-animations/
  21478. this.adapter.setScrollAreaScrollLeft(animation.finalScrollPosition);
  21479. this.adapter.setScrollContentStyleProperty('transform', "translateX(" + animation.scrollDelta + "px)");
  21480. // Force repaint
  21481. this.adapter.computeScrollAreaClientRect();
  21482. requestAnimationFrame(function () {
  21483. _this.adapter.addClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
  21484. _this.adapter.setScrollContentStyleProperty('transform', 'none');
  21485. });
  21486. this.isAnimating_ = true;
  21487. };
  21488. /**
  21489. * Stops scroll animation
  21490. */
  21491. MDCTabScrollerFoundation.prototype.stopScrollAnimation_ = function () {
  21492. this.isAnimating_ = false;
  21493. var currentScrollPosition = this.getAnimatingScrollPosition_();
  21494. this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
  21495. this.adapter.setScrollContentStyleProperty('transform', 'translateX(0px)');
  21496. this.adapter.setScrollAreaScrollLeft(currentScrollPosition);
  21497. };
  21498. /**
  21499. * Gets the current scroll position during animation
  21500. */
  21501. MDCTabScrollerFoundation.prototype.getAnimatingScrollPosition_ = function () {
  21502. var currentTranslateX = this.calculateCurrentTranslateX_();
  21503. var scrollLeft = this.adapter.getScrollAreaScrollLeft();
  21504. if (this.isRTL_()) {
  21505. return this.getRTLScroller().getAnimatingScrollPosition(scrollLeft, currentTranslateX);
  21506. }
  21507. return scrollLeft - currentTranslateX;
  21508. };
  21509. /**
  21510. * Determines the RTL Scroller to use
  21511. */
  21512. MDCTabScrollerFoundation.prototype.rtlScrollerFactory_ = function () {
  21513. // Browsers have three different implementations of scrollLeft in RTL mode,
  21514. // dependent on the browser. The behavior is based off the max LTR
  21515. // scrollLeft value and 0.
  21516. //
  21517. // * Default scrolling in RTL *
  21518. // - Left-most value: 0
  21519. // - Right-most value: Max LTR scrollLeft value
  21520. //
  21521. // * Negative scrolling in RTL *
  21522. // - Left-most value: Negated max LTR scrollLeft value
  21523. // - Right-most value: 0
  21524. //
  21525. // * Reverse scrolling in RTL *
  21526. // - Left-most value: Max LTR scrollLeft value
  21527. // - Right-most value: 0
  21528. //
  21529. // We use those principles below to determine which RTL scrollLeft
  21530. // behavior is implemented in the current browser.
  21531. var initialScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21532. this.adapter.setScrollAreaScrollLeft(initialScrollLeft - 1);
  21533. var newScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21534. // If the newScrollLeft value is negative,then we know that the browser has
  21535. // implemented negative RTL scrolling, since all other implementations have
  21536. // only positive values.
  21537. if (newScrollLeft < 0) {
  21538. // Undo the scrollLeft test check
  21539. this.adapter.setScrollAreaScrollLeft(initialScrollLeft);
  21540. return new rtl_negative_scroller_1.MDCTabScrollerRTLNegative(this.adapter);
  21541. }
  21542. var rootClientRect = this.adapter.computeScrollAreaClientRect();
  21543. var contentClientRect = this.adapter.computeScrollContentClientRect();
  21544. var rightEdgeDelta = Math.round(contentClientRect.right - rootClientRect.right);
  21545. // Undo the scrollLeft test check
  21546. this.adapter.setScrollAreaScrollLeft(initialScrollLeft);
  21547. // By calculating the clientRect of the root element and the clientRect of
  21548. // the content element, we can determine how much the scroll value changed
  21549. // when we performed the scrollLeft subtraction above.
  21550. if (rightEdgeDelta === newScrollLeft) {
  21551. return new rtl_reverse_scroller_1.MDCTabScrollerRTLReverse(this.adapter);
  21552. }
  21553. return new rtl_default_scroller_1.MDCTabScrollerRTLDefault(this.adapter);
  21554. };
  21555. MDCTabScrollerFoundation.prototype.isRTL_ = function () {
  21556. return this.adapter.getScrollContentStyleValue('direction') === 'rtl';
  21557. };
  21558. return MDCTabScrollerFoundation;
  21559. }(foundation_1.MDCFoundation);
  21560. exports.MDCTabScrollerFoundation = MDCTabScrollerFoundation;
  21561. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  21562. exports.default = MDCTabScrollerFoundation;
  21563. /***/ }),
  21564. /***/ "./packages/mdc-tab-scroller/index.ts":
  21565. /*!********************************************!*\
  21566. !*** ./packages/mdc-tab-scroller/index.ts ***!
  21567. \********************************************/
  21568. /*! no static exports found */
  21569. /***/ (function(module, exports, __webpack_require__) {
  21570. "use strict";
  21571. /**
  21572. * @license
  21573. * Copyright 2019 Google Inc.
  21574. *
  21575. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21576. * of this software and associated documentation files (the "Software"), to deal
  21577. * in the Software without restriction, including without limitation the rights
  21578. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21579. * copies of the Software, and to permit persons to whom the Software is
  21580. * furnished to do so, subject to the following conditions:
  21581. *
  21582. * The above copyright notice and this permission notice shall be included in
  21583. * all copies or substantial portions of the Software.
  21584. *
  21585. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21586. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21587. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21588. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21589. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21590. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21591. * THE SOFTWARE.
  21592. */
  21593. function __export(m) {
  21594. for (var p in m) {
  21595. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  21596. }
  21597. }
  21598. var __importStar = this && this.__importStar || function (mod) {
  21599. if (mod && mod.__esModule) return mod;
  21600. var result = {};
  21601. if (mod != null) for (var k in mod) {
  21602. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  21603. }result["default"] = mod;
  21604. return result;
  21605. };
  21606. Object.defineProperty(exports, "__esModule", { value: true });
  21607. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-tab-scroller/util.ts"));
  21608. exports.util = util;
  21609. __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab-scroller/component.ts"));
  21610. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts"));
  21611. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-scroller/foundation.ts"));
  21612. /***/ }),
  21613. /***/ "./packages/mdc-tab-scroller/rtl-default-scroller.ts":
  21614. /*!***********************************************************!*\
  21615. !*** ./packages/mdc-tab-scroller/rtl-default-scroller.ts ***!
  21616. \***********************************************************/
  21617. /*! no static exports found */
  21618. /***/ (function(module, exports, __webpack_require__) {
  21619. "use strict";
  21620. /**
  21621. * @license
  21622. * Copyright 2018 Google Inc.
  21623. *
  21624. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21625. * of this software and associated documentation files (the "Software"), to deal
  21626. * in the Software without restriction, including without limitation the rights
  21627. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21628. * copies of the Software, and to permit persons to whom the Software is
  21629. * furnished to do so, subject to the following conditions:
  21630. *
  21631. * The above copyright notice and this permission notice shall be included in
  21632. * all copies or substantial portions of the Software.
  21633. *
  21634. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21635. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21636. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21637. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21638. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21639. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21640. * THE SOFTWARE.
  21641. */
  21642. var __extends = this && this.__extends || function () {
  21643. var _extendStatics = function extendStatics(d, b) {
  21644. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  21645. d.__proto__ = b;
  21646. } || function (d, b) {
  21647. for (var p in b) {
  21648. if (b.hasOwnProperty(p)) d[p] = b[p];
  21649. }
  21650. };
  21651. return _extendStatics(d, b);
  21652. };
  21653. return function (d, b) {
  21654. _extendStatics(d, b);
  21655. function __() {
  21656. this.constructor = d;
  21657. }
  21658. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21659. };
  21660. }();
  21661. Object.defineProperty(exports, "__esModule", { value: true });
  21662. var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
  21663. var MDCTabScrollerRTLDefault = /** @class */function (_super) {
  21664. __extends(MDCTabScrollerRTLDefault, _super);
  21665. function MDCTabScrollerRTLDefault() {
  21666. return _super !== null && _super.apply(this, arguments) || this;
  21667. }
  21668. MDCTabScrollerRTLDefault.prototype.getScrollPositionRTL = function () {
  21669. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21670. var right = this.calculateScrollEdges_().right;
  21671. // Scroll values on most browsers are ints instead of floats so we round
  21672. return Math.round(right - currentScrollLeft);
  21673. };
  21674. MDCTabScrollerRTLDefault.prototype.scrollToRTL = function (scrollX) {
  21675. var edges = this.calculateScrollEdges_();
  21676. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21677. var clampedScrollLeft = this.clampScrollValue_(edges.right - scrollX);
  21678. return {
  21679. finalScrollPosition: clampedScrollLeft,
  21680. scrollDelta: clampedScrollLeft - currentScrollLeft
  21681. };
  21682. };
  21683. MDCTabScrollerRTLDefault.prototype.incrementScrollRTL = function (scrollX) {
  21684. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21685. var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft - scrollX);
  21686. return {
  21687. finalScrollPosition: clampedScrollLeft,
  21688. scrollDelta: clampedScrollLeft - currentScrollLeft
  21689. };
  21690. };
  21691. MDCTabScrollerRTLDefault.prototype.getAnimatingScrollPosition = function (scrollX) {
  21692. return scrollX;
  21693. };
  21694. MDCTabScrollerRTLDefault.prototype.calculateScrollEdges_ = function () {
  21695. var contentWidth = this.adapter.getScrollContentOffsetWidth();
  21696. var rootWidth = this.adapter.getScrollAreaOffsetWidth();
  21697. return {
  21698. left: 0,
  21699. right: contentWidth - rootWidth
  21700. };
  21701. };
  21702. MDCTabScrollerRTLDefault.prototype.clampScrollValue_ = function (scrollX) {
  21703. var edges = this.calculateScrollEdges_();
  21704. return Math.min(Math.max(edges.left, scrollX), edges.right);
  21705. };
  21706. return MDCTabScrollerRTLDefault;
  21707. }(rtl_scroller_1.MDCTabScrollerRTL);
  21708. exports.MDCTabScrollerRTLDefault = MDCTabScrollerRTLDefault;
  21709. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  21710. exports.default = MDCTabScrollerRTLDefault;
  21711. /***/ }),
  21712. /***/ "./packages/mdc-tab-scroller/rtl-negative-scroller.ts":
  21713. /*!************************************************************!*\
  21714. !*** ./packages/mdc-tab-scroller/rtl-negative-scroller.ts ***!
  21715. \************************************************************/
  21716. /*! no static exports found */
  21717. /***/ (function(module, exports, __webpack_require__) {
  21718. "use strict";
  21719. /**
  21720. * @license
  21721. * Copyright 2018 Google Inc.
  21722. *
  21723. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21724. * of this software and associated documentation files (the "Software"), to deal
  21725. * in the Software without restriction, including without limitation the rights
  21726. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21727. * copies of the Software, and to permit persons to whom the Software is
  21728. * furnished to do so, subject to the following conditions:
  21729. *
  21730. * The above copyright notice and this permission notice shall be included in
  21731. * all copies or substantial portions of the Software.
  21732. *
  21733. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21734. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21735. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21736. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21737. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21738. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21739. * THE SOFTWARE.
  21740. */
  21741. var __extends = this && this.__extends || function () {
  21742. var _extendStatics = function extendStatics(d, b) {
  21743. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  21744. d.__proto__ = b;
  21745. } || function (d, b) {
  21746. for (var p in b) {
  21747. if (b.hasOwnProperty(p)) d[p] = b[p];
  21748. }
  21749. };
  21750. return _extendStatics(d, b);
  21751. };
  21752. return function (d, b) {
  21753. _extendStatics(d, b);
  21754. function __() {
  21755. this.constructor = d;
  21756. }
  21757. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21758. };
  21759. }();
  21760. Object.defineProperty(exports, "__esModule", { value: true });
  21761. var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
  21762. var MDCTabScrollerRTLNegative = /** @class */function (_super) {
  21763. __extends(MDCTabScrollerRTLNegative, _super);
  21764. function MDCTabScrollerRTLNegative() {
  21765. return _super !== null && _super.apply(this, arguments) || this;
  21766. }
  21767. MDCTabScrollerRTLNegative.prototype.getScrollPositionRTL = function (translateX) {
  21768. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21769. return Math.round(translateX - currentScrollLeft);
  21770. };
  21771. MDCTabScrollerRTLNegative.prototype.scrollToRTL = function (scrollX) {
  21772. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21773. var clampedScrollLeft = this.clampScrollValue_(-scrollX);
  21774. return {
  21775. finalScrollPosition: clampedScrollLeft,
  21776. scrollDelta: clampedScrollLeft - currentScrollLeft
  21777. };
  21778. };
  21779. MDCTabScrollerRTLNegative.prototype.incrementScrollRTL = function (scrollX) {
  21780. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21781. var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft - scrollX);
  21782. return {
  21783. finalScrollPosition: clampedScrollLeft,
  21784. scrollDelta: clampedScrollLeft - currentScrollLeft
  21785. };
  21786. };
  21787. MDCTabScrollerRTLNegative.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
  21788. return scrollX - translateX;
  21789. };
  21790. MDCTabScrollerRTLNegative.prototype.calculateScrollEdges_ = function () {
  21791. var contentWidth = this.adapter.getScrollContentOffsetWidth();
  21792. var rootWidth = this.adapter.getScrollAreaOffsetWidth();
  21793. return {
  21794. left: rootWidth - contentWidth,
  21795. right: 0
  21796. };
  21797. };
  21798. MDCTabScrollerRTLNegative.prototype.clampScrollValue_ = function (scrollX) {
  21799. var edges = this.calculateScrollEdges_();
  21800. return Math.max(Math.min(edges.right, scrollX), edges.left);
  21801. };
  21802. return MDCTabScrollerRTLNegative;
  21803. }(rtl_scroller_1.MDCTabScrollerRTL);
  21804. exports.MDCTabScrollerRTLNegative = MDCTabScrollerRTLNegative;
  21805. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  21806. exports.default = MDCTabScrollerRTLNegative;
  21807. /***/ }),
  21808. /***/ "./packages/mdc-tab-scroller/rtl-reverse-scroller.ts":
  21809. /*!***********************************************************!*\
  21810. !*** ./packages/mdc-tab-scroller/rtl-reverse-scroller.ts ***!
  21811. \***********************************************************/
  21812. /*! no static exports found */
  21813. /***/ (function(module, exports, __webpack_require__) {
  21814. "use strict";
  21815. /**
  21816. * @license
  21817. * Copyright 2018 Google Inc.
  21818. *
  21819. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21820. * of this software and associated documentation files (the "Software"), to deal
  21821. * in the Software without restriction, including without limitation the rights
  21822. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21823. * copies of the Software, and to permit persons to whom the Software is
  21824. * furnished to do so, subject to the following conditions:
  21825. *
  21826. * The above copyright notice and this permission notice shall be included in
  21827. * all copies or substantial portions of the Software.
  21828. *
  21829. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21830. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21831. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21832. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21833. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21834. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21835. * THE SOFTWARE.
  21836. */
  21837. var __extends = this && this.__extends || function () {
  21838. var _extendStatics = function extendStatics(d, b) {
  21839. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  21840. d.__proto__ = b;
  21841. } || function (d, b) {
  21842. for (var p in b) {
  21843. if (b.hasOwnProperty(p)) d[p] = b[p];
  21844. }
  21845. };
  21846. return _extendStatics(d, b);
  21847. };
  21848. return function (d, b) {
  21849. _extendStatics(d, b);
  21850. function __() {
  21851. this.constructor = d;
  21852. }
  21853. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  21854. };
  21855. }();
  21856. Object.defineProperty(exports, "__esModule", { value: true });
  21857. var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
  21858. var MDCTabScrollerRTLReverse = /** @class */function (_super) {
  21859. __extends(MDCTabScrollerRTLReverse, _super);
  21860. function MDCTabScrollerRTLReverse() {
  21861. return _super !== null && _super.apply(this, arguments) || this;
  21862. }
  21863. MDCTabScrollerRTLReverse.prototype.getScrollPositionRTL = function (translateX) {
  21864. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21865. // Scroll values on most browsers are ints instead of floats so we round
  21866. return Math.round(currentScrollLeft - translateX);
  21867. };
  21868. MDCTabScrollerRTLReverse.prototype.scrollToRTL = function (scrollX) {
  21869. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21870. var clampedScrollLeft = this.clampScrollValue_(scrollX);
  21871. return {
  21872. finalScrollPosition: clampedScrollLeft,
  21873. scrollDelta: currentScrollLeft - clampedScrollLeft
  21874. };
  21875. };
  21876. MDCTabScrollerRTLReverse.prototype.incrementScrollRTL = function (scrollX) {
  21877. var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
  21878. var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft + scrollX);
  21879. return {
  21880. finalScrollPosition: clampedScrollLeft,
  21881. scrollDelta: currentScrollLeft - clampedScrollLeft
  21882. };
  21883. };
  21884. MDCTabScrollerRTLReverse.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
  21885. return scrollX + translateX;
  21886. };
  21887. MDCTabScrollerRTLReverse.prototype.calculateScrollEdges_ = function () {
  21888. var contentWidth = this.adapter.getScrollContentOffsetWidth();
  21889. var rootWidth = this.adapter.getScrollAreaOffsetWidth();
  21890. return {
  21891. left: contentWidth - rootWidth,
  21892. right: 0
  21893. };
  21894. };
  21895. MDCTabScrollerRTLReverse.prototype.clampScrollValue_ = function (scrollX) {
  21896. var edges = this.calculateScrollEdges_();
  21897. return Math.min(Math.max(edges.right, scrollX), edges.left);
  21898. };
  21899. return MDCTabScrollerRTLReverse;
  21900. }(rtl_scroller_1.MDCTabScrollerRTL);
  21901. exports.MDCTabScrollerRTLReverse = MDCTabScrollerRTLReverse;
  21902. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  21903. exports.default = MDCTabScrollerRTLReverse;
  21904. /***/ }),
  21905. /***/ "./packages/mdc-tab-scroller/rtl-scroller.ts":
  21906. /*!***************************************************!*\
  21907. !*** ./packages/mdc-tab-scroller/rtl-scroller.ts ***!
  21908. \***************************************************/
  21909. /*! no static exports found */
  21910. /***/ (function(module, exports, __webpack_require__) {
  21911. "use strict";
  21912. /**
  21913. * @license
  21914. * Copyright 2018 Google Inc.
  21915. *
  21916. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21917. * of this software and associated documentation files (the "Software"), to deal
  21918. * in the Software without restriction, including without limitation the rights
  21919. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21920. * copies of the Software, and to permit persons to whom the Software is
  21921. * furnished to do so, subject to the following conditions:
  21922. *
  21923. * The above copyright notice and this permission notice shall be included in
  21924. * all copies or substantial portions of the Software.
  21925. *
  21926. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21927. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21928. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21929. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21930. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21931. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21932. * THE SOFTWARE.
  21933. */
  21934. Object.defineProperty(exports, "__esModule", { value: true });
  21935. var MDCTabScrollerRTL = /** @class */function () {
  21936. function MDCTabScrollerRTL(adapter) {
  21937. this.adapter = adapter;
  21938. }
  21939. return MDCTabScrollerRTL;
  21940. }();
  21941. exports.MDCTabScrollerRTL = MDCTabScrollerRTL;
  21942. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  21943. exports.default = MDCTabScrollerRTL;
  21944. /***/ }),
  21945. /***/ "./packages/mdc-tab-scroller/util.ts":
  21946. /*!*******************************************!*\
  21947. !*** ./packages/mdc-tab-scroller/util.ts ***!
  21948. \*******************************************/
  21949. /*! no static exports found */
  21950. /***/ (function(module, exports, __webpack_require__) {
  21951. "use strict";
  21952. /**
  21953. * @license
  21954. * Copyright 2018 Google Inc.
  21955. *
  21956. * Permission is hereby granted, free of charge, to any person obtaining a copy
  21957. * of this software and associated documentation files (the "Software"), to deal
  21958. * in the Software without restriction, including without limitation the rights
  21959. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  21960. * copies of the Software, and to permit persons to whom the Software is
  21961. * furnished to do so, subject to the following conditions:
  21962. *
  21963. * The above copyright notice and this permission notice shall be included in
  21964. * all copies or substantial portions of the Software.
  21965. *
  21966. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21967. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21968. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21969. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21970. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21971. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21972. * THE SOFTWARE.
  21973. */
  21974. Object.defineProperty(exports, "__esModule", { value: true });
  21975. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts");
  21976. /**
  21977. * Stores result from computeHorizontalScrollbarHeight to avoid redundant processing.
  21978. */
  21979. var horizontalScrollbarHeight_;
  21980. /**
  21981. * Computes the height of browser-rendered horizontal scrollbars using a self-created test element.
  21982. * May return 0 (e.g. on OS X browsers under default configuration).
  21983. */
  21984. function computeHorizontalScrollbarHeight(documentObj, shouldCacheResult) {
  21985. if (shouldCacheResult === void 0) {
  21986. shouldCacheResult = true;
  21987. }
  21988. if (shouldCacheResult && typeof horizontalScrollbarHeight_ !== 'undefined') {
  21989. return horizontalScrollbarHeight_;
  21990. }
  21991. var el = documentObj.createElement('div');
  21992. el.classList.add(constants_1.cssClasses.SCROLL_TEST);
  21993. documentObj.body.appendChild(el);
  21994. var horizontalScrollbarHeight = el.offsetHeight - el.clientHeight;
  21995. documentObj.body.removeChild(el);
  21996. if (shouldCacheResult) {
  21997. horizontalScrollbarHeight_ = horizontalScrollbarHeight;
  21998. }
  21999. return horizontalScrollbarHeight;
  22000. }
  22001. exports.computeHorizontalScrollbarHeight = computeHorizontalScrollbarHeight;
  22002. /***/ }),
  22003. /***/ "./packages/mdc-tab/component.ts":
  22004. /*!***************************************!*\
  22005. !*** ./packages/mdc-tab/component.ts ***!
  22006. \***************************************/
  22007. /*! no static exports found */
  22008. /***/ (function(module, exports, __webpack_require__) {
  22009. "use strict";
  22010. /**
  22011. * @license
  22012. * Copyright 2018 Google Inc.
  22013. *
  22014. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22015. * of this software and associated documentation files (the "Software"), to deal
  22016. * in the Software without restriction, including without limitation the rights
  22017. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22018. * copies of the Software, and to permit persons to whom the Software is
  22019. * furnished to do so, subject to the following conditions:
  22020. *
  22021. * The above copyright notice and this permission notice shall be included in
  22022. * all copies or substantial portions of the Software.
  22023. *
  22024. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22025. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22026. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22027. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22028. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22029. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22030. * THE SOFTWARE.
  22031. */
  22032. var __extends = this && this.__extends || function () {
  22033. var _extendStatics = function extendStatics(d, b) {
  22034. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  22035. d.__proto__ = b;
  22036. } || function (d, b) {
  22037. for (var p in b) {
  22038. if (b.hasOwnProperty(p)) d[p] = b[p];
  22039. }
  22040. };
  22041. return _extendStatics(d, b);
  22042. };
  22043. return function (d, b) {
  22044. _extendStatics(d, b);
  22045. function __() {
  22046. this.constructor = d;
  22047. }
  22048. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22049. };
  22050. }();
  22051. var __assign = this && this.__assign || function () {
  22052. __assign = Object.assign || function (t) {
  22053. for (var s, i = 1, n = arguments.length; i < n; i++) {
  22054. s = arguments[i];
  22055. for (var p in s) {
  22056. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  22057. }
  22058. }
  22059. return t;
  22060. };
  22061. return __assign.apply(this, arguments);
  22062. };
  22063. Object.defineProperty(exports, "__esModule", { value: true });
  22064. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  22065. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  22066. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  22067. var component_3 = __webpack_require__(/*! @material/tab-indicator/component */ "./packages/mdc-tab-indicator/component.ts");
  22068. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab/foundation.ts");
  22069. var MDCTab = /** @class */function (_super) {
  22070. __extends(MDCTab, _super);
  22071. function MDCTab() {
  22072. return _super !== null && _super.apply(this, arguments) || this;
  22073. }
  22074. MDCTab.attachTo = function (root) {
  22075. return new MDCTab(root);
  22076. };
  22077. MDCTab.prototype.initialize = function (rippleFactory, tabIndicatorFactory) {
  22078. if (rippleFactory === void 0) {
  22079. rippleFactory = function rippleFactory(el, foundation) {
  22080. return new component_2.MDCRipple(el, foundation);
  22081. };
  22082. }
  22083. if (tabIndicatorFactory === void 0) {
  22084. tabIndicatorFactory = function tabIndicatorFactory(el) {
  22085. return new component_3.MDCTabIndicator(el);
  22086. };
  22087. }
  22088. this.id = this.root.id;
  22089. var rippleSurface = this.root.querySelector(foundation_2.MDCTabFoundation.strings.RIPPLE_SELECTOR);
  22090. var rippleAdapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { addClass: function addClass(className) {
  22091. return rippleSurface.classList.add(className);
  22092. }, removeClass: function removeClass(className) {
  22093. return rippleSurface.classList.remove(className);
  22094. }, updateCssVariable: function updateCssVariable(varName, value) {
  22095. return rippleSurface.style.setProperty(varName, value);
  22096. } });
  22097. var rippleFoundation = new foundation_1.MDCRippleFoundation(rippleAdapter);
  22098. this.ripple_ = rippleFactory(this.root, rippleFoundation);
  22099. var tabIndicatorElement = this.root.querySelector(foundation_2.MDCTabFoundation.strings.TAB_INDICATOR_SELECTOR);
  22100. this.tabIndicator_ = tabIndicatorFactory(tabIndicatorElement);
  22101. this.content_ = this.root.querySelector(foundation_2.MDCTabFoundation.strings.CONTENT_SELECTOR);
  22102. };
  22103. MDCTab.prototype.initialSyncWithDOM = function () {
  22104. var _this = this;
  22105. this.handleClick_ = function () {
  22106. return _this.foundation.handleClick();
  22107. };
  22108. this.listen('click', this.handleClick_);
  22109. };
  22110. MDCTab.prototype.destroy = function () {
  22111. this.unlisten('click', this.handleClick_);
  22112. this.ripple_.destroy();
  22113. _super.prototype.destroy.call(this);
  22114. };
  22115. MDCTab.prototype.getDefaultFoundation = function () {
  22116. var _this = this;
  22117. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  22118. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  22119. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  22120. var adapter = {
  22121. setAttr: function setAttr(attr, value) {
  22122. return _this.root.setAttribute(attr, value);
  22123. },
  22124. addClass: function addClass(className) {
  22125. return _this.root.classList.add(className);
  22126. },
  22127. removeClass: function removeClass(className) {
  22128. return _this.root.classList.remove(className);
  22129. },
  22130. hasClass: function hasClass(className) {
  22131. return _this.root.classList.contains(className);
  22132. },
  22133. activateIndicator: function activateIndicator(previousIndicatorClientRect) {
  22134. return _this.tabIndicator_.activate(previousIndicatorClientRect);
  22135. },
  22136. deactivateIndicator: function deactivateIndicator() {
  22137. return _this.tabIndicator_.deactivate();
  22138. },
  22139. notifyInteracted: function notifyInteracted() {
  22140. return _this.emit(foundation_2.MDCTabFoundation.strings.INTERACTED_EVENT, { tabId: _this.id }, true /* bubble */);
  22141. },
  22142. getOffsetLeft: function getOffsetLeft() {
  22143. return _this.root.offsetLeft;
  22144. },
  22145. getOffsetWidth: function getOffsetWidth() {
  22146. return _this.root.offsetWidth;
  22147. },
  22148. getContentOffsetLeft: function getContentOffsetLeft() {
  22149. return _this.content_.offsetLeft;
  22150. },
  22151. getContentOffsetWidth: function getContentOffsetWidth() {
  22152. return _this.content_.offsetWidth;
  22153. },
  22154. focus: function focus() {
  22155. return _this.root.focus();
  22156. }
  22157. };
  22158. // tslint:enable:object-literal-sort-keys
  22159. return new foundation_2.MDCTabFoundation(adapter);
  22160. };
  22161. Object.defineProperty(MDCTab.prototype, "active", {
  22162. /**
  22163. * Getter for the active state of the tab
  22164. */
  22165. get: function get() {
  22166. return this.foundation.isActive();
  22167. },
  22168. enumerable: true,
  22169. configurable: true
  22170. });
  22171. Object.defineProperty(MDCTab.prototype, "focusOnActivate", {
  22172. set: function set(focusOnActivate) {
  22173. this.foundation.setFocusOnActivate(focusOnActivate);
  22174. },
  22175. enumerable: true,
  22176. configurable: true
  22177. });
  22178. /**
  22179. * Activates the tab
  22180. */
  22181. MDCTab.prototype.activate = function (computeIndicatorClientRect) {
  22182. this.foundation.activate(computeIndicatorClientRect);
  22183. };
  22184. /**
  22185. * Deactivates the tab
  22186. */
  22187. MDCTab.prototype.deactivate = function () {
  22188. this.foundation.deactivate();
  22189. };
  22190. /**
  22191. * Returns the indicator's client rect
  22192. */
  22193. MDCTab.prototype.computeIndicatorClientRect = function () {
  22194. return this.tabIndicator_.computeContentClientRect();
  22195. };
  22196. MDCTab.prototype.computeDimensions = function () {
  22197. return this.foundation.computeDimensions();
  22198. };
  22199. /**
  22200. * Focuses the tab
  22201. */
  22202. MDCTab.prototype.focus = function () {
  22203. this.root.focus();
  22204. };
  22205. return MDCTab;
  22206. }(component_1.MDCComponent);
  22207. exports.MDCTab = MDCTab;
  22208. /***/ }),
  22209. /***/ "./packages/mdc-tab/constants.ts":
  22210. /*!***************************************!*\
  22211. !*** ./packages/mdc-tab/constants.ts ***!
  22212. \***************************************/
  22213. /*! no static exports found */
  22214. /***/ (function(module, exports, __webpack_require__) {
  22215. "use strict";
  22216. /**
  22217. * @license
  22218. * Copyright 2018 Google Inc.
  22219. *
  22220. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22221. * of this software and associated documentation files (the "Software"), to deal
  22222. * in the Software without restriction, including without limitation the rights
  22223. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22224. * copies of the Software, and to permit persons to whom the Software is
  22225. * furnished to do so, subject to the following conditions:
  22226. *
  22227. * The above copyright notice and this permission notice shall be included in
  22228. * all copies or substantial portions of the Software.
  22229. *
  22230. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22231. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22232. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22233. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22234. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22235. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22236. * THE SOFTWARE.
  22237. */
  22238. Object.defineProperty(exports, "__esModule", { value: true });
  22239. var cssClasses = {
  22240. ACTIVE: 'mdc-tab--active'
  22241. };
  22242. exports.cssClasses = cssClasses;
  22243. var strings = {
  22244. ARIA_SELECTED: 'aria-selected',
  22245. CONTENT_SELECTOR: '.mdc-tab__content',
  22246. INTERACTED_EVENT: 'MDCTab:interacted',
  22247. RIPPLE_SELECTOR: '.mdc-tab__ripple',
  22248. TABINDEX: 'tabIndex',
  22249. TAB_INDICATOR_SELECTOR: '.mdc-tab-indicator'
  22250. };
  22251. exports.strings = strings;
  22252. /***/ }),
  22253. /***/ "./packages/mdc-tab/foundation.ts":
  22254. /*!****************************************!*\
  22255. !*** ./packages/mdc-tab/foundation.ts ***!
  22256. \****************************************/
  22257. /*! no static exports found */
  22258. /***/ (function(module, exports, __webpack_require__) {
  22259. "use strict";
  22260. /**
  22261. * @license
  22262. * Copyright 2018 Google Inc.
  22263. *
  22264. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22265. * of this software and associated documentation files (the "Software"), to deal
  22266. * in the Software without restriction, including without limitation the rights
  22267. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22268. * copies of the Software, and to permit persons to whom the Software is
  22269. * furnished to do so, subject to the following conditions:
  22270. *
  22271. * The above copyright notice and this permission notice shall be included in
  22272. * all copies or substantial portions of the Software.
  22273. *
  22274. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22275. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22276. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22277. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22278. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22279. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22280. * THE SOFTWARE.
  22281. */
  22282. var __extends = this && this.__extends || function () {
  22283. var _extendStatics = function extendStatics(d, b) {
  22284. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  22285. d.__proto__ = b;
  22286. } || function (d, b) {
  22287. for (var p in b) {
  22288. if (b.hasOwnProperty(p)) d[p] = b[p];
  22289. }
  22290. };
  22291. return _extendStatics(d, b);
  22292. };
  22293. return function (d, b) {
  22294. _extendStatics(d, b);
  22295. function __() {
  22296. this.constructor = d;
  22297. }
  22298. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22299. };
  22300. }();
  22301. var __assign = this && this.__assign || function () {
  22302. __assign = Object.assign || function (t) {
  22303. for (var s, i = 1, n = arguments.length; i < n; i++) {
  22304. s = arguments[i];
  22305. for (var p in s) {
  22306. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  22307. }
  22308. }
  22309. return t;
  22310. };
  22311. return __assign.apply(this, arguments);
  22312. };
  22313. Object.defineProperty(exports, "__esModule", { value: true });
  22314. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  22315. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab/constants.ts");
  22316. var MDCTabFoundation = /** @class */function (_super) {
  22317. __extends(MDCTabFoundation, _super);
  22318. function MDCTabFoundation(adapter) {
  22319. var _this = _super.call(this, __assign(__assign({}, MDCTabFoundation.defaultAdapter), adapter)) || this;
  22320. _this.focusOnActivate_ = true;
  22321. return _this;
  22322. }
  22323. Object.defineProperty(MDCTabFoundation, "cssClasses", {
  22324. get: function get() {
  22325. return constants_1.cssClasses;
  22326. },
  22327. enumerable: true,
  22328. configurable: true
  22329. });
  22330. Object.defineProperty(MDCTabFoundation, "strings", {
  22331. get: function get() {
  22332. return constants_1.strings;
  22333. },
  22334. enumerable: true,
  22335. configurable: true
  22336. });
  22337. Object.defineProperty(MDCTabFoundation, "defaultAdapter", {
  22338. get: function get() {
  22339. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  22340. return {
  22341. addClass: function addClass() {
  22342. return undefined;
  22343. },
  22344. removeClass: function removeClass() {
  22345. return undefined;
  22346. },
  22347. hasClass: function hasClass() {
  22348. return false;
  22349. },
  22350. setAttr: function setAttr() {
  22351. return undefined;
  22352. },
  22353. activateIndicator: function activateIndicator() {
  22354. return undefined;
  22355. },
  22356. deactivateIndicator: function deactivateIndicator() {
  22357. return undefined;
  22358. },
  22359. notifyInteracted: function notifyInteracted() {
  22360. return undefined;
  22361. },
  22362. getOffsetLeft: function getOffsetLeft() {
  22363. return 0;
  22364. },
  22365. getOffsetWidth: function getOffsetWidth() {
  22366. return 0;
  22367. },
  22368. getContentOffsetLeft: function getContentOffsetLeft() {
  22369. return 0;
  22370. },
  22371. getContentOffsetWidth: function getContentOffsetWidth() {
  22372. return 0;
  22373. },
  22374. focus: function focus() {
  22375. return undefined;
  22376. }
  22377. };
  22378. // tslint:enable:object-literal-sort-keys
  22379. },
  22380. enumerable: true,
  22381. configurable: true
  22382. });
  22383. MDCTabFoundation.prototype.handleClick = function () {
  22384. // It's up to the parent component to keep track of the active Tab and
  22385. // ensure we don't activate a Tab that's already active.
  22386. this.adapter.notifyInteracted();
  22387. };
  22388. MDCTabFoundation.prototype.isActive = function () {
  22389. return this.adapter.hasClass(constants_1.cssClasses.ACTIVE);
  22390. };
  22391. /**
  22392. * Sets whether the tab should focus itself when activated
  22393. */
  22394. MDCTabFoundation.prototype.setFocusOnActivate = function (focusOnActivate) {
  22395. this.focusOnActivate_ = focusOnActivate;
  22396. };
  22397. /**
  22398. * Activates the Tab
  22399. */
  22400. MDCTabFoundation.prototype.activate = function (previousIndicatorClientRect) {
  22401. this.adapter.addClass(constants_1.cssClasses.ACTIVE);
  22402. this.adapter.setAttr(constants_1.strings.ARIA_SELECTED, 'true');
  22403. this.adapter.setAttr(constants_1.strings.TABINDEX, '0');
  22404. this.adapter.activateIndicator(previousIndicatorClientRect);
  22405. if (this.focusOnActivate_) {
  22406. this.adapter.focus();
  22407. }
  22408. };
  22409. /**
  22410. * Deactivates the Tab
  22411. */
  22412. MDCTabFoundation.prototype.deactivate = function () {
  22413. // Early exit
  22414. if (!this.isActive()) {
  22415. return;
  22416. }
  22417. this.adapter.removeClass(constants_1.cssClasses.ACTIVE);
  22418. this.adapter.setAttr(constants_1.strings.ARIA_SELECTED, 'false');
  22419. this.adapter.setAttr(constants_1.strings.TABINDEX, '-1');
  22420. this.adapter.deactivateIndicator();
  22421. };
  22422. /**
  22423. * Returns the dimensions of the Tab
  22424. */
  22425. MDCTabFoundation.prototype.computeDimensions = function () {
  22426. var rootWidth = this.adapter.getOffsetWidth();
  22427. var rootLeft = this.adapter.getOffsetLeft();
  22428. var contentWidth = this.adapter.getContentOffsetWidth();
  22429. var contentLeft = this.adapter.getContentOffsetLeft();
  22430. return {
  22431. contentLeft: rootLeft + contentLeft,
  22432. contentRight: rootLeft + contentLeft + contentWidth,
  22433. rootLeft: rootLeft,
  22434. rootRight: rootLeft + rootWidth
  22435. };
  22436. };
  22437. return MDCTabFoundation;
  22438. }(foundation_1.MDCFoundation);
  22439. exports.MDCTabFoundation = MDCTabFoundation;
  22440. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  22441. exports.default = MDCTabFoundation;
  22442. /***/ }),
  22443. /***/ "./packages/mdc-tab/index.ts":
  22444. /*!***********************************!*\
  22445. !*** ./packages/mdc-tab/index.ts ***!
  22446. \***********************************/
  22447. /*! no static exports found */
  22448. /***/ (function(module, exports, __webpack_require__) {
  22449. "use strict";
  22450. /**
  22451. * @license
  22452. * Copyright 2019 Google Inc.
  22453. *
  22454. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22455. * of this software and associated documentation files (the "Software"), to deal
  22456. * in the Software without restriction, including without limitation the rights
  22457. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22458. * copies of the Software, and to permit persons to whom the Software is
  22459. * furnished to do so, subject to the following conditions:
  22460. *
  22461. * The above copyright notice and this permission notice shall be included in
  22462. * all copies or substantial portions of the Software.
  22463. *
  22464. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22465. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22466. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22467. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22468. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22469. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22470. * THE SOFTWARE.
  22471. */
  22472. function __export(m) {
  22473. for (var p in m) {
  22474. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  22475. }
  22476. }
  22477. Object.defineProperty(exports, "__esModule", { value: true });
  22478. __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab/component.ts"));
  22479. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab/constants.ts"));
  22480. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab/foundation.ts"));
  22481. /***/ }),
  22482. /***/ "./packages/mdc-textfield/character-counter/component.ts":
  22483. /*!***************************************************************!*\
  22484. !*** ./packages/mdc-textfield/character-counter/component.ts ***!
  22485. \***************************************************************/
  22486. /*! no static exports found */
  22487. /***/ (function(module, exports, __webpack_require__) {
  22488. "use strict";
  22489. /**
  22490. * @license
  22491. * Copyright 2019 Google Inc.
  22492. *
  22493. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22494. * of this software and associated documentation files (the "Software"), to deal
  22495. * in the Software without restriction, including without limitation the rights
  22496. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22497. * copies of the Software, and to permit persons to whom the Software is
  22498. * furnished to do so, subject to the following conditions:
  22499. *
  22500. * The above copyright notice and this permission notice shall be included in
  22501. * all copies or substantial portions of the Software.
  22502. *
  22503. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22504. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22505. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22506. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22507. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22508. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22509. * THE SOFTWARE.
  22510. */
  22511. var __extends = this && this.__extends || function () {
  22512. var _extendStatics = function extendStatics(d, b) {
  22513. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  22514. d.__proto__ = b;
  22515. } || function (d, b) {
  22516. for (var p in b) {
  22517. if (b.hasOwnProperty(p)) d[p] = b[p];
  22518. }
  22519. };
  22520. return _extendStatics(d, b);
  22521. };
  22522. return function (d, b) {
  22523. _extendStatics(d, b);
  22524. function __() {
  22525. this.constructor = d;
  22526. }
  22527. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22528. };
  22529. }();
  22530. Object.defineProperty(exports, "__esModule", { value: true });
  22531. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  22532. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/character-counter/foundation.ts");
  22533. var MDCTextFieldCharacterCounter = /** @class */function (_super) {
  22534. __extends(MDCTextFieldCharacterCounter, _super);
  22535. function MDCTextFieldCharacterCounter() {
  22536. return _super !== null && _super.apply(this, arguments) || this;
  22537. }
  22538. MDCTextFieldCharacterCounter.attachTo = function (root) {
  22539. return new MDCTextFieldCharacterCounter(root);
  22540. };
  22541. Object.defineProperty(MDCTextFieldCharacterCounter.prototype, "foundationForTextField", {
  22542. // Provided for access by MDCTextField component
  22543. get: function get() {
  22544. return this.foundation;
  22545. },
  22546. enumerable: true,
  22547. configurable: true
  22548. });
  22549. MDCTextFieldCharacterCounter.prototype.getDefaultFoundation = function () {
  22550. var _this = this;
  22551. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  22552. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  22553. var adapter = {
  22554. setContent: function setContent(content) {
  22555. _this.root.textContent = content;
  22556. }
  22557. };
  22558. return new foundation_1.MDCTextFieldCharacterCounterFoundation(adapter);
  22559. };
  22560. return MDCTextFieldCharacterCounter;
  22561. }(component_1.MDCComponent);
  22562. exports.MDCTextFieldCharacterCounter = MDCTextFieldCharacterCounter;
  22563. /***/ }),
  22564. /***/ "./packages/mdc-textfield/character-counter/constants.ts":
  22565. /*!***************************************************************!*\
  22566. !*** ./packages/mdc-textfield/character-counter/constants.ts ***!
  22567. \***************************************************************/
  22568. /*! no static exports found */
  22569. /***/ (function(module, exports, __webpack_require__) {
  22570. "use strict";
  22571. /**
  22572. * @license
  22573. * Copyright 2019 Google Inc.
  22574. *
  22575. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22576. * of this software and associated documentation files (the "Software"), to deal
  22577. * in the Software without restriction, including without limitation the rights
  22578. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22579. * copies of the Software, and to permit persons to whom the Software is
  22580. * furnished to do so, subject to the following conditions:
  22581. *
  22582. * The above copyright notice and this permission notice shall be included in
  22583. * all copies or substantial portions of the Software.
  22584. *
  22585. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22586. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22587. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22588. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22589. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22590. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22591. * THE SOFTWARE.
  22592. */
  22593. Object.defineProperty(exports, "__esModule", { value: true });
  22594. var cssClasses = {
  22595. ROOT: 'mdc-text-field-character-counter'
  22596. };
  22597. exports.cssClasses = cssClasses;
  22598. var strings = {
  22599. ROOT_SELECTOR: "." + cssClasses.ROOT
  22600. };
  22601. exports.strings = strings;
  22602. /***/ }),
  22603. /***/ "./packages/mdc-textfield/character-counter/foundation.ts":
  22604. /*!****************************************************************!*\
  22605. !*** ./packages/mdc-textfield/character-counter/foundation.ts ***!
  22606. \****************************************************************/
  22607. /*! no static exports found */
  22608. /***/ (function(module, exports, __webpack_require__) {
  22609. "use strict";
  22610. /**
  22611. * @license
  22612. * Copyright 2019 Google Inc.
  22613. *
  22614. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22615. * of this software and associated documentation files (the "Software"), to deal
  22616. * in the Software without restriction, including without limitation the rights
  22617. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22618. * copies of the Software, and to permit persons to whom the Software is
  22619. * furnished to do so, subject to the following conditions:
  22620. *
  22621. * The above copyright notice and this permission notice shall be included in
  22622. * all copies or substantial portions of the Software.
  22623. *
  22624. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22625. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22626. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22627. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22628. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22629. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22630. * THE SOFTWARE.
  22631. */
  22632. var __extends = this && this.__extends || function () {
  22633. var _extendStatics = function extendStatics(d, b) {
  22634. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  22635. d.__proto__ = b;
  22636. } || function (d, b) {
  22637. for (var p in b) {
  22638. if (b.hasOwnProperty(p)) d[p] = b[p];
  22639. }
  22640. };
  22641. return _extendStatics(d, b);
  22642. };
  22643. return function (d, b) {
  22644. _extendStatics(d, b);
  22645. function __() {
  22646. this.constructor = d;
  22647. }
  22648. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22649. };
  22650. }();
  22651. var __assign = this && this.__assign || function () {
  22652. __assign = Object.assign || function (t) {
  22653. for (var s, i = 1, n = arguments.length; i < n; i++) {
  22654. s = arguments[i];
  22655. for (var p in s) {
  22656. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  22657. }
  22658. }
  22659. return t;
  22660. };
  22661. return __assign.apply(this, arguments);
  22662. };
  22663. Object.defineProperty(exports, "__esModule", { value: true });
  22664. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  22665. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/character-counter/constants.ts");
  22666. var MDCTextFieldCharacterCounterFoundation = /** @class */function (_super) {
  22667. __extends(MDCTextFieldCharacterCounterFoundation, _super);
  22668. function MDCTextFieldCharacterCounterFoundation(adapter) {
  22669. return _super.call(this, __assign(__assign({}, MDCTextFieldCharacterCounterFoundation.defaultAdapter), adapter)) || this;
  22670. }
  22671. Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "cssClasses", {
  22672. get: function get() {
  22673. return constants_1.cssClasses;
  22674. },
  22675. enumerable: true,
  22676. configurable: true
  22677. });
  22678. Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "strings", {
  22679. get: function get() {
  22680. return constants_1.strings;
  22681. },
  22682. enumerable: true,
  22683. configurable: true
  22684. });
  22685. Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "defaultAdapter", {
  22686. /**
  22687. * See {@link MDCTextFieldCharacterCounterAdapter} for typing information on parameters and return types.
  22688. */
  22689. get: function get() {
  22690. return {
  22691. setContent: function setContent() {
  22692. return undefined;
  22693. }
  22694. };
  22695. },
  22696. enumerable: true,
  22697. configurable: true
  22698. });
  22699. MDCTextFieldCharacterCounterFoundation.prototype.setCounterValue = function (currentLength, maxLength) {
  22700. currentLength = Math.min(currentLength, maxLength);
  22701. this.adapter.setContent(currentLength + " / " + maxLength);
  22702. };
  22703. return MDCTextFieldCharacterCounterFoundation;
  22704. }(foundation_1.MDCFoundation);
  22705. exports.MDCTextFieldCharacterCounterFoundation = MDCTextFieldCharacterCounterFoundation;
  22706. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  22707. exports.default = MDCTextFieldCharacterCounterFoundation;
  22708. /***/ }),
  22709. /***/ "./packages/mdc-textfield/character-counter/index.ts":
  22710. /*!***********************************************************!*\
  22711. !*** ./packages/mdc-textfield/character-counter/index.ts ***!
  22712. \***********************************************************/
  22713. /*! no static exports found */
  22714. /***/ (function(module, exports, __webpack_require__) {
  22715. "use strict";
  22716. /**
  22717. * @license
  22718. * Copyright 2019 Google Inc.
  22719. *
  22720. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22721. * of this software and associated documentation files (the "Software"), to deal
  22722. * in the Software without restriction, including without limitation the rights
  22723. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22724. * copies of the Software, and to permit persons to whom the Software is
  22725. * furnished to do so, subject to the following conditions:
  22726. *
  22727. * The above copyright notice and this permission notice shall be included in
  22728. * all copies or substantial portions of the Software.
  22729. *
  22730. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22731. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22732. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22733. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22734. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22735. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22736. * THE SOFTWARE.
  22737. */
  22738. function __export(m) {
  22739. for (var p in m) {
  22740. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  22741. }
  22742. }
  22743. Object.defineProperty(exports, "__esModule", { value: true });
  22744. __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/character-counter/component.ts"));
  22745. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/character-counter/foundation.ts"));
  22746. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/character-counter/constants.ts");
  22747. exports.characterCountCssClasses = constants_1.cssClasses;
  22748. exports.characterCountStrings = constants_1.strings;
  22749. /***/ }),
  22750. /***/ "./packages/mdc-textfield/component.ts":
  22751. /*!*********************************************!*\
  22752. !*** ./packages/mdc-textfield/component.ts ***!
  22753. \*********************************************/
  22754. /*! no static exports found */
  22755. /***/ (function(module, exports, __webpack_require__) {
  22756. "use strict";
  22757. /**
  22758. * @license
  22759. * Copyright 2016 Google Inc.
  22760. *
  22761. * Permission is hereby granted, free of charge, to any person obtaining a copy
  22762. * of this software and associated documentation files (the "Software"), to deal
  22763. * in the Software without restriction, including without limitation the rights
  22764. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  22765. * copies of the Software, and to permit persons to whom the Software is
  22766. * furnished to do so, subject to the following conditions:
  22767. *
  22768. * The above copyright notice and this permission notice shall be included in
  22769. * all copies or substantial portions of the Software.
  22770. *
  22771. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  22772. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22773. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22774. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22775. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22776. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22777. * THE SOFTWARE.
  22778. */
  22779. var __extends = this && this.__extends || function () {
  22780. var _extendStatics = function extendStatics(d, b) {
  22781. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  22782. d.__proto__ = b;
  22783. } || function (d, b) {
  22784. for (var p in b) {
  22785. if (b.hasOwnProperty(p)) d[p] = b[p];
  22786. }
  22787. };
  22788. return _extendStatics(d, b);
  22789. };
  22790. return function (d, b) {
  22791. _extendStatics(d, b);
  22792. function __() {
  22793. this.constructor = d;
  22794. }
  22795. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  22796. };
  22797. }();
  22798. var __assign = this && this.__assign || function () {
  22799. __assign = Object.assign || function (t) {
  22800. for (var s, i = 1, n = arguments.length; i < n; i++) {
  22801. s = arguments[i];
  22802. for (var p in s) {
  22803. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  22804. }
  22805. }
  22806. return t;
  22807. };
  22808. return __assign.apply(this, arguments);
  22809. };
  22810. var __importStar = this && this.__importStar || function (mod) {
  22811. if (mod && mod.__esModule) return mod;
  22812. var result = {};
  22813. if (mod != null) for (var k in mod) {
  22814. if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  22815. }result["default"] = mod;
  22816. return result;
  22817. };
  22818. Object.defineProperty(exports, "__esModule", { value: true });
  22819. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  22820. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  22821. var ponyfill = __importStar(__webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts"));
  22822. var component_2 = __webpack_require__(/*! @material/floating-label/component */ "./packages/mdc-floating-label/component.ts");
  22823. var component_3 = __webpack_require__(/*! @material/line-ripple/component */ "./packages/mdc-line-ripple/component.ts");
  22824. var component_4 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
  22825. var component_5 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  22826. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  22827. var component_6 = __webpack_require__(/*! ./character-counter/component */ "./packages/mdc-textfield/character-counter/component.ts");
  22828. var foundation_2 = __webpack_require__(/*! ./character-counter/foundation */ "./packages/mdc-textfield/character-counter/foundation.ts");
  22829. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts");
  22830. var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/foundation.ts");
  22831. var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-textfield/helper-text/component.ts");
  22832. var foundation_4 = __webpack_require__(/*! ./helper-text/foundation */ "./packages/mdc-textfield/helper-text/foundation.ts");
  22833. var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-textfield/icon/component.ts");
  22834. var MDCTextField = /** @class */function (_super) {
  22835. __extends(MDCTextField, _super);
  22836. function MDCTextField() {
  22837. return _super !== null && _super.apply(this, arguments) || this;
  22838. }
  22839. MDCTextField.attachTo = function (root) {
  22840. return new MDCTextField(root);
  22841. };
  22842. MDCTextField.prototype.initialize = function (rippleFactory, lineRippleFactory, helperTextFactory, characterCounterFactory, iconFactory, labelFactory, outlineFactory) {
  22843. if (rippleFactory === void 0) {
  22844. rippleFactory = function rippleFactory(el, foundation) {
  22845. return new component_5.MDCRipple(el, foundation);
  22846. };
  22847. }
  22848. if (lineRippleFactory === void 0) {
  22849. lineRippleFactory = function lineRippleFactory(el) {
  22850. return new component_3.MDCLineRipple(el);
  22851. };
  22852. }
  22853. if (helperTextFactory === void 0) {
  22854. helperTextFactory = function helperTextFactory(el) {
  22855. return new component_7.MDCTextFieldHelperText(el);
  22856. };
  22857. }
  22858. if (characterCounterFactory === void 0) {
  22859. characterCounterFactory = function characterCounterFactory(el) {
  22860. return new component_6.MDCTextFieldCharacterCounter(el);
  22861. };
  22862. }
  22863. if (iconFactory === void 0) {
  22864. iconFactory = function iconFactory(el) {
  22865. return new component_8.MDCTextFieldIcon(el);
  22866. };
  22867. }
  22868. if (labelFactory === void 0) {
  22869. labelFactory = function labelFactory(el) {
  22870. return new component_2.MDCFloatingLabel(el);
  22871. };
  22872. }
  22873. if (outlineFactory === void 0) {
  22874. outlineFactory = function outlineFactory(el) {
  22875. return new component_4.MDCNotchedOutline(el);
  22876. };
  22877. }
  22878. this.input_ = this.root.querySelector(constants_1.strings.INPUT_SELECTOR);
  22879. var labelElement = this.root.querySelector(constants_1.strings.LABEL_SELECTOR);
  22880. this.label_ = labelElement ? labelFactory(labelElement) : null;
  22881. var lineRippleElement = this.root.querySelector(constants_1.strings.LINE_RIPPLE_SELECTOR);
  22882. this.lineRipple_ = lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
  22883. var outlineElement = this.root.querySelector(constants_1.strings.OUTLINE_SELECTOR);
  22884. this.outline_ = outlineElement ? outlineFactory(outlineElement) : null;
  22885. // Helper text
  22886. var helperTextStrings = foundation_4.MDCTextFieldHelperTextFoundation.strings;
  22887. var nextElementSibling = this.root.nextElementSibling;
  22888. var hasHelperLine = nextElementSibling && nextElementSibling.classList.contains(constants_1.cssClasses.HELPER_LINE);
  22889. var helperTextEl = hasHelperLine && nextElementSibling && nextElementSibling.querySelector(helperTextStrings.ROOT_SELECTOR);
  22890. this.helperText_ = helperTextEl ? helperTextFactory(helperTextEl) : null;
  22891. // Character counter
  22892. var characterCounterStrings = foundation_2.MDCTextFieldCharacterCounterFoundation.strings;
  22893. var characterCounterEl = this.root.querySelector(characterCounterStrings.ROOT_SELECTOR);
  22894. // If character counter is not found in root element search in sibling element.
  22895. if (!characterCounterEl && hasHelperLine && nextElementSibling) {
  22896. characterCounterEl = nextElementSibling.querySelector(characterCounterStrings.ROOT_SELECTOR);
  22897. }
  22898. this.characterCounter_ = characterCounterEl ? characterCounterFactory(characterCounterEl) : null;
  22899. // Leading icon
  22900. var leadingIconEl = this.root.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
  22901. this.leadingIcon_ = leadingIconEl ? iconFactory(leadingIconEl) : null;
  22902. // Trailing icon
  22903. var trailingIconEl = this.root.querySelector(constants_1.strings.TRAILING_ICON_SELECTOR);
  22904. this.trailingIcon_ = trailingIconEl ? iconFactory(trailingIconEl) : null;
  22905. // Prefix and Suffix
  22906. this.prefix_ = this.root.querySelector(constants_1.strings.PREFIX_SELECTOR);
  22907. this.suffix_ = this.root.querySelector(constants_1.strings.SUFFIX_SELECTOR);
  22908. this.ripple = this.createRipple_(rippleFactory);
  22909. };
  22910. MDCTextField.prototype.destroy = function () {
  22911. if (this.ripple) {
  22912. this.ripple.destroy();
  22913. }
  22914. if (this.lineRipple_) {
  22915. this.lineRipple_.destroy();
  22916. }
  22917. if (this.helperText_) {
  22918. this.helperText_.destroy();
  22919. }
  22920. if (this.characterCounter_) {
  22921. this.characterCounter_.destroy();
  22922. }
  22923. if (this.leadingIcon_) {
  22924. this.leadingIcon_.destroy();
  22925. }
  22926. if (this.trailingIcon_) {
  22927. this.trailingIcon_.destroy();
  22928. }
  22929. if (this.label_) {
  22930. this.label_.destroy();
  22931. }
  22932. if (this.outline_) {
  22933. this.outline_.destroy();
  22934. }
  22935. _super.prototype.destroy.call(this);
  22936. };
  22937. /**
  22938. * Initializes the Text Field's internal state based on the environment's
  22939. * state.
  22940. */
  22941. MDCTextField.prototype.initialSyncWithDOM = function () {
  22942. this.disabled = this.input_.disabled;
  22943. };
  22944. Object.defineProperty(MDCTextField.prototype, "value", {
  22945. get: function get() {
  22946. return this.foundation.getValue();
  22947. },
  22948. /**
  22949. * @param value The value to set on the input.
  22950. */
  22951. set: function set(value) {
  22952. this.foundation.setValue(value);
  22953. },
  22954. enumerable: true,
  22955. configurable: true
  22956. });
  22957. Object.defineProperty(MDCTextField.prototype, "disabled", {
  22958. get: function get() {
  22959. return this.foundation.isDisabled();
  22960. },
  22961. /**
  22962. * @param disabled Sets the Text Field disabled or enabled.
  22963. */
  22964. set: function set(disabled) {
  22965. this.foundation.setDisabled(disabled);
  22966. },
  22967. enumerable: true,
  22968. configurable: true
  22969. });
  22970. Object.defineProperty(MDCTextField.prototype, "valid", {
  22971. get: function get() {
  22972. return this.foundation.isValid();
  22973. },
  22974. /**
  22975. * @param valid Sets the Text Field valid or invalid.
  22976. */
  22977. set: function set(valid) {
  22978. this.foundation.setValid(valid);
  22979. },
  22980. enumerable: true,
  22981. configurable: true
  22982. });
  22983. Object.defineProperty(MDCTextField.prototype, "required", {
  22984. get: function get() {
  22985. return this.input_.required;
  22986. },
  22987. /**
  22988. * @param required Sets the Text Field to required.
  22989. */
  22990. set: function set(required) {
  22991. this.input_.required = required;
  22992. },
  22993. enumerable: true,
  22994. configurable: true
  22995. });
  22996. Object.defineProperty(MDCTextField.prototype, "pattern", {
  22997. get: function get() {
  22998. return this.input_.pattern;
  22999. },
  23000. /**
  23001. * @param pattern Sets the input element's validation pattern.
  23002. */
  23003. set: function set(pattern) {
  23004. this.input_.pattern = pattern;
  23005. },
  23006. enumerable: true,
  23007. configurable: true
  23008. });
  23009. Object.defineProperty(MDCTextField.prototype, "minLength", {
  23010. get: function get() {
  23011. return this.input_.minLength;
  23012. },
  23013. /**
  23014. * @param minLength Sets the input element's minLength.
  23015. */
  23016. set: function set(minLength) {
  23017. this.input_.minLength = minLength;
  23018. },
  23019. enumerable: true,
  23020. configurable: true
  23021. });
  23022. Object.defineProperty(MDCTextField.prototype, "maxLength", {
  23023. get: function get() {
  23024. return this.input_.maxLength;
  23025. },
  23026. /**
  23027. * @param maxLength Sets the input element's maxLength.
  23028. */
  23029. set: function set(maxLength) {
  23030. // Chrome throws exception if maxLength is set to a value less than zero
  23031. if (maxLength < 0) {
  23032. this.input_.removeAttribute('maxLength');
  23033. } else {
  23034. this.input_.maxLength = maxLength;
  23035. }
  23036. },
  23037. enumerable: true,
  23038. configurable: true
  23039. });
  23040. Object.defineProperty(MDCTextField.prototype, "min", {
  23041. get: function get() {
  23042. return this.input_.min;
  23043. },
  23044. /**
  23045. * @param min Sets the input element's min.
  23046. */
  23047. set: function set(min) {
  23048. this.input_.min = min;
  23049. },
  23050. enumerable: true,
  23051. configurable: true
  23052. });
  23053. Object.defineProperty(MDCTextField.prototype, "max", {
  23054. get: function get() {
  23055. return this.input_.max;
  23056. },
  23057. /**
  23058. * @param max Sets the input element's max.
  23059. */
  23060. set: function set(max) {
  23061. this.input_.max = max;
  23062. },
  23063. enumerable: true,
  23064. configurable: true
  23065. });
  23066. Object.defineProperty(MDCTextField.prototype, "step", {
  23067. get: function get() {
  23068. return this.input_.step;
  23069. },
  23070. /**
  23071. * @param step Sets the input element's step.
  23072. */
  23073. set: function set(step) {
  23074. this.input_.step = step;
  23075. },
  23076. enumerable: true,
  23077. configurable: true
  23078. });
  23079. Object.defineProperty(MDCTextField.prototype, "helperTextContent", {
  23080. /**
  23081. * Sets the helper text element content.
  23082. */
  23083. set: function set(content) {
  23084. this.foundation.setHelperTextContent(content);
  23085. },
  23086. enumerable: true,
  23087. configurable: true
  23088. });
  23089. Object.defineProperty(MDCTextField.prototype, "leadingIconAriaLabel", {
  23090. /**
  23091. * Sets the aria label of the leading icon.
  23092. */
  23093. set: function set(label) {
  23094. this.foundation.setLeadingIconAriaLabel(label);
  23095. },
  23096. enumerable: true,
  23097. configurable: true
  23098. });
  23099. Object.defineProperty(MDCTextField.prototype, "leadingIconContent", {
  23100. /**
  23101. * Sets the text content of the leading icon.
  23102. */
  23103. set: function set(content) {
  23104. this.foundation.setLeadingIconContent(content);
  23105. },
  23106. enumerable: true,
  23107. configurable: true
  23108. });
  23109. Object.defineProperty(MDCTextField.prototype, "trailingIconAriaLabel", {
  23110. /**
  23111. * Sets the aria label of the trailing icon.
  23112. */
  23113. set: function set(label) {
  23114. this.foundation.setTrailingIconAriaLabel(label);
  23115. },
  23116. enumerable: true,
  23117. configurable: true
  23118. });
  23119. Object.defineProperty(MDCTextField.prototype, "trailingIconContent", {
  23120. /**
  23121. * Sets the text content of the trailing icon.
  23122. */
  23123. set: function set(content) {
  23124. this.foundation.setTrailingIconContent(content);
  23125. },
  23126. enumerable: true,
  23127. configurable: true
  23128. });
  23129. Object.defineProperty(MDCTextField.prototype, "useNativeValidation", {
  23130. /**
  23131. * Enables or disables the use of native validation. Use this for custom validation.
  23132. * @param useNativeValidation Set this to false to ignore native input validation.
  23133. */
  23134. set: function set(useNativeValidation) {
  23135. this.foundation.setUseNativeValidation(useNativeValidation);
  23136. },
  23137. enumerable: true,
  23138. configurable: true
  23139. });
  23140. Object.defineProperty(MDCTextField.prototype, "prefixText", {
  23141. /**
  23142. * Gets the text content of the prefix, or null if it does not exist.
  23143. */
  23144. get: function get() {
  23145. return this.prefix_ ? this.prefix_.textContent : null;
  23146. },
  23147. /**
  23148. * Sets the text content of the prefix, if it exists.
  23149. */
  23150. set: function set(prefixText) {
  23151. if (this.prefix_) {
  23152. this.prefix_.textContent = prefixText;
  23153. }
  23154. },
  23155. enumerable: true,
  23156. configurable: true
  23157. });
  23158. Object.defineProperty(MDCTextField.prototype, "suffixText", {
  23159. /**
  23160. * Gets the text content of the suffix, or null if it does not exist.
  23161. */
  23162. get: function get() {
  23163. return this.suffix_ ? this.suffix_.textContent : null;
  23164. },
  23165. /**
  23166. * Sets the text content of the suffix, if it exists.
  23167. */
  23168. set: function set(suffixText) {
  23169. if (this.suffix_) {
  23170. this.suffix_.textContent = suffixText;
  23171. }
  23172. },
  23173. enumerable: true,
  23174. configurable: true
  23175. });
  23176. /**
  23177. * Focuses the input element.
  23178. */
  23179. MDCTextField.prototype.focus = function () {
  23180. this.input_.focus();
  23181. };
  23182. /**
  23183. * Recomputes the outline SVG path for the outline element.
  23184. */
  23185. MDCTextField.prototype.layout = function () {
  23186. var openNotch = this.foundation.shouldFloat;
  23187. this.foundation.notchOutline(openNotch);
  23188. };
  23189. MDCTextField.prototype.getDefaultFoundation = function () {
  23190. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  23191. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  23192. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  23193. var adapter = __assign(__assign(__assign(__assign(__assign({}, this.getRootAdapterMethods_()), this.getInputAdapterMethods_()), this.getLabelAdapterMethods_()), this.getLineRippleAdapterMethods_()), this.getOutlineAdapterMethods_());
  23194. // tslint:enable:object-literal-sort-keys
  23195. return new foundation_3.MDCTextFieldFoundation(adapter, this.getFoundationMap_());
  23196. };
  23197. MDCTextField.prototype.getRootAdapterMethods_ = function () {
  23198. var _this = this;
  23199. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  23200. return {
  23201. addClass: function addClass(className) {
  23202. return _this.root.classList.add(className);
  23203. },
  23204. removeClass: function removeClass(className) {
  23205. return _this.root.classList.remove(className);
  23206. },
  23207. hasClass: function hasClass(className) {
  23208. return _this.root.classList.contains(className);
  23209. },
  23210. registerTextFieldInteractionHandler: function registerTextFieldInteractionHandler(evtType, handler) {
  23211. _this.listen(evtType, handler);
  23212. },
  23213. deregisterTextFieldInteractionHandler: function deregisterTextFieldInteractionHandler(evtType, handler) {
  23214. _this.unlisten(evtType, handler);
  23215. },
  23216. registerValidationAttributeChangeHandler: function registerValidationAttributeChangeHandler(handler) {
  23217. var getAttributesList = function getAttributesList(mutationsList) {
  23218. return mutationsList.map(function (mutation) {
  23219. return mutation.attributeName;
  23220. }).filter(function (attributeName) {
  23221. return attributeName;
  23222. });
  23223. };
  23224. var observer = new MutationObserver(function (mutationsList) {
  23225. return handler(getAttributesList(mutationsList));
  23226. });
  23227. var config = { attributes: true };
  23228. observer.observe(_this.input_, config);
  23229. return observer;
  23230. },
  23231. deregisterValidationAttributeChangeHandler: function deregisterValidationAttributeChangeHandler(observer) {
  23232. observer.disconnect();
  23233. }
  23234. };
  23235. // tslint:enable:object-literal-sort-keys
  23236. };
  23237. MDCTextField.prototype.getInputAdapterMethods_ = function () {
  23238. var _this = this;
  23239. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  23240. return {
  23241. getNativeInput: function getNativeInput() {
  23242. return _this.input_;
  23243. },
  23244. setInputAttr: function setInputAttr(attr, value) {
  23245. _this.input_.setAttribute(attr, value);
  23246. },
  23247. removeInputAttr: function removeInputAttr(attr) {
  23248. _this.input_.removeAttribute(attr);
  23249. },
  23250. isFocused: function isFocused() {
  23251. return document.activeElement === _this.input_;
  23252. },
  23253. registerInputInteractionHandler: function registerInputInteractionHandler(evtType, handler) {
  23254. _this.input_.addEventListener(evtType, handler, events_1.applyPassive());
  23255. },
  23256. deregisterInputInteractionHandler: function deregisterInputInteractionHandler(evtType, handler) {
  23257. _this.input_.removeEventListener(evtType, handler, events_1.applyPassive());
  23258. }
  23259. };
  23260. // tslint:enable:object-literal-sort-keys
  23261. };
  23262. MDCTextField.prototype.getLabelAdapterMethods_ = function () {
  23263. var _this = this;
  23264. return {
  23265. floatLabel: function floatLabel(shouldFloat) {
  23266. return _this.label_ && _this.label_.float(shouldFloat);
  23267. },
  23268. getLabelWidth: function getLabelWidth() {
  23269. return _this.label_ ? _this.label_.getWidth() : 0;
  23270. },
  23271. hasLabel: function hasLabel() {
  23272. return Boolean(_this.label_);
  23273. },
  23274. shakeLabel: function shakeLabel(shouldShake) {
  23275. return _this.label_ && _this.label_.shake(shouldShake);
  23276. },
  23277. setLabelRequired: function setLabelRequired(isRequired) {
  23278. return _this.label_ && _this.label_.setRequired(isRequired);
  23279. }
  23280. };
  23281. };
  23282. MDCTextField.prototype.getLineRippleAdapterMethods_ = function () {
  23283. var _this = this;
  23284. return {
  23285. activateLineRipple: function activateLineRipple() {
  23286. if (_this.lineRipple_) {
  23287. _this.lineRipple_.activate();
  23288. }
  23289. },
  23290. deactivateLineRipple: function deactivateLineRipple() {
  23291. if (_this.lineRipple_) {
  23292. _this.lineRipple_.deactivate();
  23293. }
  23294. },
  23295. setLineRippleTransformOrigin: function setLineRippleTransformOrigin(normalizedX) {
  23296. if (_this.lineRipple_) {
  23297. _this.lineRipple_.setRippleCenter(normalizedX);
  23298. }
  23299. }
  23300. };
  23301. };
  23302. MDCTextField.prototype.getOutlineAdapterMethods_ = function () {
  23303. var _this = this;
  23304. return {
  23305. closeOutline: function closeOutline() {
  23306. return _this.outline_ && _this.outline_.closeNotch();
  23307. },
  23308. hasOutline: function hasOutline() {
  23309. return Boolean(_this.outline_);
  23310. },
  23311. notchOutline: function notchOutline(labelWidth) {
  23312. return _this.outline_ && _this.outline_.notch(labelWidth);
  23313. }
  23314. };
  23315. };
  23316. /**
  23317. * @return A map of all subcomponents to subfoundations.
  23318. */
  23319. MDCTextField.prototype.getFoundationMap_ = function () {
  23320. return {
  23321. characterCounter: this.characterCounter_ ? this.characterCounter_.foundationForTextField : undefined,
  23322. helperText: this.helperText_ ? this.helperText_.foundationForTextField : undefined,
  23323. leadingIcon: this.leadingIcon_ ? this.leadingIcon_.foundationForTextField : undefined,
  23324. trailingIcon: this.trailingIcon_ ? this.trailingIcon_.foundationForTextField : undefined
  23325. };
  23326. };
  23327. MDCTextField.prototype.createRipple_ = function (rippleFactory) {
  23328. var _this = this;
  23329. var isTextArea = this.root.classList.contains(constants_1.cssClasses.TEXTAREA);
  23330. var isOutlined = this.root.classList.contains(constants_1.cssClasses.OUTLINED);
  23331. if (isTextArea || isOutlined) {
  23332. return null;
  23333. }
  23334. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  23335. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  23336. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  23337. var adapter = __assign(__assign({}, component_5.MDCRipple.createAdapter(this)), { isSurfaceActive: function isSurfaceActive() {
  23338. return ponyfill.matches(_this.input_, ':active');
  23339. }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  23340. return _this.input_.addEventListener(evtType, handler, events_1.applyPassive());
  23341. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  23342. return _this.input_.removeEventListener(evtType, handler, events_1.applyPassive());
  23343. } });
  23344. // tslint:enable:object-literal-sort-keys
  23345. return rippleFactory(this.root, new foundation_1.MDCRippleFoundation(adapter));
  23346. };
  23347. return MDCTextField;
  23348. }(component_1.MDCComponent);
  23349. exports.MDCTextField = MDCTextField;
  23350. /***/ }),
  23351. /***/ "./packages/mdc-textfield/constants.ts":
  23352. /*!*********************************************!*\
  23353. !*** ./packages/mdc-textfield/constants.ts ***!
  23354. \*********************************************/
  23355. /*! no static exports found */
  23356. /***/ (function(module, exports, __webpack_require__) {
  23357. "use strict";
  23358. /**
  23359. * @license
  23360. * Copyright 2016 Google Inc.
  23361. *
  23362. * Permission is hereby granted, free of charge, to any person obtaining a copy
  23363. * of this software and associated documentation files (the "Software"), to deal
  23364. * in the Software without restriction, including without limitation the rights
  23365. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  23366. * copies of the Software, and to permit persons to whom the Software is
  23367. * furnished to do so, subject to the following conditions:
  23368. *
  23369. * The above copyright notice and this permission notice shall be included in
  23370. * all copies or substantial portions of the Software.
  23371. *
  23372. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23373. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23374. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  23375. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23376. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23377. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23378. * THE SOFTWARE.
  23379. */
  23380. Object.defineProperty(exports, "__esModule", { value: true });
  23381. var strings = {
  23382. ARIA_CONTROLS: 'aria-controls',
  23383. ARIA_DESCRIBEDBY: 'aria-describedby',
  23384. INPUT_SELECTOR: '.mdc-text-field__input',
  23385. LABEL_SELECTOR: '.mdc-floating-label',
  23386. LEADING_ICON_SELECTOR: '.mdc-text-field__icon--leading',
  23387. LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
  23388. OUTLINE_SELECTOR: '.mdc-notched-outline',
  23389. PREFIX_SELECTOR: '.mdc-text-field__affix--prefix',
  23390. SUFFIX_SELECTOR: '.mdc-text-field__affix--suffix',
  23391. TRAILING_ICON_SELECTOR: '.mdc-text-field__icon--trailing'
  23392. };
  23393. exports.strings = strings;
  23394. var cssClasses = {
  23395. DISABLED: 'mdc-text-field--disabled',
  23396. FOCUSED: 'mdc-text-field--focused',
  23397. HELPER_LINE: 'mdc-text-field-helper-line',
  23398. INVALID: 'mdc-text-field--invalid',
  23399. LABEL_FLOATING: 'mdc-text-field--label-floating',
  23400. NO_LABEL: 'mdc-text-field--no-label',
  23401. OUTLINED: 'mdc-text-field--outlined',
  23402. ROOT: 'mdc-text-field',
  23403. TEXTAREA: 'mdc-text-field--textarea',
  23404. WITH_LEADING_ICON: 'mdc-text-field--with-leading-icon',
  23405. WITH_TRAILING_ICON: 'mdc-text-field--with-trailing-icon'
  23406. };
  23407. exports.cssClasses = cssClasses;
  23408. var numbers = {
  23409. LABEL_SCALE: 0.75
  23410. };
  23411. exports.numbers = numbers;
  23412. /**
  23413. * Whitelist based off of https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation
  23414. * under the "Validation-related attributes" section.
  23415. */
  23416. var VALIDATION_ATTR_WHITELIST = ['pattern', 'min', 'max', 'required', 'step', 'minlength', 'maxlength'];
  23417. exports.VALIDATION_ATTR_WHITELIST = VALIDATION_ATTR_WHITELIST;
  23418. /**
  23419. * Label should always float for these types as they show some UI even if value is empty.
  23420. */
  23421. var ALWAYS_FLOAT_TYPES = ['color', 'date', 'datetime-local', 'month', 'range', 'time', 'week'];
  23422. exports.ALWAYS_FLOAT_TYPES = ALWAYS_FLOAT_TYPES;
  23423. /***/ }),
  23424. /***/ "./packages/mdc-textfield/foundation.ts":
  23425. /*!**********************************************!*\
  23426. !*** ./packages/mdc-textfield/foundation.ts ***!
  23427. \**********************************************/
  23428. /*! no static exports found */
  23429. /***/ (function(module, exports, __webpack_require__) {
  23430. "use strict";
  23431. /**
  23432. * @license
  23433. * Copyright 2016 Google Inc.
  23434. *
  23435. * Permission is hereby granted, free of charge, to any person obtaining a copy
  23436. * of this software and associated documentation files (the "Software"), to deal
  23437. * in the Software without restriction, including without limitation the rights
  23438. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  23439. * copies of the Software, and to permit persons to whom the Software is
  23440. * furnished to do so, subject to the following conditions:
  23441. *
  23442. * The above copyright notice and this permission notice shall be included in
  23443. * all copies or substantial portions of the Software.
  23444. *
  23445. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23446. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  23447. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  23448. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23449. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23450. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23451. * THE SOFTWARE.
  23452. */
  23453. var __extends = this && this.__extends || function () {
  23454. var _extendStatics = function extendStatics(d, b) {
  23455. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  23456. d.__proto__ = b;
  23457. } || function (d, b) {
  23458. for (var p in b) {
  23459. if (b.hasOwnProperty(p)) d[p] = b[p];
  23460. }
  23461. };
  23462. return _extendStatics(d, b);
  23463. };
  23464. return function (d, b) {
  23465. _extendStatics(d, b);
  23466. function __() {
  23467. this.constructor = d;
  23468. }
  23469. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  23470. };
  23471. }();
  23472. var __assign = this && this.__assign || function () {
  23473. __assign = Object.assign || function (t) {
  23474. for (var s, i = 1, n = arguments.length; i < n; i++) {
  23475. s = arguments[i];
  23476. for (var p in s) {
  23477. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  23478. }
  23479. }
  23480. return t;
  23481. };
  23482. return __assign.apply(this, arguments);
  23483. };
  23484. Object.defineProperty(exports, "__esModule", { value: true });
  23485. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  23486. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts");
  23487. var POINTERDOWN_EVENTS = ['mousedown', 'touchstart'];
  23488. var INTERACTION_EVENTS = ['click', 'keydown'];
  23489. var MDCTextFieldFoundation = /** @class */function (_super) {
  23490. __extends(MDCTextFieldFoundation, _super);
  23491. /**
  23492. * @param adapter
  23493. * @param foundationMap Map from subcomponent names to their subfoundations.
  23494. */
  23495. function MDCTextFieldFoundation(adapter, foundationMap) {
  23496. if (foundationMap === void 0) {
  23497. foundationMap = {};
  23498. }
  23499. var _this = _super.call(this, __assign(__assign({}, MDCTextFieldFoundation.defaultAdapter), adapter)) || this;
  23500. _this.isFocused_ = false;
  23501. _this.receivedUserInput_ = false;
  23502. _this.isValid_ = true;
  23503. _this.useNativeValidation_ = true;
  23504. _this.validateOnValueChange_ = true;
  23505. _this.helperText_ = foundationMap.helperText;
  23506. _this.characterCounter_ = foundationMap.characterCounter;
  23507. _this.leadingIcon_ = foundationMap.leadingIcon;
  23508. _this.trailingIcon_ = foundationMap.trailingIcon;
  23509. _this.inputFocusHandler_ = function () {
  23510. return _this.activateFocus();
  23511. };
  23512. _this.inputBlurHandler_ = function () {
  23513. return _this.deactivateFocus();
  23514. };
  23515. _this.inputInputHandler_ = function () {
  23516. return _this.handleInput();
  23517. };
  23518. _this.setPointerXOffset_ = function (evt) {
  23519. return _this.setTransformOrigin(evt);
  23520. };
  23521. _this.textFieldInteractionHandler_ = function () {
  23522. return _this.handleTextFieldInteraction();
  23523. };
  23524. _this.validationAttributeChangeHandler_ = function (attributesList) {
  23525. return _this.handleValidationAttributeChange(attributesList);
  23526. };
  23527. return _this;
  23528. }
  23529. Object.defineProperty(MDCTextFieldFoundation, "cssClasses", {
  23530. get: function get() {
  23531. return constants_1.cssClasses;
  23532. },
  23533. enumerable: true,
  23534. configurable: true
  23535. });
  23536. Object.defineProperty(MDCTextFieldFoundation, "strings", {
  23537. get: function get() {
  23538. return constants_1.strings;
  23539. },
  23540. enumerable: true,
  23541. configurable: true
  23542. });
  23543. Object.defineProperty(MDCTextFieldFoundation, "numbers", {
  23544. get: function get() {
  23545. return constants_1.numbers;
  23546. },
  23547. enumerable: true,
  23548. configurable: true
  23549. });
  23550. Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldAlwaysFloat_", {
  23551. get: function get() {
  23552. var type = this.getNativeInput_().type;
  23553. return constants_1.ALWAYS_FLOAT_TYPES.indexOf(type) >= 0;
  23554. },
  23555. enumerable: true,
  23556. configurable: true
  23557. });
  23558. Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldFloat", {
  23559. get: function get() {
  23560. return this.shouldAlwaysFloat_ || this.isFocused_ || !!this.getValue() || this.isBadInput_();
  23561. },
  23562. enumerable: true,
  23563. configurable: true
  23564. });
  23565. Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldShake", {
  23566. get: function get() {
  23567. return !this.isFocused_ && !this.isValid() && !!this.getValue();
  23568. },
  23569. enumerable: true,
  23570. configurable: true
  23571. });
  23572. Object.defineProperty(MDCTextFieldFoundation, "defaultAdapter", {
  23573. /**
  23574. * See {@link MDCTextFieldAdapter} for typing information on parameters and
  23575. * return types.
  23576. */
  23577. get: function get() {
  23578. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  23579. return {
  23580. addClass: function addClass() {
  23581. return undefined;
  23582. },
  23583. removeClass: function removeClass() {
  23584. return undefined;
  23585. },
  23586. hasClass: function hasClass() {
  23587. return true;
  23588. },
  23589. setInputAttr: function setInputAttr() {
  23590. return undefined;
  23591. },
  23592. removeInputAttr: function removeInputAttr() {
  23593. return undefined;
  23594. },
  23595. registerTextFieldInteractionHandler: function registerTextFieldInteractionHandler() {
  23596. return undefined;
  23597. },
  23598. deregisterTextFieldInteractionHandler: function deregisterTextFieldInteractionHandler() {
  23599. return undefined;
  23600. },
  23601. registerInputInteractionHandler: function registerInputInteractionHandler() {
  23602. return undefined;
  23603. },
  23604. deregisterInputInteractionHandler: function deregisterInputInteractionHandler() {
  23605. return undefined;
  23606. },
  23607. registerValidationAttributeChangeHandler: function registerValidationAttributeChangeHandler() {
  23608. return new MutationObserver(function () {
  23609. return undefined;
  23610. });
  23611. },
  23612. deregisterValidationAttributeChangeHandler: function deregisterValidationAttributeChangeHandler() {
  23613. return undefined;
  23614. },
  23615. getNativeInput: function getNativeInput() {
  23616. return null;
  23617. },
  23618. isFocused: function isFocused() {
  23619. return false;
  23620. },
  23621. activateLineRipple: function activateLineRipple() {
  23622. return undefined;
  23623. },
  23624. deactivateLineRipple: function deactivateLineRipple() {
  23625. return undefined;
  23626. },
  23627. setLineRippleTransformOrigin: function setLineRippleTransformOrigin() {
  23628. return undefined;
  23629. },
  23630. shakeLabel: function shakeLabel() {
  23631. return undefined;
  23632. },
  23633. floatLabel: function floatLabel() {
  23634. return undefined;
  23635. },
  23636. setLabelRequired: function setLabelRequired() {
  23637. return undefined;
  23638. },
  23639. hasLabel: function hasLabel() {
  23640. return false;
  23641. },
  23642. getLabelWidth: function getLabelWidth() {
  23643. return 0;
  23644. },
  23645. hasOutline: function hasOutline() {
  23646. return false;
  23647. },
  23648. notchOutline: function notchOutline() {
  23649. return undefined;
  23650. },
  23651. closeOutline: function closeOutline() {
  23652. return undefined;
  23653. }
  23654. };
  23655. // tslint:enable:object-literal-sort-keys
  23656. },
  23657. enumerable: true,
  23658. configurable: true
  23659. });
  23660. MDCTextFieldFoundation.prototype.init = function () {
  23661. var _this = this;
  23662. if (this.adapter.hasLabel() && this.getNativeInput_().required) {
  23663. this.adapter.setLabelRequired(true);
  23664. }
  23665. if (this.adapter.isFocused()) {
  23666. this.inputFocusHandler_();
  23667. } else if (this.adapter.hasLabel() && this.shouldFloat) {
  23668. this.notchOutline(true);
  23669. this.adapter.floatLabel(true);
  23670. this.styleFloating_(true);
  23671. }
  23672. this.adapter.registerInputInteractionHandler('focus', this.inputFocusHandler_);
  23673. this.adapter.registerInputInteractionHandler('blur', this.inputBlurHandler_);
  23674. this.adapter.registerInputInteractionHandler('input', this.inputInputHandler_);
  23675. POINTERDOWN_EVENTS.forEach(function (evtType) {
  23676. _this.adapter.registerInputInteractionHandler(evtType, _this.setPointerXOffset_);
  23677. });
  23678. INTERACTION_EVENTS.forEach(function (evtType) {
  23679. _this.adapter.registerTextFieldInteractionHandler(evtType, _this.textFieldInteractionHandler_);
  23680. });
  23681. this.validationObserver_ = this.adapter.registerValidationAttributeChangeHandler(this.validationAttributeChangeHandler_);
  23682. this.setCharacterCounter_(this.getValue().length);
  23683. };
  23684. MDCTextFieldFoundation.prototype.destroy = function () {
  23685. var _this = this;
  23686. this.adapter.deregisterInputInteractionHandler('focus', this.inputFocusHandler_);
  23687. this.adapter.deregisterInputInteractionHandler('blur', this.inputBlurHandler_);
  23688. this.adapter.deregisterInputInteractionHandler('input', this.inputInputHandler_);
  23689. POINTERDOWN_EVENTS.forEach(function (evtType) {
  23690. _this.adapter.deregisterInputInteractionHandler(evtType, _this.setPointerXOffset_);
  23691. });
  23692. INTERACTION_EVENTS.forEach(function (evtType) {
  23693. _this.adapter.deregisterTextFieldInteractionHandler(evtType, _this.textFieldInteractionHandler_);
  23694. });
  23695. this.adapter.deregisterValidationAttributeChangeHandler(this.validationObserver_);
  23696. };
  23697. /**
  23698. * Handles user interactions with the Text Field.
  23699. */
  23700. MDCTextFieldFoundation.prototype.handleTextFieldInteraction = function () {
  23701. var nativeInput = this.adapter.getNativeInput();
  23702. if (nativeInput && nativeInput.disabled) {
  23703. return;
  23704. }
  23705. this.receivedUserInput_ = true;
  23706. };
  23707. /**
  23708. * Handles validation attribute changes
  23709. */
  23710. MDCTextFieldFoundation.prototype.handleValidationAttributeChange = function (attributesList) {
  23711. var _this = this;
  23712. attributesList.some(function (attributeName) {
  23713. if (constants_1.VALIDATION_ATTR_WHITELIST.indexOf(attributeName) > -1) {
  23714. _this.styleValidity_(true);
  23715. _this.adapter.setLabelRequired(_this.getNativeInput_().required);
  23716. return true;
  23717. }
  23718. return false;
  23719. });
  23720. if (attributesList.indexOf('maxlength') > -1) {
  23721. this.setCharacterCounter_(this.getValue().length);
  23722. }
  23723. };
  23724. /**
  23725. * Opens/closes the notched outline.
  23726. */
  23727. MDCTextFieldFoundation.prototype.notchOutline = function (openNotch) {
  23728. if (!this.adapter.hasOutline() || !this.adapter.hasLabel()) {
  23729. return;
  23730. }
  23731. if (openNotch) {
  23732. var labelWidth = this.adapter.getLabelWidth() * constants_1.numbers.LABEL_SCALE;
  23733. this.adapter.notchOutline(labelWidth);
  23734. } else {
  23735. this.adapter.closeOutline();
  23736. }
  23737. };
  23738. /**
  23739. * Activates the text field focus state.
  23740. */
  23741. MDCTextFieldFoundation.prototype.activateFocus = function () {
  23742. this.isFocused_ = true;
  23743. this.styleFocused_(this.isFocused_);
  23744. this.adapter.activateLineRipple();
  23745. if (this.adapter.hasLabel()) {
  23746. this.notchOutline(this.shouldFloat);
  23747. this.adapter.floatLabel(this.shouldFloat);
  23748. this.styleFloating_(this.shouldFloat);
  23749. this.adapter.shakeLabel(this.shouldShake);
  23750. }
  23751. if (this.helperText_ && (this.helperText_.isPersistent() || !this.helperText_.isValidation() || !this.isValid_)) {
  23752. this.helperText_.showToScreenReader();
  23753. }
  23754. };
  23755. /**
  23756. * Sets the line ripple's transform origin, so that the line ripple activate
  23757. * animation will animate out from the user's click location.
  23758. */
  23759. MDCTextFieldFoundation.prototype.setTransformOrigin = function (evt) {
  23760. if (this.isDisabled() || this.adapter.hasOutline()) {
  23761. return;
  23762. }
  23763. var touches = evt.touches;
  23764. var targetEvent = touches ? touches[0] : evt;
  23765. var targetClientRect = targetEvent.target.getBoundingClientRect();
  23766. var normalizedX = targetEvent.clientX - targetClientRect.left;
  23767. this.adapter.setLineRippleTransformOrigin(normalizedX);
  23768. };
  23769. /**
  23770. * Handles input change of text input and text area.
  23771. */
  23772. MDCTextFieldFoundation.prototype.handleInput = function () {
  23773. this.autoCompleteFocus();
  23774. this.setCharacterCounter_(this.getValue().length);
  23775. };
  23776. /**
  23777. * Activates the Text Field's focus state in cases when the input value
  23778. * changes without user input (e.g. programmatically).
  23779. */
  23780. MDCTextFieldFoundation.prototype.autoCompleteFocus = function () {
  23781. if (!this.receivedUserInput_) {
  23782. this.activateFocus();
  23783. }
  23784. };
  23785. /**
  23786. * Deactivates the Text Field's focus state.
  23787. */
  23788. MDCTextFieldFoundation.prototype.deactivateFocus = function () {
  23789. this.isFocused_ = false;
  23790. this.adapter.deactivateLineRipple();
  23791. var isValid = this.isValid();
  23792. this.styleValidity_(isValid);
  23793. this.styleFocused_(this.isFocused_);
  23794. if (this.adapter.hasLabel()) {
  23795. this.notchOutline(this.shouldFloat);
  23796. this.adapter.floatLabel(this.shouldFloat);
  23797. this.styleFloating_(this.shouldFloat);
  23798. this.adapter.shakeLabel(this.shouldShake);
  23799. }
  23800. if (!this.shouldFloat) {
  23801. this.receivedUserInput_ = false;
  23802. }
  23803. };
  23804. MDCTextFieldFoundation.prototype.getValue = function () {
  23805. return this.getNativeInput_().value;
  23806. };
  23807. /**
  23808. * @param value The value to set on the input Element.
  23809. */
  23810. MDCTextFieldFoundation.prototype.setValue = function (value) {
  23811. // Prevent Safari from moving the caret to the end of the input when the
  23812. // value has not changed.
  23813. if (this.getValue() !== value) {
  23814. this.getNativeInput_().value = value;
  23815. }
  23816. this.setCharacterCounter_(value.length);
  23817. if (this.validateOnValueChange_) {
  23818. var isValid = this.isValid();
  23819. this.styleValidity_(isValid);
  23820. }
  23821. if (this.adapter.hasLabel()) {
  23822. this.notchOutline(this.shouldFloat);
  23823. this.adapter.floatLabel(this.shouldFloat);
  23824. this.styleFloating_(this.shouldFloat);
  23825. if (this.validateOnValueChange_) {
  23826. this.adapter.shakeLabel(this.shouldShake);
  23827. }
  23828. }
  23829. };
  23830. /**
  23831. * @return The custom validity state, if set; otherwise, the result of a
  23832. * native validity check.
  23833. */
  23834. MDCTextFieldFoundation.prototype.isValid = function () {
  23835. return this.useNativeValidation_ ? this.isNativeInputValid_() : this.isValid_;
  23836. };
  23837. /**
  23838. * @param isValid Sets the custom validity state of the Text Field.
  23839. */
  23840. MDCTextFieldFoundation.prototype.setValid = function (isValid) {
  23841. this.isValid_ = isValid;
  23842. this.styleValidity_(isValid);
  23843. var shouldShake = !isValid && !this.isFocused_ && !!this.getValue();
  23844. if (this.adapter.hasLabel()) {
  23845. this.adapter.shakeLabel(shouldShake);
  23846. }
  23847. };
  23848. /**
  23849. * @param shouldValidate Whether or not validity should be updated on
  23850. * value change.
  23851. */
  23852. MDCTextFieldFoundation.prototype.setValidateOnValueChange = function (shouldValidate) {
  23853. this.validateOnValueChange_ = shouldValidate;
  23854. };
  23855. /**
  23856. * @return Whether or not validity should be updated on value change. `true`
  23857. * by default.
  23858. */
  23859. MDCTextFieldFoundation.prototype.getValidateOnValueChange = function () {
  23860. return this.validateOnValueChange_;
  23861. };
  23862. /**
  23863. * Enables or disables the use of native validation. Use this for custom
  23864. * validation.
  23865. * @param useNativeValidation Set this to false to ignore native input
  23866. * validation.
  23867. */
  23868. MDCTextFieldFoundation.prototype.setUseNativeValidation = function (useNativeValidation) {
  23869. this.useNativeValidation_ = useNativeValidation;
  23870. };
  23871. MDCTextFieldFoundation.prototype.isDisabled = function () {
  23872. return this.getNativeInput_().disabled;
  23873. };
  23874. /**
  23875. * @param disabled Sets the text-field disabled or enabled.
  23876. */
  23877. MDCTextFieldFoundation.prototype.setDisabled = function (disabled) {
  23878. this.getNativeInput_().disabled = disabled;
  23879. this.styleDisabled_(disabled);
  23880. };
  23881. /**
  23882. * @param content Sets the content of the helper text.
  23883. */
  23884. MDCTextFieldFoundation.prototype.setHelperTextContent = function (content) {
  23885. if (this.helperText_) {
  23886. this.helperText_.setContent(content);
  23887. }
  23888. };
  23889. /**
  23890. * Sets the aria label of the leading icon.
  23891. */
  23892. MDCTextFieldFoundation.prototype.setLeadingIconAriaLabel = function (label) {
  23893. if (this.leadingIcon_) {
  23894. this.leadingIcon_.setAriaLabel(label);
  23895. }
  23896. };
  23897. /**
  23898. * Sets the text content of the leading icon.
  23899. */
  23900. MDCTextFieldFoundation.prototype.setLeadingIconContent = function (content) {
  23901. if (this.leadingIcon_) {
  23902. this.leadingIcon_.setContent(content);
  23903. }
  23904. };
  23905. /**
  23906. * Sets the aria label of the trailing icon.
  23907. */
  23908. MDCTextFieldFoundation.prototype.setTrailingIconAriaLabel = function (label) {
  23909. if (this.trailingIcon_) {
  23910. this.trailingIcon_.setAriaLabel(label);
  23911. }
  23912. };
  23913. /**
  23914. * Sets the text content of the trailing icon.
  23915. */
  23916. MDCTextFieldFoundation.prototype.setTrailingIconContent = function (content) {
  23917. if (this.trailingIcon_) {
  23918. this.trailingIcon_.setContent(content);
  23919. }
  23920. };
  23921. /**
  23922. * Sets character counter values that shows characters used and the total
  23923. * character limit.
  23924. */
  23925. MDCTextFieldFoundation.prototype.setCharacterCounter_ = function (currentLength) {
  23926. if (!this.characterCounter_) {
  23927. return;
  23928. }
  23929. var maxLength = this.getNativeInput_().maxLength;
  23930. if (maxLength === -1) {
  23931. throw new Error('MDCTextFieldFoundation: Expected maxlength html property on text input or textarea.');
  23932. }
  23933. this.characterCounter_.setCounterValue(currentLength, maxLength);
  23934. };
  23935. /**
  23936. * @return True if the Text Field input fails in converting the user-supplied
  23937. * value.
  23938. */
  23939. MDCTextFieldFoundation.prototype.isBadInput_ = function () {
  23940. // The badInput property is not supported in IE 11 💩.
  23941. return this.getNativeInput_().validity.badInput || false;
  23942. };
  23943. /**
  23944. * @return The result of native validity checking (ValidityState.valid).
  23945. */
  23946. MDCTextFieldFoundation.prototype.isNativeInputValid_ = function () {
  23947. return this.getNativeInput_().validity.valid;
  23948. };
  23949. /**
  23950. * Styles the component based on the validity state.
  23951. */
  23952. MDCTextFieldFoundation.prototype.styleValidity_ = function (isValid) {
  23953. var INVALID = MDCTextFieldFoundation.cssClasses.INVALID;
  23954. if (isValid) {
  23955. this.adapter.removeClass(INVALID);
  23956. } else {
  23957. this.adapter.addClass(INVALID);
  23958. }
  23959. if (this.helperText_) {
  23960. this.helperText_.setValidity(isValid);
  23961. // We dynamically set or unset aria-describedby for validation helper text
  23962. // only, based on whether the field is valid
  23963. var helperTextValidation = this.helperText_.isValidation();
  23964. if (!helperTextValidation) {
  23965. return;
  23966. }
  23967. var helperTextVisible = this.helperText_.isVisible();
  23968. var helperTextId = this.helperText_.getId();
  23969. if (helperTextVisible && helperTextId) {
  23970. this.adapter.setInputAttr(constants_1.strings.ARIA_DESCRIBEDBY, helperTextId);
  23971. } else {
  23972. this.adapter.removeInputAttr(constants_1.strings.ARIA_DESCRIBEDBY);
  23973. }
  23974. }
  23975. };
  23976. /**
  23977. * Styles the component based on the focused state.
  23978. */
  23979. MDCTextFieldFoundation.prototype.styleFocused_ = function (isFocused) {
  23980. var FOCUSED = MDCTextFieldFoundation.cssClasses.FOCUSED;
  23981. if (isFocused) {
  23982. this.adapter.addClass(FOCUSED);
  23983. } else {
  23984. this.adapter.removeClass(FOCUSED);
  23985. }
  23986. };
  23987. /**
  23988. * Styles the component based on the disabled state.
  23989. */
  23990. MDCTextFieldFoundation.prototype.styleDisabled_ = function (isDisabled) {
  23991. var _a = MDCTextFieldFoundation.cssClasses,
  23992. DISABLED = _a.DISABLED,
  23993. INVALID = _a.INVALID;
  23994. if (isDisabled) {
  23995. this.adapter.addClass(DISABLED);
  23996. this.adapter.removeClass(INVALID);
  23997. } else {
  23998. this.adapter.removeClass(DISABLED);
  23999. }
  24000. if (this.leadingIcon_) {
  24001. this.leadingIcon_.setDisabled(isDisabled);
  24002. }
  24003. if (this.trailingIcon_) {
  24004. this.trailingIcon_.setDisabled(isDisabled);
  24005. }
  24006. };
  24007. /**
  24008. * Styles the component based on the label floating state.
  24009. */
  24010. MDCTextFieldFoundation.prototype.styleFloating_ = function (isFloating) {
  24011. var LABEL_FLOATING = MDCTextFieldFoundation.cssClasses.LABEL_FLOATING;
  24012. if (isFloating) {
  24013. this.adapter.addClass(LABEL_FLOATING);
  24014. } else {
  24015. this.adapter.removeClass(LABEL_FLOATING);
  24016. }
  24017. };
  24018. /**
  24019. * @return The native text input element from the host environment, or an
  24020. * object with the same shape for unit tests.
  24021. */
  24022. MDCTextFieldFoundation.prototype.getNativeInput_ = function () {
  24023. // this.adapter may be undefined in foundation unit tests. This happens when
  24024. // testdouble is creating a mock object and invokes the
  24025. // shouldShake/shouldFloat getters (which in turn call getValue(), which
  24026. // calls this method) before init() has been called from the MDCTextField
  24027. // constructor. To work around that issue, we return a dummy object.
  24028. var nativeInput = this.adapter ? this.adapter.getNativeInput() : null;
  24029. return nativeInput || {
  24030. disabled: false,
  24031. maxLength: -1,
  24032. required: false,
  24033. type: 'input',
  24034. validity: {
  24035. badInput: false,
  24036. valid: true
  24037. },
  24038. value: ''
  24039. };
  24040. };
  24041. return MDCTextFieldFoundation;
  24042. }(foundation_1.MDCFoundation);
  24043. exports.MDCTextFieldFoundation = MDCTextFieldFoundation;
  24044. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  24045. exports.default = MDCTextFieldFoundation;
  24046. /***/ }),
  24047. /***/ "./packages/mdc-textfield/helper-text/component.ts":
  24048. /*!*********************************************************!*\
  24049. !*** ./packages/mdc-textfield/helper-text/component.ts ***!
  24050. \*********************************************************/
  24051. /*! no static exports found */
  24052. /***/ (function(module, exports, __webpack_require__) {
  24053. "use strict";
  24054. /**
  24055. * @license
  24056. * Copyright 2017 Google Inc.
  24057. *
  24058. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24059. * of this software and associated documentation files (the "Software"), to deal
  24060. * in the Software without restriction, including without limitation the rights
  24061. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24062. * copies of the Software, and to permit persons to whom the Software is
  24063. * furnished to do so, subject to the following conditions:
  24064. *
  24065. * The above copyright notice and this permission notice shall be included in
  24066. * all copies or substantial portions of the Software.
  24067. *
  24068. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24069. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24070. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24071. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24072. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24073. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24074. * THE SOFTWARE.
  24075. */
  24076. var __extends = this && this.__extends || function () {
  24077. var _extendStatics = function extendStatics(d, b) {
  24078. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  24079. d.__proto__ = b;
  24080. } || function (d, b) {
  24081. for (var p in b) {
  24082. if (b.hasOwnProperty(p)) d[p] = b[p];
  24083. }
  24084. };
  24085. return _extendStatics(d, b);
  24086. };
  24087. return function (d, b) {
  24088. _extendStatics(d, b);
  24089. function __() {
  24090. this.constructor = d;
  24091. }
  24092. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24093. };
  24094. }();
  24095. Object.defineProperty(exports, "__esModule", { value: true });
  24096. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  24097. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/helper-text/foundation.ts");
  24098. var MDCTextFieldHelperText = /** @class */function (_super) {
  24099. __extends(MDCTextFieldHelperText, _super);
  24100. function MDCTextFieldHelperText() {
  24101. return _super !== null && _super.apply(this, arguments) || this;
  24102. }
  24103. MDCTextFieldHelperText.attachTo = function (root) {
  24104. return new MDCTextFieldHelperText(root);
  24105. };
  24106. Object.defineProperty(MDCTextFieldHelperText.prototype, "foundationForTextField", {
  24107. // Provided for access by MDCTextField component
  24108. get: function get() {
  24109. return this.foundation;
  24110. },
  24111. enumerable: true,
  24112. configurable: true
  24113. });
  24114. MDCTextFieldHelperText.prototype.getDefaultFoundation = function () {
  24115. var _this = this;
  24116. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  24117. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  24118. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  24119. var adapter = {
  24120. addClass: function addClass(className) {
  24121. return _this.root.classList.add(className);
  24122. },
  24123. removeClass: function removeClass(className) {
  24124. return _this.root.classList.remove(className);
  24125. },
  24126. hasClass: function hasClass(className) {
  24127. return _this.root.classList.contains(className);
  24128. },
  24129. getAttr: function getAttr(attr) {
  24130. return _this.root.getAttribute(attr);
  24131. },
  24132. setAttr: function setAttr(attr, value) {
  24133. return _this.root.setAttribute(attr, value);
  24134. },
  24135. removeAttr: function removeAttr(attr) {
  24136. return _this.root.removeAttribute(attr);
  24137. },
  24138. setContent: function setContent(content) {
  24139. _this.root.textContent = content;
  24140. }
  24141. };
  24142. // tslint:enable:object-literal-sort-keys
  24143. return new foundation_1.MDCTextFieldHelperTextFoundation(adapter);
  24144. };
  24145. return MDCTextFieldHelperText;
  24146. }(component_1.MDCComponent);
  24147. exports.MDCTextFieldHelperText = MDCTextFieldHelperText;
  24148. /***/ }),
  24149. /***/ "./packages/mdc-textfield/helper-text/constants.ts":
  24150. /*!*********************************************************!*\
  24151. !*** ./packages/mdc-textfield/helper-text/constants.ts ***!
  24152. \*********************************************************/
  24153. /*! no static exports found */
  24154. /***/ (function(module, exports, __webpack_require__) {
  24155. "use strict";
  24156. /**
  24157. * @license
  24158. * Copyright 2016 Google Inc.
  24159. *
  24160. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24161. * of this software and associated documentation files (the "Software"), to deal
  24162. * in the Software without restriction, including without limitation the rights
  24163. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24164. * copies of the Software, and to permit persons to whom the Software is
  24165. * furnished to do so, subject to the following conditions:
  24166. *
  24167. * The above copyright notice and this permission notice shall be included in
  24168. * all copies or substantial portions of the Software.
  24169. *
  24170. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24171. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24172. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24173. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24174. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24175. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24176. * THE SOFTWARE.
  24177. */
  24178. Object.defineProperty(exports, "__esModule", { value: true });
  24179. var cssClasses = {
  24180. HELPER_TEXT_PERSISTENT: 'mdc-text-field-helper-text--persistent',
  24181. HELPER_TEXT_VALIDATION_MSG: 'mdc-text-field-helper-text--validation-msg',
  24182. ROOT: 'mdc-text-field-helper-text'
  24183. };
  24184. exports.cssClasses = cssClasses;
  24185. var strings = {
  24186. ARIA_HIDDEN: 'aria-hidden',
  24187. ROLE: 'role',
  24188. ROOT_SELECTOR: "." + cssClasses.ROOT
  24189. };
  24190. exports.strings = strings;
  24191. /***/ }),
  24192. /***/ "./packages/mdc-textfield/helper-text/foundation.ts":
  24193. /*!**********************************************************!*\
  24194. !*** ./packages/mdc-textfield/helper-text/foundation.ts ***!
  24195. \**********************************************************/
  24196. /*! no static exports found */
  24197. /***/ (function(module, exports, __webpack_require__) {
  24198. "use strict";
  24199. /**
  24200. * @license
  24201. * Copyright 2017 Google Inc.
  24202. *
  24203. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24204. * of this software and associated documentation files (the "Software"), to deal
  24205. * in the Software without restriction, including without limitation the rights
  24206. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24207. * copies of the Software, and to permit persons to whom the Software is
  24208. * furnished to do so, subject to the following conditions:
  24209. *
  24210. * The above copyright notice and this permission notice shall be included in
  24211. * all copies or substantial portions of the Software.
  24212. *
  24213. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24214. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24215. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24216. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24217. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24218. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24219. * THE SOFTWARE.
  24220. */
  24221. var __extends = this && this.__extends || function () {
  24222. var _extendStatics = function extendStatics(d, b) {
  24223. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  24224. d.__proto__ = b;
  24225. } || function (d, b) {
  24226. for (var p in b) {
  24227. if (b.hasOwnProperty(p)) d[p] = b[p];
  24228. }
  24229. };
  24230. return _extendStatics(d, b);
  24231. };
  24232. return function (d, b) {
  24233. _extendStatics(d, b);
  24234. function __() {
  24235. this.constructor = d;
  24236. }
  24237. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24238. };
  24239. }();
  24240. var __assign = this && this.__assign || function () {
  24241. __assign = Object.assign || function (t) {
  24242. for (var s, i = 1, n = arguments.length; i < n; i++) {
  24243. s = arguments[i];
  24244. for (var p in s) {
  24245. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  24246. }
  24247. }
  24248. return t;
  24249. };
  24250. return __assign.apply(this, arguments);
  24251. };
  24252. Object.defineProperty(exports, "__esModule", { value: true });
  24253. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  24254. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/helper-text/constants.ts");
  24255. var MDCTextFieldHelperTextFoundation = /** @class */function (_super) {
  24256. __extends(MDCTextFieldHelperTextFoundation, _super);
  24257. function MDCTextFieldHelperTextFoundation(adapter) {
  24258. return _super.call(this, __assign(__assign({}, MDCTextFieldHelperTextFoundation.defaultAdapter), adapter)) || this;
  24259. }
  24260. Object.defineProperty(MDCTextFieldHelperTextFoundation, "cssClasses", {
  24261. get: function get() {
  24262. return constants_1.cssClasses;
  24263. },
  24264. enumerable: true,
  24265. configurable: true
  24266. });
  24267. Object.defineProperty(MDCTextFieldHelperTextFoundation, "strings", {
  24268. get: function get() {
  24269. return constants_1.strings;
  24270. },
  24271. enumerable: true,
  24272. configurable: true
  24273. });
  24274. Object.defineProperty(MDCTextFieldHelperTextFoundation, "defaultAdapter", {
  24275. /**
  24276. * See {@link MDCTextFieldHelperTextAdapter} for typing information on parameters and return types.
  24277. */
  24278. get: function get() {
  24279. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  24280. return {
  24281. addClass: function addClass() {
  24282. return undefined;
  24283. },
  24284. removeClass: function removeClass() {
  24285. return undefined;
  24286. },
  24287. hasClass: function hasClass() {
  24288. return false;
  24289. },
  24290. getAttr: function getAttr() {
  24291. return null;
  24292. },
  24293. setAttr: function setAttr() {
  24294. return undefined;
  24295. },
  24296. removeAttr: function removeAttr() {
  24297. return undefined;
  24298. },
  24299. setContent: function setContent() {
  24300. return undefined;
  24301. }
  24302. };
  24303. // tslint:enable:object-literal-sort-keys
  24304. },
  24305. enumerable: true,
  24306. configurable: true
  24307. });
  24308. MDCTextFieldHelperTextFoundation.prototype.getId = function () {
  24309. return this.adapter.getAttr('id');
  24310. };
  24311. MDCTextFieldHelperTextFoundation.prototype.isVisible = function () {
  24312. return this.adapter.getAttr(constants_1.strings.ARIA_HIDDEN) !== 'true';
  24313. };
  24314. /**
  24315. * Sets the content of the helper text field.
  24316. */
  24317. MDCTextFieldHelperTextFoundation.prototype.setContent = function (content) {
  24318. this.adapter.setContent(content);
  24319. };
  24320. MDCTextFieldHelperTextFoundation.prototype.isPersistent = function () {
  24321. return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
  24322. };
  24323. /**
  24324. * @param isPersistent Sets the persistency of the helper text.
  24325. */
  24326. MDCTextFieldHelperTextFoundation.prototype.setPersistent = function (isPersistent) {
  24327. if (isPersistent) {
  24328. this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
  24329. } else {
  24330. this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
  24331. }
  24332. };
  24333. /**
  24334. * @return whether the helper text acts as an error validation message.
  24335. */
  24336. MDCTextFieldHelperTextFoundation.prototype.isValidation = function () {
  24337. return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  24338. };
  24339. /**
  24340. * @param isValidation True to make the helper text act as an error validation message.
  24341. */
  24342. MDCTextFieldHelperTextFoundation.prototype.setValidation = function (isValidation) {
  24343. if (isValidation) {
  24344. this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  24345. } else {
  24346. this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  24347. }
  24348. };
  24349. /**
  24350. * Makes the helper text visible to the screen reader.
  24351. */
  24352. MDCTextFieldHelperTextFoundation.prototype.showToScreenReader = function () {
  24353. this.adapter.removeAttr(constants_1.strings.ARIA_HIDDEN);
  24354. };
  24355. /**
  24356. * Sets the validity of the helper text based on the input validity.
  24357. */
  24358. MDCTextFieldHelperTextFoundation.prototype.setValidity = function (inputIsValid) {
  24359. var helperTextIsPersistent = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
  24360. var helperTextIsValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  24361. var validationMsgNeedsDisplay = helperTextIsValidationMsg && !inputIsValid;
  24362. if (validationMsgNeedsDisplay) {
  24363. this.showToScreenReader();
  24364. this.adapter.setAttr(constants_1.strings.ROLE, 'alert');
  24365. } else {
  24366. this.adapter.removeAttr(constants_1.strings.ROLE);
  24367. }
  24368. if (!helperTextIsPersistent && !validationMsgNeedsDisplay) {
  24369. this.hide_();
  24370. }
  24371. };
  24372. /**
  24373. * Hides the help text from screen readers.
  24374. */
  24375. MDCTextFieldHelperTextFoundation.prototype.hide_ = function () {
  24376. this.adapter.setAttr(constants_1.strings.ARIA_HIDDEN, 'true');
  24377. };
  24378. return MDCTextFieldHelperTextFoundation;
  24379. }(foundation_1.MDCFoundation);
  24380. exports.MDCTextFieldHelperTextFoundation = MDCTextFieldHelperTextFoundation;
  24381. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  24382. exports.default = MDCTextFieldHelperTextFoundation;
  24383. /***/ }),
  24384. /***/ "./packages/mdc-textfield/helper-text/index.ts":
  24385. /*!*****************************************************!*\
  24386. !*** ./packages/mdc-textfield/helper-text/index.ts ***!
  24387. \*****************************************************/
  24388. /*! no static exports found */
  24389. /***/ (function(module, exports, __webpack_require__) {
  24390. "use strict";
  24391. /**
  24392. * @license
  24393. * Copyright 2019 Google Inc.
  24394. *
  24395. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24396. * of this software and associated documentation files (the "Software"), to deal
  24397. * in the Software without restriction, including without limitation the rights
  24398. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24399. * copies of the Software, and to permit persons to whom the Software is
  24400. * furnished to do so, subject to the following conditions:
  24401. *
  24402. * The above copyright notice and this permission notice shall be included in
  24403. * all copies or substantial portions of the Software.
  24404. *
  24405. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24406. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24407. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24408. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24409. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24410. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24411. * THE SOFTWARE.
  24412. */
  24413. function __export(m) {
  24414. for (var p in m) {
  24415. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  24416. }
  24417. }
  24418. Object.defineProperty(exports, "__esModule", { value: true });
  24419. __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/helper-text/component.ts"));
  24420. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/helper-text/foundation.ts"));
  24421. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/helper-text/constants.ts");
  24422. exports.helperTextCssClasses = constants_1.cssClasses;
  24423. exports.helperTextStrings = constants_1.strings;
  24424. /***/ }),
  24425. /***/ "./packages/mdc-textfield/icon/component.ts":
  24426. /*!**************************************************!*\
  24427. !*** ./packages/mdc-textfield/icon/component.ts ***!
  24428. \**************************************************/
  24429. /*! no static exports found */
  24430. /***/ (function(module, exports, __webpack_require__) {
  24431. "use strict";
  24432. /**
  24433. * @license
  24434. * Copyright 2017 Google Inc.
  24435. *
  24436. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24437. * of this software and associated documentation files (the "Software"), to deal
  24438. * in the Software without restriction, including without limitation the rights
  24439. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24440. * copies of the Software, and to permit persons to whom the Software is
  24441. * furnished to do so, subject to the following conditions:
  24442. *
  24443. * The above copyright notice and this permission notice shall be included in
  24444. * all copies or substantial portions of the Software.
  24445. *
  24446. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24447. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24448. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24449. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24450. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24451. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24452. * THE SOFTWARE.
  24453. */
  24454. var __extends = this && this.__extends || function () {
  24455. var _extendStatics = function extendStatics(d, b) {
  24456. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  24457. d.__proto__ = b;
  24458. } || function (d, b) {
  24459. for (var p in b) {
  24460. if (b.hasOwnProperty(p)) d[p] = b[p];
  24461. }
  24462. };
  24463. return _extendStatics(d, b);
  24464. };
  24465. return function (d, b) {
  24466. _extendStatics(d, b);
  24467. function __() {
  24468. this.constructor = d;
  24469. }
  24470. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24471. };
  24472. }();
  24473. Object.defineProperty(exports, "__esModule", { value: true });
  24474. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  24475. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/icon/foundation.ts");
  24476. var MDCTextFieldIcon = /** @class */function (_super) {
  24477. __extends(MDCTextFieldIcon, _super);
  24478. function MDCTextFieldIcon() {
  24479. return _super !== null && _super.apply(this, arguments) || this;
  24480. }
  24481. MDCTextFieldIcon.attachTo = function (root) {
  24482. return new MDCTextFieldIcon(root);
  24483. };
  24484. Object.defineProperty(MDCTextFieldIcon.prototype, "foundationForTextField", {
  24485. // Provided for access by MDCTextField component
  24486. get: function get() {
  24487. return this.foundation;
  24488. },
  24489. enumerable: true,
  24490. configurable: true
  24491. });
  24492. MDCTextFieldIcon.prototype.getDefaultFoundation = function () {
  24493. var _this = this;
  24494. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  24495. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  24496. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  24497. var adapter = {
  24498. getAttr: function getAttr(attr) {
  24499. return _this.root.getAttribute(attr);
  24500. },
  24501. setAttr: function setAttr(attr, value) {
  24502. return _this.root.setAttribute(attr, value);
  24503. },
  24504. removeAttr: function removeAttr(attr) {
  24505. return _this.root.removeAttribute(attr);
  24506. },
  24507. setContent: function setContent(content) {
  24508. _this.root.textContent = content;
  24509. },
  24510. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  24511. return _this.listen(evtType, handler);
  24512. },
  24513. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  24514. return _this.unlisten(evtType, handler);
  24515. },
  24516. notifyIconAction: function notifyIconAction() {
  24517. return _this.emit(foundation_1.MDCTextFieldIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */);
  24518. }
  24519. };
  24520. // tslint:enable:object-literal-sort-keys
  24521. return new foundation_1.MDCTextFieldIconFoundation(adapter);
  24522. };
  24523. return MDCTextFieldIcon;
  24524. }(component_1.MDCComponent);
  24525. exports.MDCTextFieldIcon = MDCTextFieldIcon;
  24526. /***/ }),
  24527. /***/ "./packages/mdc-textfield/icon/constants.ts":
  24528. /*!**************************************************!*\
  24529. !*** ./packages/mdc-textfield/icon/constants.ts ***!
  24530. \**************************************************/
  24531. /*! no static exports found */
  24532. /***/ (function(module, exports, __webpack_require__) {
  24533. "use strict";
  24534. /**
  24535. * @license
  24536. * Copyright 2016 Google Inc.
  24537. *
  24538. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24539. * of this software and associated documentation files (the "Software"), to deal
  24540. * in the Software without restriction, including without limitation the rights
  24541. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24542. * copies of the Software, and to permit persons to whom the Software is
  24543. * furnished to do so, subject to the following conditions:
  24544. *
  24545. * The above copyright notice and this permission notice shall be included in
  24546. * all copies or substantial portions of the Software.
  24547. *
  24548. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24549. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24550. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24551. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24552. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24553. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24554. * THE SOFTWARE.
  24555. */
  24556. Object.defineProperty(exports, "__esModule", { value: true });
  24557. var strings = {
  24558. ICON_EVENT: 'MDCTextField:icon',
  24559. ICON_ROLE: 'button'
  24560. };
  24561. exports.strings = strings;
  24562. var cssClasses = {
  24563. ROOT: 'mdc-text-field__icon'
  24564. };
  24565. exports.cssClasses = cssClasses;
  24566. /***/ }),
  24567. /***/ "./packages/mdc-textfield/icon/foundation.ts":
  24568. /*!***************************************************!*\
  24569. !*** ./packages/mdc-textfield/icon/foundation.ts ***!
  24570. \***************************************************/
  24571. /*! no static exports found */
  24572. /***/ (function(module, exports, __webpack_require__) {
  24573. "use strict";
  24574. /**
  24575. * @license
  24576. * Copyright 2017 Google Inc.
  24577. *
  24578. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24579. * of this software and associated documentation files (the "Software"), to deal
  24580. * in the Software without restriction, including without limitation the rights
  24581. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24582. * copies of the Software, and to permit persons to whom the Software is
  24583. * furnished to do so, subject to the following conditions:
  24584. *
  24585. * The above copyright notice and this permission notice shall be included in
  24586. * all copies or substantial portions of the Software.
  24587. *
  24588. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24589. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24590. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24591. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24592. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24593. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24594. * THE SOFTWARE.
  24595. */
  24596. var __extends = this && this.__extends || function () {
  24597. var _extendStatics = function extendStatics(d, b) {
  24598. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  24599. d.__proto__ = b;
  24600. } || function (d, b) {
  24601. for (var p in b) {
  24602. if (b.hasOwnProperty(p)) d[p] = b[p];
  24603. }
  24604. };
  24605. return _extendStatics(d, b);
  24606. };
  24607. return function (d, b) {
  24608. _extendStatics(d, b);
  24609. function __() {
  24610. this.constructor = d;
  24611. }
  24612. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24613. };
  24614. }();
  24615. var __assign = this && this.__assign || function () {
  24616. __assign = Object.assign || function (t) {
  24617. for (var s, i = 1, n = arguments.length; i < n; i++) {
  24618. s = arguments[i];
  24619. for (var p in s) {
  24620. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  24621. }
  24622. }
  24623. return t;
  24624. };
  24625. return __assign.apply(this, arguments);
  24626. };
  24627. Object.defineProperty(exports, "__esModule", { value: true });
  24628. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  24629. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/icon/constants.ts");
  24630. var INTERACTION_EVENTS = ['click', 'keydown'];
  24631. var MDCTextFieldIconFoundation = /** @class */function (_super) {
  24632. __extends(MDCTextFieldIconFoundation, _super);
  24633. function MDCTextFieldIconFoundation(adapter) {
  24634. var _this = _super.call(this, __assign(__assign({}, MDCTextFieldIconFoundation.defaultAdapter), adapter)) || this;
  24635. _this.savedTabIndex_ = null;
  24636. _this.interactionHandler_ = function (evt) {
  24637. return _this.handleInteraction(evt);
  24638. };
  24639. return _this;
  24640. }
  24641. Object.defineProperty(MDCTextFieldIconFoundation, "strings", {
  24642. get: function get() {
  24643. return constants_1.strings;
  24644. },
  24645. enumerable: true,
  24646. configurable: true
  24647. });
  24648. Object.defineProperty(MDCTextFieldIconFoundation, "cssClasses", {
  24649. get: function get() {
  24650. return constants_1.cssClasses;
  24651. },
  24652. enumerable: true,
  24653. configurable: true
  24654. });
  24655. Object.defineProperty(MDCTextFieldIconFoundation, "defaultAdapter", {
  24656. /**
  24657. * See {@link MDCTextFieldIconAdapter} for typing information on parameters and return types.
  24658. */
  24659. get: function get() {
  24660. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  24661. return {
  24662. getAttr: function getAttr() {
  24663. return null;
  24664. },
  24665. setAttr: function setAttr() {
  24666. return undefined;
  24667. },
  24668. removeAttr: function removeAttr() {
  24669. return undefined;
  24670. },
  24671. setContent: function setContent() {
  24672. return undefined;
  24673. },
  24674. registerInteractionHandler: function registerInteractionHandler() {
  24675. return undefined;
  24676. },
  24677. deregisterInteractionHandler: function deregisterInteractionHandler() {
  24678. return undefined;
  24679. },
  24680. notifyIconAction: function notifyIconAction() {
  24681. return undefined;
  24682. }
  24683. };
  24684. // tslint:enable:object-literal-sort-keys
  24685. },
  24686. enumerable: true,
  24687. configurable: true
  24688. });
  24689. MDCTextFieldIconFoundation.prototype.init = function () {
  24690. var _this = this;
  24691. this.savedTabIndex_ = this.adapter.getAttr('tabindex');
  24692. INTERACTION_EVENTS.forEach(function (evtType) {
  24693. _this.adapter.registerInteractionHandler(evtType, _this.interactionHandler_);
  24694. });
  24695. };
  24696. MDCTextFieldIconFoundation.prototype.destroy = function () {
  24697. var _this = this;
  24698. INTERACTION_EVENTS.forEach(function (evtType) {
  24699. _this.adapter.deregisterInteractionHandler(evtType, _this.interactionHandler_);
  24700. });
  24701. };
  24702. MDCTextFieldIconFoundation.prototype.setDisabled = function (disabled) {
  24703. if (!this.savedTabIndex_) {
  24704. return;
  24705. }
  24706. if (disabled) {
  24707. this.adapter.setAttr('tabindex', '-1');
  24708. this.adapter.removeAttr('role');
  24709. } else {
  24710. this.adapter.setAttr('tabindex', this.savedTabIndex_);
  24711. this.adapter.setAttr('role', constants_1.strings.ICON_ROLE);
  24712. }
  24713. };
  24714. MDCTextFieldIconFoundation.prototype.setAriaLabel = function (label) {
  24715. this.adapter.setAttr('aria-label', label);
  24716. };
  24717. MDCTextFieldIconFoundation.prototype.setContent = function (content) {
  24718. this.adapter.setContent(content);
  24719. };
  24720. MDCTextFieldIconFoundation.prototype.handleInteraction = function (evt) {
  24721. var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
  24722. if (evt.type === 'click' || isEnterKey) {
  24723. evt.preventDefault(); // stop click from causing host label to focus
  24724. // input
  24725. this.adapter.notifyIconAction();
  24726. }
  24727. };
  24728. return MDCTextFieldIconFoundation;
  24729. }(foundation_1.MDCFoundation);
  24730. exports.MDCTextFieldIconFoundation = MDCTextFieldIconFoundation;
  24731. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  24732. exports.default = MDCTextFieldIconFoundation;
  24733. /***/ }),
  24734. /***/ "./packages/mdc-textfield/icon/index.ts":
  24735. /*!**********************************************!*\
  24736. !*** ./packages/mdc-textfield/icon/index.ts ***!
  24737. \**********************************************/
  24738. /*! no static exports found */
  24739. /***/ (function(module, exports, __webpack_require__) {
  24740. "use strict";
  24741. /**
  24742. * @license
  24743. * Copyright 2019 Google Inc.
  24744. *
  24745. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24746. * of this software and associated documentation files (the "Software"), to deal
  24747. * in the Software without restriction, including without limitation the rights
  24748. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24749. * copies of the Software, and to permit persons to whom the Software is
  24750. * furnished to do so, subject to the following conditions:
  24751. *
  24752. * The above copyright notice and this permission notice shall be included in
  24753. * all copies or substantial portions of the Software.
  24754. *
  24755. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24756. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24757. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24758. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24759. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24760. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24761. * THE SOFTWARE.
  24762. */
  24763. function __export(m) {
  24764. for (var p in m) {
  24765. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  24766. }
  24767. }
  24768. Object.defineProperty(exports, "__esModule", { value: true });
  24769. __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/icon/component.ts"));
  24770. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/icon/foundation.ts"));
  24771. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/icon/constants.ts");
  24772. exports.iconCssClasses = constants_1.cssClasses;
  24773. exports.iconStrings = constants_1.strings;
  24774. /***/ }),
  24775. /***/ "./packages/mdc-textfield/index.ts":
  24776. /*!*****************************************!*\
  24777. !*** ./packages/mdc-textfield/index.ts ***!
  24778. \*****************************************/
  24779. /*! no static exports found */
  24780. /***/ (function(module, exports, __webpack_require__) {
  24781. "use strict";
  24782. /**
  24783. * @license
  24784. * Copyright 2019 Google Inc.
  24785. *
  24786. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24787. * of this software and associated documentation files (the "Software"), to deal
  24788. * in the Software without restriction, including without limitation the rights
  24789. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24790. * copies of the Software, and to permit persons to whom the Software is
  24791. * furnished to do so, subject to the following conditions:
  24792. *
  24793. * The above copyright notice and this permission notice shall be included in
  24794. * all copies or substantial portions of the Software.
  24795. *
  24796. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24797. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24798. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24799. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24800. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24801. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24802. * THE SOFTWARE.
  24803. */
  24804. function __export(m) {
  24805. for (var p in m) {
  24806. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  24807. }
  24808. }
  24809. Object.defineProperty(exports, "__esModule", { value: true });
  24810. __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/component.ts"));
  24811. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts"));
  24812. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/foundation.ts"));
  24813. __export(__webpack_require__(/*! ./character-counter/index */ "./packages/mdc-textfield/character-counter/index.ts"));
  24814. __export(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-textfield/helper-text/index.ts"));
  24815. __export(__webpack_require__(/*! ./icon/index */ "./packages/mdc-textfield/icon/index.ts"));
  24816. /***/ }),
  24817. /***/ "./packages/mdc-tooltip/component.ts":
  24818. /*!*******************************************!*\
  24819. !*** ./packages/mdc-tooltip/component.ts ***!
  24820. \*******************************************/
  24821. /*! no static exports found */
  24822. /***/ (function(module, exports, __webpack_require__) {
  24823. "use strict";
  24824. /**
  24825. * @license
  24826. * Copyright 2020 Google Inc.
  24827. *
  24828. * Permission is hereby granted, free of charge, to any person obtaining a copy
  24829. * of this software and associated documentation files (the "Software"), to deal
  24830. * in the Software without restriction, including without limitation the rights
  24831. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24832. * copies of the Software, and to permit persons to whom the Software is
  24833. * furnished to do so, subject to the following conditions:
  24834. *
  24835. * The above copyright notice and this permission notice shall be included in
  24836. * all copies or substantial portions of the Software.
  24837. *
  24838. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24839. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24840. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  24841. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24842. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24843. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24844. * THE SOFTWARE.
  24845. */
  24846. var __extends = this && this.__extends || function () {
  24847. var _extendStatics = function extendStatics(d, b) {
  24848. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  24849. d.__proto__ = b;
  24850. } || function (d, b) {
  24851. for (var p in b) {
  24852. if (b.hasOwnProperty(p)) d[p] = b[p];
  24853. }
  24854. };
  24855. return _extendStatics(d, b);
  24856. };
  24857. return function (d, b) {
  24858. _extendStatics(d, b);
  24859. function __() {
  24860. this.constructor = d;
  24861. }
  24862. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  24863. };
  24864. }();
  24865. Object.defineProperty(exports, "__esModule", { value: true });
  24866. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  24867. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts");
  24868. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tooltip/foundation.ts");
  24869. var MDCTooltip = /** @class */function (_super) {
  24870. __extends(MDCTooltip, _super);
  24871. function MDCTooltip() {
  24872. return _super !== null && _super.apply(this, arguments) || this;
  24873. }
  24874. MDCTooltip.attachTo = function (root) {
  24875. return new MDCTooltip(root);
  24876. };
  24877. MDCTooltip.prototype.initialize = function () {
  24878. var tooltipId = this.root.getAttribute('id');
  24879. if (!tooltipId) {
  24880. throw new Error('MDCTooltip: Tooltip component must have an id.');
  24881. }
  24882. var anchorElem = document.querySelector("[aria-describedby=\"" + tooltipId + "\"]") || document.querySelector("[data-tooltip-id=\"" + tooltipId + "\"]");
  24883. if (!anchorElem) {
  24884. throw new Error('MDCTooltip: Tooltip component requires an anchor element annotated with [aria-describedby] or [data-tooltip-id] anchor element.');
  24885. }
  24886. this.anchorElem = anchorElem;
  24887. };
  24888. MDCTooltip.prototype.initialSyncWithDOM = function () {
  24889. var _this = this;
  24890. this.isTooltipRich = this.foundation.isRich();
  24891. this.isTooltipPersistent = this.foundation.isPersistent();
  24892. this.handleMouseEnter = function () {
  24893. _this.foundation.handleAnchorMouseEnter();
  24894. };
  24895. this.handleFocus = function (evt) {
  24896. _this.foundation.handleAnchorFocus(evt);
  24897. };
  24898. this.handleMouseLeave = function () {
  24899. _this.foundation.handleAnchorMouseLeave();
  24900. };
  24901. this.handleBlur = function (evt) {
  24902. _this.foundation.handleAnchorBlur(evt);
  24903. };
  24904. this.handleTransitionEnd = function () {
  24905. _this.foundation.handleTransitionEnd();
  24906. };
  24907. this.handleClick = function () {
  24908. _this.foundation.handleAnchorClick();
  24909. };
  24910. this.anchorElem.addEventListener('blur', this.handleBlur);
  24911. if (this.isTooltipRich && this.isTooltipPersistent) {
  24912. this.anchorElem.addEventListener('click', this.handleClick);
  24913. } else {
  24914. this.anchorElem.addEventListener('mouseenter', this.handleMouseEnter);
  24915. // TODO(b/157075286): Listening for a 'focus' event is too broad.
  24916. this.anchorElem.addEventListener('focus', this.handleFocus);
  24917. this.anchorElem.addEventListener('mouseleave', this.handleMouseLeave);
  24918. }
  24919. this.listen('transitionend', this.handleTransitionEnd);
  24920. };
  24921. MDCTooltip.prototype.destroy = function () {
  24922. if (this.anchorElem) {
  24923. this.anchorElem.removeEventListener('blur', this.handleBlur);
  24924. if (this.isTooltipRich && this.isTooltipPersistent) {
  24925. this.anchorElem.removeEventListener('click', this.handleClick);
  24926. } else {
  24927. this.anchorElem.removeEventListener('mouseenter', this.handleMouseEnter);
  24928. this.anchorElem.removeEventListener('focus', this.handleFocus);
  24929. this.anchorElem.removeEventListener('mouseleave', this.handleMouseLeave);
  24930. }
  24931. }
  24932. this.unlisten('transitionend', this.handleTransitionEnd);
  24933. _super.prototype.destroy.call(this);
  24934. };
  24935. MDCTooltip.prototype.setTooltipPosition = function (position) {
  24936. this.foundation.setTooltipPosition(position);
  24937. };
  24938. MDCTooltip.prototype.setAnchorBoundaryType = function (type) {
  24939. this.foundation.setAnchorBoundaryType(type);
  24940. };
  24941. MDCTooltip.prototype.hide = function () {
  24942. this.foundation.hide();
  24943. };
  24944. MDCTooltip.prototype.isShown = function () {
  24945. this.foundation.isShown();
  24946. };
  24947. MDCTooltip.prototype.getDefaultFoundation = function () {
  24948. var _this = this;
  24949. var adapter = {
  24950. getAttribute: function getAttribute(attr) {
  24951. return _this.root.getAttribute(attr);
  24952. },
  24953. setAttribute: function setAttribute(attr, value) {
  24954. _this.root.setAttribute(attr, value);
  24955. },
  24956. addClass: function addClass(className) {
  24957. _this.root.classList.add(className);
  24958. },
  24959. hasClass: function hasClass(className) {
  24960. return _this.root.classList.contains(className);
  24961. },
  24962. removeClass: function removeClass(className) {
  24963. _this.root.classList.remove(className);
  24964. },
  24965. setStyleProperty: function setStyleProperty(propertyName, value) {
  24966. _this.root.style.setProperty(propertyName, value);
  24967. },
  24968. getViewportWidth: function getViewportWidth() {
  24969. return window.innerWidth;
  24970. },
  24971. getViewportHeight: function getViewportHeight() {
  24972. return window.innerHeight;
  24973. },
  24974. getTooltipSize: function getTooltipSize() {
  24975. return {
  24976. width: _this.root.offsetWidth,
  24977. height: _this.root.offsetHeight
  24978. };
  24979. },
  24980. getAnchorBoundingRect: function getAnchorBoundingRect() {
  24981. return _this.anchorElem ? _this.anchorElem.getBoundingClientRect() : null;
  24982. },
  24983. getAnchorAttribute: function getAnchorAttribute(attr) {
  24984. return _this.anchorElem ? _this.anchorElem.getAttribute(attr) : null;
  24985. },
  24986. setAnchorAttribute: function setAnchorAttribute(attr, value) {
  24987. var _a;
  24988. (_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.setAttribute(attr, value);
  24989. },
  24990. isRTL: function isRTL() {
  24991. return getComputedStyle(_this.root).direction === 'rtl';
  24992. },
  24993. anchorContainsElement: function anchorContainsElement(element) {
  24994. var _a;
  24995. return !!((_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.contains(element));
  24996. },
  24997. tooltipContainsElement: function tooltipContainsElement(element) {
  24998. return _this.root.contains(element);
  24999. },
  25000. focusAnchorElement: function focusAnchorElement() {
  25001. var _a;
  25002. (_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.focus();
  25003. },
  25004. registerEventHandler: function registerEventHandler(evt, handler) {
  25005. if (_this.root instanceof HTMLElement) {
  25006. _this.root.addEventListener(evt, handler);
  25007. }
  25008. },
  25009. deregisterEventHandler: function deregisterEventHandler(evt, handler) {
  25010. if (_this.root instanceof HTMLElement) {
  25011. _this.root.removeEventListener(evt, handler);
  25012. }
  25013. },
  25014. registerDocumentEventHandler: function registerDocumentEventHandler(evt, handler) {
  25015. document.body.addEventListener(evt, handler);
  25016. },
  25017. deregisterDocumentEventHandler: function deregisterDocumentEventHandler(evt, handler) {
  25018. document.body.removeEventListener(evt, handler);
  25019. },
  25020. registerWindowEventHandler: function registerWindowEventHandler(evt, handler) {
  25021. window.addEventListener(evt, handler);
  25022. },
  25023. deregisterWindowEventHandler: function deregisterWindowEventHandler(evt, handler) {
  25024. window.removeEventListener(evt, handler);
  25025. },
  25026. notifyHidden: function notifyHidden() {
  25027. _this.emit(constants_1.events.HIDDEN, {});
  25028. }
  25029. };
  25030. //tslint:enable:object-literal-sort-keys
  25031. return new foundation_1.MDCTooltipFoundation(adapter);
  25032. };
  25033. return MDCTooltip;
  25034. }(component_1.MDCComponent);
  25035. exports.MDCTooltip = MDCTooltip;
  25036. /***/ }),
  25037. /***/ "./packages/mdc-tooltip/constants.ts":
  25038. /*!*******************************************!*\
  25039. !*** ./packages/mdc-tooltip/constants.ts ***!
  25040. \*******************************************/
  25041. /*! no static exports found */
  25042. /***/ (function(module, exports, __webpack_require__) {
  25043. "use strict";
  25044. /**
  25045. * @license
  25046. * Copyright 2020 Google Inc.
  25047. *
  25048. * Permission is hereby granted, free of charge, to any person obtaining a copy
  25049. * of this software and associated documentation files (the "Software"), to deal
  25050. * in the Software without restriction, including without limitation the rights
  25051. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  25052. * copies of the Software, and to permit persons to whom the Software is
  25053. * furnished to do so, subject to the following conditions:
  25054. *
  25055. * The above copyright notice and this permission notice shall be included in
  25056. * all copies or substantial portions of the Software.
  25057. *
  25058. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25059. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25060. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25061. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25062. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25063. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25064. * THE SOFTWARE.
  25065. */
  25066. Object.defineProperty(exports, "__esModule", { value: true });
  25067. var CssClasses;
  25068. (function (CssClasses) {
  25069. CssClasses["RICH"] = "mdc-tooltip--rich";
  25070. CssClasses["SHOWN"] = "mdc-tooltip--shown";
  25071. CssClasses["SHOWING"] = "mdc-tooltip--showing";
  25072. CssClasses["SHOWING_TRANSITION"] = "mdc-tooltip--showing-transition";
  25073. CssClasses["HIDE"] = "mdc-tooltip--hide";
  25074. CssClasses["HIDE_TRANSITION"] = "mdc-tooltip--hide-transition";
  25075. CssClasses["MULTILINE_TOOLTIP"] = "mdc-tooltip--multiline";
  25076. })(CssClasses || (CssClasses = {}));
  25077. exports.CssClasses = CssClasses;
  25078. var numbers = {
  25079. BOUNDED_ANCHOR_GAP: 4,
  25080. UNBOUNDED_ANCHOR_GAP: 8,
  25081. MIN_VIEWPORT_TOOLTIP_THRESHOLD: 8,
  25082. HIDE_DELAY_MS: 600,
  25083. SHOW_DELAY_MS: 500,
  25084. // LINT.IfChange(tooltip-dimensions)
  25085. MIN_HEIGHT: 24,
  25086. MAX_WIDTH: 200
  25087. };
  25088. exports.numbers = numbers;
  25089. var attributes = {
  25090. ARIA_EXPANDED: 'aria-expanded',
  25091. ARIA_HASPOPUP: 'aria-haspopup',
  25092. PERSISTENT: 'data-mdc-tooltip-persistent'
  25093. };
  25094. exports.attributes = attributes;
  25095. var events = {
  25096. HIDDEN: 'MDCTooltip:hidden'
  25097. };
  25098. exports.events = events;
  25099. /** Enum for possible tooltip positioning relative to its anchor element. */
  25100. var XPosition;
  25101. (function (XPosition) {
  25102. XPosition[XPosition["DETECTED"] = 0] = "DETECTED";
  25103. XPosition[XPosition["START"] = 1] = "START";
  25104. // Note: CENTER is not valid for rich tooltips.
  25105. XPosition[XPosition["CENTER"] = 2] = "CENTER";
  25106. XPosition[XPosition["END"] = 3] = "END";
  25107. })(XPosition || (XPosition = {}));
  25108. exports.XPosition = XPosition;
  25109. var YPosition;
  25110. (function (YPosition) {
  25111. YPosition[YPosition["DETECTED"] = 0] = "DETECTED";
  25112. YPosition[YPosition["ABOVE"] = 1] = "ABOVE";
  25113. YPosition[YPosition["BELOW"] = 2] = "BELOW";
  25114. })(YPosition || (YPosition = {}));
  25115. exports.YPosition = YPosition;
  25116. /**
  25117. * Enum for possible anchor boundary types. This determines the gap between the
  25118. * bottom of the anchor and the tooltip element.
  25119. * Bounded anchors have an identifiable boundary (e.g. buttons).
  25120. * Unbounded anchors don't have a visually declared boundary (e.g. plain text).
  25121. */
  25122. var AnchorBoundaryType;
  25123. (function (AnchorBoundaryType) {
  25124. AnchorBoundaryType[AnchorBoundaryType["BOUNDED"] = 0] = "BOUNDED";
  25125. AnchorBoundaryType[AnchorBoundaryType["UNBOUNDED"] = 1] = "UNBOUNDED";
  25126. })(AnchorBoundaryType || (AnchorBoundaryType = {}));
  25127. exports.AnchorBoundaryType = AnchorBoundaryType;
  25128. /***/ }),
  25129. /***/ "./packages/mdc-tooltip/foundation.ts":
  25130. /*!********************************************!*\
  25131. !*** ./packages/mdc-tooltip/foundation.ts ***!
  25132. \********************************************/
  25133. /*! no static exports found */
  25134. /***/ (function(module, exports, __webpack_require__) {
  25135. "use strict";
  25136. /**
  25137. * @license
  25138. * Copyright 2020 Google Inc.
  25139. *
  25140. * Permission is hereby granted, free of charge, to any person obtaining a copy
  25141. * of this software and associated documentation files (the "Software"), to deal
  25142. * in the Software without restriction, including without limitation the rights
  25143. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  25144. * copies of the Software, and to permit persons to whom the Software is
  25145. * furnished to do so, subject to the following conditions:
  25146. *
  25147. * The above copyright notice and this permission notice shall be included in
  25148. * all copies or substantial portions of the Software.
  25149. *
  25150. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25151. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25152. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25153. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25154. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25155. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25156. * THE SOFTWARE.
  25157. */
  25158. var __extends = this && this.__extends || function () {
  25159. var _extendStatics = function extendStatics(d, b) {
  25160. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  25161. d.__proto__ = b;
  25162. } || function (d, b) {
  25163. for (var p in b) {
  25164. if (b.hasOwnProperty(p)) d[p] = b[p];
  25165. }
  25166. };
  25167. return _extendStatics(d, b);
  25168. };
  25169. return function (d, b) {
  25170. _extendStatics(d, b);
  25171. function __() {
  25172. this.constructor = d;
  25173. }
  25174. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25175. };
  25176. }();
  25177. var __assign = this && this.__assign || function () {
  25178. __assign = Object.assign || function (t) {
  25179. for (var s, i = 1, n = arguments.length; i < n; i++) {
  25180. s = arguments[i];
  25181. for (var p in s) {
  25182. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  25183. }
  25184. }
  25185. return t;
  25186. };
  25187. return __assign.apply(this, arguments);
  25188. };
  25189. var __values = this && this.__values || function (o) {
  25190. var s = typeof Symbol === "function" && Symbol.iterator,
  25191. m = s && o[s],
  25192. i = 0;
  25193. if (m) return m.call(o);
  25194. if (o && typeof o.length === "number") return {
  25195. next: function next() {
  25196. if (o && i >= o.length) o = void 0;
  25197. return { value: o && o[i++], done: !o };
  25198. }
  25199. };
  25200. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  25201. };
  25202. Object.defineProperty(exports, "__esModule", { value: true });
  25203. var animationframe_1 = __webpack_require__(/*! @material/animation/animationframe */ "./packages/mdc-animation/animationframe.ts");
  25204. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  25205. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  25206. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts");
  25207. var RICH = constants_1.CssClasses.RICH,
  25208. SHOWN = constants_1.CssClasses.SHOWN,
  25209. SHOWING = constants_1.CssClasses.SHOWING,
  25210. SHOWING_TRANSITION = constants_1.CssClasses.SHOWING_TRANSITION,
  25211. HIDE = constants_1.CssClasses.HIDE,
  25212. HIDE_TRANSITION = constants_1.CssClasses.HIDE_TRANSITION,
  25213. MULTILINE_TOOLTIP = constants_1.CssClasses.MULTILINE_TOOLTIP;
  25214. var AnimationKeys;
  25215. (function (AnimationKeys) {
  25216. AnimationKeys["POLL_ANCHOR"] = "poll_anchor";
  25217. })(AnimationKeys || (AnimationKeys = {}));
  25218. var MDCTooltipFoundation = /** @class */function (_super) {
  25219. __extends(MDCTooltipFoundation, _super);
  25220. function MDCTooltipFoundation(adapter) {
  25221. var _this = _super.call(this, __assign(__assign({}, MDCTooltipFoundation.defaultAdapter), adapter)) || this;
  25222. _this.tooltipShown = false;
  25223. _this.anchorGap = constants_1.numbers.BOUNDED_ANCHOR_GAP;
  25224. _this.xTooltipPos = constants_1.XPosition.DETECTED;
  25225. _this.yTooltipPos = constants_1.YPosition.DETECTED;
  25226. // Minimum threshold distance needed between the tooltip and the viewport.
  25227. _this.minViewportTooltipThreshold = constants_1.numbers.MIN_VIEWPORT_TOOLTIP_THRESHOLD;
  25228. _this.hideDelayMs = constants_1.numbers.HIDE_DELAY_MS;
  25229. _this.showDelayMs = constants_1.numbers.SHOW_DELAY_MS;
  25230. _this.anchorRect = null;
  25231. _this.frameId = null;
  25232. _this.hideTimeout = null;
  25233. _this.showTimeout = null;
  25234. _this.animFrame = new animationframe_1.AnimationFrame();
  25235. _this.documentClickHandler = function (evt) {
  25236. _this.handleDocumentClick(evt);
  25237. };
  25238. _this.documentKeydownHandler = function (evt) {
  25239. _this.handleKeydown(evt);
  25240. };
  25241. _this.richTooltipMouseEnterHandler = function () {
  25242. _this.handleRichTooltipMouseEnter();
  25243. };
  25244. _this.richTooltipMouseLeaveHandler = function () {
  25245. _this.handleRichTooltipMouseLeave();
  25246. };
  25247. _this.richTooltipFocusOutHandler = function (evt) {
  25248. _this.handleRichTooltipFocusOut(evt);
  25249. };
  25250. _this.windowScrollHandler = function () {
  25251. _this.handleWindowChangeEvent();
  25252. };
  25253. _this.windowResizeHandler = function () {
  25254. _this.handleWindowChangeEvent();
  25255. };
  25256. return _this;
  25257. }
  25258. Object.defineProperty(MDCTooltipFoundation, "defaultAdapter", {
  25259. get: function get() {
  25260. return {
  25261. getAttribute: function getAttribute() {
  25262. return null;
  25263. },
  25264. setAttribute: function setAttribute() {
  25265. return undefined;
  25266. },
  25267. addClass: function addClass() {
  25268. return undefined;
  25269. },
  25270. hasClass: function hasClass() {
  25271. return false;
  25272. },
  25273. removeClass: function removeClass() {
  25274. return undefined;
  25275. },
  25276. setStyleProperty: function setStyleProperty() {
  25277. return undefined;
  25278. },
  25279. getViewportWidth: function getViewportWidth() {
  25280. return 0;
  25281. },
  25282. getViewportHeight: function getViewportHeight() {
  25283. return 0;
  25284. },
  25285. getTooltipSize: function getTooltipSize() {
  25286. return { width: 0, height: 0 };
  25287. },
  25288. getAnchorBoundingRect: function getAnchorBoundingRect() {
  25289. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  25290. },
  25291. getAnchorAttribute: function getAnchorAttribute() {
  25292. return null;
  25293. },
  25294. setAnchorAttribute: function setAnchorAttribute() {
  25295. return null;
  25296. },
  25297. isRTL: function isRTL() {
  25298. return false;
  25299. },
  25300. anchorContainsElement: function anchorContainsElement() {
  25301. return false;
  25302. },
  25303. tooltipContainsElement: function tooltipContainsElement() {
  25304. return false;
  25305. },
  25306. focusAnchorElement: function focusAnchorElement() {
  25307. return undefined;
  25308. },
  25309. registerEventHandler: function registerEventHandler() {
  25310. return undefined;
  25311. },
  25312. deregisterEventHandler: function deregisterEventHandler() {
  25313. return undefined;
  25314. },
  25315. registerDocumentEventHandler: function registerDocumentEventHandler() {
  25316. return undefined;
  25317. },
  25318. deregisterDocumentEventHandler: function deregisterDocumentEventHandler() {
  25319. return undefined;
  25320. },
  25321. registerWindowEventHandler: function registerWindowEventHandler() {
  25322. return undefined;
  25323. },
  25324. deregisterWindowEventHandler: function deregisterWindowEventHandler() {
  25325. return undefined;
  25326. },
  25327. notifyHidden: function notifyHidden() {
  25328. return undefined;
  25329. }
  25330. };
  25331. },
  25332. enumerable: true,
  25333. configurable: true
  25334. });
  25335. MDCTooltipFoundation.prototype.init = function () {
  25336. this.richTooltip = this.adapter.hasClass(RICH);
  25337. this.persistentTooltip = this.adapter.getAttribute(constants_1.attributes.PERSISTENT) === 'true';
  25338. this.interactiveTooltip = !!this.adapter.getAnchorAttribute(constants_1.attributes.ARIA_EXPANDED) && this.adapter.getAnchorAttribute(constants_1.attributes.ARIA_HASPOPUP) === 'dialog';
  25339. };
  25340. MDCTooltipFoundation.prototype.isShown = function () {
  25341. return this.tooltipShown;
  25342. };
  25343. MDCTooltipFoundation.prototype.isRich = function () {
  25344. return this.richTooltip;
  25345. };
  25346. MDCTooltipFoundation.prototype.isPersistent = function () {
  25347. return this.persistentTooltip;
  25348. };
  25349. MDCTooltipFoundation.prototype.handleAnchorMouseEnter = function () {
  25350. var _this = this;
  25351. if (this.tooltipShown) {
  25352. // Covers the instance where a user hovers over the anchor to reveal the
  25353. // tooltip, and then quickly navigates away and then back to the anchor.
  25354. // The tooltip should stay visible without animating out and then back in
  25355. // again.
  25356. this.show();
  25357. } else {
  25358. // clearHideTimeout here since handleAnchorMouseLeave sets a hideTimeout
  25359. // and that can execute before the showTimeout executes, resulting in hide
  25360. // being called and the showTimeout set below to be cleared.
  25361. this.clearHideTimeout();
  25362. this.showTimeout = setTimeout(function () {
  25363. _this.show();
  25364. }, this.showDelayMs);
  25365. }
  25366. };
  25367. MDCTooltipFoundation.prototype.handleAnchorFocus = function (evt) {
  25368. var _this = this;
  25369. // TODO(b/157075286): Need to add some way to distinguish keyboard
  25370. // navigation focus events from other focus events, and only show the
  25371. // tooltip on the former of these events.
  25372. var relatedTarget = evt.relatedTarget;
  25373. var tooltipContainsRelatedTarget = relatedTarget instanceof HTMLElement && this.adapter.tooltipContainsElement(relatedTarget);
  25374. // Do not show tooltip if the previous focus was on a tooltip element. This
  25375. // occurs when a rich tooltip is closed and focus is restored to the anchor
  25376. // or when user tab-navigates back into the anchor from the rich tooltip.
  25377. if (tooltipContainsRelatedTarget) {
  25378. return;
  25379. }
  25380. this.showTimeout = setTimeout(function () {
  25381. _this.show();
  25382. }, this.showDelayMs);
  25383. };
  25384. MDCTooltipFoundation.prototype.handleAnchorMouseLeave = function () {
  25385. var _this = this;
  25386. this.clearShowTimeout();
  25387. this.hideTimeout = setTimeout(function () {
  25388. _this.hide();
  25389. }, this.hideDelayMs);
  25390. };
  25391. MDCTooltipFoundation.prototype.handleAnchorBlur = function (evt) {
  25392. if (this.richTooltip) {
  25393. var tooltipContainsRelatedTargetElement = evt.relatedTarget instanceof HTMLElement && this.adapter.tooltipContainsElement(evt.relatedTarget);
  25394. // If focus changed to the tooltip element, don't hide the tooltip.
  25395. if (tooltipContainsRelatedTargetElement) {
  25396. return;
  25397. }
  25398. }
  25399. // Hide tooltip immediately on focus change.
  25400. this.hide();
  25401. };
  25402. MDCTooltipFoundation.prototype.handleAnchorClick = function () {
  25403. if (this.tooltipShown) {
  25404. this.hide();
  25405. } else {
  25406. this.show();
  25407. }
  25408. };
  25409. MDCTooltipFoundation.prototype.handleDocumentClick = function (evt) {
  25410. var anchorOrTooltipContainsTargetElement = evt.target instanceof HTMLElement && (this.adapter.anchorContainsElement(evt.target) || this.adapter.tooltipContainsElement(evt.target));
  25411. // For persistent rich tooltips, we will not hide if:
  25412. // - The click target is within the anchor element. Otherwise, both
  25413. // the anchor element's click handler and this handler will handle the
  25414. // click (due to event propagation), resulting in a shown tooltip
  25415. // being immediately hidden if the tooltip was initially hidden.
  25416. // - The click target is within the tooltip element, since clicks
  25417. // on the tooltip do not close the tooltip.
  25418. if (this.richTooltip && this.persistentTooltip && anchorOrTooltipContainsTargetElement) {
  25419. return;
  25420. }
  25421. // Hide the tooltip immediately on click.
  25422. this.hide();
  25423. };
  25424. MDCTooltipFoundation.prototype.handleKeydown = function (evt) {
  25425. // Hide the tooltip immediately on ESC key.
  25426. var key = keyboard_1.normalizeKey(evt);
  25427. if (key === keyboard_1.KEY.ESCAPE) {
  25428. var tooltipContainsActiveElement = document.activeElement instanceof HTMLElement && this.adapter.tooltipContainsElement(document.activeElement);
  25429. if (tooltipContainsActiveElement) {
  25430. this.adapter.focusAnchorElement();
  25431. }
  25432. this.hide();
  25433. }
  25434. };
  25435. MDCTooltipFoundation.prototype.handleRichTooltipMouseEnter = function () {
  25436. this.show();
  25437. };
  25438. MDCTooltipFoundation.prototype.handleRichTooltipMouseLeave = function () {
  25439. var _this = this;
  25440. this.clearShowTimeout();
  25441. this.hideTimeout = setTimeout(function () {
  25442. _this.hide();
  25443. }, this.hideDelayMs);
  25444. };
  25445. MDCTooltipFoundation.prototype.handleRichTooltipFocusOut = function (evt) {
  25446. var anchorOrTooltipContainsRelatedTargetElement = evt.relatedTarget instanceof HTMLElement && (this.adapter.anchorContainsElement(evt.relatedTarget) || this.adapter.tooltipContainsElement(evt.relatedTarget));
  25447. // If the focus is still within the anchor or the tooltip, do not hide the
  25448. // tooltip.
  25449. if (anchorOrTooltipContainsRelatedTargetElement) {
  25450. return;
  25451. }
  25452. this.hide();
  25453. };
  25454. /**
  25455. * On window resize or scroll, check the anchor position and size and
  25456. * repostion tooltip if necessary.
  25457. */
  25458. MDCTooltipFoundation.prototype.handleWindowChangeEvent = function () {
  25459. var _this = this;
  25460. // Since scroll and resize events can fire at a high rate, we throttle
  25461. // the potential re-positioning of tooltip component using
  25462. // requestAnimationFrame.
  25463. this.animFrame.request(AnimationKeys.POLL_ANCHOR, function () {
  25464. _this.repositionTooltipOnAnchorMove();
  25465. });
  25466. };
  25467. MDCTooltipFoundation.prototype.show = function () {
  25468. var _this = this;
  25469. this.clearHideTimeout();
  25470. this.clearShowTimeout();
  25471. if (this.tooltipShown) {
  25472. return;
  25473. }
  25474. this.tooltipShown = true;
  25475. var showTooltipOptions = this.parseShowTooltipOptions();
  25476. if (!showTooltipOptions.hideFromScreenreader) {
  25477. this.adapter.setAttribute('aria-hidden', 'false');
  25478. }
  25479. if (this.richTooltip) {
  25480. if (this.interactiveTooltip) {
  25481. this.adapter.setAnchorAttribute('aria-expanded', 'true');
  25482. }
  25483. this.adapter.registerEventHandler('focusout', this.richTooltipFocusOutHandler);
  25484. if (!this.persistentTooltip) {
  25485. this.adapter.registerEventHandler('mouseenter', this.richTooltipMouseEnterHandler);
  25486. this.adapter.registerEventHandler('mouseleave', this.richTooltipMouseLeaveHandler);
  25487. }
  25488. }
  25489. this.adapter.removeClass(HIDE);
  25490. this.adapter.addClass(SHOWING);
  25491. if (this.isTooltipMultiline() && !this.richTooltip) {
  25492. this.adapter.addClass(MULTILINE_TOOLTIP);
  25493. }
  25494. this.anchorRect = this.adapter.getAnchorBoundingRect();
  25495. this.positionTooltip();
  25496. this.adapter.registerDocumentEventHandler('click', this.documentClickHandler);
  25497. this.adapter.registerDocumentEventHandler('keydown', this.documentKeydownHandler);
  25498. this.adapter.registerWindowEventHandler('scroll', this.windowScrollHandler);
  25499. this.adapter.registerWindowEventHandler('resize', this.windowResizeHandler);
  25500. this.frameId = requestAnimationFrame(function () {
  25501. _this.clearAllAnimationClasses();
  25502. _this.adapter.addClass(SHOWN);
  25503. _this.adapter.addClass(SHOWING_TRANSITION);
  25504. });
  25505. };
  25506. MDCTooltipFoundation.prototype.hide = function () {
  25507. this.clearHideTimeout();
  25508. this.clearShowTimeout();
  25509. if (!this.tooltipShown) {
  25510. return;
  25511. }
  25512. if (this.frameId) {
  25513. cancelAnimationFrame(this.frameId);
  25514. }
  25515. this.tooltipShown = false;
  25516. this.adapter.setAttribute('aria-hidden', 'true');
  25517. this.adapter.deregisterEventHandler('focusout', this.richTooltipFocusOutHandler);
  25518. if (this.richTooltip) {
  25519. if (this.interactiveTooltip) {
  25520. this.adapter.setAnchorAttribute('aria-expanded', 'false');
  25521. }
  25522. if (!this.persistentTooltip) {
  25523. this.adapter.deregisterEventHandler('mouseenter', this.richTooltipMouseEnterHandler);
  25524. this.adapter.deregisterEventHandler('mouseleave', this.richTooltipMouseLeaveHandler);
  25525. }
  25526. }
  25527. this.clearAllAnimationClasses();
  25528. this.adapter.addClass(HIDE);
  25529. this.adapter.addClass(HIDE_TRANSITION);
  25530. this.adapter.removeClass(SHOWN);
  25531. this.adapter.deregisterDocumentEventHandler('click', this.documentClickHandler);
  25532. this.adapter.deregisterDocumentEventHandler('keydown', this.documentKeydownHandler);
  25533. this.adapter.deregisterWindowEventHandler('scroll', this.windowScrollHandler);
  25534. this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
  25535. };
  25536. MDCTooltipFoundation.prototype.handleTransitionEnd = function () {
  25537. var isHidingTooltip = this.adapter.hasClass(HIDE);
  25538. this.adapter.removeClass(SHOWING);
  25539. this.adapter.removeClass(SHOWING_TRANSITION);
  25540. this.adapter.removeClass(HIDE);
  25541. this.adapter.removeClass(HIDE_TRANSITION);
  25542. // If handleTransitionEnd is called after hiding the tooltip, the tooltip
  25543. // will have the HIDE class (before calling the adapter removeClass method).
  25544. // If tooltip is now hidden, send a notification that the animation has
  25545. // completed and the tooltip is no longer visible.
  25546. if (isHidingTooltip) {
  25547. this.adapter.notifyHidden();
  25548. }
  25549. };
  25550. MDCTooltipFoundation.prototype.clearAllAnimationClasses = function () {
  25551. this.adapter.removeClass(SHOWING_TRANSITION);
  25552. this.adapter.removeClass(HIDE_TRANSITION);
  25553. };
  25554. MDCTooltipFoundation.prototype.setTooltipPosition = function (position) {
  25555. var xPos = position.xPos,
  25556. yPos = position.yPos;
  25557. if (xPos) {
  25558. this.xTooltipPos = xPos;
  25559. }
  25560. if (yPos) {
  25561. this.yTooltipPos = yPos;
  25562. }
  25563. };
  25564. MDCTooltipFoundation.prototype.setAnchorBoundaryType = function (type) {
  25565. if (type === constants_1.AnchorBoundaryType.UNBOUNDED) {
  25566. this.anchorGap = constants_1.numbers.UNBOUNDED_ANCHOR_GAP;
  25567. } else {
  25568. this.anchorGap = constants_1.numbers.BOUNDED_ANCHOR_GAP;
  25569. }
  25570. };
  25571. MDCTooltipFoundation.prototype.parseShowTooltipOptions = function () {
  25572. var hideFromScreenreader = Boolean(this.adapter.getAnchorAttribute('data-tooltip-id'));
  25573. return { hideFromScreenreader: hideFromScreenreader };
  25574. };
  25575. MDCTooltipFoundation.prototype.isTooltipMultiline = function () {
  25576. var tooltipSize = this.adapter.getTooltipSize();
  25577. return tooltipSize.height > constants_1.numbers.MIN_HEIGHT && tooltipSize.width >= constants_1.numbers.MAX_WIDTH;
  25578. };
  25579. MDCTooltipFoundation.prototype.positionTooltip = function () {
  25580. var _a = this.calculateTooltipDistance(this.anchorRect),
  25581. top = _a.top,
  25582. left = _a.left;
  25583. this.adapter.setStyleProperty('top', top + "px");
  25584. this.adapter.setStyleProperty('left', left + "px");
  25585. };
  25586. /**
  25587. * Calculates the position of the tooltip. A tooltip will be placed beneath
  25588. * the anchor element and aligned either with the 'start'/'end' edge of the
  25589. * anchor element or the 'center'.
  25590. *
  25591. * Tooltip alignment is selected such that the tooltip maintains a threshold
  25592. * distance away from the viewport (defaulting to 'center' alignment). If the
  25593. * placement of the anchor prevents this threshold distance from being
  25594. * maintained, the tooltip is positioned so that it does not collide with the
  25595. * viewport.
  25596. *
  25597. * Users can specify an alignment, however, if this alignment results in the
  25598. * tooltip colliding with the viewport, this specification is overwritten.
  25599. */
  25600. MDCTooltipFoundation.prototype.calculateTooltipDistance = function (anchorRect) {
  25601. if (!anchorRect) {
  25602. return { top: 0, left: 0 };
  25603. }
  25604. var tooltipSize = this.adapter.getTooltipSize();
  25605. var top = this.calculateYTooltipDistance(anchorRect, tooltipSize.height);
  25606. var left = this.calculateXTooltipDistance(anchorRect, tooltipSize.width);
  25607. return { top: top, left: left };
  25608. };
  25609. /**
  25610. * Calculates the `left` distance for the tooltip.
  25611. */
  25612. MDCTooltipFoundation.prototype.calculateXTooltipDistance = function (anchorRect, tooltipWidth) {
  25613. var isLTR = !this.adapter.isRTL();
  25614. var startPos, endPos, centerPos;
  25615. if (this.richTooltip) {
  25616. startPos = isLTR ? anchorRect.left - tooltipWidth : anchorRect.right;
  25617. endPos = isLTR ? anchorRect.right : anchorRect.left - tooltipWidth;
  25618. } else {
  25619. startPos = isLTR ? anchorRect.left : anchorRect.right - tooltipWidth;
  25620. endPos = isLTR ? anchorRect.right - tooltipWidth : anchorRect.left;
  25621. centerPos = anchorRect.left + (anchorRect.width - tooltipWidth) / 2;
  25622. }
  25623. var positionOptions = this.richTooltip ? this.determineValidPositionOptions(startPos, endPos) :
  25624. // For plain tooltips, centerPos is defined
  25625. this.determineValidPositionOptions(centerPos, startPos, endPos);
  25626. if (this.xTooltipPos === constants_1.XPosition.START && positionOptions.has(startPos)) {
  25627. return startPos;
  25628. }
  25629. if (this.xTooltipPos === constants_1.XPosition.END && positionOptions.has(endPos)) {
  25630. return endPos;
  25631. }
  25632. if (this.xTooltipPos === constants_1.XPosition.CENTER && positionOptions.has(centerPos)) {
  25633. return centerPos;
  25634. }
  25635. // If no user position is supplied, rich tooltips default to end pos, then
  25636. // start position. Plain tooltips default to center, start, then end.
  25637. var possiblePositions = this.richTooltip ? [endPos, startPos] : [centerPos, startPos, endPos];
  25638. var validPosition = possiblePositions.find(function (pos) {
  25639. return positionOptions.has(pos);
  25640. });
  25641. if (validPosition) {
  25642. return validPosition;
  25643. }
  25644. // Indicates that all potential positions would result in the tooltip
  25645. // colliding with the viewport. This would only occur when the anchor
  25646. // element itself collides with the viewport, or the viewport is very
  25647. // narrow. In this case, we allow the tooltip to be mis-aligned from the
  25648. // anchor element.
  25649. if (anchorRect.left < 0) {
  25650. return this.minViewportTooltipThreshold;
  25651. } else {
  25652. var viewportWidth = this.adapter.getViewportWidth();
  25653. return viewportWidth - (tooltipWidth + this.minViewportTooltipThreshold);
  25654. }
  25655. };
  25656. /**
  25657. * Given the values for the horizontal alignments of the tooltip, calculates
  25658. * which of these options would result in the tooltip maintaining the required
  25659. * threshold distance vs which would result in the tooltip staying within the
  25660. * viewport.
  25661. *
  25662. * A Set of values is returned holding the distances that would honor the
  25663. * above requirements. Following the logic for determining the tooltip
  25664. * position, if all alignments violate the threshold, then the returned Set
  25665. * contains values that keep the tooltip within the viewport.
  25666. */
  25667. MDCTooltipFoundation.prototype.determineValidPositionOptions = function () {
  25668. var e_1, _a;
  25669. var positions = [];
  25670. for (var _i = 0; _i < arguments.length; _i++) {
  25671. positions[_i] = arguments[_i];
  25672. }
  25673. var posWithinThreshold = new Set();
  25674. var posWithinViewport = new Set();
  25675. try {
  25676. for (var positions_1 = __values(positions), positions_1_1 = positions_1.next(); !positions_1_1.done; positions_1_1 = positions_1.next()) {
  25677. var position = positions_1_1.value;
  25678. if (this.positionHonorsViewportThreshold(position)) {
  25679. posWithinThreshold.add(position);
  25680. } else if (this.positionDoesntCollideWithViewport(position)) {
  25681. posWithinViewport.add(position);
  25682. }
  25683. }
  25684. } catch (e_1_1) {
  25685. e_1 = { error: e_1_1 };
  25686. } finally {
  25687. try {
  25688. if (positions_1_1 && !positions_1_1.done && (_a = positions_1.return)) _a.call(positions_1);
  25689. } finally {
  25690. if (e_1) throw e_1.error;
  25691. }
  25692. }
  25693. return posWithinThreshold.size ? posWithinThreshold : posWithinViewport;
  25694. };
  25695. MDCTooltipFoundation.prototype.positionHonorsViewportThreshold = function (leftPos) {
  25696. var viewportWidth = this.adapter.getViewportWidth();
  25697. var tooltipWidth = this.adapter.getTooltipSize().width;
  25698. return leftPos + tooltipWidth <= viewportWidth - this.minViewportTooltipThreshold && leftPos >= this.minViewportTooltipThreshold;
  25699. };
  25700. MDCTooltipFoundation.prototype.positionDoesntCollideWithViewport = function (leftPos) {
  25701. var viewportWidth = this.adapter.getViewportWidth();
  25702. var tooltipWidth = this.adapter.getTooltipSize().width;
  25703. return leftPos + tooltipWidth <= viewportWidth && leftPos >= 0;
  25704. };
  25705. /**
  25706. * Calculates the `top` distance for the tooltip.
  25707. */
  25708. MDCTooltipFoundation.prototype.calculateYTooltipDistance = function (anchorRect, tooltipHeight) {
  25709. var belowYPos = anchorRect.bottom + this.anchorGap;
  25710. var aboveYPos = anchorRect.top - (this.anchorGap + tooltipHeight);
  25711. var yPositionOptions = this.determineValidYPositionOptions(aboveYPos, belowYPos);
  25712. if (this.yTooltipPos === constants_1.YPosition.ABOVE && yPositionOptions.has(aboveYPos)) {
  25713. return aboveYPos;
  25714. } else if (this.yTooltipPos === constants_1.YPosition.BELOW && yPositionOptions.has(belowYPos)) {
  25715. return belowYPos;
  25716. }
  25717. if (yPositionOptions.has(belowYPos)) {
  25718. return belowYPos;
  25719. }
  25720. if (yPositionOptions.has(aboveYPos)) {
  25721. return aboveYPos;
  25722. }
  25723. // Indicates that all potential positions would result in the tooltip
  25724. // colliding with the viewport. This would only occur when the viewport is
  25725. // very short.
  25726. return belowYPos;
  25727. };
  25728. /**
  25729. * Given the values for above/below alignment of the tooltip, calculates
  25730. * which of these options would result in the tooltip maintaining the required
  25731. * threshold distance vs which would result in the tooltip staying within the
  25732. * viewport.
  25733. *
  25734. * A Set of values is returned holding the distances that would honor the
  25735. * above requirements. Following the logic for determining the tooltip
  25736. * position, if all possible alignments violate the threshold, then the
  25737. * returned Set contains values that keep the tooltip within the viewport.
  25738. */
  25739. MDCTooltipFoundation.prototype.determineValidYPositionOptions = function (aboveAnchorPos, belowAnchorPos) {
  25740. var posWithinThreshold = new Set();
  25741. var posWithinViewport = new Set();
  25742. if (this.yPositionHonorsViewportThreshold(aboveAnchorPos)) {
  25743. posWithinThreshold.add(aboveAnchorPos);
  25744. } else if (this.yPositionDoesntCollideWithViewport(aboveAnchorPos)) {
  25745. posWithinViewport.add(aboveAnchorPos);
  25746. }
  25747. if (this.yPositionHonorsViewportThreshold(belowAnchorPos)) {
  25748. posWithinThreshold.add(belowAnchorPos);
  25749. } else if (this.yPositionDoesntCollideWithViewport(belowAnchorPos)) {
  25750. posWithinViewport.add(belowAnchorPos);
  25751. }
  25752. return posWithinThreshold.size ? posWithinThreshold : posWithinViewport;
  25753. };
  25754. MDCTooltipFoundation.prototype.yPositionHonorsViewportThreshold = function (yPos) {
  25755. var viewportHeight = this.adapter.getViewportHeight();
  25756. var tooltipHeight = this.adapter.getTooltipSize().height;
  25757. return yPos + tooltipHeight + this.minViewportTooltipThreshold <= viewportHeight && yPos >= this.minViewportTooltipThreshold;
  25758. };
  25759. MDCTooltipFoundation.prototype.yPositionDoesntCollideWithViewport = function (yPos) {
  25760. var viewportHeight = this.adapter.getViewportHeight();
  25761. var tooltipHeight = this.adapter.getTooltipSize().height;
  25762. return yPos + tooltipHeight <= viewportHeight && yPos >= 0;
  25763. };
  25764. MDCTooltipFoundation.prototype.repositionTooltipOnAnchorMove = function () {
  25765. var newAnchorRect = this.adapter.getAnchorBoundingRect();
  25766. if (!newAnchorRect || !this.anchorRect) return;
  25767. if (newAnchorRect.top !== this.anchorRect.top || newAnchorRect.left !== this.anchorRect.left || newAnchorRect.height !== this.anchorRect.height || newAnchorRect.width !== this.anchorRect.width) {
  25768. this.anchorRect = newAnchorRect;
  25769. this.positionTooltip();
  25770. }
  25771. };
  25772. MDCTooltipFoundation.prototype.clearShowTimeout = function () {
  25773. if (this.showTimeout) {
  25774. clearTimeout(this.showTimeout);
  25775. this.showTimeout = null;
  25776. }
  25777. };
  25778. MDCTooltipFoundation.prototype.clearHideTimeout = function () {
  25779. if (this.hideTimeout) {
  25780. clearTimeout(this.hideTimeout);
  25781. this.hideTimeout = null;
  25782. }
  25783. };
  25784. MDCTooltipFoundation.prototype.destroy = function () {
  25785. if (this.frameId) {
  25786. cancelAnimationFrame(this.frameId);
  25787. this.frameId = null;
  25788. }
  25789. this.clearHideTimeout();
  25790. this.clearShowTimeout();
  25791. this.adapter.removeClass(SHOWN);
  25792. this.adapter.removeClass(SHOWING_TRANSITION);
  25793. this.adapter.removeClass(SHOWING);
  25794. this.adapter.removeClass(HIDE);
  25795. this.adapter.removeClass(HIDE_TRANSITION);
  25796. if (this.richTooltip) {
  25797. this.adapter.deregisterEventHandler('focusout', this.richTooltipFocusOutHandler);
  25798. if (!this.persistentTooltip) {
  25799. this.adapter.deregisterEventHandler('mouseenter', this.richTooltipMouseEnterHandler);
  25800. this.adapter.deregisterEventHandler('mouseleave', this.richTooltipMouseLeaveHandler);
  25801. }
  25802. }
  25803. this.adapter.deregisterDocumentEventHandler('click', this.documentClickHandler);
  25804. this.adapter.deregisterDocumentEventHandler('keydown', this.documentKeydownHandler);
  25805. this.adapter.deregisterWindowEventHandler('scroll', this.windowScrollHandler);
  25806. this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
  25807. this.animFrame.cancelAll();
  25808. };
  25809. return MDCTooltipFoundation;
  25810. }(foundation_1.MDCFoundation);
  25811. exports.MDCTooltipFoundation = MDCTooltipFoundation;
  25812. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  25813. exports.default = MDCTooltipFoundation;
  25814. /***/ }),
  25815. /***/ "./packages/mdc-tooltip/index.ts":
  25816. /*!***************************************!*\
  25817. !*** ./packages/mdc-tooltip/index.ts ***!
  25818. \***************************************/
  25819. /*! no static exports found */
  25820. /***/ (function(module, exports, __webpack_require__) {
  25821. "use strict";
  25822. /**
  25823. * @license
  25824. * Copyright 2020 Google Inc.
  25825. *
  25826. * Permission is hereby granted, free of charge, to any person obtaining a copy
  25827. * of this software and associated documentation files (the "Software"), to deal
  25828. * in the Software without restriction, including without limitation the rights
  25829. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  25830. * copies of the Software, and to permit persons to whom the Software is
  25831. * furnished to do so, subject to the following conditions:
  25832. *
  25833. * The above copyright notice and this permission notice shall be included in
  25834. * all copies or substantial portions of the Software.
  25835. *
  25836. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25837. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25838. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25839. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25840. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25841. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25842. * THE SOFTWARE.
  25843. */
  25844. function __export(m) {
  25845. for (var p in m) {
  25846. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  25847. }
  25848. }
  25849. Object.defineProperty(exports, "__esModule", { value: true });
  25850. __export(__webpack_require__(/*! ./component */ "./packages/mdc-tooltip/component.ts"));
  25851. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tooltip/foundation.ts"));
  25852. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts"));
  25853. /***/ }),
  25854. /***/ "./packages/mdc-top-app-bar/component.ts":
  25855. /*!***********************************************!*\
  25856. !*** ./packages/mdc-top-app-bar/component.ts ***!
  25857. \***********************************************/
  25858. /*! no static exports found */
  25859. /***/ (function(module, exports, __webpack_require__) {
  25860. "use strict";
  25861. /**
  25862. * @license
  25863. * Copyright 2018 Google Inc.
  25864. *
  25865. * Permission is hereby granted, free of charge, to any person obtaining a copy
  25866. * of this software and associated documentation files (the "Software"), to deal
  25867. * in the Software without restriction, including without limitation the rights
  25868. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  25869. * copies of the Software, and to permit persons to whom the Software is
  25870. * furnished to do so, subject to the following conditions:
  25871. *
  25872. * The above copyright notice and this permission notice shall be included in
  25873. * all copies or substantial portions of the Software.
  25874. *
  25875. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  25876. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25877. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25878. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  25879. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25880. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25881. * THE SOFTWARE.
  25882. */
  25883. var __extends = this && this.__extends || function () {
  25884. var _extendStatics = function extendStatics(d, b) {
  25885. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  25886. d.__proto__ = b;
  25887. } || function (d, b) {
  25888. for (var p in b) {
  25889. if (b.hasOwnProperty(p)) d[p] = b[p];
  25890. }
  25891. };
  25892. return _extendStatics(d, b);
  25893. };
  25894. return function (d, b) {
  25895. _extendStatics(d, b);
  25896. function __() {
  25897. this.constructor = d;
  25898. }
  25899. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25900. };
  25901. }();
  25902. Object.defineProperty(exports, "__esModule", { value: true });
  25903. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  25904. var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  25905. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts");
  25906. var foundation_1 = __webpack_require__(/*! ./fixed/foundation */ "./packages/mdc-top-app-bar/fixed/foundation.ts");
  25907. var foundation_2 = __webpack_require__(/*! ./short/foundation */ "./packages/mdc-top-app-bar/short/foundation.ts");
  25908. var foundation_3 = __webpack_require__(/*! ./standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts");
  25909. var MDCTopAppBar = /** @class */function (_super) {
  25910. __extends(MDCTopAppBar, _super);
  25911. function MDCTopAppBar() {
  25912. return _super !== null && _super.apply(this, arguments) || this;
  25913. }
  25914. MDCTopAppBar.attachTo = function (root) {
  25915. return new MDCTopAppBar(root);
  25916. };
  25917. MDCTopAppBar.prototype.initialize = function (rippleFactory) {
  25918. if (rippleFactory === void 0) {
  25919. rippleFactory = function rippleFactory(el) {
  25920. return component_2.MDCRipple.attachTo(el);
  25921. };
  25922. }
  25923. this.navIcon_ = this.root.querySelector(constants_1.strings.NAVIGATION_ICON_SELECTOR);
  25924. // Get all icons in the toolbar and instantiate the ripples
  25925. var icons = [].slice.call(this.root.querySelectorAll(constants_1.strings.ACTION_ITEM_SELECTOR));
  25926. if (this.navIcon_) {
  25927. icons.push(this.navIcon_);
  25928. }
  25929. this.iconRipples_ = icons.map(function (icon) {
  25930. var ripple = rippleFactory(icon);
  25931. ripple.unbounded = true;
  25932. return ripple;
  25933. });
  25934. this.scrollTarget_ = window;
  25935. };
  25936. MDCTopAppBar.prototype.initialSyncWithDOM = function () {
  25937. this.handleNavigationClick_ = this.foundation.handleNavigationClick.bind(this.foundation);
  25938. this.handleWindowResize_ = this.foundation.handleWindowResize.bind(this.foundation);
  25939. this.handleTargetScroll_ = this.foundation.handleTargetScroll.bind(this.foundation);
  25940. this.scrollTarget_.addEventListener('scroll', this.handleTargetScroll_);
  25941. if (this.navIcon_) {
  25942. this.navIcon_.addEventListener('click', this.handleNavigationClick_);
  25943. }
  25944. var isFixed = this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS);
  25945. var isShort = this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS);
  25946. if (!isShort && !isFixed) {
  25947. window.addEventListener('resize', this.handleWindowResize_);
  25948. }
  25949. };
  25950. MDCTopAppBar.prototype.destroy = function () {
  25951. this.iconRipples_.forEach(function (iconRipple) {
  25952. return iconRipple.destroy();
  25953. });
  25954. this.scrollTarget_.removeEventListener('scroll', this.handleTargetScroll_);
  25955. if (this.navIcon_) {
  25956. this.navIcon_.removeEventListener('click', this.handleNavigationClick_);
  25957. }
  25958. var isFixed = this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS);
  25959. var isShort = this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS);
  25960. if (!isShort && !isFixed) {
  25961. window.removeEventListener('resize', this.handleWindowResize_);
  25962. }
  25963. _super.prototype.destroy.call(this);
  25964. };
  25965. MDCTopAppBar.prototype.setScrollTarget = function (target) {
  25966. // Remove scroll handler from the previous scroll target
  25967. this.scrollTarget_.removeEventListener('scroll', this.handleTargetScroll_);
  25968. this.scrollTarget_ = target;
  25969. // Initialize scroll handler on the new scroll target
  25970. this.handleTargetScroll_ = this.foundation.handleTargetScroll.bind(this.foundation);
  25971. this.scrollTarget_.addEventListener('scroll', this.handleTargetScroll_);
  25972. };
  25973. MDCTopAppBar.prototype.getDefaultFoundation = function () {
  25974. var _this = this;
  25975. // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
  25976. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
  25977. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  25978. var adapter = {
  25979. hasClass: function hasClass(className) {
  25980. return _this.root.classList.contains(className);
  25981. },
  25982. addClass: function addClass(className) {
  25983. return _this.root.classList.add(className);
  25984. },
  25985. removeClass: function removeClass(className) {
  25986. return _this.root.classList.remove(className);
  25987. },
  25988. setStyle: function setStyle(property, value) {
  25989. return _this.root.style.setProperty(property, value);
  25990. },
  25991. getTopAppBarHeight: function getTopAppBarHeight() {
  25992. return _this.root.clientHeight;
  25993. },
  25994. notifyNavigationIconClicked: function notifyNavigationIconClicked() {
  25995. return _this.emit(constants_1.strings.NAVIGATION_EVENT, {});
  25996. },
  25997. getViewportScrollY: function getViewportScrollY() {
  25998. var win = _this.scrollTarget_;
  25999. var el = _this.scrollTarget_;
  26000. return win.pageYOffset !== undefined ? win.pageYOffset : el.scrollTop;
  26001. },
  26002. getTotalActionItems: function getTotalActionItems() {
  26003. return _this.root.querySelectorAll(constants_1.strings.ACTION_ITEM_SELECTOR).length;
  26004. }
  26005. };
  26006. // tslint:enable:object-literal-sort-keys
  26007. var foundation;
  26008. if (this.root.classList.contains(constants_1.cssClasses.SHORT_CLASS)) {
  26009. foundation = new foundation_2.MDCShortTopAppBarFoundation(adapter);
  26010. } else if (this.root.classList.contains(constants_1.cssClasses.FIXED_CLASS)) {
  26011. foundation = new foundation_1.MDCFixedTopAppBarFoundation(adapter);
  26012. } else {
  26013. foundation = new foundation_3.MDCTopAppBarFoundation(adapter);
  26014. }
  26015. return foundation;
  26016. };
  26017. return MDCTopAppBar;
  26018. }(component_1.MDCComponent);
  26019. exports.MDCTopAppBar = MDCTopAppBar;
  26020. /***/ }),
  26021. /***/ "./packages/mdc-top-app-bar/constants.ts":
  26022. /*!***********************************************!*\
  26023. !*** ./packages/mdc-top-app-bar/constants.ts ***!
  26024. \***********************************************/
  26025. /*! no static exports found */
  26026. /***/ (function(module, exports, __webpack_require__) {
  26027. "use strict";
  26028. /**
  26029. * @license
  26030. * Copyright 2018 Google Inc.
  26031. *
  26032. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26033. * of this software and associated documentation files (the "Software"), to deal
  26034. * in the Software without restriction, including without limitation the rights
  26035. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26036. * copies of the Software, and to permit persons to whom the Software is
  26037. * furnished to do so, subject to the following conditions:
  26038. *
  26039. * The above copyright notice and this permission notice shall be included in
  26040. * all copies or substantial portions of the Software.
  26041. *
  26042. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26043. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26044. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26045. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26046. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26047. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26048. * THE SOFTWARE.
  26049. */
  26050. Object.defineProperty(exports, "__esModule", { value: true });
  26051. var cssClasses = {
  26052. FIXED_CLASS: 'mdc-top-app-bar--fixed',
  26053. FIXED_SCROLLED_CLASS: 'mdc-top-app-bar--fixed-scrolled',
  26054. SHORT_CLASS: 'mdc-top-app-bar--short',
  26055. SHORT_COLLAPSED_CLASS: 'mdc-top-app-bar--short-collapsed',
  26056. SHORT_HAS_ACTION_ITEM_CLASS: 'mdc-top-app-bar--short-has-action-item'
  26057. };
  26058. exports.cssClasses = cssClasses;
  26059. var numbers = {
  26060. DEBOUNCE_THROTTLE_RESIZE_TIME_MS: 100,
  26061. MAX_TOP_APP_BAR_HEIGHT: 128
  26062. };
  26063. exports.numbers = numbers;
  26064. var strings = {
  26065. ACTION_ITEM_SELECTOR: '.mdc-top-app-bar__action-item',
  26066. NAVIGATION_EVENT: 'MDCTopAppBar:nav',
  26067. NAVIGATION_ICON_SELECTOR: '.mdc-top-app-bar__navigation-icon',
  26068. ROOT_SELECTOR: '.mdc-top-app-bar',
  26069. TITLE_SELECTOR: '.mdc-top-app-bar__title'
  26070. };
  26071. exports.strings = strings;
  26072. /***/ }),
  26073. /***/ "./packages/mdc-top-app-bar/fixed/foundation.ts":
  26074. /*!******************************************************!*\
  26075. !*** ./packages/mdc-top-app-bar/fixed/foundation.ts ***!
  26076. \******************************************************/
  26077. /*! no static exports found */
  26078. /***/ (function(module, exports, __webpack_require__) {
  26079. "use strict";
  26080. /**
  26081. * @license
  26082. * Copyright 2018 Google Inc.
  26083. *
  26084. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26085. * of this software and associated documentation files (the "Software"), to deal
  26086. * in the Software without restriction, including without limitation the rights
  26087. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26088. * copies of the Software, and to permit persons to whom the Software is
  26089. * furnished to do so, subject to the following conditions:
  26090. *
  26091. * The above copyright notice and this permission notice shall be included in
  26092. * all copies or substantial portions of the Software.
  26093. *
  26094. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26095. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26096. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26097. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26098. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26099. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26100. * THE SOFTWARE.
  26101. */
  26102. var __extends = this && this.__extends || function () {
  26103. var _extendStatics = function extendStatics(d, b) {
  26104. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  26105. d.__proto__ = b;
  26106. } || function (d, b) {
  26107. for (var p in b) {
  26108. if (b.hasOwnProperty(p)) d[p] = b[p];
  26109. }
  26110. };
  26111. return _extendStatics(d, b);
  26112. };
  26113. return function (d, b) {
  26114. _extendStatics(d, b);
  26115. function __() {
  26116. this.constructor = d;
  26117. }
  26118. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26119. };
  26120. }();
  26121. Object.defineProperty(exports, "__esModule", { value: true });
  26122. var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
  26123. var foundation_1 = __webpack_require__(/*! ../standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts");
  26124. var MDCFixedTopAppBarFoundation = /** @class */function (_super) {
  26125. __extends(MDCFixedTopAppBarFoundation, _super);
  26126. function MDCFixedTopAppBarFoundation() {
  26127. var _this = _super !== null && _super.apply(this, arguments) || this;
  26128. /**
  26129. * State variable for the previous scroll iteration top app bar state
  26130. */
  26131. _this.wasScrolled_ = false;
  26132. return _this;
  26133. }
  26134. /**
  26135. * Scroll handler for applying/removing the modifier class on the fixed top app bar.
  26136. * @override
  26137. */
  26138. MDCFixedTopAppBarFoundation.prototype.handleTargetScroll = function () {
  26139. var currentScroll = this.adapter.getViewportScrollY();
  26140. if (currentScroll <= 0) {
  26141. if (this.wasScrolled_) {
  26142. this.adapter.removeClass(constants_1.cssClasses.FIXED_SCROLLED_CLASS);
  26143. this.wasScrolled_ = false;
  26144. }
  26145. } else {
  26146. if (!this.wasScrolled_) {
  26147. this.adapter.addClass(constants_1.cssClasses.FIXED_SCROLLED_CLASS);
  26148. this.wasScrolled_ = true;
  26149. }
  26150. }
  26151. };
  26152. return MDCFixedTopAppBarFoundation;
  26153. }(foundation_1.MDCTopAppBarFoundation);
  26154. exports.MDCFixedTopAppBarFoundation = MDCFixedTopAppBarFoundation;
  26155. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  26156. exports.default = MDCFixedTopAppBarFoundation;
  26157. /***/ }),
  26158. /***/ "./packages/mdc-top-app-bar/foundation.ts":
  26159. /*!************************************************!*\
  26160. !*** ./packages/mdc-top-app-bar/foundation.ts ***!
  26161. \************************************************/
  26162. /*! no static exports found */
  26163. /***/ (function(module, exports, __webpack_require__) {
  26164. "use strict";
  26165. /**
  26166. * @license
  26167. * Copyright 2018 Google Inc.
  26168. *
  26169. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26170. * of this software and associated documentation files (the "Software"), to deal
  26171. * in the Software without restriction, including without limitation the rights
  26172. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26173. * copies of the Software, and to permit persons to whom the Software is
  26174. * furnished to do so, subject to the following conditions:
  26175. *
  26176. * The above copyright notice and this permission notice shall be included in
  26177. * all copies or substantial portions of the Software.
  26178. *
  26179. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26180. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26181. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26182. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26183. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26184. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26185. * THE SOFTWARE.
  26186. */
  26187. var __extends = this && this.__extends || function () {
  26188. var _extendStatics = function extendStatics(d, b) {
  26189. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  26190. d.__proto__ = b;
  26191. } || function (d, b) {
  26192. for (var p in b) {
  26193. if (b.hasOwnProperty(p)) d[p] = b[p];
  26194. }
  26195. };
  26196. return _extendStatics(d, b);
  26197. };
  26198. return function (d, b) {
  26199. _extendStatics(d, b);
  26200. function __() {
  26201. this.constructor = d;
  26202. }
  26203. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26204. };
  26205. }();
  26206. var __assign = this && this.__assign || function () {
  26207. __assign = Object.assign || function (t) {
  26208. for (var s, i = 1, n = arguments.length; i < n; i++) {
  26209. s = arguments[i];
  26210. for (var p in s) {
  26211. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  26212. }
  26213. }
  26214. return t;
  26215. };
  26216. return __assign.apply(this, arguments);
  26217. };
  26218. Object.defineProperty(exports, "__esModule", { value: true });
  26219. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  26220. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts");
  26221. var MDCTopAppBarBaseFoundation = /** @class */function (_super) {
  26222. __extends(MDCTopAppBarBaseFoundation, _super);
  26223. /* istanbul ignore next: optional argument is not a branch statement */
  26224. function MDCTopAppBarBaseFoundation(adapter) {
  26225. return _super.call(this, __assign(__assign({}, MDCTopAppBarBaseFoundation.defaultAdapter), adapter)) || this;
  26226. }
  26227. Object.defineProperty(MDCTopAppBarBaseFoundation, "strings", {
  26228. get: function get() {
  26229. return constants_1.strings;
  26230. },
  26231. enumerable: true,
  26232. configurable: true
  26233. });
  26234. Object.defineProperty(MDCTopAppBarBaseFoundation, "cssClasses", {
  26235. get: function get() {
  26236. return constants_1.cssClasses;
  26237. },
  26238. enumerable: true,
  26239. configurable: true
  26240. });
  26241. Object.defineProperty(MDCTopAppBarBaseFoundation, "numbers", {
  26242. get: function get() {
  26243. return constants_1.numbers;
  26244. },
  26245. enumerable: true,
  26246. configurable: true
  26247. });
  26248. Object.defineProperty(MDCTopAppBarBaseFoundation, "defaultAdapter", {
  26249. /**
  26250. * See {@link MDCTopAppBarAdapter} for typing information on parameters and return types.
  26251. */
  26252. get: function get() {
  26253. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  26254. return {
  26255. addClass: function addClass() {
  26256. return undefined;
  26257. },
  26258. removeClass: function removeClass() {
  26259. return undefined;
  26260. },
  26261. hasClass: function hasClass() {
  26262. return false;
  26263. },
  26264. setStyle: function setStyle() {
  26265. return undefined;
  26266. },
  26267. getTopAppBarHeight: function getTopAppBarHeight() {
  26268. return 0;
  26269. },
  26270. notifyNavigationIconClicked: function notifyNavigationIconClicked() {
  26271. return undefined;
  26272. },
  26273. getViewportScrollY: function getViewportScrollY() {
  26274. return 0;
  26275. },
  26276. getTotalActionItems: function getTotalActionItems() {
  26277. return 0;
  26278. }
  26279. };
  26280. // tslint:enable:object-literal-sort-keys
  26281. },
  26282. enumerable: true,
  26283. configurable: true
  26284. });
  26285. /** Other variants of TopAppBar foundation overrides this method */
  26286. MDCTopAppBarBaseFoundation.prototype.handleTargetScroll = function () {}; // tslint:disable-line:no-empty
  26287. /** Other variants of TopAppBar foundation overrides this method */
  26288. MDCTopAppBarBaseFoundation.prototype.handleWindowResize = function () {}; // tslint:disable-line:no-empty
  26289. MDCTopAppBarBaseFoundation.prototype.handleNavigationClick = function () {
  26290. this.adapter.notifyNavigationIconClicked();
  26291. };
  26292. return MDCTopAppBarBaseFoundation;
  26293. }(foundation_1.MDCFoundation);
  26294. exports.MDCTopAppBarBaseFoundation = MDCTopAppBarBaseFoundation;
  26295. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  26296. exports.default = MDCTopAppBarBaseFoundation;
  26297. /***/ }),
  26298. /***/ "./packages/mdc-top-app-bar/index.ts":
  26299. /*!*******************************************!*\
  26300. !*** ./packages/mdc-top-app-bar/index.ts ***!
  26301. \*******************************************/
  26302. /*! no static exports found */
  26303. /***/ (function(module, exports, __webpack_require__) {
  26304. "use strict";
  26305. /**
  26306. * @license
  26307. * Copyright 2019 Google Inc.
  26308. *
  26309. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26310. * of this software and associated documentation files (the "Software"), to deal
  26311. * in the Software without restriction, including without limitation the rights
  26312. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26313. * copies of the Software, and to permit persons to whom the Software is
  26314. * furnished to do so, subject to the following conditions:
  26315. *
  26316. * The above copyright notice and this permission notice shall be included in
  26317. * all copies or substantial portions of the Software.
  26318. *
  26319. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26320. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26321. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26322. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26323. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26324. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26325. * THE SOFTWARE.
  26326. */
  26327. function __export(m) {
  26328. for (var p in m) {
  26329. if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  26330. }
  26331. }
  26332. Object.defineProperty(exports, "__esModule", { value: true });
  26333. __export(__webpack_require__(/*! ./component */ "./packages/mdc-top-app-bar/component.ts"));
  26334. __export(__webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts"));
  26335. __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-top-app-bar/foundation.ts"));
  26336. __export(__webpack_require__(/*! ./fixed/foundation */ "./packages/mdc-top-app-bar/fixed/foundation.ts"));
  26337. __export(__webpack_require__(/*! ./short/foundation */ "./packages/mdc-top-app-bar/short/foundation.ts"));
  26338. __export(__webpack_require__(/*! ./standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts"));
  26339. /***/ }),
  26340. /***/ "./packages/mdc-top-app-bar/short/foundation.ts":
  26341. /*!******************************************************!*\
  26342. !*** ./packages/mdc-top-app-bar/short/foundation.ts ***!
  26343. \******************************************************/
  26344. /*! no static exports found */
  26345. /***/ (function(module, exports, __webpack_require__) {
  26346. "use strict";
  26347. /**
  26348. * @license
  26349. * Copyright 2018 Google Inc.
  26350. *
  26351. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26352. * of this software and associated documentation files (the "Software"), to deal
  26353. * in the Software without restriction, including without limitation the rights
  26354. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26355. * copies of the Software, and to permit persons to whom the Software is
  26356. * furnished to do so, subject to the following conditions:
  26357. *
  26358. * The above copyright notice and this permission notice shall be included in
  26359. * all copies or substantial portions of the Software.
  26360. *
  26361. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26362. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26363. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26364. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26365. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26366. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26367. * THE SOFTWARE.
  26368. */
  26369. var __extends = this && this.__extends || function () {
  26370. var _extendStatics = function extendStatics(d, b) {
  26371. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  26372. d.__proto__ = b;
  26373. } || function (d, b) {
  26374. for (var p in b) {
  26375. if (b.hasOwnProperty(p)) d[p] = b[p];
  26376. }
  26377. };
  26378. return _extendStatics(d, b);
  26379. };
  26380. return function (d, b) {
  26381. _extendStatics(d, b);
  26382. function __() {
  26383. this.constructor = d;
  26384. }
  26385. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26386. };
  26387. }();
  26388. Object.defineProperty(exports, "__esModule", { value: true });
  26389. var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
  26390. var foundation_1 = __webpack_require__(/*! ../foundation */ "./packages/mdc-top-app-bar/foundation.ts");
  26391. var MDCShortTopAppBarFoundation = /** @class */function (_super) {
  26392. __extends(MDCShortTopAppBarFoundation, _super);
  26393. /* istanbul ignore next: optional argument is not a branch statement */
  26394. function MDCShortTopAppBarFoundation(adapter) {
  26395. var _this = _super.call(this, adapter) || this;
  26396. _this.isCollapsed_ = false;
  26397. _this.isAlwaysCollapsed_ = false;
  26398. return _this;
  26399. }
  26400. Object.defineProperty(MDCShortTopAppBarFoundation.prototype, "isCollapsed", {
  26401. // Public visibility for backward compatibility.
  26402. get: function get() {
  26403. return this.isCollapsed_;
  26404. },
  26405. enumerable: true,
  26406. configurable: true
  26407. });
  26408. MDCShortTopAppBarFoundation.prototype.init = function () {
  26409. _super.prototype.init.call(this);
  26410. if (this.adapter.getTotalActionItems() > 0) {
  26411. this.adapter.addClass(constants_1.cssClasses.SHORT_HAS_ACTION_ITEM_CLASS);
  26412. }
  26413. // If initialized with SHORT_COLLAPSED_CLASS, the bar should always be collapsed
  26414. this.setAlwaysCollapsed(this.adapter.hasClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS));
  26415. };
  26416. /**
  26417. * Set if the short top app bar should always be collapsed.
  26418. *
  26419. * @param value When `true`, bar will always be collapsed. When `false`, bar may collapse or expand based on scroll.
  26420. */
  26421. MDCShortTopAppBarFoundation.prototype.setAlwaysCollapsed = function (value) {
  26422. this.isAlwaysCollapsed_ = !!value;
  26423. if (this.isAlwaysCollapsed_) {
  26424. this.collapse_();
  26425. } else {
  26426. // let maybeCollapseBar_ determine if the bar should be collapsed
  26427. this.maybeCollapseBar_();
  26428. }
  26429. };
  26430. MDCShortTopAppBarFoundation.prototype.getAlwaysCollapsed = function () {
  26431. return this.isAlwaysCollapsed_;
  26432. };
  26433. /**
  26434. * Scroll handler for applying/removing the collapsed modifier class on the short top app bar.
  26435. * @override
  26436. */
  26437. MDCShortTopAppBarFoundation.prototype.handleTargetScroll = function () {
  26438. this.maybeCollapseBar_();
  26439. };
  26440. MDCShortTopAppBarFoundation.prototype.maybeCollapseBar_ = function () {
  26441. if (this.isAlwaysCollapsed_) {
  26442. return;
  26443. }
  26444. var currentScroll = this.adapter.getViewportScrollY();
  26445. if (currentScroll <= 0) {
  26446. if (this.isCollapsed_) {
  26447. this.uncollapse_();
  26448. }
  26449. } else {
  26450. if (!this.isCollapsed_) {
  26451. this.collapse_();
  26452. }
  26453. }
  26454. };
  26455. MDCShortTopAppBarFoundation.prototype.uncollapse_ = function () {
  26456. this.adapter.removeClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS);
  26457. this.isCollapsed_ = false;
  26458. };
  26459. MDCShortTopAppBarFoundation.prototype.collapse_ = function () {
  26460. this.adapter.addClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS);
  26461. this.isCollapsed_ = true;
  26462. };
  26463. return MDCShortTopAppBarFoundation;
  26464. }(foundation_1.MDCTopAppBarBaseFoundation);
  26465. exports.MDCShortTopAppBarFoundation = MDCShortTopAppBarFoundation;
  26466. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  26467. exports.default = MDCShortTopAppBarFoundation;
  26468. /***/ }),
  26469. /***/ "./packages/mdc-top-app-bar/standard/foundation.ts":
  26470. /*!*********************************************************!*\
  26471. !*** ./packages/mdc-top-app-bar/standard/foundation.ts ***!
  26472. \*********************************************************/
  26473. /*! no static exports found */
  26474. /***/ (function(module, exports, __webpack_require__) {
  26475. "use strict";
  26476. /**
  26477. * @license
  26478. * Copyright 2018 Google Inc.
  26479. *
  26480. * Permission is hereby granted, free of charge, to any person obtaining a copy
  26481. * of this software and associated documentation files (the "Software"), to deal
  26482. * in the Software without restriction, including without limitation the rights
  26483. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  26484. * copies of the Software, and to permit persons to whom the Software is
  26485. * furnished to do so, subject to the following conditions:
  26486. *
  26487. * The above copyright notice and this permission notice shall be included in
  26488. * all copies or substantial portions of the Software.
  26489. *
  26490. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26491. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  26492. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26493. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26494. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  26495. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  26496. * THE SOFTWARE.
  26497. */
  26498. var __extends = this && this.__extends || function () {
  26499. var _extendStatics = function extendStatics(d, b) {
  26500. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  26501. d.__proto__ = b;
  26502. } || function (d, b) {
  26503. for (var p in b) {
  26504. if (b.hasOwnProperty(p)) d[p] = b[p];
  26505. }
  26506. };
  26507. return _extendStatics(d, b);
  26508. };
  26509. return function (d, b) {
  26510. _extendStatics(d, b);
  26511. function __() {
  26512. this.constructor = d;
  26513. }
  26514. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26515. };
  26516. }();
  26517. Object.defineProperty(exports, "__esModule", { value: true });
  26518. var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
  26519. var foundation_1 = __webpack_require__(/*! ../foundation */ "./packages/mdc-top-app-bar/foundation.ts");
  26520. var INITIAL_VALUE = 0;
  26521. var MDCTopAppBarFoundation = /** @class */function (_super) {
  26522. __extends(MDCTopAppBarFoundation, _super);
  26523. /* istanbul ignore next: optional argument is not a branch statement */
  26524. function MDCTopAppBarFoundation(adapter) {
  26525. var _this = _super.call(this, adapter) || this;
  26526. /**
  26527. * Indicates if the top app bar was docked in the previous scroll handler iteration.
  26528. */
  26529. _this.wasDocked_ = true;
  26530. /**
  26531. * Indicates if the top app bar is docked in the fully shown position.
  26532. */
  26533. _this.isDockedShowing_ = true;
  26534. /**
  26535. * Variable for current scroll position of the top app bar
  26536. */
  26537. _this.currentAppBarOffsetTop_ = 0;
  26538. /**
  26539. * Used to prevent the top app bar from being scrolled out of view during resize events
  26540. */
  26541. _this.isCurrentlyBeingResized_ = false;
  26542. /**
  26543. * The timeout that's used to throttle the resize events
  26544. */
  26545. _this.resizeThrottleId_ = INITIAL_VALUE;
  26546. /**
  26547. * The timeout that's used to debounce toggling the isCurrentlyBeingResized_ variable after a resize
  26548. */
  26549. _this.resizeDebounceId_ = INITIAL_VALUE;
  26550. _this.lastScrollPosition_ = _this.adapter.getViewportScrollY();
  26551. _this.topAppBarHeight_ = _this.adapter.getTopAppBarHeight();
  26552. return _this;
  26553. }
  26554. MDCTopAppBarFoundation.prototype.destroy = function () {
  26555. _super.prototype.destroy.call(this);
  26556. this.adapter.setStyle('top', '');
  26557. };
  26558. /**
  26559. * Scroll handler for the default scroll behavior of the top app bar.
  26560. * @override
  26561. */
  26562. MDCTopAppBarFoundation.prototype.handleTargetScroll = function () {
  26563. var currentScrollPosition = Math.max(this.adapter.getViewportScrollY(), 0);
  26564. var diff = currentScrollPosition - this.lastScrollPosition_;
  26565. this.lastScrollPosition_ = currentScrollPosition;
  26566. // If the window is being resized the lastScrollPosition_ needs to be updated but the
  26567. // current scroll of the top app bar should stay in the same position.
  26568. if (!this.isCurrentlyBeingResized_) {
  26569. this.currentAppBarOffsetTop_ -= diff;
  26570. if (this.currentAppBarOffsetTop_ > 0) {
  26571. this.currentAppBarOffsetTop_ = 0;
  26572. } else if (Math.abs(this.currentAppBarOffsetTop_) > this.topAppBarHeight_) {
  26573. this.currentAppBarOffsetTop_ = -this.topAppBarHeight_;
  26574. }
  26575. this.moveTopAppBar_();
  26576. }
  26577. };
  26578. /**
  26579. * Top app bar resize handler that throttle/debounce functions that execute updates.
  26580. * @override
  26581. */
  26582. MDCTopAppBarFoundation.prototype.handleWindowResize = function () {
  26583. var _this = this;
  26584. // Throttle resize events 10 p/s
  26585. if (!this.resizeThrottleId_) {
  26586. this.resizeThrottleId_ = setTimeout(function () {
  26587. _this.resizeThrottleId_ = INITIAL_VALUE;
  26588. _this.throttledResizeHandler_();
  26589. }, constants_1.numbers.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
  26590. }
  26591. this.isCurrentlyBeingResized_ = true;
  26592. if (this.resizeDebounceId_) {
  26593. clearTimeout(this.resizeDebounceId_);
  26594. }
  26595. this.resizeDebounceId_ = setTimeout(function () {
  26596. _this.handleTargetScroll();
  26597. _this.isCurrentlyBeingResized_ = false;
  26598. _this.resizeDebounceId_ = INITIAL_VALUE;
  26599. }, constants_1.numbers.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
  26600. };
  26601. /**
  26602. * Function to determine if the DOM needs to update.
  26603. */
  26604. MDCTopAppBarFoundation.prototype.checkForUpdate_ = function () {
  26605. var offscreenBoundaryTop = -this.topAppBarHeight_;
  26606. var hasAnyPixelsOffscreen = this.currentAppBarOffsetTop_ < 0;
  26607. var hasAnyPixelsOnscreen = this.currentAppBarOffsetTop_ > offscreenBoundaryTop;
  26608. var partiallyShowing = hasAnyPixelsOffscreen && hasAnyPixelsOnscreen;
  26609. // If it's partially showing, it can't be docked.
  26610. if (partiallyShowing) {
  26611. this.wasDocked_ = false;
  26612. } else {
  26613. // Not previously docked and not partially showing, it's now docked.
  26614. if (!this.wasDocked_) {
  26615. this.wasDocked_ = true;
  26616. return true;
  26617. } else if (this.isDockedShowing_ !== hasAnyPixelsOnscreen) {
  26618. this.isDockedShowing_ = hasAnyPixelsOnscreen;
  26619. return true;
  26620. }
  26621. }
  26622. return partiallyShowing;
  26623. };
  26624. /**
  26625. * Function to move the top app bar if needed.
  26626. */
  26627. MDCTopAppBarFoundation.prototype.moveTopAppBar_ = function () {
  26628. if (this.checkForUpdate_()) {
  26629. // Once the top app bar is fully hidden we use the max potential top app bar height as our offset
  26630. // so the top app bar doesn't show if the window resizes and the new height > the old height.
  26631. var offset = this.currentAppBarOffsetTop_;
  26632. if (Math.abs(offset) >= this.topAppBarHeight_) {
  26633. offset = -constants_1.numbers.MAX_TOP_APP_BAR_HEIGHT;
  26634. }
  26635. this.adapter.setStyle('top', offset + 'px');
  26636. }
  26637. };
  26638. /**
  26639. * Throttled function that updates the top app bar scrolled values if the
  26640. * top app bar height changes.
  26641. */
  26642. MDCTopAppBarFoundation.prototype.throttledResizeHandler_ = function () {
  26643. var currentHeight = this.adapter.getTopAppBarHeight();
  26644. if (this.topAppBarHeight_ !== currentHeight) {
  26645. this.wasDocked_ = false;
  26646. // Since the top app bar has a different height depending on the screen width, this
  26647. // will ensure that the top app bar remains in the correct location if
  26648. // completely hidden and a resize makes the top app bar a different height.
  26649. this.currentAppBarOffsetTop_ -= this.topAppBarHeight_ - currentHeight;
  26650. this.topAppBarHeight_ = currentHeight;
  26651. }
  26652. this.handleTargetScroll();
  26653. };
  26654. return MDCTopAppBarFoundation;
  26655. }(foundation_1.MDCTopAppBarBaseFoundation);
  26656. exports.MDCTopAppBarFoundation = MDCTopAppBarFoundation;
  26657. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  26658. exports.default = MDCTopAppBarFoundation;
  26659. /***/ })
  26660. /******/ });
  26661. });
  26662. //# sourceMappingURL=material-components-web.js.map