mdc.select.js 516 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380
  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("@material/select", [], factory);
  13. else if(typeof exports === 'object')
  14. exports["select"] = factory();
  15. else
  16. root["mdc"] = root["mdc"] || {}, root["mdc"]["select"] = 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/mdc-select/index.ts");
  102. /******/ })
  103. /************************************************************************/
  104. /******/ ({
  105. /***/ "./node_modules/process/browser.js":
  106. /*!*****************************************!*\
  107. !*** ./node_modules/process/browser.js ***!
  108. \*****************************************/
  109. /*! no static exports found */
  110. /***/ (function(module, exports) {
  111. // shim for using process in browser
  112. var process = module.exports = {};
  113. // cached from whatever global is present so that test runners that stub it
  114. // don't break things. But we need to wrap it in a try catch in case it is
  115. // wrapped in strict mode code which doesn't define any globals. It's inside a
  116. // function because try/catches deoptimize in certain engines.
  117. var cachedSetTimeout;
  118. var cachedClearTimeout;
  119. function defaultSetTimout() {
  120. throw new Error('setTimeout has not been defined');
  121. }
  122. function defaultClearTimeout () {
  123. throw new Error('clearTimeout has not been defined');
  124. }
  125. (function () {
  126. try {
  127. if (typeof setTimeout === 'function') {
  128. cachedSetTimeout = setTimeout;
  129. } else {
  130. cachedSetTimeout = defaultSetTimout;
  131. }
  132. } catch (e) {
  133. cachedSetTimeout = defaultSetTimout;
  134. }
  135. try {
  136. if (typeof clearTimeout === 'function') {
  137. cachedClearTimeout = clearTimeout;
  138. } else {
  139. cachedClearTimeout = defaultClearTimeout;
  140. }
  141. } catch (e) {
  142. cachedClearTimeout = defaultClearTimeout;
  143. }
  144. } ())
  145. function runTimeout(fun) {
  146. if (cachedSetTimeout === setTimeout) {
  147. //normal enviroments in sane situations
  148. return setTimeout(fun, 0);
  149. }
  150. // if setTimeout wasn't available but was latter defined
  151. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  152. cachedSetTimeout = setTimeout;
  153. return setTimeout(fun, 0);
  154. }
  155. try {
  156. // when when somebody has screwed with setTimeout but no I.E. maddness
  157. return cachedSetTimeout(fun, 0);
  158. } catch(e){
  159. try {
  160. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  161. return cachedSetTimeout.call(null, fun, 0);
  162. } catch(e){
  163. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  164. return cachedSetTimeout.call(this, fun, 0);
  165. }
  166. }
  167. }
  168. function runClearTimeout(marker) {
  169. if (cachedClearTimeout === clearTimeout) {
  170. //normal enviroments in sane situations
  171. return clearTimeout(marker);
  172. }
  173. // if clearTimeout wasn't available but was latter defined
  174. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  175. cachedClearTimeout = clearTimeout;
  176. return clearTimeout(marker);
  177. }
  178. try {
  179. // when when somebody has screwed with setTimeout but no I.E. maddness
  180. return cachedClearTimeout(marker);
  181. } catch (e){
  182. try {
  183. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  184. return cachedClearTimeout.call(null, marker);
  185. } catch (e){
  186. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  187. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  188. return cachedClearTimeout.call(this, marker);
  189. }
  190. }
  191. }
  192. var queue = [];
  193. var draining = false;
  194. var currentQueue;
  195. var queueIndex = -1;
  196. function cleanUpNextTick() {
  197. if (!draining || !currentQueue) {
  198. return;
  199. }
  200. draining = false;
  201. if (currentQueue.length) {
  202. queue = currentQueue.concat(queue);
  203. } else {
  204. queueIndex = -1;
  205. }
  206. if (queue.length) {
  207. drainQueue();
  208. }
  209. }
  210. function drainQueue() {
  211. if (draining) {
  212. return;
  213. }
  214. var timeout = runTimeout(cleanUpNextTick);
  215. draining = true;
  216. var len = queue.length;
  217. while(len) {
  218. currentQueue = queue;
  219. queue = [];
  220. while (++queueIndex < len) {
  221. if (currentQueue) {
  222. currentQueue[queueIndex].run();
  223. }
  224. }
  225. queueIndex = -1;
  226. len = queue.length;
  227. }
  228. currentQueue = null;
  229. draining = false;
  230. runClearTimeout(timeout);
  231. }
  232. process.nextTick = function (fun) {
  233. var args = new Array(arguments.length - 1);
  234. if (arguments.length > 1) {
  235. for (var i = 1; i < arguments.length; i++) {
  236. args[i - 1] = arguments[i];
  237. }
  238. }
  239. queue.push(new Item(fun, args));
  240. if (queue.length === 1 && !draining) {
  241. runTimeout(drainQueue);
  242. }
  243. };
  244. // v8 likes predictible objects
  245. function Item(fun, array) {
  246. this.fun = fun;
  247. this.array = array;
  248. }
  249. Item.prototype.run = function () {
  250. this.fun.apply(null, this.array);
  251. };
  252. process.title = 'browser';
  253. process.browser = true;
  254. process.env = {};
  255. process.argv = [];
  256. process.version = ''; // empty string to avoid regexp issues
  257. process.versions = {};
  258. function noop() {}
  259. process.on = noop;
  260. process.addListener = noop;
  261. process.once = noop;
  262. process.off = noop;
  263. process.removeListener = noop;
  264. process.removeAllListeners = noop;
  265. process.emit = noop;
  266. process.prependListener = noop;
  267. process.prependOnceListener = noop;
  268. process.listeners = function (name) { return [] }
  269. process.binding = function (name) {
  270. throw new Error('process.binding is not supported');
  271. };
  272. process.cwd = function () { return '/' };
  273. process.chdir = function (dir) {
  274. throw new Error('process.chdir is not supported');
  275. };
  276. process.umask = function() { return 0; };
  277. /***/ }),
  278. /***/ "./node_modules/safevalues/builders/attribute_builders.js":
  279. /*!****************************************************************!*\
  280. !*** ./node_modules/safevalues/builders/attribute_builders.js ***!
  281. \****************************************************************/
  282. /*! no static exports found */
  283. /***/ (function(module, exports, __webpack_require__) {
  284. "use strict";
  285. /**
  286. * @license
  287. * SPDX-License-Identifier: Apache-2.0
  288. */
  289. Object.defineProperty(exports, "__esModule", { value: true });
  290. exports.safeAttrPrefix = void 0;
  291. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  292. var attribute_impl_1 = __webpack_require__(/*! ../internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
  293. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  294. var sensitive_attributes_1 = __webpack_require__(/*! ./sensitive_attributes */ "./node_modules/safevalues/builders/sensitive_attributes.js");
  295. /**
  296. * Creates a SafeAttributePrefix object from a template literal with no
  297. * interpolations for attributes that share a common prefix guaranteed to be not
  298. * security sensitive.
  299. *
  300. * The template literal is a prefix that makes it obvious this attribute is not
  301. * security sensitive. If it doesn't, this function will throw.
  302. */
  303. function safeAttrPrefix(templ) {
  304. if (true) {
  305. (0, string_literal_1.assertIsTemplateObject)(templ, true, 'safeAttr is a template literal tag function ' +
  306. 'and should be called using the tagged template syntax. ' +
  307. 'For example, safeAttr`foo`;');
  308. }
  309. var attrPrefix = templ[0].toLowerCase();
  310. if (true) {
  311. if (attrPrefix.indexOf('on') === 0 || 'on'.indexOf(attrPrefix) === 0) {
  312. throw new Error("Prefix '".concat(templ[0], "' does not guarantee the attribute ") +
  313. "to be safe as it is also a prefix for event handler attributes" +
  314. "Please use 'addEventListener' to set event handlers.");
  315. }
  316. sensitive_attributes_1.SECURITY_SENSITIVE_ATTRIBUTES.forEach(function (sensitiveAttr) {
  317. if (sensitiveAttr.indexOf(attrPrefix) === 0) {
  318. throw new Error("Prefix '".concat(templ[0], "' does not guarantee the attribute ") +
  319. "to be safe as it is also a prefix for " +
  320. "the security sensitive attribute '".concat(sensitiveAttr, "'. ") +
  321. "Please use native or safe DOM APIs to set the attribute.");
  322. }
  323. });
  324. }
  325. return (0, attribute_impl_1.createAttributePrefix)(attrPrefix);
  326. }
  327. exports.safeAttrPrefix = safeAttrPrefix;
  328. /***/ }),
  329. /***/ "./node_modules/safevalues/builders/html_builders.js":
  330. /*!***********************************************************!*\
  331. !*** ./node_modules/safevalues/builders/html_builders.js ***!
  332. \***********************************************************/
  333. /*! no static exports found */
  334. /***/ (function(module, exports, __webpack_require__) {
  335. "use strict";
  336. /**
  337. * @license
  338. * SPDX-License-Identifier: Apache-2.0
  339. */
  340. Object.defineProperty(exports, "__esModule", { value: true });
  341. exports.concatHtmls = exports.createScriptSrc = exports.createScript = exports.htmlEscape = void 0;
  342. var html_impl_1 = __webpack_require__(/*! ../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  343. var resource_url_impl_1 = __webpack_require__(/*! ../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  344. var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  345. /**
  346. * Returns HTML-escaped text as a `SafeHtml` object.
  347. *
  348. * Available options:
  349. * - `preserveSpaces` turns every second consecutive space character into its
  350. * HTML entity representation (`&#160;`).
  351. * - `preserveNewlines` turns newline characters into breaks (`<br>`).
  352. * - `preserveTabs` wraps tab characters in a span with style=white-space:pre.
  353. */
  354. function htmlEscape(text, options) {
  355. if (options === void 0) { options = {}; }
  356. var htmlEscapedString = htmlEscapeToString(text);
  357. if (options.preserveSpaces) {
  358. // Do this first to ensure we preserve spaces after newlines and tabs.
  359. htmlEscapedString =
  360. htmlEscapedString.replace(/(^|[\r\n\t ]) /g, '$1&#160;');
  361. }
  362. if (options.preserveNewlines) {
  363. htmlEscapedString = htmlEscapedString.replace(/(\r\n|\n|\r)/g, '<br>');
  364. }
  365. if (options.preserveTabs) {
  366. htmlEscapedString = htmlEscapedString.replace(/(\t+)/g, '<span style="white-space:pre">$1</span>');
  367. }
  368. return (0, html_impl_1.createHtml)(htmlEscapedString);
  369. }
  370. exports.htmlEscape = htmlEscape;
  371. /**
  372. * Creates a `SafeHtml` representing a script tag with inline script content.
  373. */
  374. function createScript(script, options) {
  375. if (options === void 0) { options = {}; }
  376. var unwrappedScript = (0, script_impl_1.unwrapScript)(script).toString();
  377. var stringTag = "<script";
  378. if (options.id) {
  379. stringTag += " id=\"".concat(htmlEscapeToString(options.id), "\"");
  380. }
  381. if (options.nonce) {
  382. stringTag += " nonce=\"".concat(htmlEscapeToString(options.nonce), "\"");
  383. }
  384. if (options.type) {
  385. stringTag += " type=\"".concat(htmlEscapeToString(options.type), "\"");
  386. }
  387. stringTag += ">".concat(unwrappedScript, "</script>");
  388. return (0, html_impl_1.createHtml)(stringTag);
  389. }
  390. exports.createScript = createScript;
  391. /**
  392. * Creates a `SafeHtml` representing a script tag with the src attribute.
  393. * This also supports CSP nonces and async loading.
  394. */
  395. function createScriptSrc(src, async, nonce) {
  396. var unwrappedSrc = (0, resource_url_impl_1.unwrapResourceUrl)(src).toString();
  397. var stringTag = "<script src=\"".concat(htmlEscapeToString(unwrappedSrc), "\"");
  398. if (async) {
  399. stringTag += ' async';
  400. }
  401. if (nonce) {
  402. stringTag += " nonce=\"".concat(htmlEscapeToString(nonce), "\"");
  403. }
  404. stringTag += '>\x3c/script>';
  405. return (0, html_impl_1.createHtml)(stringTag);
  406. }
  407. exports.createScriptSrc = createScriptSrc;
  408. /**
  409. * HTML-escapes the given text (`&`, `<`, `>`, `"` and `'`).
  410. */
  411. function htmlEscapeToString(text) {
  412. var escaped = text.replace(/&/g, '&amp;')
  413. .replace(/</g, '&lt;')
  414. .replace(/>/g, '&gt;')
  415. .replace(/"/g, '&quot;')
  416. .replace(/'/g, '&apos;');
  417. return escaped;
  418. }
  419. /** Creates a `SafeHtml` value by concatenating multiple `SafeHtml`s. */
  420. function concatHtmls(htmls) {
  421. return (0, html_impl_1.createHtml)(htmls.map(html_impl_1.unwrapHtml).join(''));
  422. }
  423. exports.concatHtmls = concatHtmls;
  424. /***/ }),
  425. /***/ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js":
  426. /*!***************************************************************************!*\
  427. !*** ./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js ***!
  428. \***************************************************************************/
  429. /*! no static exports found */
  430. /***/ (function(module, exports, __webpack_require__) {
  431. "use strict";
  432. /**
  433. * @license
  434. * SPDX-License-Identifier: Apache-2.0
  435. */
  436. var __values = (this && this.__values) || function(o) {
  437. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  438. if (m) return m.call(o);
  439. if (o && typeof o.length === "number") return {
  440. next: function () {
  441. if (o && i >= o.length) o = void 0;
  442. return { value: o && o[i++], done: !o };
  443. }
  444. };
  445. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  446. };
  447. var __read = (this && this.__read) || function (o, n) {
  448. var m = typeof Symbol === "function" && o[Symbol.iterator];
  449. if (!m) return o;
  450. var i = m.call(o), r, ar = [], e;
  451. try {
  452. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  453. }
  454. catch (error) { e = { error: error }; }
  455. finally {
  456. try {
  457. if (r && !r.done && (m = i["return"])) m.call(i);
  458. }
  459. finally { if (e) throw e.error; }
  460. }
  461. return ar;
  462. };
  463. Object.defineProperty(exports, "__esModule", { value: true });
  464. exports.sanitizeHtmlToFragment = exports.sanitizeHtmlAssertUnchanged = exports.sanitizeHtml = exports.HtmlSanitizerImpl = void 0;
  465. __webpack_require__(/*! ../../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  466. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  467. /* g3_import_pure from '../../internals/pure' */
  468. var secrets_1 = __webpack_require__(/*! ../../internals/secrets */ "./node_modules/safevalues/internals/secrets.js");
  469. var url_sanitizer_1 = __webpack_require__(/*! ../url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  470. var inert_fragment_1 = __webpack_require__(/*! ./inert_fragment */ "./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js");
  471. var no_clobber_1 = __webpack_require__(/*! ./no_clobber */ "./node_modules/safevalues/builders/html_sanitizer/no_clobber.js");
  472. var default_sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/default_sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js");
  473. var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
  474. /** Implementation for `HtmlSanitizer` */
  475. var HtmlSanitizerImpl = /** @class */ (function () {
  476. function HtmlSanitizerImpl(sanitizerTable, token) {
  477. this.sanitizerTable = sanitizerTable;
  478. this.changes = [];
  479. (0, secrets_1.ensureTokenIsValid)(token);
  480. }
  481. HtmlSanitizerImpl.prototype.sanitizeAssertUnchanged = function (html) {
  482. this.changes = [];
  483. var sanitizedHtml = this.sanitize(html);
  484. if (this.changes.length !== 0) {
  485. var message = '';
  486. if (true) {
  487. message =
  488. "Unexpected change to HTML value as a result of sanitization. " +
  489. "Input: \"".concat(html, "\", sanitized output: \"").concat(sanitizedHtml, "\"\n") +
  490. "List of changes:".concat(this.changes.join('\n'));
  491. }
  492. throw new Error(message);
  493. }
  494. return sanitizedHtml;
  495. };
  496. HtmlSanitizerImpl.prototype.sanitize = function (html) {
  497. var fakeRoot = document.createElement('span');
  498. fakeRoot.appendChild(this.sanitizeToFragment(html));
  499. // XML serialization is preferred over HTML serialization as it is
  500. // stricter and makes sure all attributes are properly escaped, avoiding
  501. // cases where the tree might mutate when parsed again later due to the
  502. // complexities of the HTML parsing algorithm
  503. var serializedNewTree = new XMLSerializer().serializeToString(fakeRoot);
  504. // We remove the outer most element as this is the span node created as
  505. // the root for the sanitized tree and contains a spurious xmlns attribute
  506. // from the XML serialization step.
  507. serializedNewTree = serializedNewTree.slice(serializedNewTree.indexOf('>') + 1, serializedNewTree.lastIndexOf('</'));
  508. return (0, html_impl_1.createHtml)(serializedNewTree);
  509. };
  510. HtmlSanitizerImpl.prototype.sanitizeToFragment = function (html) {
  511. var _this = this;
  512. var dirtyFragment = (0, inert_fragment_1.createInertFragment)(html);
  513. var treeWalker = document.createTreeWalker(dirtyFragment, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
  514. // IE10 and IE11 won't accept a proper `NodeFilter` interface, and
  515. // expect the filtering function to be passed directly. It seems that
  516. // other browsers also do not mind getting the function directly. see
  517. // https://stackoverflow.com/q/38245898
  518. (function (n) { return _this.nodeFilter(n); }),
  519. // @ts-ignore: error TS2554: Expected 1-3 arguments, but got 4.
  520. false);
  521. // `nextNode` is called so we skip the root `DocumentFragment`.
  522. var currentNode = treeWalker.nextNode();
  523. // We create a root element to attach all the children of the body to. We
  524. // use div as it as a semantic-free, generic container and does not
  525. // represent anything. This is removed when we serialize the tree back
  526. // into a string.
  527. var sanitizedFragment = document.createDocumentFragment();
  528. var sanitizedParent = sanitizedFragment;
  529. while (currentNode !== null) {
  530. var sanitizedNode = void 0;
  531. if ((0, no_clobber_1.isText)(currentNode)) {
  532. sanitizedNode = this.sanitizeTextNode(currentNode);
  533. }
  534. else if ((0, no_clobber_1.isElement)(currentNode)) {
  535. sanitizedNode = this.sanitizeElementNode(currentNode);
  536. }
  537. else {
  538. throw new Error('Node is not of type text or element');
  539. }
  540. sanitizedParent.appendChild(sanitizedNode);
  541. // Advance iterator while keeping track of the sanitized parent for the
  542. // current node
  543. currentNode = treeWalker.firstChild();
  544. if (currentNode) {
  545. sanitizedParent = sanitizedNode;
  546. }
  547. else {
  548. while (!(currentNode = treeWalker.nextSibling())) {
  549. if (!(currentNode = treeWalker.parentNode())) {
  550. break;
  551. }
  552. sanitizedParent = sanitizedParent.parentNode;
  553. }
  554. }
  555. }
  556. return sanitizedFragment;
  557. };
  558. HtmlSanitizerImpl.prototype.sanitizeTextNode = function (textNode) {
  559. return document.createTextNode(textNode.data);
  560. };
  561. HtmlSanitizerImpl.prototype.sanitizeElementNode = function (elementNode) {
  562. var e_1, _a;
  563. var elementName = (0, no_clobber_1.getNodeName)(elementNode);
  564. var newNode = document.createElement(elementName);
  565. var dirtyAttributes = elementNode.attributes;
  566. try {
  567. for (var dirtyAttributes_1 = __values(dirtyAttributes), dirtyAttributes_1_1 = dirtyAttributes_1.next(); !dirtyAttributes_1_1.done; dirtyAttributes_1_1 = dirtyAttributes_1.next()) {
  568. var _b = dirtyAttributes_1_1.value, name_1 = _b.name, value = _b.value;
  569. var policy = this.sanitizerTable.getAttributePolicy(name_1, elementName);
  570. if (!this.satisfiesAllConditions(policy.conditions, dirtyAttributes)) {
  571. this.recordChange("Not all conditions satisfied for attribute: ".concat(name_1, "."));
  572. continue;
  573. }
  574. switch (policy.policyAction) {
  575. case sanitizer_table_1.AttributePolicyAction.KEEP:
  576. newNode.setAttribute(name_1, value);
  577. break;
  578. case sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL:
  579. var sanitizedAttrUrl = (0, url_sanitizer_1.restrictivelySanitizeUrl)(value);
  580. if (sanitizedAttrUrl !== value) {
  581. this.recordChange("Url in attribute ".concat(name_1, " was modified during sanitization. Original url:\"").concat(value, "\" was sanitized to: \"").concat(sanitizedAttrUrl, "\""));
  582. }
  583. newNode.setAttribute(name_1, sanitizedAttrUrl);
  584. break;
  585. case sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE:
  586. // We don't consider changing the case of an attribute value to be a
  587. // semantic change
  588. newNode.setAttribute(name_1, value.toLowerCase());
  589. break;
  590. case sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_STYLE:
  591. newNode.setAttribute(name_1, value);
  592. break;
  593. case sanitizer_table_1.AttributePolicyAction.DROP:
  594. this.recordChange("Attribute: ".concat(name_1, " was dropped"));
  595. break;
  596. default:
  597. checkExhaustive(policy.policyAction, 'Unhandled AttributePolicyAction case');
  598. }
  599. }
  600. }
  601. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  602. finally {
  603. try {
  604. if (dirtyAttributes_1_1 && !dirtyAttributes_1_1.done && (_a = dirtyAttributes_1.return)) _a.call(dirtyAttributes_1);
  605. }
  606. finally { if (e_1) throw e_1.error; }
  607. }
  608. return newNode;
  609. };
  610. HtmlSanitizerImpl.prototype.nodeFilter = function (node) {
  611. if ((0, no_clobber_1.isText)(node)) {
  612. return NodeFilter.FILTER_ACCEPT;
  613. }
  614. else if (!(0, no_clobber_1.isElement)(node)) {
  615. // Getting a node that is neither an `Element` or a `Text` node. This is
  616. // likely due to something that is not supposed to be an element in user
  617. // code but recognized as such by the TreeWalker (e.g. a polyfill for
  618. // other kind of nodes). Since we can't recognize it as an element, we
  619. // drop the node, but we don't record it as a meaningful change.
  620. return NodeFilter.FILTER_REJECT;
  621. }
  622. var nodeName = (0, no_clobber_1.getNodeName)(node);
  623. if (nodeName === null) {
  624. this.recordChange("Node name was null for node: ".concat(node));
  625. return NodeFilter.FILTER_REJECT;
  626. }
  627. if (this.sanitizerTable.isAllowedElement(nodeName)) {
  628. return NodeFilter.FILTER_ACCEPT;
  629. }
  630. this.recordChange("Element: ".concat(nodeName, " was dropped"));
  631. return NodeFilter.FILTER_REJECT;
  632. };
  633. HtmlSanitizerImpl.prototype.recordChange = function (errorMessage) {
  634. if (true) {
  635. this.changes.push(errorMessage);
  636. }
  637. else {}
  638. };
  639. HtmlSanitizerImpl.prototype.satisfiesAllConditions = function (conditions, attrs) {
  640. var e_2, _a;
  641. var _b;
  642. if (!conditions) {
  643. return true;
  644. }
  645. try {
  646. for (var conditions_1 = __values(conditions), conditions_1_1 = conditions_1.next(); !conditions_1_1.done; conditions_1_1 = conditions_1.next()) {
  647. var _c = __read(conditions_1_1.value, 2), attrName = _c[0], expectedValues = _c[1];
  648. var value = (_b = attrs.getNamedItem(attrName)) === null || _b === void 0 ? void 0 : _b.value;
  649. if (value && !expectedValues.has(value)) {
  650. return false;
  651. }
  652. }
  653. }
  654. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  655. finally {
  656. try {
  657. if (conditions_1_1 && !conditions_1_1.done && (_a = conditions_1.return)) _a.call(conditions_1);
  658. }
  659. finally { if (e_2) throw e_2.error; }
  660. }
  661. return true;
  662. };
  663. return HtmlSanitizerImpl;
  664. }());
  665. exports.HtmlSanitizerImpl = HtmlSanitizerImpl;
  666. var defaultHtmlSanitizer =
  667. /* #__PURE__ */ (function () { return new HtmlSanitizerImpl(default_sanitizer_table_1.defaultSanitizerTable, secrets_1.secretToken); })();
  668. /** Sanitizes untrusted html using the default sanitizer configuration. */
  669. function sanitizeHtml(html) {
  670. return defaultHtmlSanitizer.sanitize(html);
  671. }
  672. exports.sanitizeHtml = sanitizeHtml;
  673. /**
  674. * Sanitizes untrusted html using the default sanitizer configuration. Throws
  675. * an error if the html was changed.
  676. */
  677. function sanitizeHtmlAssertUnchanged(html) {
  678. return defaultHtmlSanitizer.sanitizeAssertUnchanged(html);
  679. }
  680. exports.sanitizeHtmlAssertUnchanged = sanitizeHtmlAssertUnchanged;
  681. /**
  682. * Sanitizes untrusted html using the default sanitizer configuration. Throws
  683. * an error if the html was changed.
  684. */
  685. function sanitizeHtmlToFragment(html) {
  686. return defaultHtmlSanitizer.sanitizeToFragment(html);
  687. }
  688. exports.sanitizeHtmlToFragment = sanitizeHtmlToFragment;
  689. function checkExhaustive(value, msg) {
  690. if (msg === void 0) { msg = "unexpected value ".concat(value, "!"); }
  691. throw new Error(msg);
  692. }
  693. /***/ }),
  694. /***/ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js":
  695. /*!***********************************************************************************!*\
  696. !*** ./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js ***!
  697. \***********************************************************************************/
  698. /*! no static exports found */
  699. /***/ (function(module, exports, __webpack_require__) {
  700. "use strict";
  701. /**
  702. * @license
  703. * SPDX-License-Identifier: Apache-2.0
  704. */
  705. var __values = (this && this.__values) || function(o) {
  706. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  707. if (m) return m.call(o);
  708. if (o && typeof o.length === "number") return {
  709. next: function () {
  710. if (o && i >= o.length) o = void 0;
  711. return { value: o && o[i++], done: !o };
  712. }
  713. };
  714. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  715. };
  716. var __read = (this && this.__read) || function (o, n) {
  717. var m = typeof Symbol === "function" && o[Symbol.iterator];
  718. if (!m) return o;
  719. var i = m.call(o), r, ar = [], e;
  720. try {
  721. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  722. }
  723. catch (error) { e = { error: error }; }
  724. finally {
  725. try {
  726. if (r && !r.done && (m = i["return"])) m.call(i);
  727. }
  728. finally { if (e) throw e.error; }
  729. }
  730. return ar;
  731. };
  732. Object.defineProperty(exports, "__esModule", { value: true });
  733. exports.HtmlSanitizerBuilder = void 0;
  734. var secrets_1 = __webpack_require__(/*! ../../internals/secrets */ "./node_modules/safevalues/internals/secrets.js");
  735. var html_sanitizer_1 = __webpack_require__(/*! ./html_sanitizer */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js");
  736. var default_sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/default_sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js");
  737. var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
  738. /** This class allows modifications to the default sanitizer configuration. */
  739. var HtmlSanitizerBuilder = /** @class */ (function () {
  740. function HtmlSanitizerBuilder() {
  741. // To denote if the builder has called build() and therefore should make no
  742. // further changes to the sanitizer table.
  743. this.calledBuild = false;
  744. this.sanitizerTable = default_sanitizer_table_1.defaultSanitizerTable;
  745. }
  746. /** Builder option to restrict allowed elements to a smaller subset. */
  747. HtmlSanitizerBuilder.prototype.onlyAllowElements = function (elementSet) {
  748. var e_1, _a;
  749. var allowedElements = new Set();
  750. var allowedElementPolicies = new Map();
  751. try {
  752. for (var elementSet_1 = __values(elementSet), elementSet_1_1 = elementSet_1.next(); !elementSet_1_1.done; elementSet_1_1 = elementSet_1.next()) {
  753. var element = elementSet_1_1.value;
  754. element = element.toUpperCase();
  755. if (!this.sanitizerTable.isAllowedElement(element)) {
  756. throw new Error("Element: ".concat(element, ", is not allowed by html5_contract.textpb"));
  757. }
  758. var elementPolicy = this.sanitizerTable.elementPolicies.get(element);
  759. if (elementPolicy !== undefined) {
  760. allowedElementPolicies.set(element, elementPolicy);
  761. }
  762. else {
  763. allowedElements.add(element);
  764. }
  765. }
  766. }
  767. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  768. finally {
  769. try {
  770. if (elementSet_1_1 && !elementSet_1_1.done && (_a = elementSet_1.return)) _a.call(elementSet_1);
  771. }
  772. finally { if (e_1) throw e_1.error; }
  773. }
  774. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(allowedElements, allowedElementPolicies, this.sanitizerTable.allowedGlobalAttributes, this.sanitizerTable.globalAttributePolicies);
  775. return this;
  776. };
  777. /**
  778. * Builder option to restrict allowed attributes to a smaller subset.
  779. *
  780. * If the attribute isn't currently allowed then it won't be added.
  781. */
  782. HtmlSanitizerBuilder.prototype.onlyAllowAttributes = function (attributeSet) {
  783. var e_2, _a, e_3, _b, e_4, _c;
  784. var allowedGlobalAttributes = new Set();
  785. var globalAttributePolicies = new Map();
  786. var elementPolicies = new Map();
  787. try {
  788. for (var attributeSet_1 = __values(attributeSet), attributeSet_1_1 = attributeSet_1.next(); !attributeSet_1_1.done; attributeSet_1_1 = attributeSet_1.next()) {
  789. var attribute = attributeSet_1_1.value;
  790. if (this.sanitizerTable.allowedGlobalAttributes.has(attribute)) {
  791. allowedGlobalAttributes.add(attribute);
  792. }
  793. if (this.sanitizerTable.globalAttributePolicies.has(attribute)) {
  794. globalAttributePolicies.set(attribute, this.sanitizerTable.globalAttributePolicies.get(attribute));
  795. }
  796. }
  797. }
  798. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  799. finally {
  800. try {
  801. if (attributeSet_1_1 && !attributeSet_1_1.done && (_a = attributeSet_1.return)) _a.call(attributeSet_1);
  802. }
  803. finally { if (e_2) throw e_2.error; }
  804. }
  805. try {
  806. for (var _d = __values(this.sanitizerTable
  807. .elementPolicies.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
  808. var _f = __read(_e.value, 2), elementName = _f[0], originalElementPolicy = _f[1];
  809. var newElementPolicy = new Map();
  810. try {
  811. for (var _g = (e_4 = void 0, __values(originalElementPolicy
  812. .entries())), _h = _g.next(); !_h.done; _h = _g.next()) {
  813. var _j = __read(_h.value, 2), attribute = _j[0], attributePolicy = _j[1];
  814. if (attributeSet.has(attribute)) {
  815. newElementPolicy.set(attribute, attributePolicy);
  816. }
  817. }
  818. }
  819. catch (e_4_1) { e_4 = { error: e_4_1 }; }
  820. finally {
  821. try {
  822. if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
  823. }
  824. finally { if (e_4) throw e_4.error; }
  825. }
  826. elementPolicies.set(elementName, newElementPolicy);
  827. }
  828. }
  829. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  830. finally {
  831. try {
  832. if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
  833. }
  834. finally { if (e_3) throw e_3.error; }
  835. }
  836. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, elementPolicies, allowedGlobalAttributes, globalAttributePolicies);
  837. return this;
  838. };
  839. /**
  840. * Allows the set of data attributes passed.
  841. *
  842. * These values must be prefixed with "data-"
  843. *
  844. * If called with onlyAllowElements or onlyAllowAttributes, those methods must
  845. * be called first.
  846. */
  847. HtmlSanitizerBuilder.prototype.allowDataAttributes = function (attributes) {
  848. var e_5, _a;
  849. var allowedGlobalAttributes = new Set(this.sanitizerTable.allowedGlobalAttributes);
  850. try {
  851. for (var attributes_1 = __values(attributes), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) {
  852. var attribute = attributes_1_1.value;
  853. if (attribute.indexOf('data-') !== 0) {
  854. throw new Error("data attribute: ".concat(attribute, " does not begin with the prefix \"data-\""));
  855. }
  856. allowedGlobalAttributes.add(attribute);
  857. }
  858. }
  859. catch (e_5_1) { e_5 = { error: e_5_1 }; }
  860. finally {
  861. try {
  862. if (attributes_1_1 && !attributes_1_1.done && (_a = attributes_1.return)) _a.call(attributes_1);
  863. }
  864. finally { if (e_5) throw e_5.error; }
  865. }
  866. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, allowedGlobalAttributes, this.sanitizerTable.globalAttributePolicies);
  867. return this;
  868. };
  869. /**
  870. * Preserves style attributes. Note that the sanitizer won't parse and
  871. * sanitize the values but keep them as they are. In particular this means
  872. * that the code will be able to call functions that could do undesirable
  873. * things (e.g. `url` to trigger a network request), as well as any custom
  874. * properties or functions defined by the application.
  875. */
  876. HtmlSanitizerBuilder.prototype.allowStyleAttributes = function () {
  877. var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
  878. globalAttributePolicies.set('style', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_STYLE });
  879. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
  880. return this;
  881. };
  882. /**
  883. * Preserves the class attribute on all elements. This means contents can
  884. * adopt CSS styles from other page elements and possibly mask themselves as
  885. * legitimate UI elements, which can lead to phishing.
  886. */
  887. HtmlSanitizerBuilder.prototype.allowClassAttributes = function () {
  888. var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
  889. globalAttributePolicies.set('class', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP });
  890. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
  891. return this;
  892. };
  893. /**
  894. * Preserves id attributes. This carries moderate risk as it allows an
  895. * element to override other elements with the same ID.
  896. */
  897. HtmlSanitizerBuilder.prototype.allowIdAttributes = function () {
  898. var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
  899. globalAttributePolicies.set('id', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP });
  900. this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
  901. return this;
  902. };
  903. HtmlSanitizerBuilder.prototype.build = function () {
  904. if (this.calledBuild) {
  905. throw new Error('this sanitizer has already called build');
  906. }
  907. this.calledBuild = true;
  908. return new html_sanitizer_1.HtmlSanitizerImpl(this.sanitizerTable, secrets_1.secretToken);
  909. };
  910. return HtmlSanitizerBuilder;
  911. }());
  912. exports.HtmlSanitizerBuilder = HtmlSanitizerBuilder;
  913. /***/ }),
  914. /***/ "./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js":
  915. /*!***************************************************************************!*\
  916. !*** ./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js ***!
  917. \***************************************************************************/
  918. /*! no static exports found */
  919. /***/ (function(module, exports, __webpack_require__) {
  920. "use strict";
  921. /**
  922. * @license
  923. * SPDX-License-Identifier: Apache-2.0
  924. */
  925. Object.defineProperty(exports, "__esModule", { value: true });
  926. exports.createInertFragment = void 0;
  927. var element_1 = __webpack_require__(/*! ../../dom/elements/element */ "./node_modules/safevalues/dom/elements/element.js");
  928. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  929. /**
  930. * Returns a fragment that contains the parsed HTML for `dirtyHtml` without
  931. * executing any of the potential payload.
  932. */
  933. function createInertFragment(dirtyHtml) {
  934. var template = document.createElement('template');
  935. // This call is only used to create an inert tree for the sanitizer to
  936. // further process and is never returned directly to the caller. We can't use
  937. // a reviewed conversion in order to avoid an import loop.
  938. var temporarySafeHtml = (0, html_impl_1.createHtml)(dirtyHtml);
  939. (0, element_1.setInnerHtml)(template, temporarySafeHtml);
  940. return template.content;
  941. }
  942. exports.createInertFragment = createInertFragment;
  943. /***/ }),
  944. /***/ "./node_modules/safevalues/builders/html_sanitizer/no_clobber.js":
  945. /*!***********************************************************************!*\
  946. !*** ./node_modules/safevalues/builders/html_sanitizer/no_clobber.js ***!
  947. \***********************************************************************/
  948. /*! no static exports found */
  949. /***/ (function(module, exports, __webpack_require__) {
  950. "use strict";
  951. /**
  952. * @license
  953. * SPDX-License-Identifier: Apache-2.0
  954. */
  955. Object.defineProperty(exports, "__esModule", { value: true });
  956. exports.isElement = exports.isText = exports.getNodeName = void 0;
  957. /**
  958. * Library that provides safe getters for different node properties and
  959. * checks for clobbering.
  960. */
  961. /** Gets a reasonable nodeName, even for clobbered nodes. */
  962. function getNodeName(node) {
  963. var nodeName = node.nodeName;
  964. // If the property is clobbered, assume it is an `HTMLFormElement`.
  965. return (typeof nodeName === 'string') ? nodeName : 'FORM';
  966. }
  967. exports.getNodeName = getNodeName;
  968. /** Returns true if the object passed is a Text node. */
  969. function isText(node) {
  970. // The property cannot get clobbered on Text nodes.
  971. return node.nodeType === Node.TEXT_NODE;
  972. }
  973. exports.isText = isText;
  974. /** Returns true if the object passed is an Element node. */
  975. function isElement(node) {
  976. var nodeType = node.nodeType;
  977. // If the property is clobbered, we can assume it is an `HTMLFormElement`, and
  978. // thus an `Element`.
  979. return (nodeType === Node.ELEMENT_NODE) || (typeof nodeType !== 'number');
  980. }
  981. exports.isElement = isElement;
  982. /***/ }),
  983. /***/ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js":
  984. /*!****************************************************************************************************!*\
  985. !*** ./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js ***!
  986. \****************************************************************************************************/
  987. /*! no static exports found */
  988. /***/ (function(module, exports, __webpack_require__) {
  989. "use strict";
  990. /**
  991. * @license
  992. * SPDX-License-Identifier: Apache-2.0
  993. */
  994. Object.defineProperty(exports, "__esModule", { value: true });
  995. exports.defaultSanitizerTable = void 0;
  996. var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
  997. /**
  998. * GENERATED CODE, DO NOT MODIFY
  999. * This SanitizerTable was generated from the checked in html contract:
  1000. * webutil/html/types/codegen/html5_contract.textpb
  1001. *
  1002. * You can regenerate this file with:
  1003. * webutil/html/types/codegen/update_generated_source_files.sh
  1004. */
  1005. exports.defaultSanitizerTable = new sanitizer_table_1.SanitizerTable(new Set([
  1006. 'ARTICLE', 'SECTION', 'NAV', 'ASIDE', 'H1', 'H2',
  1007. 'H3', 'H4', 'H5', 'H6', 'HEADER', 'FOOTER',
  1008. 'ADDRESS', 'P', 'HR', 'PRE', 'BLOCKQUOTE', 'OL',
  1009. 'UL', 'LH', 'LI', 'DL', 'DT', 'DD',
  1010. 'FIGURE', 'FIGCAPTION', 'MAIN', 'DIV', 'EM', 'STRONG',
  1011. 'SMALL', 'S', 'CITE', 'Q', 'DFN', 'ABBR',
  1012. 'RUBY', 'RB', 'RT', 'RTC', 'RP', 'DATA',
  1013. 'TIME', 'CODE', 'VAR', 'SAMP', 'KBD', 'SUB',
  1014. 'SUP', 'I', 'B', 'U', 'MARK', 'BDI',
  1015. 'BDO', 'SPAN', 'BR', 'WBR', 'INS', 'DEL',
  1016. 'PICTURE', 'PARAM', 'TRACK', 'MAP', 'TABLE', 'CAPTION',
  1017. 'COLGROUP', 'COL', 'TBODY', 'THEAD', 'TFOOT', 'TR',
  1018. 'TD', 'TH', 'SELECT', 'DATALIST', 'OPTGROUP', 'OPTION',
  1019. 'OUTPUT', 'PROGRESS', 'METER', 'FIELDSET', 'LEGEND', 'DETAILS',
  1020. 'SUMMARY', 'MENU', 'DIALOG', 'SLOT', 'CANVAS', 'FONT',
  1021. 'CENTER',
  1022. ]), new Map([
  1023. [
  1024. 'A', new Map([
  1025. ['href', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1026. ])
  1027. ],
  1028. [
  1029. 'AREA', new Map([
  1030. ['href', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1031. ])
  1032. ],
  1033. [
  1034. 'LINK', new Map([
  1035. [
  1036. 'href', {
  1037. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL,
  1038. conditions: new Map([[
  1039. 'rel', new Set([
  1040. 'alternate',
  1041. 'author',
  1042. 'bookmark',
  1043. 'canonical',
  1044. 'cite',
  1045. 'help',
  1046. 'icon',
  1047. 'license',
  1048. 'next',
  1049. 'prefetch',
  1050. 'dns-prefetch',
  1051. 'prerender',
  1052. 'preconnect',
  1053. 'preload',
  1054. 'prev',
  1055. 'search',
  1056. 'subresource',
  1057. ])
  1058. ]])
  1059. }
  1060. ],
  1061. ])
  1062. ],
  1063. [
  1064. 'SOURCE', new Map([
  1065. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1066. ])
  1067. ],
  1068. [
  1069. 'IMG', new Map([
  1070. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1071. ])
  1072. ],
  1073. [
  1074. 'VIDEO', new Map([
  1075. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1076. ])
  1077. ],
  1078. [
  1079. 'AUDIO', new Map([
  1080. ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1081. ])
  1082. ],
  1083. ]), new Set([
  1084. 'title',
  1085. 'aria-atomic',
  1086. 'aria-autocomplete',
  1087. 'aria-busy',
  1088. 'aria-checked',
  1089. 'aria-current',
  1090. 'aria-disabled',
  1091. 'aria-dropeffect',
  1092. 'aria-expanded',
  1093. 'aria-haspopup',
  1094. 'aria-hidden',
  1095. 'aria-invalid',
  1096. 'aria-label',
  1097. 'aria-level',
  1098. 'aria-live',
  1099. 'aria-multiline',
  1100. 'aria-multiselectable',
  1101. 'aria-orientation',
  1102. 'aria-posinset',
  1103. 'aria-pressed',
  1104. 'aria-readonly',
  1105. 'aria-relevant',
  1106. 'aria-required',
  1107. 'aria-selected',
  1108. 'aria-setsize',
  1109. 'aria-sort',
  1110. 'aria-valuemax',
  1111. 'aria-valuemin',
  1112. 'aria-valuenow',
  1113. 'aria-valuetext',
  1114. 'alt',
  1115. 'align',
  1116. 'autocapitalize',
  1117. 'autocomplete',
  1118. 'autocorrect',
  1119. 'autofocus',
  1120. 'autoplay',
  1121. 'bgcolor',
  1122. 'border',
  1123. 'cellpadding',
  1124. 'cellspacing',
  1125. 'checked',
  1126. 'color',
  1127. 'cols',
  1128. 'colspan',
  1129. 'controls',
  1130. 'datetime',
  1131. 'disabled',
  1132. 'download',
  1133. 'draggable',
  1134. 'enctype',
  1135. 'face',
  1136. 'formenctype',
  1137. 'frameborder',
  1138. 'height',
  1139. 'hreflang',
  1140. 'hidden',
  1141. 'ismap',
  1142. 'label',
  1143. 'lang',
  1144. 'loop',
  1145. 'max',
  1146. 'maxlength',
  1147. 'media',
  1148. 'minlength',
  1149. 'min',
  1150. 'multiple',
  1151. 'muted',
  1152. 'nonce',
  1153. 'open',
  1154. 'placeholder',
  1155. 'preload',
  1156. 'rel',
  1157. 'required',
  1158. 'reversed',
  1159. 'role',
  1160. 'rows',
  1161. 'rowspan',
  1162. 'selected',
  1163. 'shape',
  1164. 'size',
  1165. 'sizes',
  1166. 'slot',
  1167. 'span',
  1168. 'spellcheck',
  1169. 'start',
  1170. 'step',
  1171. 'summary',
  1172. 'translate',
  1173. 'type',
  1174. 'valign',
  1175. 'value',
  1176. 'width',
  1177. 'wrap',
  1178. 'itemscope',
  1179. 'itemtype',
  1180. 'itemid',
  1181. 'itemprop',
  1182. 'itemref',
  1183. ]), new Map([
  1184. [
  1185. 'dir', {
  1186. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1187. conditions: new Map([[
  1188. 'dir', new Set([
  1189. 'auto',
  1190. 'ltr',
  1191. 'rtl',
  1192. ])
  1193. ]])
  1194. }
  1195. ],
  1196. [
  1197. 'async', {
  1198. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1199. conditions: new Map([[
  1200. 'async', new Set([
  1201. 'async',
  1202. ])
  1203. ]])
  1204. }
  1205. ],
  1206. ['cite', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1207. [
  1208. 'loading', {
  1209. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1210. conditions: new Map([[
  1211. 'loading', new Set([
  1212. 'eager',
  1213. 'lazy',
  1214. ])
  1215. ]])
  1216. }
  1217. ],
  1218. ['poster', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
  1219. [
  1220. 'target', {
  1221. policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
  1222. conditions: new Map([[
  1223. 'target', new Set([
  1224. '_self',
  1225. '_blank',
  1226. ])
  1227. ]])
  1228. }
  1229. ],
  1230. ]));
  1231. /***/ }),
  1232. /***/ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js":
  1233. /*!********************************************************************************************!*\
  1234. !*** ./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js ***!
  1235. \********************************************************************************************/
  1236. /*! no static exports found */
  1237. /***/ (function(module, exports, __webpack_require__) {
  1238. "use strict";
  1239. /**
  1240. * @license
  1241. * SPDX-License-Identifier: Apache-2.0
  1242. */
  1243. Object.defineProperty(exports, "__esModule", { value: true });
  1244. exports.AttributePolicyAction = exports.SanitizerTable = void 0;
  1245. /** Class for holding element and attribute policies used for sanitization. */
  1246. var SanitizerTable = /** @class */ (function () {
  1247. function SanitizerTable(allowedElements, elementPolicies, allowedGlobalAttributes, globalAttributePolicies) {
  1248. this.allowedElements = allowedElements;
  1249. this.elementPolicies = elementPolicies;
  1250. this.allowedGlobalAttributes = allowedGlobalAttributes;
  1251. this.globalAttributePolicies = globalAttributePolicies;
  1252. }
  1253. SanitizerTable.prototype.isAllowedElement = function (elementName) {
  1254. // Note: `HTMLFormElement`s are always dropped, supporting them is very
  1255. // costly because of the DOM clobberring they can cause. The additional code
  1256. // size required to properly work around DOM clobberring issues is large and
  1257. // shouldn't be put on every user of the sanitizer. Thoroughly review
  1258. // b/210975025 and the CLs linked there before you start allowing form
  1259. // elements.
  1260. return elementName.toLowerCase() !== 'form' &&
  1261. (this.allowedElements.has(elementName) ||
  1262. this.elementPolicies.has(elementName));
  1263. };
  1264. SanitizerTable.prototype.getAttributePolicy = function (attributeName, elementName) {
  1265. var elementPolicy = this.elementPolicies.get(elementName);
  1266. if (elementPolicy === null || elementPolicy === void 0 ? void 0 : elementPolicy.has(attributeName)) {
  1267. return elementPolicy.get(attributeName);
  1268. }
  1269. if (this.allowedGlobalAttributes.has(attributeName)) {
  1270. return { policyAction: AttributePolicyAction.KEEP };
  1271. }
  1272. var globalPolicy = this.globalAttributePolicies.get(attributeName);
  1273. return globalPolicy || { policyAction: AttributePolicyAction.DROP };
  1274. };
  1275. return SanitizerTable;
  1276. }());
  1277. exports.SanitizerTable = SanitizerTable;
  1278. /**
  1279. * Values derived from
  1280. * https://godoc.corp.google.com/pkg/google3/third_party/safehtml/sanitizer/policy#AttributePolicy
  1281. */
  1282. var AttributePolicyAction;
  1283. (function (AttributePolicyAction) {
  1284. AttributePolicyAction[AttributePolicyAction["DROP"] = 0] = "DROP";
  1285. AttributePolicyAction[AttributePolicyAction["KEEP"] = 1] = "KEEP";
  1286. AttributePolicyAction[AttributePolicyAction["KEEP_AND_SANITIZE_URL"] = 2] = "KEEP_AND_SANITIZE_URL";
  1287. AttributePolicyAction[AttributePolicyAction["KEEP_AND_NORMALIZE"] = 3] = "KEEP_AND_NORMALIZE";
  1288. AttributePolicyAction[AttributePolicyAction["KEEP_AND_SANITIZE_STYLE"] = 4] = "KEEP_AND_SANITIZE_STYLE";
  1289. })(AttributePolicyAction = exports.AttributePolicyAction || (exports.AttributePolicyAction = {}));
  1290. /***/ }),
  1291. /***/ "./node_modules/safevalues/builders/resource_url_builders.js":
  1292. /*!*******************************************************************!*\
  1293. !*** ./node_modules/safevalues/builders/resource_url_builders.js ***!
  1294. \*******************************************************************/
  1295. /*! no static exports found */
  1296. /***/ (function(module, exports, __webpack_require__) {
  1297. "use strict";
  1298. /**
  1299. * @license
  1300. * SPDX-License-Identifier: Apache-2.0
  1301. */
  1302. Object.defineProperty(exports, "__esModule", { value: true });
  1303. exports.blobUrlFromScript = exports.replaceFragment = exports.appendParams = exports.trustedResourceUrl = void 0;
  1304. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1305. var resource_url_impl_1 = __webpack_require__(/*! ../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  1306. var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  1307. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1308. /**
  1309. * Check whether the base url contains a valid origin,
  1310. *
  1311. * A string for an origin must contain only alphanumeric or any of the
  1312. * following: `-.:`, and must not be an IP address. Remember that, as per the
  1313. * documentation for TrustedResourceUrl, the origin must be trustworthy.
  1314. *
  1315. * @param base The base url that contains an origin.
  1316. */
  1317. function hasValidOrigin(base) {
  1318. if (!(/^https:\/\//.test(base) || /^\/\//.test(base))) {
  1319. return false;
  1320. }
  1321. var originStart = base.indexOf('//') + 2;
  1322. var originEnd = base.indexOf('/', originStart);
  1323. // If the base url only contains the prefix (e.g. //), or the slash
  1324. // for the origin is right after the prefix (e.g. ///), the origin is
  1325. // missing.
  1326. if (originEnd <= originStart) {
  1327. throw new Error("Can't interpolate data in a url's origin, " +
  1328. "Please make sure to fully specify the origin, terminated with '/'.");
  1329. }
  1330. var origin = base.substring(originStart, originEnd);
  1331. if (!/^[0-9a-z.:-]+$/i.test(origin)) {
  1332. throw new Error('The origin contains unsupported characters.');
  1333. }
  1334. if (!/^[^:]*(:[0-9]+)?$/i.test(origin)) {
  1335. throw new Error('Invalid port number.');
  1336. }
  1337. if (!/(^|\.)[a-z][^.]*$/i.test(origin)) {
  1338. throw new Error('The top-level domain must start with a letter.');
  1339. }
  1340. return true;
  1341. }
  1342. /**
  1343. * Check whether the base url contains a valid about url at its beginning.
  1344. *
  1345. * An about url is either exactly 'about:blank' or 'about:blank#<str>' where
  1346. * <str> can be an arbitrary string.
  1347. *
  1348. * @param base The base url.
  1349. */
  1350. function isValidAboutUrl(base) {
  1351. if (!/^about:blank/.test(base)) {
  1352. return false;
  1353. }
  1354. if (base !== 'about:blank' && !/^about:blank#/.test(base)) {
  1355. throw new Error('The about url is invalid.');
  1356. }
  1357. return true;
  1358. }
  1359. /**
  1360. * Check whether the base url contains a valid path start at its beginning.
  1361. *
  1362. * A valid path start is either a '/' or a '/' followed by at least one
  1363. * character that is not '/' or '\'.
  1364. *
  1365. * @param base The base url.
  1366. */
  1367. function isValidPathStart(base) {
  1368. if (!/^\//.test(base)) {
  1369. return false;
  1370. }
  1371. if ((base === '/') ||
  1372. (base.length > 1 && base[1] !== '/' && base[1] !== '\\')) {
  1373. return true;
  1374. }
  1375. throw new Error('The path start in the url is invalid.');
  1376. }
  1377. /**
  1378. * Builds TrustedResourceUrl from a template literal.
  1379. *
  1380. * This factory is a template literal tag function. It should be called with
  1381. * a template literal, with or without embedded expressions. For example,
  1382. * trustedResourceUrl`//example.com/${bar}`;
  1383. * or
  1384. * trustedResourceUrl`//example.com`;
  1385. *
  1386. * When this function is called with a template literal without any embedded
  1387. * expressions, the template string may contain anything as the whole URL is
  1388. * a compile-time string constant.
  1389. *
  1390. * When this function is called with a template literal that contains embedded
  1391. * expressions, the template must start with one of the following:
  1392. * - `https://<origin>/`
  1393. * - `//<origin>/`
  1394. * - `/<pathStart>`
  1395. * - `about:blank`
  1396. * - `data:`
  1397. *
  1398. * `<origin>` must contain only alphanumeric or any of the following: `-.:`.
  1399. * Remember that, as per the documentation for TrustedResourceUrl, the origin
  1400. * must be trustworthy. An origin of "example.com" could be set with this
  1401. * method, but would tie the security of your site to the security of
  1402. * example.com. Similarly, formats that potentially cover redirects hosted
  1403. * on a trusted origin are problematic, since that could lead to untrusted
  1404. * origins.
  1405. *
  1406. * `<pathStart>` is either an empty string, or a non empty string that does not
  1407. * start with '/' or '\'.
  1408. * In other words, `/<pathStart>` is either a '/' or a
  1409. * '/' followed by at least one character that is not '/' or '\'.
  1410. *
  1411. * `data:` (data URL) does not allow embedded expressions in the template
  1412. * literal input.
  1413. *
  1414. * All embedded expressions are URL encoded when they are interpolated. Do not
  1415. * embed expressions that are already URL encoded as they will be double encoded
  1416. * by the builder.
  1417. *
  1418. * @param templateObj This contains the literal part of the template literal.
  1419. * @param rest This represents the template's embedded expressions.
  1420. */
  1421. function trustedResourceUrl(templateObj) {
  1422. var rest = [];
  1423. for (var _i = 1; _i < arguments.length; _i++) {
  1424. rest[_i - 1] = arguments[_i];
  1425. }
  1426. // Check if templateObj is actually from a template literal.
  1427. if (true) {
  1428. (0, string_literal_1.assertIsTemplateObject)(templateObj, true, 'trustedResourceUrl is a template literal tag function and ' +
  1429. 'can only be called as such (e.g. trustedResourceUrl`/somepath.js`)');
  1430. }
  1431. if (rest.length === 0) {
  1432. return (0, resource_url_impl_1.createResourceUrl)(templateObj[0]);
  1433. }
  1434. var base = templateObj[0].toLowerCase();
  1435. if (true) {
  1436. if (/^data:/.test(base)) {
  1437. throw new Error('Data URLs cannot have expressions in the template literal input.');
  1438. }
  1439. if (!hasValidOrigin(base) && !isValidPathStart(base) &&
  1440. !isValidAboutUrl(base)) {
  1441. throw new Error('Trying to interpolate expressions in an unsupported url format.');
  1442. }
  1443. }
  1444. var urlParts = [templateObj[0]];
  1445. for (var i = 0; i < rest.length; i++) {
  1446. urlParts.push(encodeURIComponent(rest[i]));
  1447. urlParts.push(templateObj[i + 1]);
  1448. }
  1449. return (0, resource_url_impl_1.createResourceUrl)(urlParts.join(''));
  1450. }
  1451. exports.trustedResourceUrl = trustedResourceUrl;
  1452. /**
  1453. * Creates a new TrustedResourceUrl with params added to the URL's search
  1454. * parameters.
  1455. *
  1456. * @param params What to add to the URL. Parameters with value `null` or
  1457. * `undefined` are skipped. Both keys and values will be encoded. Do not pass
  1458. * pre-encoded values as this will result them being double encoded. If the
  1459. * value is an array then the same parameter is added for every element in the
  1460. * array.
  1461. */
  1462. function appendParams(trustedUrl, params) {
  1463. var url = (0, resource_url_impl_1.unwrapResourceUrl)(trustedUrl).toString();
  1464. if (/#/.test(url)) {
  1465. var message = '';
  1466. if (true) {
  1467. message = "Found a hash in url (".concat(url, "), appending not supported");
  1468. }
  1469. throw new Error(message);
  1470. }
  1471. var separator = /\?/.test(url) ? '&' : '?';
  1472. // for-of has a big polyfill.
  1473. // tslint:disable-next-line:ban-iterable-foreach
  1474. params.forEach(function (value, key) {
  1475. var values = (value instanceof Array) ? value : [value];
  1476. for (var i = 0; i < values.length; i++) {
  1477. var v = values[i];
  1478. if (v === null || v === undefined) {
  1479. continue;
  1480. }
  1481. url += separator + encodeURIComponent(key) + '=' +
  1482. encodeURIComponent(String(v));
  1483. separator = '&';
  1484. }
  1485. });
  1486. return (0, resource_url_impl_1.createResourceUrl)(url);
  1487. }
  1488. exports.appendParams = appendParams;
  1489. var BEFORE_FRAGMENT_REGEXP = /[^#]*/;
  1490. /**
  1491. * Creates a new TrustedResourceUrl based on an existing one but with the
  1492. * addition of a fragment (the part after `#`). If the URL already has a
  1493. * fragment, it is replaced with the new one.
  1494. * @param fragment The fragment to add to the URL, verbatim, without the leading
  1495. * `#`. No additional escaping is applied.
  1496. */
  1497. function replaceFragment(trustedUrl, fragment) {
  1498. var urlString = (0, resource_url_impl_1.unwrapResourceUrl)(trustedUrl).toString();
  1499. return (0, resource_url_impl_1.createResourceUrl)(BEFORE_FRAGMENT_REGEXP.exec(urlString)[0] + '#' + fragment);
  1500. }
  1501. exports.replaceFragment = replaceFragment;
  1502. /**
  1503. * Creates a `TrustedResourceUrl` by generating a `Blob` from a
  1504. * `SafeScript` and then calling `URL.createObjectURL` with that `Blob`.
  1505. *
  1506. * Caller must call `URL.revokeObjectUrl()` on the stringified url to
  1507. * release the underlying `Blob`.
  1508. */
  1509. function blobUrlFromScript(safeScript) {
  1510. var scriptContent = (0, script_impl_1.unwrapScript)(safeScript).toString();
  1511. var blob = new Blob([scriptContent], { type: 'text/javascript' });
  1512. return (0, resource_url_impl_1.createResourceUrl)(URL.createObjectURL(blob));
  1513. }
  1514. exports.blobUrlFromScript = blobUrlFromScript;
  1515. /***/ }),
  1516. /***/ "./node_modules/safevalues/builders/script_builders.js":
  1517. /*!*************************************************************!*\
  1518. !*** ./node_modules/safevalues/builders/script_builders.js ***!
  1519. \*************************************************************/
  1520. /*! no static exports found */
  1521. /***/ (function(module, exports, __webpack_require__) {
  1522. "use strict";
  1523. /**
  1524. * @license
  1525. * SPDX-License-Identifier: Apache-2.0
  1526. */
  1527. Object.defineProperty(exports, "__esModule", { value: true });
  1528. exports.safeScriptWithArgs = exports.scriptFromJson = exports.concatScripts = exports.safeScript = void 0;
  1529. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1530. var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  1531. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1532. /**
  1533. * Creates a SafeScript object from a template literal (without any embedded
  1534. * expressions).
  1535. *
  1536. * This function is a template literal tag function. It should be called with
  1537. * a template literal that does not contain any expressions. For example,
  1538. * safeScript`foo`;
  1539. *
  1540. * @param templateObj This contains the literal part of the template literal.
  1541. */
  1542. function safeScript(templateObj) {
  1543. if (true) {
  1544. (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeScript is a template literal tag function ' +
  1545. 'that only accepts template literals without expressions. ' +
  1546. 'For example, safeScript`foo`;');
  1547. }
  1548. return (0, script_impl_1.createScript)(templateObj[0]);
  1549. }
  1550. exports.safeScript = safeScript;
  1551. /** Creates a `SafeScript` value by concatenating multiple `SafeScript`s. */
  1552. function concatScripts(scripts) {
  1553. return (0, script_impl_1.createScript)(scripts.map(script_impl_1.unwrapScript).join(''));
  1554. }
  1555. exports.concatScripts = concatScripts;
  1556. /**
  1557. * Converts a serializable value into JSON that is safe to interpolate into a
  1558. * script context. In particular it escapes < characters so that a value of
  1559. * "</script>" doesn't break out of the context.
  1560. * @param value The value to serialize.
  1561. */
  1562. function scriptFromJson(value) {
  1563. return (0, script_impl_1.createScript)(JSON.stringify(value).replace(/</g, '\\x3c'));
  1564. }
  1565. exports.scriptFromJson = scriptFromJson;
  1566. /**
  1567. * Creates a `SafeScript` object from a template literal (without any embedded
  1568. * expressions) along with additional arguments that the script should have
  1569. * access to. These arguments will be JSON-encoded and passed to the script as
  1570. * a function call.
  1571. * @example
  1572. * ```ts
  1573. * safeScriptWithArgs`function (name, props) {
  1574. * console.log(name + ' is ' + props.age);
  1575. * }`('Bob', { 'age': 42 })
  1576. * ```
  1577. * would return a `SafeScript` that represents the following code:
  1578. * ```js
  1579. * (function (name, props) {
  1580. * console.log(name + ' is ' + props.age);
  1581. * })("Bob",{"age":42})
  1582. * ```
  1583. * @note Be careful when passing objects as arguments, as unquoted property
  1584. * names may be changed during compilation.
  1585. * @param templateObj This contains the literal part of the template literal.
  1586. * @param emptyArgs Expressions that evaluate to the empty string to enable
  1587. * inline comments.
  1588. */
  1589. function safeScriptWithArgs(templateObj) {
  1590. var emptyArgs = [];
  1591. for (var _i = 1; _i < arguments.length; _i++) {
  1592. emptyArgs[_i - 1] = arguments[_i];
  1593. }
  1594. if (true) {
  1595. if (emptyArgs.some(function (a) { return a !== ''; })) {
  1596. throw new Error('safeScriptWithArgs only allows empty string expressions ' +
  1597. 'to enable inline comments.');
  1598. }
  1599. (0, string_literal_1.assertIsTemplateObject)(templateObj, true, 'safeScriptWithArgs is a template literal tag function ' +
  1600. 'that only accepts template literals. ' +
  1601. 'For example, safeScriptWithArgs`foo`;');
  1602. }
  1603. return function () {
  1604. var argValues = [];
  1605. for (var _i = 0; _i < arguments.length; _i++) {
  1606. argValues[_i] = arguments[_i];
  1607. }
  1608. var values = argValues.map(function (v) { return scriptFromJson(v).toString(); });
  1609. return (0, script_impl_1.createScript)("(".concat(templateObj.join(''), ")(").concat(values.join(','), ")"));
  1610. };
  1611. }
  1612. exports.safeScriptWithArgs = safeScriptWithArgs;
  1613. /***/ }),
  1614. /***/ "./node_modules/safevalues/builders/sensitive_attributes.js":
  1615. /*!******************************************************************!*\
  1616. !*** ./node_modules/safevalues/builders/sensitive_attributes.js ***!
  1617. \******************************************************************/
  1618. /*! no static exports found */
  1619. /***/ (function(module, exports, __webpack_require__) {
  1620. "use strict";
  1621. /**
  1622. * @license
  1623. * SPDX-License-Identifier: Apache-2.0
  1624. */
  1625. Object.defineProperty(exports, "__esModule", { value: true });
  1626. exports.SECURITY_SENSITIVE_ATTRIBUTES = void 0;
  1627. // AUTOGENERATED. DO NOT EDIT.
  1628. /**
  1629. * Security sensitive attribute names that should not be set through
  1630. * `setAttribute` or similar functions.
  1631. */
  1632. exports.SECURITY_SENSITIVE_ATTRIBUTES = [
  1633. 'href',
  1634. 'rel',
  1635. 'src',
  1636. 'srcdoc',
  1637. 'action',
  1638. 'formaction',
  1639. 'sandbox',
  1640. 'cite',
  1641. 'poster',
  1642. 'icon',
  1643. ];
  1644. /***/ }),
  1645. /***/ "./node_modules/safevalues/builders/style_builders.js":
  1646. /*!************************************************************!*\
  1647. !*** ./node_modules/safevalues/builders/style_builders.js ***!
  1648. \************************************************************/
  1649. /*! no static exports found */
  1650. /***/ (function(module, exports, __webpack_require__) {
  1651. "use strict";
  1652. /**
  1653. * @license
  1654. * SPDX-License-Identifier: Apache-2.0
  1655. */
  1656. Object.defineProperty(exports, "__esModule", { value: true });
  1657. exports.concatStyles = exports.safeStyle = void 0;
  1658. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1659. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1660. var style_impl_1 = __webpack_require__(/*! ../internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
  1661. /**
  1662. * Creates a SafeStyle object from a template literal (without any embedded
  1663. * expressions).
  1664. *
  1665. * ` style` should be in the format
  1666. * ` name: value; [name: value; ...]` and must not have any < or >
  1667. * characters in it. This is so that SafeStyle's contract is preserved,
  1668. * allowing the SafeStyle to correctly be interpreted as a sequence of CSS
  1669. * declarations and without affecting the syntactic structure of any
  1670. * surrounding CSS and HTML.
  1671. *
  1672. * This function is a template literal tag function. It should be called with
  1673. * a template literal that does not contain any expressions. For example,
  1674. * safeStyle`foo`;
  1675. * This function first checks if it is called with a literal template, and
  1676. * then performs basic sanity checks on the format of ` style`
  1677. * but does not constrain the format of ` name} and {@code value`, except
  1678. * for disallowing tag characters.
  1679. *
  1680. * @param templateObj This contains the literal part of the template literal.
  1681. */
  1682. function safeStyle(templateObj) {
  1683. if (true) {
  1684. (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeStyle is a template literal tag function ' +
  1685. 'that only accepts template literals without expressions. ' +
  1686. 'For example, safeStyle`foo`;');
  1687. }
  1688. var style = templateObj[0];
  1689. if (true) {
  1690. if (/[<>]/.test(style)) {
  1691. throw new Error('Forbidden characters in style string: ' + style);
  1692. }
  1693. if (!/;$/.test(style)) {
  1694. throw new Error('Style string does not end with ";": ' + style);
  1695. }
  1696. if (!/:/.test(style)) {
  1697. throw new Error('Style string should contain one or more ":": ' + style);
  1698. }
  1699. }
  1700. return (0, style_impl_1.createStyle)(style);
  1701. }
  1702. exports.safeStyle = safeStyle;
  1703. /** Creates a `SafeStyle` value by concatenating multiple `SafeStyle`s. */
  1704. function concatStyles(styles) {
  1705. return (0, style_impl_1.createStyle)(styles.map(style_impl_1.unwrapStyle).join(''));
  1706. }
  1707. exports.concatStyles = concatStyles;
  1708. /***/ }),
  1709. /***/ "./node_modules/safevalues/builders/style_sheet_builders.js":
  1710. /*!******************************************************************!*\
  1711. !*** ./node_modules/safevalues/builders/style_sheet_builders.js ***!
  1712. \******************************************************************/
  1713. /*! no static exports found */
  1714. /***/ (function(module, exports, __webpack_require__) {
  1715. "use strict";
  1716. /**
  1717. * @license
  1718. * SPDX-License-Identifier: Apache-2.0
  1719. */
  1720. Object.defineProperty(exports, "__esModule", { value: true });
  1721. exports.concatStyleSheets = exports.safeStyleSheet = void 0;
  1722. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1723. var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
  1724. var style_sheet_impl_1 = __webpack_require__(/*! ../internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
  1725. /**
  1726. * Creates a SafeStyleSheet object from a template literal (without any
  1727. * embedded expressions).
  1728. *
  1729. * This function is a template literal tag function. It should be called with
  1730. * a template literal that does not contain any expressions. For example,
  1731. * safeStyleSheet`foo`;
  1732. * The argument must not have any < or > characters in it. This is so that
  1733. * SafeStyleSheet's contract is preserved, allowing the SafeStyleSheet to
  1734. * correctly be interpreted as a sequence of CSS declarations and without
  1735. * affecting the syntactic structure of any surrounding CSS and HTML.
  1736. *
  1737. * @param templateObj This contains the literal part of the template literal.
  1738. */
  1739. function safeStyleSheet(templateObj) {
  1740. if (true) {
  1741. (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeStyleSheet is a template literal tag ' +
  1742. 'function that only accepts template literals without ' +
  1743. 'expressions. For example, safeStyleSheet`foo`;');
  1744. }
  1745. var styleSheet = templateObj[0];
  1746. if (true) {
  1747. if (/[<>]/.test(styleSheet)) {
  1748. throw new Error('Forbidden characters in styleSheet string: ' + styleSheet);
  1749. }
  1750. }
  1751. return (0, style_sheet_impl_1.createStyleSheet)(styleSheet);
  1752. }
  1753. exports.safeStyleSheet = safeStyleSheet;
  1754. /**
  1755. * Creates a `SafeStyleSheet` value by concatenating multiple `SafeStyleSheet`s.
  1756. */
  1757. function concatStyleSheets(sheets) {
  1758. return (0, style_sheet_impl_1.createStyleSheet)(sheets.map(style_sheet_impl_1.unwrapStyleSheet).join(''));
  1759. }
  1760. exports.concatStyleSheets = concatStyleSheets;
  1761. /***/ }),
  1762. /***/ "./node_modules/safevalues/builders/url_sanitizer.js":
  1763. /*!***********************************************************!*\
  1764. !*** ./node_modules/safevalues/builders/url_sanitizer.js ***!
  1765. \***********************************************************/
  1766. /*! no static exports found */
  1767. /***/ (function(module, exports, __webpack_require__) {
  1768. "use strict";
  1769. /**
  1770. * @license
  1771. * SPDX-License-Identifier: Apache-2.0
  1772. */
  1773. Object.defineProperty(exports, "__esModule", { value: true });
  1774. exports.restrictivelySanitizeUrl = exports.unwrapUrlOrSanitize = exports.sanitizeJavascriptUrl = void 0;
  1775. /**
  1776. * @fileoverview Provides functions to enforce the SafeUrl contract at the sink
  1777. * level.
  1778. */
  1779. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  1780. function extractScheme(url) {
  1781. var parsedUrl;
  1782. try {
  1783. parsedUrl = new URL(url);
  1784. }
  1785. catch (e) {
  1786. // According to https://url.spec.whatwg.org/#constructors, the URL
  1787. // constructor with one parameter throws if `url` is not absolute. In this
  1788. // case, we are sure that no explicit scheme (javascript: ) is set.
  1789. // This can also be a URL parsing error, but in this case the URL won't be
  1790. // run anyway.
  1791. return 'https:';
  1792. }
  1793. return parsedUrl.protocol;
  1794. }
  1795. // We can't use an ES6 Set here because gws somehow depends on this code and
  1796. // doesn't want to pay the cost of a polyfill.
  1797. var ALLOWED_SCHEMES = ['data:', 'http:', 'https:', 'mailto:', 'ftp:'];
  1798. /**
  1799. * Checks that the URL scheme is not javascript.
  1800. * The URL parsing relies on the URL API in browsers that support it.
  1801. * @param url The URL to sanitize for a SafeUrl sink.
  1802. * @return undefined if url has a javascript: scheme, the original URL
  1803. * otherwise.
  1804. */
  1805. function sanitizeJavascriptUrl(url) {
  1806. var parsedScheme = extractScheme(url);
  1807. if (parsedScheme === 'javascript:') {
  1808. if (true) {
  1809. console.error("A URL with content '".concat(url, "' was sanitized away."));
  1810. }
  1811. return undefined;
  1812. }
  1813. return url;
  1814. }
  1815. exports.sanitizeJavascriptUrl = sanitizeJavascriptUrl;
  1816. /**
  1817. * Adapter to sanitize string URLs in DOM sink wrappers.
  1818. * @return undefined if the URL was sanitized.
  1819. */
  1820. function unwrapUrlOrSanitize(url) {
  1821. return sanitizeJavascriptUrl(url);
  1822. }
  1823. exports.unwrapUrlOrSanitize = unwrapUrlOrSanitize;
  1824. /**
  1825. * Sanitizes a URL restrictively.
  1826. * This sanitizer protects against XSS and potentially other uncommon and
  1827. * undesirable schemes that an attacker could use for e.g. phishing (tel:,
  1828. * callto: ssh: etc schemes). This sanitizer is primarily meant to be used by
  1829. * the HTML sanitizer.
  1830. */
  1831. function restrictivelySanitizeUrl(url) {
  1832. var parsedScheme = extractScheme(url);
  1833. if (parsedScheme !== undefined &&
  1834. ALLOWED_SCHEMES.indexOf(parsedScheme.toLowerCase()) !== -1) {
  1835. return url;
  1836. }
  1837. return 'about:invalid#zClosurez';
  1838. }
  1839. exports.restrictivelySanitizeUrl = restrictivelySanitizeUrl;
  1840. /***/ }),
  1841. /***/ "./node_modules/safevalues/dom/elements/anchor.js":
  1842. /*!********************************************************!*\
  1843. !*** ./node_modules/safevalues/dom/elements/anchor.js ***!
  1844. \********************************************************/
  1845. /*! no static exports found */
  1846. /***/ (function(module, exports, __webpack_require__) {
  1847. "use strict";
  1848. /**
  1849. * @license
  1850. * SPDX-License-Identifier: Apache-2.0
  1851. */
  1852. Object.defineProperty(exports, "__esModule", { value: true });
  1853. exports.setHref = void 0;
  1854. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  1855. /**
  1856. * Sets the Href attribute from the given Url.
  1857. */
  1858. function setHref(anchor, url) {
  1859. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  1860. if (sanitizedUrl !== undefined) {
  1861. anchor.href = sanitizedUrl;
  1862. }
  1863. }
  1864. exports.setHref = setHref;
  1865. /***/ }),
  1866. /***/ "./node_modules/safevalues/dom/elements/area.js":
  1867. /*!******************************************************!*\
  1868. !*** ./node_modules/safevalues/dom/elements/area.js ***!
  1869. \******************************************************/
  1870. /*! no static exports found */
  1871. /***/ (function(module, exports, __webpack_require__) {
  1872. "use strict";
  1873. /**
  1874. * @license
  1875. * SPDX-License-Identifier: Apache-2.0
  1876. */
  1877. Object.defineProperty(exports, "__esModule", { value: true });
  1878. exports.setHref = void 0;
  1879. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  1880. /**
  1881. * Sets the Href attribute from the given Url.
  1882. */
  1883. function setHref(area, url) {
  1884. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  1885. if (sanitizedUrl !== undefined) {
  1886. area.href = sanitizedUrl;
  1887. }
  1888. }
  1889. exports.setHref = setHref;
  1890. /***/ }),
  1891. /***/ "./node_modules/safevalues/dom/elements/button.js":
  1892. /*!********************************************************!*\
  1893. !*** ./node_modules/safevalues/dom/elements/button.js ***!
  1894. \********************************************************/
  1895. /*! no static exports found */
  1896. /***/ (function(module, exports, __webpack_require__) {
  1897. "use strict";
  1898. /**
  1899. * @license
  1900. * SPDX-License-Identifier: Apache-2.0
  1901. */
  1902. Object.defineProperty(exports, "__esModule", { value: true });
  1903. exports.setFormaction = void 0;
  1904. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  1905. /**
  1906. * Sets the Formaction attribute from the given Url.
  1907. */
  1908. function setFormaction(button, url) {
  1909. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  1910. if (sanitizedUrl !== undefined) {
  1911. button.formAction = sanitizedUrl;
  1912. }
  1913. }
  1914. exports.setFormaction = setFormaction;
  1915. /***/ }),
  1916. /***/ "./node_modules/safevalues/dom/elements/element.js":
  1917. /*!*********************************************************!*\
  1918. !*** ./node_modules/safevalues/dom/elements/element.js ***!
  1919. \*********************************************************/
  1920. /*! no static exports found */
  1921. /***/ (function(module, exports, __webpack_require__) {
  1922. "use strict";
  1923. /**
  1924. * @license
  1925. * SPDX-License-Identifier: Apache-2.0
  1926. */
  1927. var __read = (this && this.__read) || function (o, n) {
  1928. var m = typeof Symbol === "function" && o[Symbol.iterator];
  1929. if (!m) return o;
  1930. var i = m.call(o), r, ar = [], e;
  1931. try {
  1932. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  1933. }
  1934. catch (error) { e = { error: error }; }
  1935. finally {
  1936. try {
  1937. if (r && !r.done && (m = i["return"])) m.call(i);
  1938. }
  1939. finally { if (e) throw e.error; }
  1940. }
  1941. return ar;
  1942. };
  1943. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  1944. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  1945. if (ar || !(i in from)) {
  1946. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  1947. ar[i] = from[i];
  1948. }
  1949. }
  1950. return to.concat(ar || Array.prototype.slice.call(from));
  1951. };
  1952. Object.defineProperty(exports, "__esModule", { value: true });
  1953. exports.setPrefixedAttribute = exports.buildPrefixedAttributeSetter = exports.insertAdjacentHtml = exports.setCssText = exports.setOuterHtml = exports.setInnerHtml = void 0;
  1954. /**
  1955. * @fileoverview This contains safe wrappers for properties that aren't specific
  1956. * to one kind of HTMLElement (like innerHTML), plus other setters and functions
  1957. * that are not tied to elements (like location.href or Worker constructor).
  1958. */
  1959. var attribute_impl_1 = __webpack_require__(/*! ../../internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
  1960. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  1961. var style_impl_1 = __webpack_require__(/*! ../../internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
  1962. /**
  1963. * Safely set {@link Element.innerHTML} on a given ShadowRoot or Element which
  1964. * may not be a `<script>` element or a `<style>` element.
  1965. */
  1966. function setInnerHtml(elOrRoot, v) {
  1967. if (isElement(elOrRoot)) {
  1968. throwIfScriptOrStyle(elOrRoot);
  1969. }
  1970. elOrRoot.innerHTML = (0, html_impl_1.unwrapHtml)(v);
  1971. }
  1972. exports.setInnerHtml = setInnerHtml;
  1973. /**
  1974. * Safely set {@link Element.outerHTML} for the given Element.
  1975. */
  1976. function setOuterHtml(e, v) {
  1977. var parent = e.parentElement;
  1978. if (parent !== null) {
  1979. throwIfScriptOrStyle(parent);
  1980. }
  1981. e.outerHTML = (0, html_impl_1.unwrapHtml)(v);
  1982. }
  1983. exports.setOuterHtml = setOuterHtml;
  1984. /**
  1985. * Set `ElementCSSInlineStyle.cssText` for the given `ElementCSSInlineStyle`.
  1986. */
  1987. function setCssText(e, v) {
  1988. e.style.cssText = (0, style_impl_1.unwrapStyle)(v);
  1989. }
  1990. exports.setCssText = setCssText;
  1991. /**
  1992. * Safely call {@link Element.insertAdjacentHTML} for the given Element.
  1993. */
  1994. function insertAdjacentHtml(element, position, v) {
  1995. var tagContext = (position === 'beforebegin' || position === 'afterend') ?
  1996. element.parentElement :
  1997. element;
  1998. if (tagContext !== null) {
  1999. throwIfScriptOrStyle(tagContext);
  2000. }
  2001. element.insertAdjacentHTML(position, (0, html_impl_1.unwrapHtml)(v));
  2002. }
  2003. exports.insertAdjacentHtml = insertAdjacentHtml;
  2004. /**
  2005. * Given a set of known-to-be-safe prefixes (e.g., "data-", "aria-", "js"),
  2006. * return a setter function that allows you to set attributes on an element,
  2007. * as long as the names of the attributes to be set has one of the prefixes.
  2008. *
  2009. * The returned setter ensures that setting any dangerous attribute, e.g.,
  2010. * "src", "href" will cause an exception. This is intended to be used as the
  2011. * safe alterantive of `Element#setAttribute`, when applications need to set
  2012. * attributes that do not have security implications and do not have a
  2013. * corresponding DOM property.
  2014. */
  2015. function buildPrefixedAttributeSetter(prefix) {
  2016. var otherPrefixes = [];
  2017. for (var _i = 1; _i < arguments.length; _i++) {
  2018. otherPrefixes[_i - 1] = arguments[_i];
  2019. }
  2020. var prefixes = __spreadArray([prefix], __read(otherPrefixes), false);
  2021. return function (e, attr, value) {
  2022. setPrefixedAttribute(prefixes, e, attr, value);
  2023. };
  2024. }
  2025. exports.buildPrefixedAttributeSetter = buildPrefixedAttributeSetter;
  2026. /**
  2027. * The safe alternative to Element#setAttribute. The function takes a list of
  2028. * `SafeAttributePrefix`, making developer intention explicit. The attribute
  2029. * to be set must has one of the safe prefixes, otherwise the function throws
  2030. * an Error.
  2031. */
  2032. function setPrefixedAttribute(attrPrefixes, e, attr, value) {
  2033. if (attrPrefixes.length === 0) {
  2034. throw new Error('No prefixes are provided');
  2035. }
  2036. var prefixes = attrPrefixes.map(function (s) { return (0, attribute_impl_1.unwrapAttributePrefix)(s); });
  2037. var attrLower = attr.toLowerCase();
  2038. if (prefixes.every(function (p) { return attrLower.indexOf(p) !== 0; })) {
  2039. throw new Error("Attribute \"".concat(attr, "\" does not match any of the allowed prefixes."));
  2040. }
  2041. e.setAttribute(attr, value);
  2042. }
  2043. exports.setPrefixedAttribute = setPrefixedAttribute;
  2044. function throwIfScriptOrStyle(element) {
  2045. if (element.tagName.toLowerCase() === 'script') {
  2046. throw new Error('Use setTextContent with a SafeScript.');
  2047. }
  2048. else if (element.tagName.toLowerCase() === 'style') {
  2049. throw new Error('Use setTextContent with a SafeStyleSheet.');
  2050. }
  2051. }
  2052. function isElement(elOrRoot) {
  2053. return elOrRoot.tagName !== undefined;
  2054. }
  2055. /***/ }),
  2056. /***/ "./node_modules/safevalues/dom/elements/embed.js":
  2057. /*!*******************************************************!*\
  2058. !*** ./node_modules/safevalues/dom/elements/embed.js ***!
  2059. \*******************************************************/
  2060. /*! no static exports found */
  2061. /***/ (function(module, exports, __webpack_require__) {
  2062. "use strict";
  2063. /**
  2064. * @license
  2065. * SPDX-License-Identifier: Apache-2.0
  2066. */
  2067. Object.defineProperty(exports, "__esModule", { value: true });
  2068. exports.setSrc = void 0;
  2069. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2070. /**
  2071. * Sets the Src attribute from the given SafeUrl.
  2072. */
  2073. function setSrc(embedEl, url) {
  2074. embedEl.src = (0, resource_url_impl_1.unwrapResourceUrl)(url);
  2075. }
  2076. exports.setSrc = setSrc;
  2077. /***/ }),
  2078. /***/ "./node_modules/safevalues/dom/elements/form.js":
  2079. /*!******************************************************!*\
  2080. !*** ./node_modules/safevalues/dom/elements/form.js ***!
  2081. \******************************************************/
  2082. /*! no static exports found */
  2083. /***/ (function(module, exports, __webpack_require__) {
  2084. "use strict";
  2085. /**
  2086. * @license
  2087. * SPDX-License-Identifier: Apache-2.0
  2088. */
  2089. Object.defineProperty(exports, "__esModule", { value: true });
  2090. exports.setAction = void 0;
  2091. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2092. /**
  2093. * Sets the Action attribute from the given Url.
  2094. */
  2095. function setAction(form, url) {
  2096. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2097. if (sanitizedUrl !== undefined) {
  2098. form.action = sanitizedUrl;
  2099. }
  2100. }
  2101. exports.setAction = setAction;
  2102. /***/ }),
  2103. /***/ "./node_modules/safevalues/dom/elements/iframe.js":
  2104. /*!********************************************************!*\
  2105. !*** ./node_modules/safevalues/dom/elements/iframe.js ***!
  2106. \********************************************************/
  2107. /*! no static exports found */
  2108. /***/ (function(module, exports, __webpack_require__) {
  2109. "use strict";
  2110. /**
  2111. * @license
  2112. * SPDX-License-Identifier: Apache-2.0
  2113. */
  2114. Object.defineProperty(exports, "__esModule", { value: true });
  2115. exports.setSrcdoc = exports.setSrc = void 0;
  2116. /**
  2117. * @fileoverview Safe iframe helpers and go/intents-for-iframes-for-closure
  2118. */
  2119. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2120. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2121. /** Sets the Src attribute using a TrustedResourceUrl */
  2122. function setSrc(iframe, v) {
  2123. iframe.src = (0, resource_url_impl_1.unwrapResourceUrl)(v).toString();
  2124. }
  2125. exports.setSrc = setSrc;
  2126. /** Sets the Srcdoc attribute using a SafeHtml */
  2127. function setSrcdoc(iframe, v) {
  2128. iframe.srcdoc = (0, html_impl_1.unwrapHtml)(v);
  2129. }
  2130. exports.setSrcdoc = setSrcdoc;
  2131. /***/ }),
  2132. /***/ "./node_modules/safevalues/dom/elements/input.js":
  2133. /*!*******************************************************!*\
  2134. !*** ./node_modules/safevalues/dom/elements/input.js ***!
  2135. \*******************************************************/
  2136. /*! no static exports found */
  2137. /***/ (function(module, exports, __webpack_require__) {
  2138. "use strict";
  2139. /**
  2140. * @license
  2141. * SPDX-License-Identifier: Apache-2.0
  2142. */
  2143. Object.defineProperty(exports, "__esModule", { value: true });
  2144. exports.setFormaction = void 0;
  2145. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2146. /**
  2147. * Sets the Formaction attribute from the given Url.
  2148. */
  2149. function setFormaction(input, url) {
  2150. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2151. if (sanitizedUrl !== undefined) {
  2152. input.formAction = sanitizedUrl;
  2153. }
  2154. }
  2155. exports.setFormaction = setFormaction;
  2156. /***/ }),
  2157. /***/ "./node_modules/safevalues/dom/elements/link.js":
  2158. /*!******************************************************!*\
  2159. !*** ./node_modules/safevalues/dom/elements/link.js ***!
  2160. \******************************************************/
  2161. /*! no static exports found */
  2162. /***/ (function(module, exports, __webpack_require__) {
  2163. "use strict";
  2164. /**
  2165. * @license
  2166. * SPDX-License-Identifier: Apache-2.0
  2167. */
  2168. Object.defineProperty(exports, "__esModule", { value: true });
  2169. exports.setHrefAndRel = void 0;
  2170. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2171. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2172. var SAFE_URL_REL_VALUES = [
  2173. 'alternate',
  2174. 'author',
  2175. 'bookmark',
  2176. 'canonical',
  2177. 'cite',
  2178. 'help',
  2179. 'icon',
  2180. 'license',
  2181. 'next',
  2182. 'prefetch',
  2183. 'dns-prefetch',
  2184. 'prerender',
  2185. 'preconnect',
  2186. 'preload',
  2187. 'prev',
  2188. 'search',
  2189. 'subresource',
  2190. ];
  2191. function setHrefAndRel(link, url, rel) {
  2192. if (url instanceof resource_url_impl_1.TrustedResourceUrl) {
  2193. link.href = (0, resource_url_impl_1.unwrapResourceUrl)(url).toString();
  2194. }
  2195. else {
  2196. if (SAFE_URL_REL_VALUES.indexOf(rel) === -1) {
  2197. throw new Error("TrustedResourceUrl href attribute required with rel=\"".concat(rel, "\""));
  2198. }
  2199. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2200. if (sanitizedUrl === undefined) {
  2201. return;
  2202. }
  2203. link.href = sanitizedUrl;
  2204. }
  2205. link.rel = rel;
  2206. }
  2207. exports.setHrefAndRel = setHrefAndRel;
  2208. /***/ }),
  2209. /***/ "./node_modules/safevalues/dom/elements/object.js":
  2210. /*!********************************************************!*\
  2211. !*** ./node_modules/safevalues/dom/elements/object.js ***!
  2212. \********************************************************/
  2213. /*! no static exports found */
  2214. /***/ (function(module, exports, __webpack_require__) {
  2215. "use strict";
  2216. /**
  2217. * @license
  2218. * SPDX-License-Identifier: Apache-2.0
  2219. */
  2220. Object.defineProperty(exports, "__esModule", { value: true });
  2221. exports.setData = void 0;
  2222. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2223. /** Sets the data attribute using a TrustedResourceUrl */
  2224. function setData(obj, v) {
  2225. obj.data = (0, resource_url_impl_1.unwrapResourceUrl)(v);
  2226. }
  2227. exports.setData = setData;
  2228. /***/ }),
  2229. /***/ "./node_modules/safevalues/dom/elements/script.js":
  2230. /*!********************************************************!*\
  2231. !*** ./node_modules/safevalues/dom/elements/script.js ***!
  2232. \********************************************************/
  2233. /*! no static exports found */
  2234. /***/ (function(module, exports, __webpack_require__) {
  2235. "use strict";
  2236. /**
  2237. * @license
  2238. * SPDX-License-Identifier: Apache-2.0
  2239. */
  2240. Object.defineProperty(exports, "__esModule", { value: true });
  2241. exports.setSrc = exports.setTextContent = void 0;
  2242. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2243. var script_impl_1 = __webpack_require__(/*! ../../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  2244. /** Returns CSP nonce, if set for any script tag. */
  2245. function getScriptNonceFromWindow(win) {
  2246. var _a;
  2247. var doc = win.document;
  2248. // document.querySelector can be undefined in non-browser environments.
  2249. var script = (_a = doc.querySelector) === null || _a === void 0 ? void 0 : _a.call(doc, 'script[nonce]');
  2250. if (script) {
  2251. // Try to get the nonce from the IDL property first, because browsers that
  2252. // implement additional nonce protection features (currently only Chrome) to
  2253. // prevent nonce stealing via CSS do not expose the nonce via attributes.
  2254. // See https://github.com/whatwg/html/issues/2369
  2255. return script['nonce'] || script.getAttribute('nonce') || '';
  2256. }
  2257. return '';
  2258. }
  2259. /** Propagates CSP nonce to dynamically created scripts. */
  2260. function setNonceForScriptElement(script) {
  2261. var win = script.ownerDocument && script.ownerDocument.defaultView;
  2262. var nonce = getScriptNonceFromWindow(win || window);
  2263. if (nonce) {
  2264. script.setAttribute('nonce', nonce);
  2265. }
  2266. }
  2267. /** Sets textContent from the given SafeScript. */
  2268. function setTextContent(script, v) {
  2269. script.textContent = (0, script_impl_1.unwrapScript)(v);
  2270. setNonceForScriptElement(script);
  2271. }
  2272. exports.setTextContent = setTextContent;
  2273. /** Sets the Src attribute using a TrustedResourceUrl */
  2274. function setSrc(script, v) {
  2275. script.src = (0, resource_url_impl_1.unwrapResourceUrl)(v);
  2276. setNonceForScriptElement(script);
  2277. }
  2278. exports.setSrc = setSrc;
  2279. /***/ }),
  2280. /***/ "./node_modules/safevalues/dom/elements/style.js":
  2281. /*!*******************************************************!*\
  2282. !*** ./node_modules/safevalues/dom/elements/style.js ***!
  2283. \*******************************************************/
  2284. /*! no static exports found */
  2285. /***/ (function(module, exports, __webpack_require__) {
  2286. "use strict";
  2287. /**
  2288. * @license
  2289. * SPDX-License-Identifier: Apache-2.0
  2290. */
  2291. Object.defineProperty(exports, "__esModule", { value: true });
  2292. exports.setTextContent = void 0;
  2293. var style_sheet_impl_1 = __webpack_require__(/*! ../../internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
  2294. /** Safe setters for `HTMLStyleElement`s. */
  2295. function setTextContent(elem, safeStyleSheet) {
  2296. elem.textContent = (0, style_sheet_impl_1.unwrapStyleSheet)(safeStyleSheet);
  2297. }
  2298. exports.setTextContent = setTextContent;
  2299. /***/ }),
  2300. /***/ "./node_modules/safevalues/dom/globals/document.js":
  2301. /*!*********************************************************!*\
  2302. !*** ./node_modules/safevalues/dom/globals/document.js ***!
  2303. \*********************************************************/
  2304. /*! no static exports found */
  2305. /***/ (function(module, exports, __webpack_require__) {
  2306. "use strict";
  2307. /**
  2308. * @license
  2309. * SPDX-License-Identifier: Apache-2.0
  2310. */
  2311. Object.defineProperty(exports, "__esModule", { value: true });
  2312. exports.execCommandInsertHtml = exports.execCommand = exports.write = void 0;
  2313. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2314. /**
  2315. * write safely calls {@link Document.write} on the given {@link Document} with
  2316. * the given {@link SafeHtml}.
  2317. */
  2318. function write(doc, text) {
  2319. doc.write((0, html_impl_1.unwrapHtml)(text));
  2320. }
  2321. exports.write = write;
  2322. /**
  2323. * Safely calls {@link Document.execCommand}. When command is insertHtml, a
  2324. * SafeHtml must be passed in as value.
  2325. */
  2326. function execCommand(doc, command, value) {
  2327. var commandString = String(command);
  2328. var valueArgument = value;
  2329. if (commandString.toLowerCase() === 'inserthtml') {
  2330. valueArgument = (0, html_impl_1.unwrapHtml)(value);
  2331. }
  2332. return doc.execCommand(commandString, /* showUi= */ false, valueArgument);
  2333. }
  2334. exports.execCommand = execCommand;
  2335. /**
  2336. * Safely calls {@link Document.execCommand}('insertHtml').
  2337. * @deprecated Use safeDocument.execCommand.
  2338. */
  2339. function execCommandInsertHtml(doc, html) {
  2340. return doc.execCommand('insertHTML', /* showUi= */ false, (0, html_impl_1.unwrapHtml)(html));
  2341. }
  2342. exports.execCommandInsertHtml = execCommandInsertHtml;
  2343. /***/ }),
  2344. /***/ "./node_modules/safevalues/dom/globals/dom_parser.js":
  2345. /*!***********************************************************!*\
  2346. !*** ./node_modules/safevalues/dom/globals/dom_parser.js ***!
  2347. \***********************************************************/
  2348. /*! no static exports found */
  2349. /***/ (function(module, exports, __webpack_require__) {
  2350. "use strict";
  2351. /**
  2352. * @license
  2353. * SPDX-License-Identifier: Apache-2.0
  2354. */
  2355. Object.defineProperty(exports, "__esModule", { value: true });
  2356. exports.parseFromString = exports.parseHtml = void 0;
  2357. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2358. /** Safely parses a string using the HTML parser. */
  2359. function parseHtml(parser, html) {
  2360. return parseFromString(parser, html, 'text/html');
  2361. }
  2362. exports.parseHtml = parseHtml;
  2363. /** Safely parses a string using the HTML or XML parser. */
  2364. function parseFromString(parser, content, contentType) {
  2365. return parser.parseFromString((0, html_impl_1.unwrapHtml)(content), contentType);
  2366. }
  2367. exports.parseFromString = parseFromString;
  2368. /***/ }),
  2369. /***/ "./node_modules/safevalues/dom/globals/global.js":
  2370. /*!*******************************************************!*\
  2371. !*** ./node_modules/safevalues/dom/globals/global.js ***!
  2372. \*******************************************************/
  2373. /*! no static exports found */
  2374. /***/ (function(module, exports, __webpack_require__) {
  2375. "use strict";
  2376. /**
  2377. * @license
  2378. * SPDX-License-Identifier: Apache-2.0
  2379. */
  2380. Object.defineProperty(exports, "__esModule", { value: true });
  2381. exports.globalEval = void 0;
  2382. var script_impl_1 = __webpack_require__(/*! ../../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  2383. /**
  2384. * Evaluates a SafeScript value in the given scope using eval.
  2385. *
  2386. * Strongly consider avoiding this, as eval blocks CSP adoption and does not
  2387. * benefit from compiler optimizations.
  2388. */
  2389. function globalEval(win, script) {
  2390. var trustedScript = (0, script_impl_1.unwrapScript)(script);
  2391. var result = win.eval(trustedScript);
  2392. if (result === trustedScript) {
  2393. // https://crbug.com/1024786 manifesting in workers.
  2394. result = win.eval(trustedScript.toString());
  2395. }
  2396. return result;
  2397. }
  2398. exports.globalEval = globalEval;
  2399. /***/ }),
  2400. /***/ "./node_modules/safevalues/dom/globals/location.js":
  2401. /*!*********************************************************!*\
  2402. !*** ./node_modules/safevalues/dom/globals/location.js ***!
  2403. \*********************************************************/
  2404. /*! no static exports found */
  2405. /***/ (function(module, exports, __webpack_require__) {
  2406. "use strict";
  2407. /**
  2408. * @license
  2409. * SPDX-License-Identifier: Apache-2.0
  2410. */
  2411. Object.defineProperty(exports, "__esModule", { value: true });
  2412. exports.assign = exports.replace = exports.setHref = void 0;
  2413. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2414. /**
  2415. * setHref safely sets {@link Location.href} on the given {@link Location} with
  2416. * given {@link Url}.
  2417. */
  2418. function setHref(loc, url) {
  2419. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2420. if (sanitizedUrl !== undefined) {
  2421. loc.href = sanitizedUrl;
  2422. }
  2423. }
  2424. exports.setHref = setHref;
  2425. /**
  2426. * replace safely calls {@link Location.replace} on the given {@link Location}
  2427. * with given {@link Url}.
  2428. */
  2429. function replace(loc, url) {
  2430. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2431. if (sanitizedUrl !== undefined) {
  2432. loc.replace(sanitizedUrl);
  2433. }
  2434. }
  2435. exports.replace = replace;
  2436. /**
  2437. * assign safely calls {@link Location.assign} on the given {@link Location}
  2438. * with given {@link Url}.
  2439. */
  2440. function assign(loc, url) {
  2441. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2442. if (sanitizedUrl !== undefined) {
  2443. loc.assign(sanitizedUrl);
  2444. }
  2445. }
  2446. exports.assign = assign;
  2447. /***/ }),
  2448. /***/ "./node_modules/safevalues/dom/globals/range.js":
  2449. /*!******************************************************!*\
  2450. !*** ./node_modules/safevalues/dom/globals/range.js ***!
  2451. \******************************************************/
  2452. /*! no static exports found */
  2453. /***/ (function(module, exports, __webpack_require__) {
  2454. "use strict";
  2455. /**
  2456. * @license
  2457. * SPDX-License-Identifier: Apache-2.0
  2458. */
  2459. Object.defineProperty(exports, "__esModule", { value: true });
  2460. exports.createContextualFragment = void 0;
  2461. var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2462. /** Safely creates a contextualFragment. */
  2463. function createContextualFragment(range, html) {
  2464. return range.createContextualFragment((0, html_impl_1.unwrapHtml)(html));
  2465. }
  2466. exports.createContextualFragment = createContextualFragment;
  2467. /***/ }),
  2468. /***/ "./node_modules/safevalues/dom/globals/service_worker_container.js":
  2469. /*!*************************************************************************!*\
  2470. !*** ./node_modules/safevalues/dom/globals/service_worker_container.js ***!
  2471. \*************************************************************************/
  2472. /*! no static exports found */
  2473. /***/ (function(module, exports, __webpack_require__) {
  2474. "use strict";
  2475. /**
  2476. * @license
  2477. * SPDX-License-Identifier: Apache-2.0
  2478. */
  2479. Object.defineProperty(exports, "__esModule", { value: true });
  2480. exports.register = void 0;
  2481. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2482. /** Safely registers a service worker by URL */
  2483. function register(container, scriptURL, options) {
  2484. return container.register((0, resource_url_impl_1.unwrapResourceUrl)(scriptURL), options);
  2485. }
  2486. exports.register = register;
  2487. /***/ }),
  2488. /***/ "./node_modules/safevalues/dom/globals/window.js":
  2489. /*!*******************************************************!*\
  2490. !*** ./node_modules/safevalues/dom/globals/window.js ***!
  2491. \*******************************************************/
  2492. /*! no static exports found */
  2493. /***/ (function(module, exports, __webpack_require__) {
  2494. "use strict";
  2495. /**
  2496. * @license
  2497. * SPDX-License-Identifier: Apache-2.0
  2498. */
  2499. Object.defineProperty(exports, "__esModule", { value: true });
  2500. exports.open = void 0;
  2501. var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
  2502. /**
  2503. * open calls {@link Window.open} on the given {@link Window}, given a
  2504. * target {@link Url}.
  2505. */
  2506. function open(win, url, target, features) {
  2507. var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
  2508. if (sanitizedUrl !== undefined) {
  2509. return win.open(sanitizedUrl, target, features);
  2510. }
  2511. return null;
  2512. }
  2513. exports.open = open;
  2514. /***/ }),
  2515. /***/ "./node_modules/safevalues/dom/globals/worker.js":
  2516. /*!*******************************************************!*\
  2517. !*** ./node_modules/safevalues/dom/globals/worker.js ***!
  2518. \*******************************************************/
  2519. /*! no static exports found */
  2520. /***/ (function(module, exports, __webpack_require__) {
  2521. "use strict";
  2522. /**
  2523. * @license
  2524. * SPDX-License-Identifier: Apache-2.0
  2525. */
  2526. var __read = (this && this.__read) || function (o, n) {
  2527. var m = typeof Symbol === "function" && o[Symbol.iterator];
  2528. if (!m) return o;
  2529. var i = m.call(o), r, ar = [], e;
  2530. try {
  2531. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  2532. }
  2533. catch (error) { e = { error: error }; }
  2534. finally {
  2535. try {
  2536. if (r && !r.done && (m = i["return"])) m.call(i);
  2537. }
  2538. finally { if (e) throw e.error; }
  2539. }
  2540. return ar;
  2541. };
  2542. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  2543. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  2544. if (ar || !(i in from)) {
  2545. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  2546. ar[i] = from[i];
  2547. }
  2548. }
  2549. return to.concat(ar || Array.prototype.slice.call(from));
  2550. };
  2551. Object.defineProperty(exports, "__esModule", { value: true });
  2552. exports.importScripts = exports.createShared = exports.create = void 0;
  2553. var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2554. /**
  2555. * Safely creates a Web Worker.
  2556. *
  2557. * Example usage:
  2558. * const trustedResourceUrl = trustedResourceUrl`/safe_script.js`;
  2559. * safedom.safeWorker.create(trustedResourceUrl);
  2560. * which is a safe alternative to
  2561. * new Worker(url);
  2562. * The latter can result in loading untrusted code.
  2563. */
  2564. function create(url, options) {
  2565. return new Worker((0, resource_url_impl_1.unwrapResourceUrl)(url), options);
  2566. }
  2567. exports.create = create;
  2568. /** Safely creates a shared Web Worker. */
  2569. function createShared(url, options) {
  2570. return new SharedWorker((0, resource_url_impl_1.unwrapResourceUrl)(url), options);
  2571. }
  2572. exports.createShared = createShared;
  2573. /** Safely calls importScripts */
  2574. function importScripts(scope) {
  2575. var urls = [];
  2576. for (var _i = 1; _i < arguments.length; _i++) {
  2577. urls[_i - 1] = arguments[_i];
  2578. }
  2579. scope.importScripts.apply(scope, __spreadArray([], __read(urls.map(function (url) { return (0, resource_url_impl_1.unwrapResourceUrl)(url); })), false));
  2580. }
  2581. exports.importScripts = importScripts;
  2582. /***/ }),
  2583. /***/ "./node_modules/safevalues/dom/index.js":
  2584. /*!**********************************************!*\
  2585. !*** ./node_modules/safevalues/dom/index.js ***!
  2586. \**********************************************/
  2587. /*! no static exports found */
  2588. /***/ (function(module, exports, __webpack_require__) {
  2589. "use strict";
  2590. /**
  2591. * @license
  2592. * SPDX-License-Identifier: Apache-2.0
  2593. */
  2594. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  2595. if (k2 === undefined) k2 = k;
  2596. var desc = Object.getOwnPropertyDescriptor(m, k);
  2597. if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
  2598. desc = { enumerable: true, get: function() { return m[k]; } };
  2599. }
  2600. Object.defineProperty(o, k2, desc);
  2601. }) : (function(o, m, k, k2) {
  2602. if (k2 === undefined) k2 = k;
  2603. o[k2] = m[k];
  2604. }));
  2605. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  2606. Object.defineProperty(o, "default", { enumerable: true, value: v });
  2607. }) : function(o, v) {
  2608. o["default"] = v;
  2609. });
  2610. var __importStar = (this && this.__importStar) || function (mod) {
  2611. if (mod && mod.__esModule) return mod;
  2612. var result = {};
  2613. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  2614. __setModuleDefault(result, mod);
  2615. return result;
  2616. };
  2617. Object.defineProperty(exports, "__esModule", { value: true });
  2618. exports.safeWorker = exports.safeWindow = exports.safeServiceWorkerContainer = exports.safeRange = exports.safeLocation = exports.safeGlobal = exports.safeDomParser = exports.safeDocument = exports.safeStyleEl = exports.safeScriptEl = exports.safeObjectEl = exports.safeLinkEl = exports.safeInputEl = exports.safeIframeEl = exports.safeFormEl = exports.safeEmbedEl = exports.safeElement = exports.safeButtonEl = exports.safeAreaEl = exports.safeAnchorEl = void 0;
  2619. /**
  2620. * @fileoverview This file re-exports all of the wrappers to ensure that we have
  2621. * a clearly defined interface.
  2622. */
  2623. exports.safeAnchorEl = __importStar(__webpack_require__(/*! ./elements/anchor */ "./node_modules/safevalues/dom/elements/anchor.js"));
  2624. exports.safeAreaEl = __importStar(__webpack_require__(/*! ./elements/area */ "./node_modules/safevalues/dom/elements/area.js"));
  2625. exports.safeButtonEl = __importStar(__webpack_require__(/*! ./elements/button */ "./node_modules/safevalues/dom/elements/button.js"));
  2626. exports.safeElement = __importStar(__webpack_require__(/*! ./elements/element */ "./node_modules/safevalues/dom/elements/element.js"));
  2627. exports.safeEmbedEl = __importStar(__webpack_require__(/*! ./elements/embed */ "./node_modules/safevalues/dom/elements/embed.js"));
  2628. exports.safeFormEl = __importStar(__webpack_require__(/*! ./elements/form */ "./node_modules/safevalues/dom/elements/form.js"));
  2629. exports.safeIframeEl = __importStar(__webpack_require__(/*! ./elements/iframe */ "./node_modules/safevalues/dom/elements/iframe.js"));
  2630. exports.safeInputEl = __importStar(__webpack_require__(/*! ./elements/input */ "./node_modules/safevalues/dom/elements/input.js"));
  2631. exports.safeLinkEl = __importStar(__webpack_require__(/*! ./elements/link */ "./node_modules/safevalues/dom/elements/link.js"));
  2632. exports.safeObjectEl = __importStar(__webpack_require__(/*! ./elements/object */ "./node_modules/safevalues/dom/elements/object.js"));
  2633. exports.safeScriptEl = __importStar(__webpack_require__(/*! ./elements/script */ "./node_modules/safevalues/dom/elements/script.js"));
  2634. exports.safeStyleEl = __importStar(__webpack_require__(/*! ./elements/style */ "./node_modules/safevalues/dom/elements/style.js"));
  2635. exports.safeDocument = __importStar(__webpack_require__(/*! ./globals/document */ "./node_modules/safevalues/dom/globals/document.js"));
  2636. exports.safeDomParser = __importStar(__webpack_require__(/*! ./globals/dom_parser */ "./node_modules/safevalues/dom/globals/dom_parser.js"));
  2637. exports.safeGlobal = __importStar(__webpack_require__(/*! ./globals/global */ "./node_modules/safevalues/dom/globals/global.js"));
  2638. exports.safeLocation = __importStar(__webpack_require__(/*! ./globals/location */ "./node_modules/safevalues/dom/globals/location.js"));
  2639. exports.safeRange = __importStar(__webpack_require__(/*! ./globals/range */ "./node_modules/safevalues/dom/globals/range.js"));
  2640. exports.safeServiceWorkerContainer = __importStar(__webpack_require__(/*! ./globals/service_worker_container */ "./node_modules/safevalues/dom/globals/service_worker_container.js"));
  2641. exports.safeWindow = __importStar(__webpack_require__(/*! ./globals/window */ "./node_modules/safevalues/dom/globals/window.js"));
  2642. exports.safeWorker = __importStar(__webpack_require__(/*! ./globals/worker */ "./node_modules/safevalues/dom/globals/worker.js"));
  2643. /***/ }),
  2644. /***/ "./node_modules/safevalues/environment/dev.js":
  2645. /*!****************************************************!*\
  2646. !*** ./node_modules/safevalues/environment/dev.js ***!
  2647. \****************************************************/
  2648. /*! no static exports found */
  2649. /***/ (function(module, exports, __webpack_require__) {
  2650. "use strict";
  2651. /* WEBPACK VAR INJECTION */(function(process) {
  2652. /**
  2653. * @license
  2654. * SPDX-License-Identifier: Apache-2.0
  2655. */
  2656. /**
  2657. * Ensure process.env.NODE_ENV is set even when not running under Webpack or
  2658. * Node. Terser will strip this out of production binaries.
  2659. */
  2660. /*#__PURE__*/ (function () {
  2661. if (typeof process === 'undefined') {
  2662. window.process = { env: { NODE_ENV: 'development' } };
  2663. }
  2664. })();
  2665. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
  2666. /***/ }),
  2667. /***/ "./node_modules/safevalues/index.js":
  2668. /*!******************************************!*\
  2669. !*** ./node_modules/safevalues/index.js ***!
  2670. \******************************************/
  2671. /*! no static exports found */
  2672. /***/ (function(module, exports, __webpack_require__) {
  2673. "use strict";
  2674. /**
  2675. * @license
  2676. * SPDX-License-Identifier: Apache-2.0
  2677. */
  2678. Object.defineProperty(exports, "__esModule", { value: true });
  2679. exports.unwrapStyleSheet = exports.SafeStyleSheet = exports.isStyleSheet = exports.unwrapStyle = exports.SafeStyle = exports.isStyle = exports.unwrapScript = exports.SafeScript = exports.isScript = exports.EMPTY_SCRIPT = exports.unwrapResourceUrl = exports.TrustedResourceUrl = exports.isResourceUrl = exports.unwrapHtml = exports.SafeHtml = exports.isHtml = exports.EMPTY_HTML = exports.unwrapAttributePrefix = exports.SafeAttributePrefix = exports.safeStyleSheet = exports.concatStyleSheets = exports.safeStyle = exports.concatStyles = exports.scriptFromJson = exports.safeScriptWithArgs = exports.safeScript = exports.concatScripts = exports.trustedResourceUrl = exports.replaceFragment = exports.blobUrlFromScript = exports.appendParams = exports.HtmlSanitizerBuilder = exports.sanitizeHtmlToFragment = exports.sanitizeHtmlAssertUnchanged = exports.sanitizeHtml = exports.htmlEscape = exports.createScriptSrc = exports.createScript = exports.concatHtmls = exports.safeAttrPrefix = void 0;
  2680. /** Safe builders */
  2681. var attribute_builders_1 = __webpack_require__(/*! ./builders/attribute_builders */ "./node_modules/safevalues/builders/attribute_builders.js");
  2682. Object.defineProperty(exports, "safeAttrPrefix", { enumerable: true, get: function () { return attribute_builders_1.safeAttrPrefix; } });
  2683. var html_builders_1 = __webpack_require__(/*! ./builders/html_builders */ "./node_modules/safevalues/builders/html_builders.js");
  2684. Object.defineProperty(exports, "concatHtmls", { enumerable: true, get: function () { return html_builders_1.concatHtmls; } });
  2685. Object.defineProperty(exports, "createScript", { enumerable: true, get: function () { return html_builders_1.createScript; } });
  2686. Object.defineProperty(exports, "createScriptSrc", { enumerable: true, get: function () { return html_builders_1.createScriptSrc; } });
  2687. Object.defineProperty(exports, "htmlEscape", { enumerable: true, get: function () { return html_builders_1.htmlEscape; } });
  2688. var html_sanitizer_1 = __webpack_require__(/*! ./builders/html_sanitizer/html_sanitizer */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js");
  2689. Object.defineProperty(exports, "sanitizeHtml", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtml; } });
  2690. Object.defineProperty(exports, "sanitizeHtmlAssertUnchanged", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtmlAssertUnchanged; } });
  2691. Object.defineProperty(exports, "sanitizeHtmlToFragment", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtmlToFragment; } });
  2692. var html_sanitizer_builder_1 = __webpack_require__(/*! ./builders/html_sanitizer/html_sanitizer_builder */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js");
  2693. Object.defineProperty(exports, "HtmlSanitizerBuilder", { enumerable: true, get: function () { return html_sanitizer_builder_1.HtmlSanitizerBuilder; } });
  2694. var resource_url_builders_1 = __webpack_require__(/*! ./builders/resource_url_builders */ "./node_modules/safevalues/builders/resource_url_builders.js");
  2695. Object.defineProperty(exports, "appendParams", { enumerable: true, get: function () { return resource_url_builders_1.appendParams; } });
  2696. Object.defineProperty(exports, "blobUrlFromScript", { enumerable: true, get: function () { return resource_url_builders_1.blobUrlFromScript; } });
  2697. Object.defineProperty(exports, "replaceFragment", { enumerable: true, get: function () { return resource_url_builders_1.replaceFragment; } });
  2698. Object.defineProperty(exports, "trustedResourceUrl", { enumerable: true, get: function () { return resource_url_builders_1.trustedResourceUrl; } });
  2699. var script_builders_1 = __webpack_require__(/*! ./builders/script_builders */ "./node_modules/safevalues/builders/script_builders.js");
  2700. Object.defineProperty(exports, "concatScripts", { enumerable: true, get: function () { return script_builders_1.concatScripts; } });
  2701. Object.defineProperty(exports, "safeScript", { enumerable: true, get: function () { return script_builders_1.safeScript; } });
  2702. Object.defineProperty(exports, "safeScriptWithArgs", { enumerable: true, get: function () { return script_builders_1.safeScriptWithArgs; } });
  2703. Object.defineProperty(exports, "scriptFromJson", { enumerable: true, get: function () { return script_builders_1.scriptFromJson; } });
  2704. var style_builders_1 = __webpack_require__(/*! ./builders/style_builders */ "./node_modules/safevalues/builders/style_builders.js");
  2705. Object.defineProperty(exports, "concatStyles", { enumerable: true, get: function () { return style_builders_1.concatStyles; } });
  2706. Object.defineProperty(exports, "safeStyle", { enumerable: true, get: function () { return style_builders_1.safeStyle; } });
  2707. var style_sheet_builders_1 = __webpack_require__(/*! ./builders/style_sheet_builders */ "./node_modules/safevalues/builders/style_sheet_builders.js");
  2708. Object.defineProperty(exports, "concatStyleSheets", { enumerable: true, get: function () { return style_sheet_builders_1.concatStyleSheets; } });
  2709. Object.defineProperty(exports, "safeStyleSheet", { enumerable: true, get: function () { return style_sheet_builders_1.safeStyleSheet; } });
  2710. /** Types, constants and unwrappers */
  2711. var attribute_impl_1 = __webpack_require__(/*! ./internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
  2712. Object.defineProperty(exports, "SafeAttributePrefix", { enumerable: true, get: function () { return attribute_impl_1.SafeAttributePrefix; } });
  2713. Object.defineProperty(exports, "unwrapAttributePrefix", { enumerable: true, get: function () { return attribute_impl_1.unwrapAttributePrefix; } });
  2714. var html_impl_1 = __webpack_require__(/*! ./internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
  2715. Object.defineProperty(exports, "EMPTY_HTML", { enumerable: true, get: function () { return html_impl_1.EMPTY_HTML; } });
  2716. Object.defineProperty(exports, "isHtml", { enumerable: true, get: function () { return html_impl_1.isHtml; } });
  2717. Object.defineProperty(exports, "SafeHtml", { enumerable: true, get: function () { return html_impl_1.SafeHtml; } });
  2718. Object.defineProperty(exports, "unwrapHtml", { enumerable: true, get: function () { return html_impl_1.unwrapHtml; } });
  2719. var resource_url_impl_1 = __webpack_require__(/*! ./internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
  2720. Object.defineProperty(exports, "isResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.isResourceUrl; } });
  2721. Object.defineProperty(exports, "TrustedResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.TrustedResourceUrl; } });
  2722. Object.defineProperty(exports, "unwrapResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.unwrapResourceUrl; } });
  2723. var script_impl_1 = __webpack_require__(/*! ./internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
  2724. Object.defineProperty(exports, "EMPTY_SCRIPT", { enumerable: true, get: function () { return script_impl_1.EMPTY_SCRIPT; } });
  2725. Object.defineProperty(exports, "isScript", { enumerable: true, get: function () { return script_impl_1.isScript; } });
  2726. Object.defineProperty(exports, "SafeScript", { enumerable: true, get: function () { return script_impl_1.SafeScript; } });
  2727. Object.defineProperty(exports, "unwrapScript", { enumerable: true, get: function () { return script_impl_1.unwrapScript; } });
  2728. var style_impl_1 = __webpack_require__(/*! ./internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
  2729. Object.defineProperty(exports, "isStyle", { enumerable: true, get: function () { return style_impl_1.isStyle; } });
  2730. Object.defineProperty(exports, "SafeStyle", { enumerable: true, get: function () { return style_impl_1.SafeStyle; } });
  2731. Object.defineProperty(exports, "unwrapStyle", { enumerable: true, get: function () { return style_impl_1.unwrapStyle; } });
  2732. var style_sheet_impl_1 = __webpack_require__(/*! ./internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
  2733. Object.defineProperty(exports, "isStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.isStyleSheet; } });
  2734. Object.defineProperty(exports, "SafeStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.SafeStyleSheet; } });
  2735. Object.defineProperty(exports, "unwrapStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.unwrapStyleSheet; } });
  2736. /***/ }),
  2737. /***/ "./node_modules/safevalues/internals/attribute_impl.js":
  2738. /*!*************************************************************!*\
  2739. !*** ./node_modules/safevalues/internals/attribute_impl.js ***!
  2740. \*************************************************************/
  2741. /*! no static exports found */
  2742. /***/ (function(module, exports, __webpack_require__) {
  2743. "use strict";
  2744. /**
  2745. * @license
  2746. * SPDX-License-Identifier: Apache-2.0
  2747. */
  2748. var __extends = (this && this.__extends) || (function () {
  2749. var extendStatics = function (d, b) {
  2750. extendStatics = Object.setPrototypeOf ||
  2751. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  2752. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  2753. return extendStatics(d, b);
  2754. };
  2755. return function (d, b) {
  2756. if (typeof b !== "function" && b !== null)
  2757. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  2758. extendStatics(d, b);
  2759. function __() { this.constructor = d; }
  2760. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2761. };
  2762. })();
  2763. Object.defineProperty(exports, "__esModule", { value: true });
  2764. exports.unwrapAttributePrefix = exports.createAttributePrefix = exports.SafeAttributePrefix = void 0;
  2765. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  2766. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  2767. /** A prefix with which an attribute is safe to set using plain strings. */
  2768. var SafeAttributePrefix = /** @class */ (function () {
  2769. function SafeAttributePrefix() {
  2770. }
  2771. return SafeAttributePrefix;
  2772. }());
  2773. exports.SafeAttributePrefix = SafeAttributePrefix;
  2774. /** Implementation for `SafeAttributePrefix` */
  2775. var AttributePrefixImpl = /** @class */ (function (_super) {
  2776. __extends(AttributePrefixImpl, _super);
  2777. function AttributePrefixImpl(attrPrefix, token) {
  2778. var _this = _super.call(this) || this;
  2779. if (true) {
  2780. (0, secrets_1.ensureTokenIsValid)(token);
  2781. }
  2782. _this.privateDoNotAccessOrElseWrappedAttrPrefix = attrPrefix;
  2783. return _this;
  2784. }
  2785. AttributePrefixImpl.prototype.toString = function () {
  2786. return this.privateDoNotAccessOrElseWrappedAttrPrefix;
  2787. };
  2788. return AttributePrefixImpl;
  2789. }(SafeAttributePrefix));
  2790. /**
  2791. * Builds a new `SafeAttribute` from the given string, without enforcing
  2792. * safety guarantees. This shouldn't be exposed to application developers, and
  2793. * must only be used as a step towards safe builders or safe constants.
  2794. */
  2795. function createAttributePrefix(attrPrefix) {
  2796. return new AttributePrefixImpl(attrPrefix, secrets_1.secretToken);
  2797. }
  2798. exports.createAttributePrefix = createAttributePrefix;
  2799. /**
  2800. * Returns the string value of the passed `SafeAttributePrefix` object while
  2801. * ensuring it has the correct type.
  2802. */
  2803. function unwrapAttributePrefix(value) {
  2804. if (value instanceof AttributePrefixImpl) {
  2805. return value.privateDoNotAccessOrElseWrappedAttrPrefix;
  2806. }
  2807. else {
  2808. var message = '';
  2809. if (true) {
  2810. message = 'Unexpected type when unwrapping SafeAttributePrefix';
  2811. }
  2812. throw new Error(message);
  2813. }
  2814. }
  2815. exports.unwrapAttributePrefix = unwrapAttributePrefix;
  2816. /***/ }),
  2817. /***/ "./node_modules/safevalues/internals/html_impl.js":
  2818. /*!********************************************************!*\
  2819. !*** ./node_modules/safevalues/internals/html_impl.js ***!
  2820. \********************************************************/
  2821. /*! no static exports found */
  2822. /***/ (function(module, exports, __webpack_require__) {
  2823. "use strict";
  2824. /**
  2825. * @license
  2826. * SPDX-License-Identifier: Apache-2.0
  2827. */
  2828. Object.defineProperty(exports, "__esModule", { value: true });
  2829. exports.unwrapHtml = exports.isHtml = exports.EMPTY_HTML = exports.createHtml = exports.SafeHtml = void 0;
  2830. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  2831. /* g3_import_pure from './pure' */
  2832. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  2833. var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
  2834. /**
  2835. * Runtime implementation of `TrustedHTML` in browsers that don't support it.
  2836. */
  2837. var HtmlImpl = /** @class */ (function () {
  2838. function HtmlImpl(html, token) {
  2839. if (true) {
  2840. (0, secrets_1.ensureTokenIsValid)(token);
  2841. }
  2842. this.privateDoNotAccessOrElseWrappedHtml = html;
  2843. }
  2844. HtmlImpl.prototype.toString = function () {
  2845. return this.privateDoNotAccessOrElseWrappedHtml.toString();
  2846. };
  2847. return HtmlImpl;
  2848. }());
  2849. function createHtmlInternal(html, trusted) {
  2850. return (trusted !== null && trusted !== void 0 ? trusted : new HtmlImpl(html, secrets_1.secretToken));
  2851. }
  2852. var GlobalTrustedHTML = (typeof window !== undefined) ? window.TrustedHTML : undefined;
  2853. /**
  2854. * Also exports the constructor so that instanceof checks work.
  2855. */
  2856. exports.SafeHtml = (GlobalTrustedHTML !== null && GlobalTrustedHTML !== void 0 ? GlobalTrustedHTML : HtmlImpl);
  2857. /**
  2858. * Builds a new `SafeHtml` from the given string, without enforcing safety
  2859. * guarantees. It may cause side effects by creating a Trusted Types policy.
  2860. * This shouldn't be exposed to application developers, and must only be used as
  2861. * a step towards safe builders or safe constants.
  2862. */
  2863. function createHtml(html) {
  2864. var _a;
  2865. /** @noinline */
  2866. var noinlineHtml = html;
  2867. return createHtmlInternal(noinlineHtml, (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createHTML(noinlineHtml));
  2868. }
  2869. exports.createHtml = createHtml;
  2870. /**
  2871. * An empty `SafeHtml` constant.
  2872. * Unlike the function above, using this will not create a policy.
  2873. */
  2874. exports.EMPTY_HTML =
  2875. /* #__PURE__ */ (function () { var _a; return createHtmlInternal('', (_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.emptyHTML); })();
  2876. /**
  2877. * Checks if the given value is a `SafeHtml` instance.
  2878. */
  2879. function isHtml(value) {
  2880. return value instanceof exports.SafeHtml;
  2881. }
  2882. exports.isHtml = isHtml;
  2883. /**
  2884. * Returns the value of the passed `SafeHtml` object while ensuring it
  2885. * has the correct type.
  2886. *
  2887. * Returns a native `TrustedHTML` or a string if Trusted Types are disabled.
  2888. */
  2889. function unwrapHtml(value) {
  2890. var _a;
  2891. if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isHTML(value)) {
  2892. return value;
  2893. }
  2894. else if (value instanceof HtmlImpl) {
  2895. return value.privateDoNotAccessOrElseWrappedHtml;
  2896. }
  2897. else {
  2898. var message = '';
  2899. if (true) {
  2900. message = 'Unexpected type when unwrapping SafeHtml';
  2901. }
  2902. throw new Error(message);
  2903. }
  2904. }
  2905. exports.unwrapHtml = unwrapHtml;
  2906. /***/ }),
  2907. /***/ "./node_modules/safevalues/internals/resource_url_impl.js":
  2908. /*!****************************************************************!*\
  2909. !*** ./node_modules/safevalues/internals/resource_url_impl.js ***!
  2910. \****************************************************************/
  2911. /*! no static exports found */
  2912. /***/ (function(module, exports, __webpack_require__) {
  2913. "use strict";
  2914. /**
  2915. * @license
  2916. * SPDX-License-Identifier: Apache-2.0
  2917. */
  2918. Object.defineProperty(exports, "__esModule", { value: true });
  2919. exports.unwrapResourceUrl = exports.isResourceUrl = exports.createResourceUrl = exports.TrustedResourceUrl = void 0;
  2920. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  2921. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  2922. var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
  2923. /**
  2924. * Runtime implementation of `TrustedScriptURL` in browsers that don't support
  2925. * it.
  2926. */
  2927. var ResourceUrlImpl = /** @class */ (function () {
  2928. function ResourceUrlImpl(url, token) {
  2929. if (true) {
  2930. (0, secrets_1.ensureTokenIsValid)(token);
  2931. }
  2932. this.privateDoNotAccessOrElseWrappedResourceUrl = url;
  2933. }
  2934. ResourceUrlImpl.prototype.toString = function () {
  2935. return this.privateDoNotAccessOrElseWrappedResourceUrl.toString();
  2936. };
  2937. return ResourceUrlImpl;
  2938. }());
  2939. var GlobalTrustedScriptURL = (typeof window !== undefined) ? window.TrustedScriptURL : undefined;
  2940. /**
  2941. * Also exports the constructor so that instanceof checks work.
  2942. */
  2943. exports.TrustedResourceUrl = (GlobalTrustedScriptURL !== null && GlobalTrustedScriptURL !== void 0 ? GlobalTrustedScriptURL : ResourceUrlImpl);
  2944. /**
  2945. * Builds a new `TrustedResourceUrl` from the given string, without
  2946. * enforcing safety guarantees. It may cause side effects by creating a Trusted
  2947. * Types policy. This shouldn't be exposed to application developers, and must
  2948. * only be used as a step towards safe builders or safe constants.
  2949. */
  2950. function createResourceUrl(url) {
  2951. var _a;
  2952. /** @noinline */
  2953. var noinlineUrl = url;
  2954. var trustedScriptURL = (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createScriptURL(noinlineUrl);
  2955. return (trustedScriptURL !== null && trustedScriptURL !== void 0 ? trustedScriptURL : new ResourceUrlImpl(noinlineUrl, secrets_1.secretToken));
  2956. }
  2957. exports.createResourceUrl = createResourceUrl;
  2958. /**
  2959. * Checks if the given value is a `TrustedResourceUrl` instance.
  2960. */
  2961. function isResourceUrl(value) {
  2962. return value instanceof exports.TrustedResourceUrl;
  2963. }
  2964. exports.isResourceUrl = isResourceUrl;
  2965. /**
  2966. * Returns the value of the passed `TrustedResourceUrl` object while ensuring it
  2967. * has the correct type.
  2968. *
  2969. * Returns a native `TrustedScriptURL` or a string if Trusted Types are
  2970. * disabled.
  2971. */
  2972. function unwrapResourceUrl(value) {
  2973. var _a;
  2974. if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isScriptURL(value)) {
  2975. return value;
  2976. }
  2977. else if (value instanceof ResourceUrlImpl) {
  2978. return value.privateDoNotAccessOrElseWrappedResourceUrl;
  2979. }
  2980. else {
  2981. var message = '';
  2982. if (true) {
  2983. message = 'Unexpected type when unwrapping TrustedResourceUrl';
  2984. }
  2985. throw new Error(message);
  2986. }
  2987. }
  2988. exports.unwrapResourceUrl = unwrapResourceUrl;
  2989. /***/ }),
  2990. /***/ "./node_modules/safevalues/internals/script_impl.js":
  2991. /*!**********************************************************!*\
  2992. !*** ./node_modules/safevalues/internals/script_impl.js ***!
  2993. \**********************************************************/
  2994. /*! no static exports found */
  2995. /***/ (function(module, exports, __webpack_require__) {
  2996. "use strict";
  2997. /**
  2998. * @license
  2999. * SPDX-License-Identifier: Apache-2.0
  3000. */
  3001. Object.defineProperty(exports, "__esModule", { value: true });
  3002. exports.unwrapScript = exports.isScript = exports.EMPTY_SCRIPT = exports.createScript = exports.SafeScript = void 0;
  3003. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  3004. /* g3_import_pure from './pure' */
  3005. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  3006. var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
  3007. /**
  3008. * Runtime implementation of `TrustedScript` in browswers that don't support it.
  3009. * script element.
  3010. */
  3011. var ScriptImpl = /** @class */ (function () {
  3012. function ScriptImpl(script, token) {
  3013. if (true) {
  3014. (0, secrets_1.ensureTokenIsValid)(token);
  3015. }
  3016. this.privateDoNotAccessOrElseWrappedScript = script;
  3017. }
  3018. ScriptImpl.prototype.toString = function () {
  3019. return this.privateDoNotAccessOrElseWrappedScript.toString();
  3020. };
  3021. return ScriptImpl;
  3022. }());
  3023. function createScriptInternal(script, trusted) {
  3024. return (trusted !== null && trusted !== void 0 ? trusted : new ScriptImpl(script, secrets_1.secretToken));
  3025. }
  3026. var GlobalTrustedScript = (typeof window !== undefined) ? window.TrustedScript : undefined;
  3027. /**
  3028. * Also exports the constructor so that instanceof checks work.
  3029. */
  3030. exports.SafeScript = (GlobalTrustedScript !== null && GlobalTrustedScript !== void 0 ? GlobalTrustedScript : ScriptImpl);
  3031. /**
  3032. * Builds a new `SafeScript` from the given string, without enforcing
  3033. * safety guarantees. It may cause side effects by creating a Trusted Types
  3034. * policy. This shouldn't be exposed to application developers, and must only be
  3035. * used as a step towards safe builders or safe constants.
  3036. */
  3037. function createScript(script) {
  3038. var _a;
  3039. /** @noinline */
  3040. var noinlineScript = script;
  3041. return createScriptInternal(noinlineScript, (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createScript(noinlineScript));
  3042. }
  3043. exports.createScript = createScript;
  3044. /**
  3045. * An empty `SafeScript` constant.
  3046. * Unlike the functions above, using this will not create a policy.
  3047. */
  3048. exports.EMPTY_SCRIPT =
  3049. /* #__PURE__ */ (function () { var _a; return createScriptInternal('', (_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.emptyScript); })();
  3050. /**
  3051. * Checks if the given value is a `SafeScript` instance.
  3052. */
  3053. function isScript(value) {
  3054. return value instanceof exports.SafeScript;
  3055. }
  3056. exports.isScript = isScript;
  3057. /**
  3058. * Returns the value of the passed `SafeScript` object while ensuring it
  3059. * has the correct type.
  3060. *
  3061. * Returns a native `TrustedScript` or a string if Trusted Types are disabled.
  3062. */
  3063. function unwrapScript(value) {
  3064. var _a;
  3065. if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isScript(value)) {
  3066. return value;
  3067. }
  3068. else if (value instanceof ScriptImpl) {
  3069. return value.privateDoNotAccessOrElseWrappedScript;
  3070. }
  3071. else {
  3072. var message = '';
  3073. if (true) {
  3074. message = 'Unexpected type when unwrapping SafeScript';
  3075. }
  3076. throw new Error(message);
  3077. }
  3078. }
  3079. exports.unwrapScript = unwrapScript;
  3080. /***/ }),
  3081. /***/ "./node_modules/safevalues/internals/secrets.js":
  3082. /*!******************************************************!*\
  3083. !*** ./node_modules/safevalues/internals/secrets.js ***!
  3084. \******************************************************/
  3085. /*! no static exports found */
  3086. /***/ (function(module, exports, __webpack_require__) {
  3087. "use strict";
  3088. /**
  3089. * @license
  3090. * SPDX-License-Identifier: Apache-2.0
  3091. */
  3092. Object.defineProperty(exports, "__esModule", { value: true });
  3093. exports.ensureTokenIsValid = exports.secretToken = void 0;
  3094. /**
  3095. * A secret token that must be passed to safe type constructors. It is only
  3096. * accessible from within safevalues, ensuring that unrestricted safe type
  3097. * creation is only possible within safevalues. In particular, this prevents
  3098. * forgery such as `safeHtmlValue.constructor('javascript:evil')`.
  3099. */
  3100. exports.secretToken = {};
  3101. /**
  3102. * Asserts that the given token matches the secret safevalues token. An
  3103. * exception is thrown if that is not the case.
  3104. */
  3105. function ensureTokenIsValid(token) {
  3106. if (token !== exports.secretToken) {
  3107. throw new Error('Bad secret');
  3108. }
  3109. }
  3110. exports.ensureTokenIsValid = ensureTokenIsValid;
  3111. /***/ }),
  3112. /***/ "./node_modules/safevalues/internals/string_literal.js":
  3113. /*!*************************************************************!*\
  3114. !*** ./node_modules/safevalues/internals/string_literal.js ***!
  3115. \*************************************************************/
  3116. /*! no static exports found */
  3117. /***/ (function(module, exports, __webpack_require__) {
  3118. "use strict";
  3119. /**
  3120. * @license
  3121. * SPDX-License-Identifier: Apache-2.0
  3122. */
  3123. Object.defineProperty(exports, "__esModule", { value: true });
  3124. exports.assertIsTemplateObject = void 0;
  3125. /**
  3126. * An object of type TemplateStringsArray represents the literal part(s) of a
  3127. * template literal. This function checks if a TemplateStringsArray object is
  3128. * actually from a template literal.
  3129. *
  3130. * @param templateObj This contains the literal part of the template literal.
  3131. * @param hasExprs If true, the input template may contain embedded expressions.
  3132. * @param errorMsg The custom error message in case any checks fail.
  3133. */
  3134. function assertIsTemplateObject(templateObj, hasExprs, errorMsg) {
  3135. if (!Array.isArray(templateObj) || !Array.isArray(templateObj.raw) ||
  3136. (!hasExprs && templateObj.length !== 1)) {
  3137. throw new TypeError(errorMsg);
  3138. }
  3139. }
  3140. exports.assertIsTemplateObject = assertIsTemplateObject;
  3141. /***/ }),
  3142. /***/ "./node_modules/safevalues/internals/style_impl.js":
  3143. /*!*********************************************************!*\
  3144. !*** ./node_modules/safevalues/internals/style_impl.js ***!
  3145. \*********************************************************/
  3146. /*! no static exports found */
  3147. /***/ (function(module, exports, __webpack_require__) {
  3148. "use strict";
  3149. /**
  3150. * @license
  3151. * SPDX-License-Identifier: Apache-2.0
  3152. */
  3153. var __extends = (this && this.__extends) || (function () {
  3154. var extendStatics = function (d, b) {
  3155. extendStatics = Object.setPrototypeOf ||
  3156. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3157. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  3158. return extendStatics(d, b);
  3159. };
  3160. return function (d, b) {
  3161. if (typeof b !== "function" && b !== null)
  3162. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  3163. extendStatics(d, b);
  3164. function __() { this.constructor = d; }
  3165. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3166. };
  3167. })();
  3168. Object.defineProperty(exports, "__esModule", { value: true });
  3169. exports.unwrapStyle = exports.isStyle = exports.createStyle = exports.SafeStyle = void 0;
  3170. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  3171. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  3172. /**
  3173. * Sequence of CSS declarations safe to use in style contexts in an HTML
  3174. * document or in DOM APIs.
  3175. */
  3176. var SafeStyle = /** @class */ (function () {
  3177. function SafeStyle() {
  3178. }
  3179. return SafeStyle;
  3180. }());
  3181. exports.SafeStyle = SafeStyle;
  3182. /** Implementation for `SafeStyle` */
  3183. var StyleImpl = /** @class */ (function (_super) {
  3184. __extends(StyleImpl, _super);
  3185. function StyleImpl(style, token) {
  3186. var _this = _super.call(this) || this;
  3187. if (true) {
  3188. (0, secrets_1.ensureTokenIsValid)(token);
  3189. }
  3190. _this.privateDoNotAccessOrElseWrappedStyle = style;
  3191. return _this;
  3192. }
  3193. StyleImpl.prototype.toString = function () {
  3194. return this.privateDoNotAccessOrElseWrappedStyle;
  3195. };
  3196. return StyleImpl;
  3197. }(SafeStyle));
  3198. /**
  3199. * Builds a new `SafeStyle` from the given string, without enforcing
  3200. * safety guarantees. This shouldn't be exposed to application developers, and
  3201. * must only be used as a step towards safe builders or safe constants.
  3202. */
  3203. function createStyle(style) {
  3204. return new StyleImpl(style, secrets_1.secretToken);
  3205. }
  3206. exports.createStyle = createStyle;
  3207. /**
  3208. * Checks if the given value is a `SafeStyle` instance.
  3209. */
  3210. function isStyle(value) {
  3211. return value instanceof StyleImpl;
  3212. }
  3213. exports.isStyle = isStyle;
  3214. /**
  3215. * Returns the string value of the passed `SafeStyle` object while ensuring it
  3216. * has the correct type.
  3217. */
  3218. function unwrapStyle(value) {
  3219. if (value instanceof StyleImpl) {
  3220. return value.privateDoNotAccessOrElseWrappedStyle;
  3221. }
  3222. else {
  3223. var message = '';
  3224. if (true) {
  3225. message = 'Unexpected type when unwrapping SafeStyle';
  3226. }
  3227. throw new Error(message);
  3228. }
  3229. }
  3230. exports.unwrapStyle = unwrapStyle;
  3231. /***/ }),
  3232. /***/ "./node_modules/safevalues/internals/style_sheet_impl.js":
  3233. /*!***************************************************************!*\
  3234. !*** ./node_modules/safevalues/internals/style_sheet_impl.js ***!
  3235. \***************************************************************/
  3236. /*! no static exports found */
  3237. /***/ (function(module, exports, __webpack_require__) {
  3238. "use strict";
  3239. /**
  3240. * @license
  3241. * SPDX-License-Identifier: Apache-2.0
  3242. */
  3243. var __extends = (this && this.__extends) || (function () {
  3244. var extendStatics = function (d, b) {
  3245. extendStatics = Object.setPrototypeOf ||
  3246. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  3247. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  3248. return extendStatics(d, b);
  3249. };
  3250. return function (d, b) {
  3251. if (typeof b !== "function" && b !== null)
  3252. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  3253. extendStatics(d, b);
  3254. function __() { this.constructor = d; }
  3255. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3256. };
  3257. })();
  3258. Object.defineProperty(exports, "__esModule", { value: true });
  3259. exports.unwrapStyleSheet = exports.isStyleSheet = exports.createStyleSheet = exports.SafeStyleSheet = void 0;
  3260. __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
  3261. var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
  3262. /**
  3263. * A complete CSS style sheet, safe to use in style contexts in an HTML document
  3264. * or DOM APIs.
  3265. */
  3266. var SafeStyleSheet = /** @class */ (function () {
  3267. function SafeStyleSheet() {
  3268. }
  3269. return SafeStyleSheet;
  3270. }());
  3271. exports.SafeStyleSheet = SafeStyleSheet;
  3272. /** Implementation for `SafeStyleSheet` */
  3273. var StyleSheetImpl = /** @class */ (function (_super) {
  3274. __extends(StyleSheetImpl, _super);
  3275. function StyleSheetImpl(styleSheet, token) {
  3276. var _this = _super.call(this) || this;
  3277. if (true) {
  3278. (0, secrets_1.ensureTokenIsValid)(token);
  3279. }
  3280. _this.privateDoNotAccessOrElseWrappedStyleSheet = styleSheet;
  3281. return _this;
  3282. }
  3283. StyleSheetImpl.prototype.toString = function () {
  3284. return this.privateDoNotAccessOrElseWrappedStyleSheet;
  3285. };
  3286. return StyleSheetImpl;
  3287. }(SafeStyleSheet));
  3288. /**
  3289. * Builds a new `SafeStyleSheet` from the given string, without enforcing
  3290. * safety guarantees. This shouldn't be exposed to application developers, and
  3291. * must only be used as a step towards safe builders or safe constants.
  3292. */
  3293. function createStyleSheet(styleSheet) {
  3294. return new StyleSheetImpl(styleSheet, secrets_1.secretToken);
  3295. }
  3296. exports.createStyleSheet = createStyleSheet;
  3297. /**
  3298. * Checks if the given value is a `SafeStyleSheet` instance.
  3299. */
  3300. function isStyleSheet(value) {
  3301. return value instanceof StyleSheetImpl;
  3302. }
  3303. exports.isStyleSheet = isStyleSheet;
  3304. /**
  3305. * Returns the string value of the passed `SafeStyleSheet` object while
  3306. * ensuring it has the correct type.
  3307. */
  3308. function unwrapStyleSheet(value) {
  3309. if (value instanceof StyleSheetImpl) {
  3310. return value.privateDoNotAccessOrElseWrappedStyleSheet;
  3311. }
  3312. else {
  3313. var message = '';
  3314. if (true) {
  3315. message = 'Unexpected type when unwrapping SafeStyleSheet';
  3316. }
  3317. throw new Error(message);
  3318. }
  3319. }
  3320. exports.unwrapStyleSheet = unwrapStyleSheet;
  3321. /***/ }),
  3322. /***/ "./node_modules/safevalues/internals/trusted_types.js":
  3323. /*!************************************************************!*\
  3324. !*** ./node_modules/safevalues/internals/trusted_types.js ***!
  3325. \************************************************************/
  3326. /*! no static exports found */
  3327. /***/ (function(module, exports, __webpack_require__) {
  3328. "use strict";
  3329. /**
  3330. * @license
  3331. * SPDX-License-Identifier: Apache-2.0
  3332. */
  3333. Object.defineProperty(exports, "__esModule", { value: true });
  3334. exports.TEST_ONLY = exports.getTrustedTypesPolicy = exports.getTrustedTypes = void 0;
  3335. /**
  3336. * The name of the Trusted Types policy used by TS safevalues, or empty
  3337. * to disable Trusted Types. This duplicates the 'google#safe', but
  3338. * can be overridden in tests.
  3339. */
  3340. var trustedTypesPolicyName = 'google#safe';
  3341. /** Helper to retrieve the value of `window.trustedTypes`. */
  3342. function trustedTypes() {
  3343. if (typeof window !== 'undefined') {
  3344. return window.trustedTypes;
  3345. }
  3346. return undefined;
  3347. }
  3348. /**
  3349. * Returns window.trustedTypes if Trusted Types are enabled and supported, or
  3350. * null otherwise.
  3351. */
  3352. function getTrustedTypes() {
  3353. var _a;
  3354. return (trustedTypesPolicyName !== '') ? ((_a = trustedTypes()) !== null && _a !== void 0 ? _a : null) : null;
  3355. }
  3356. exports.getTrustedTypes = getTrustedTypes;
  3357. /**
  3358. * The Trusted Types policy used by TS safevalues, or null if Trusted Types
  3359. * are not enabled/supported, or undefined if the policy has not been created
  3360. * yet.
  3361. */
  3362. var trustedTypesPolicy;
  3363. /**
  3364. * Returns the Trusted Types policy used by TS safevalues, or null if Trusted
  3365. * Types are not enabled/supported. The first call to this function will
  3366. * create the policy.
  3367. */
  3368. function getTrustedTypesPolicy() {
  3369. var _a, _b;
  3370. if (trustedTypesPolicy === undefined) {
  3371. try {
  3372. trustedTypesPolicy =
  3373. (_b = (_a = getTrustedTypes()) === null || _a === void 0 ? void 0 : _a.createPolicy(trustedTypesPolicyName, {
  3374. createHTML: function (s) { return s; },
  3375. createScript: function (s) { return s; },
  3376. createScriptURL: function (s) { return s; }
  3377. })) !== null && _b !== void 0 ? _b : null;
  3378. }
  3379. catch (_c) {
  3380. // In Chromium versions before 81, trustedTypes.createPolicy throws if
  3381. // called with a name that is already registered, even if no CSP is set.
  3382. // Until users have largely migrated to 81 or above, catch the error not
  3383. // to break the applications functionally. In such case, the code will
  3384. // fall back to using regular Safe Types.
  3385. trustedTypesPolicy = null;
  3386. }
  3387. }
  3388. return trustedTypesPolicy;
  3389. }
  3390. exports.getTrustedTypesPolicy = getTrustedTypesPolicy;
  3391. /** Helpers for tests. */
  3392. exports.TEST_ONLY = {
  3393. resetDefaults: function () {
  3394. trustedTypesPolicy = undefined;
  3395. trustedTypesPolicyName = 'google#safe';
  3396. },
  3397. setTrustedTypesPolicyName: function (name) {
  3398. trustedTypesPolicyName = name;
  3399. },
  3400. };
  3401. /***/ }),
  3402. /***/ "./packages/mdc-animation/util.ts":
  3403. /*!****************************************!*\
  3404. !*** ./packages/mdc-animation/util.ts ***!
  3405. \****************************************/
  3406. /*! no static exports found */
  3407. /***/ (function(module, exports, __webpack_require__) {
  3408. "use strict";
  3409. /**
  3410. * @license
  3411. * Copyright 2016 Google Inc.
  3412. *
  3413. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3414. * of this software and associated documentation files (the "Software"), to deal
  3415. * in the Software without restriction, including without limitation the rights
  3416. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3417. * copies of the Software, and to permit persons to whom the Software is
  3418. * furnished to do so, subject to the following conditions:
  3419. *
  3420. * The above copyright notice and this permission notice shall be included in
  3421. * all copies or substantial portions of the Software.
  3422. *
  3423. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3424. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3425. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3426. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3427. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3428. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3429. * THE SOFTWARE.
  3430. */
  3431. Object.defineProperty(exports, "__esModule", { value: true });
  3432. exports.getCorrectEventName = exports.getCorrectPropertyName = void 0;
  3433. var cssPropertyNameMap = {
  3434. animation: {
  3435. prefixed: '-webkit-animation',
  3436. standard: 'animation'
  3437. },
  3438. transform: {
  3439. prefixed: '-webkit-transform',
  3440. standard: 'transform'
  3441. },
  3442. transition: {
  3443. prefixed: '-webkit-transition',
  3444. standard: 'transition'
  3445. }
  3446. };
  3447. var jsEventTypeMap = {
  3448. animationend: {
  3449. cssProperty: 'animation',
  3450. prefixed: 'webkitAnimationEnd',
  3451. standard: 'animationend'
  3452. },
  3453. animationiteration: {
  3454. cssProperty: 'animation',
  3455. prefixed: 'webkitAnimationIteration',
  3456. standard: 'animationiteration'
  3457. },
  3458. animationstart: {
  3459. cssProperty: 'animation',
  3460. prefixed: 'webkitAnimationStart',
  3461. standard: 'animationstart'
  3462. },
  3463. transitionend: {
  3464. cssProperty: 'transition',
  3465. prefixed: 'webkitTransitionEnd',
  3466. standard: 'transitionend'
  3467. }
  3468. };
  3469. function isWindow(windowObj) {
  3470. return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function';
  3471. }
  3472. function getCorrectPropertyName(windowObj, cssProperty) {
  3473. if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) {
  3474. var el = windowObj.document.createElement('div');
  3475. var _a = cssPropertyNameMap[cssProperty],
  3476. standard = _a.standard,
  3477. prefixed = _a.prefixed;
  3478. var isStandard = standard in el.style;
  3479. return isStandard ? standard : prefixed;
  3480. }
  3481. return cssProperty;
  3482. }
  3483. exports.getCorrectPropertyName = getCorrectPropertyName;
  3484. function getCorrectEventName(windowObj, eventType) {
  3485. if (isWindow(windowObj) && eventType in jsEventTypeMap) {
  3486. var el = windowObj.document.createElement('div');
  3487. var _a = jsEventTypeMap[eventType],
  3488. standard = _a.standard,
  3489. prefixed = _a.prefixed,
  3490. cssProperty = _a.cssProperty;
  3491. var isStandard = cssProperty in el.style;
  3492. return isStandard ? standard : prefixed;
  3493. }
  3494. return eventType;
  3495. }
  3496. exports.getCorrectEventName = getCorrectEventName;
  3497. /***/ }),
  3498. /***/ "./packages/mdc-base/component.ts":
  3499. /*!****************************************!*\
  3500. !*** ./packages/mdc-base/component.ts ***!
  3501. \****************************************/
  3502. /*! no static exports found */
  3503. /***/ (function(module, exports, __webpack_require__) {
  3504. "use strict";
  3505. /**
  3506. * @license
  3507. * Copyright 2016 Google Inc.
  3508. *
  3509. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3510. * of this software and associated documentation files (the "Software"), to deal
  3511. * in the Software without restriction, including without limitation the rights
  3512. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3513. * copies of the Software, and to permit persons to whom the Software is
  3514. * furnished to do so, subject to the following conditions:
  3515. *
  3516. * The above copyright notice and this permission notice shall be included in
  3517. * all copies or substantial portions of the Software.
  3518. *
  3519. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3520. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3521. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3522. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3523. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3524. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3525. * THE SOFTWARE.
  3526. */
  3527. var __makeTemplateObject = this && this.__makeTemplateObject || function (cooked, raw) {
  3528. if (Object.defineProperty) {
  3529. Object.defineProperty(cooked, "raw", { value: raw });
  3530. } else {
  3531. cooked.raw = raw;
  3532. }
  3533. return cooked;
  3534. };
  3535. var __read = this && this.__read || function (o, n) {
  3536. var m = typeof Symbol === "function" && o[Symbol.iterator];
  3537. if (!m) return o;
  3538. var i = m.call(o),
  3539. r,
  3540. ar = [],
  3541. e;
  3542. try {
  3543. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  3544. ar.push(r.value);
  3545. }
  3546. } catch (error) {
  3547. e = { error: error };
  3548. } finally {
  3549. try {
  3550. if (r && !r.done && (m = i["return"])) m.call(i);
  3551. } finally {
  3552. if (e) throw e.error;
  3553. }
  3554. }
  3555. return ar;
  3556. };
  3557. var __spreadArray = this && this.__spreadArray || function (to, from) {
  3558. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
  3559. to[j] = from[i];
  3560. }return to;
  3561. };
  3562. Object.defineProperty(exports, "__esModule", { value: true });
  3563. exports.MDCComponent = void 0;
  3564. var safevalues_1 = __webpack_require__(/*! safevalues */ "./node_modules/safevalues/index.js");
  3565. var dom_1 = __webpack_require__(/*! safevalues/dom */ "./node_modules/safevalues/dom/index.js");
  3566. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
  3567. function toCamelCase(str) {
  3568. // tslint:disable-next-line:enforce-name-casing
  3569. return String(str).replace(/\-([a-z])/g, function (_, match) {
  3570. return match.toUpperCase();
  3571. });
  3572. }
  3573. /** MDC Component base */
  3574. var MDCComponent = /** @class */function () {
  3575. function MDCComponent(root, foundation) {
  3576. var args = [];
  3577. for (var _i = 2; _i < arguments.length; _i++) {
  3578. args[_i - 2] = arguments[_i];
  3579. }
  3580. this.root = root;
  3581. this.initialize.apply(this, __spreadArray([], __read(args)));
  3582. // Note that we initialize foundation here and not within the constructor's
  3583. // default param so that this.root is defined and can be used within the
  3584. // foundation class.
  3585. this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
  3586. this.foundation.init();
  3587. this.initialSyncWithDOM();
  3588. }
  3589. MDCComponent.attachTo = function (root) {
  3590. // Subclasses which extend MDCBase should provide an attachTo() method that
  3591. // takes a root element and returns an instantiated component with its root
  3592. // set to that element. Also note that in the cases of subclasses, an
  3593. // explicit foundation class will not have to be passed in; it will simply
  3594. // be initialized from getDefaultFoundation().
  3595. return new MDCComponent(root, new foundation_1.MDCFoundation({}));
  3596. };
  3597. /* istanbul ignore next: method param only exists for typing purposes; it does
  3598. * not need to be unit tested */
  3599. // tslint:disable-next-line:enforce-name-casing
  3600. MDCComponent.prototype.initialize = function () {
  3601. var _args = [];
  3602. for (var _i = 0; _i < arguments.length; _i++) {
  3603. _args[_i] = arguments[_i];
  3604. }
  3605. // Subclasses can override this to do any additional setup work that would
  3606. // be considered part of a "constructor". Essentially, it is a hook into the
  3607. // parent constructor before the foundation is initialized. Any additional
  3608. // arguments besides root and foundation will be passed in here.
  3609. };
  3610. MDCComponent.prototype.getDefaultFoundation = function () {
  3611. // Subclasses must override this method to return a properly configured
  3612. // foundation class for the component.
  3613. throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
  3614. };
  3615. MDCComponent.prototype.initialSyncWithDOM = function () {
  3616. // Subclasses should override this method if they need to perform work to
  3617. // synchronize with a host DOM object. An example of this would be a form
  3618. // control wrapper that needs to synchronize its internal state to some
  3619. // property or attribute of the host DOM. Please note: this is *not* the
  3620. // place to perform DOM reads/writes that would cause layout / paint, as
  3621. // this is called synchronously from within the constructor.
  3622. };
  3623. MDCComponent.prototype.destroy = function () {
  3624. // Subclasses may implement this method to release any resources /
  3625. // deregister any listeners they have attached. An example of this might be
  3626. // deregistering a resize event from the window object.
  3627. this.foundation.destroy();
  3628. };
  3629. MDCComponent.prototype.listen = function (evtType, handler, options) {
  3630. this.root.addEventListener(evtType, handler, options);
  3631. };
  3632. MDCComponent.prototype.unlisten = function (evtType, handler, options) {
  3633. this.root.removeEventListener(evtType, handler, options);
  3634. };
  3635. /**
  3636. * Fires a cross-browser-compatible custom event from the component root of
  3637. * the given type, with the given data.
  3638. */
  3639. MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
  3640. if (shouldBubble === void 0) {
  3641. shouldBubble = false;
  3642. }
  3643. var evt;
  3644. if (typeof CustomEvent === 'function') {
  3645. evt = new CustomEvent(evtType, {
  3646. bubbles: shouldBubble,
  3647. detail: evtData
  3648. });
  3649. } else {
  3650. evt = document.createEvent('CustomEvent');
  3651. evt.initCustomEvent(evtType, shouldBubble, false, evtData);
  3652. }
  3653. this.root.dispatchEvent(evt);
  3654. };
  3655. /**
  3656. * This is a intermediate fix to allow components to use safevalues. This
  3657. * limits setAttribute to setting tabindex, data attributes, and aria
  3658. * attributes.
  3659. *
  3660. * TODO(b/263990206): remove this method and add these directly in each
  3661. * component. This will remove this abstraction and make it clear that the
  3662. * caller can't set any attribute.
  3663. */
  3664. MDCComponent.prototype.safeSetAttribute = function (element, attribute, value) {
  3665. if (attribute.toLowerCase() === 'tabindex') {
  3666. element.tabIndex = Number(value);
  3667. } else if (attribute.indexOf('data-') === 0) {
  3668. var dataKey = toCamelCase(attribute.replace(/^data-/, ''));
  3669. element.dataset[dataKey] = value;
  3670. } else {
  3671. dom_1.safeElement.setPrefixedAttribute([safevalues_1.safeAttrPrefix(templateObject_1 || (templateObject_1 = __makeTemplateObject(["aria-"], ["aria-"]))), safevalues_1.safeAttrPrefix(templateObject_2 || (templateObject_2 = __makeTemplateObject(["role"], ["role"])))], element, attribute, value);
  3672. }
  3673. };
  3674. return MDCComponent;
  3675. }();
  3676. exports.MDCComponent = MDCComponent;
  3677. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  3678. exports.default = MDCComponent;
  3679. var templateObject_1, templateObject_2;
  3680. /***/ }),
  3681. /***/ "./packages/mdc-base/foundation.ts":
  3682. /*!*****************************************!*\
  3683. !*** ./packages/mdc-base/foundation.ts ***!
  3684. \*****************************************/
  3685. /*! no static exports found */
  3686. /***/ (function(module, exports, __webpack_require__) {
  3687. "use strict";
  3688. /**
  3689. * @license
  3690. * Copyright 2016 Google Inc.
  3691. *
  3692. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3693. * of this software and associated documentation files (the "Software"), to deal
  3694. * in the Software without restriction, including without limitation the rights
  3695. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3696. * copies of the Software, and to permit persons to whom the Software is
  3697. * furnished to do so, subject to the following conditions:
  3698. *
  3699. * The above copyright notice and this permission notice shall be included in
  3700. * all copies or substantial portions of the Software.
  3701. *
  3702. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3703. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3704. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3705. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3706. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3707. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3708. * THE SOFTWARE.
  3709. */
  3710. Object.defineProperty(exports, "__esModule", { value: true });
  3711. exports.MDCFoundation = void 0;
  3712. /** MDC Foundation */
  3713. var MDCFoundation = /** @class */function () {
  3714. function MDCFoundation(adapter) {
  3715. if (adapter === void 0) {
  3716. adapter = {};
  3717. }
  3718. this.adapter = adapter;
  3719. }
  3720. Object.defineProperty(MDCFoundation, "cssClasses", {
  3721. get: function get() {
  3722. // Classes extending MDCFoundation should implement this method to return an
  3723. // object which exports every CSS class the foundation class needs as a
  3724. // property. e.g. {ACTIVE: 'mdc-component--active'}
  3725. return {};
  3726. },
  3727. enumerable: false,
  3728. configurable: true
  3729. });
  3730. Object.defineProperty(MDCFoundation, "strings", {
  3731. get: function get() {
  3732. // Classes extending MDCFoundation should implement this method to return an
  3733. // object which exports all semantic strings as constants. e.g. {ARIA_ROLE:
  3734. // 'tablist'}
  3735. return {};
  3736. },
  3737. enumerable: false,
  3738. configurable: true
  3739. });
  3740. Object.defineProperty(MDCFoundation, "numbers", {
  3741. get: function get() {
  3742. // Classes extending MDCFoundation should implement this method to return an
  3743. // object which exports all of its semantic numbers as constants.
  3744. // e.g. {ANIMATION_DELAY_MS: 350}
  3745. return {};
  3746. },
  3747. enumerable: false,
  3748. configurable: true
  3749. });
  3750. Object.defineProperty(MDCFoundation, "defaultAdapter", {
  3751. get: function get() {
  3752. // Classes extending MDCFoundation may choose to implement this getter in
  3753. // order to provide a convenient way of viewing the necessary methods of an
  3754. // adapter. In the future, this could also be used for adapter validation.
  3755. return {};
  3756. },
  3757. enumerable: false,
  3758. configurable: true
  3759. });
  3760. MDCFoundation.prototype.init = function () {
  3761. // Subclasses should override this method to perform initialization routines
  3762. // (registering events, etc.)
  3763. };
  3764. MDCFoundation.prototype.destroy = function () {
  3765. // Subclasses should override this method to perform de-initialization
  3766. // routines (de-registering events, etc.)
  3767. };
  3768. return MDCFoundation;
  3769. }();
  3770. exports.MDCFoundation = MDCFoundation;
  3771. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  3772. exports.default = MDCFoundation;
  3773. /***/ }),
  3774. /***/ "./packages/mdc-dom/events.ts":
  3775. /*!************************************!*\
  3776. !*** ./packages/mdc-dom/events.ts ***!
  3777. \************************************/
  3778. /*! no static exports found */
  3779. /***/ (function(module, exports, __webpack_require__) {
  3780. "use strict";
  3781. /**
  3782. * @license
  3783. * Copyright 2019 Google Inc.
  3784. *
  3785. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3786. * of this software and associated documentation files (the "Software"), to deal
  3787. * in the Software without restriction, including without limitation the rights
  3788. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3789. * copies of the Software, and to permit persons to whom the Software is
  3790. * furnished to do so, subject to the following conditions:
  3791. *
  3792. * The above copyright notice and this permission notice shall be included in
  3793. * all copies or substantial portions of the Software.
  3794. *
  3795. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3796. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3797. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3798. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3799. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3800. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3801. * THE SOFTWARE.
  3802. */
  3803. Object.defineProperty(exports, "__esModule", { value: true });
  3804. exports.applyPassive = void 0;
  3805. /**
  3806. * Determine whether the current browser supports passive event listeners, and
  3807. * if so, use them.
  3808. */
  3809. function applyPassive(globalObj) {
  3810. if (globalObj === void 0) {
  3811. globalObj = window;
  3812. }
  3813. return supportsPassiveOption(globalObj) ? { passive: true } : false;
  3814. }
  3815. exports.applyPassive = applyPassive;
  3816. function supportsPassiveOption(globalObj) {
  3817. if (globalObj === void 0) {
  3818. globalObj = window;
  3819. }
  3820. // See
  3821. // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
  3822. var passiveSupported = false;
  3823. try {
  3824. var options = {
  3825. // This function will be called when the browser
  3826. // attempts to access the passive property.
  3827. get passive() {
  3828. passiveSupported = true;
  3829. return false;
  3830. }
  3831. };
  3832. var handler = function handler() {};
  3833. globalObj.document.addEventListener('test', handler, options);
  3834. globalObj.document.removeEventListener('test', handler, options);
  3835. } catch (err) {
  3836. passiveSupported = false;
  3837. }
  3838. return passiveSupported;
  3839. }
  3840. /***/ }),
  3841. /***/ "./packages/mdc-dom/keyboard.ts":
  3842. /*!**************************************!*\
  3843. !*** ./packages/mdc-dom/keyboard.ts ***!
  3844. \**************************************/
  3845. /*! no static exports found */
  3846. /***/ (function(module, exports, __webpack_require__) {
  3847. "use strict";
  3848. /**
  3849. * @license
  3850. * Copyright 2020 Google Inc.
  3851. *
  3852. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3853. * of this software and associated documentation files (the "Software"), to deal
  3854. * in the Software without restriction, including without limitation the rights
  3855. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3856. * copies of the Software, and to permit persons to whom the Software is
  3857. * furnished to do so, subject to the following conditions:
  3858. *
  3859. * The above copyright notice and this permission notice shall be included in
  3860. * all copies or substantial portions of the Software.
  3861. *
  3862. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  3863. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  3864. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  3865. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  3866. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  3867. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  3868. * THE SOFTWARE.
  3869. */
  3870. Object.defineProperty(exports, "__esModule", { value: true });
  3871. exports.isNavigationEvent = exports.normalizeKey = exports.KEY = void 0;
  3872. /**
  3873. * KEY provides normalized string values for keys.
  3874. */
  3875. exports.KEY = {
  3876. UNKNOWN: 'Unknown',
  3877. BACKSPACE: 'Backspace',
  3878. ENTER: 'Enter',
  3879. SPACEBAR: 'Spacebar',
  3880. PAGE_UP: 'PageUp',
  3881. PAGE_DOWN: 'PageDown',
  3882. END: 'End',
  3883. HOME: 'Home',
  3884. ARROW_LEFT: 'ArrowLeft',
  3885. ARROW_UP: 'ArrowUp',
  3886. ARROW_RIGHT: 'ArrowRight',
  3887. ARROW_DOWN: 'ArrowDown',
  3888. DELETE: 'Delete',
  3889. ESCAPE: 'Escape',
  3890. TAB: 'Tab'
  3891. };
  3892. var normalizedKeys = new Set();
  3893. // IE11 has no support for new Map with iterable so we need to initialize this
  3894. // by hand.
  3895. normalizedKeys.add(exports.KEY.BACKSPACE);
  3896. normalizedKeys.add(exports.KEY.ENTER);
  3897. normalizedKeys.add(exports.KEY.SPACEBAR);
  3898. normalizedKeys.add(exports.KEY.PAGE_UP);
  3899. normalizedKeys.add(exports.KEY.PAGE_DOWN);
  3900. normalizedKeys.add(exports.KEY.END);
  3901. normalizedKeys.add(exports.KEY.HOME);
  3902. normalizedKeys.add(exports.KEY.ARROW_LEFT);
  3903. normalizedKeys.add(exports.KEY.ARROW_UP);
  3904. normalizedKeys.add(exports.KEY.ARROW_RIGHT);
  3905. normalizedKeys.add(exports.KEY.ARROW_DOWN);
  3906. normalizedKeys.add(exports.KEY.DELETE);
  3907. normalizedKeys.add(exports.KEY.ESCAPE);
  3908. normalizedKeys.add(exports.KEY.TAB);
  3909. var KEY_CODE = {
  3910. BACKSPACE: 8,
  3911. ENTER: 13,
  3912. SPACEBAR: 32,
  3913. PAGE_UP: 33,
  3914. PAGE_DOWN: 34,
  3915. END: 35,
  3916. HOME: 36,
  3917. ARROW_LEFT: 37,
  3918. ARROW_UP: 38,
  3919. ARROW_RIGHT: 39,
  3920. ARROW_DOWN: 40,
  3921. DELETE: 46,
  3922. ESCAPE: 27,
  3923. TAB: 9
  3924. };
  3925. var mappedKeyCodes = new Map();
  3926. // IE11 has no support for new Map with iterable so we need to initialize this
  3927. // by hand.
  3928. mappedKeyCodes.set(KEY_CODE.BACKSPACE, exports.KEY.BACKSPACE);
  3929. mappedKeyCodes.set(KEY_CODE.ENTER, exports.KEY.ENTER);
  3930. mappedKeyCodes.set(KEY_CODE.SPACEBAR, exports.KEY.SPACEBAR);
  3931. mappedKeyCodes.set(KEY_CODE.PAGE_UP, exports.KEY.PAGE_UP);
  3932. mappedKeyCodes.set(KEY_CODE.PAGE_DOWN, exports.KEY.PAGE_DOWN);
  3933. mappedKeyCodes.set(KEY_CODE.END, exports.KEY.END);
  3934. mappedKeyCodes.set(KEY_CODE.HOME, exports.KEY.HOME);
  3935. mappedKeyCodes.set(KEY_CODE.ARROW_LEFT, exports.KEY.ARROW_LEFT);
  3936. mappedKeyCodes.set(KEY_CODE.ARROW_UP, exports.KEY.ARROW_UP);
  3937. mappedKeyCodes.set(KEY_CODE.ARROW_RIGHT, exports.KEY.ARROW_RIGHT);
  3938. mappedKeyCodes.set(KEY_CODE.ARROW_DOWN, exports.KEY.ARROW_DOWN);
  3939. mappedKeyCodes.set(KEY_CODE.DELETE, exports.KEY.DELETE);
  3940. mappedKeyCodes.set(KEY_CODE.ESCAPE, exports.KEY.ESCAPE);
  3941. mappedKeyCodes.set(KEY_CODE.TAB, exports.KEY.TAB);
  3942. var navigationKeys = new Set();
  3943. // IE11 has no support for new Set with iterable so we need to initialize this
  3944. // by hand.
  3945. navigationKeys.add(exports.KEY.PAGE_UP);
  3946. navigationKeys.add(exports.KEY.PAGE_DOWN);
  3947. navigationKeys.add(exports.KEY.END);
  3948. navigationKeys.add(exports.KEY.HOME);
  3949. navigationKeys.add(exports.KEY.ARROW_LEFT);
  3950. navigationKeys.add(exports.KEY.ARROW_UP);
  3951. navigationKeys.add(exports.KEY.ARROW_RIGHT);
  3952. navigationKeys.add(exports.KEY.ARROW_DOWN);
  3953. /**
  3954. * normalizeKey returns the normalized string for a navigational action.
  3955. */
  3956. function normalizeKey(evt) {
  3957. var key = evt.key;
  3958. // If the event already has a normalized key, return it
  3959. if (normalizedKeys.has(key)) {
  3960. return key;
  3961. }
  3962. // tslint:disable-next-line:deprecation
  3963. var mappedKey = mappedKeyCodes.get(evt.keyCode);
  3964. if (mappedKey) {
  3965. return mappedKey;
  3966. }
  3967. return exports.KEY.UNKNOWN;
  3968. }
  3969. exports.normalizeKey = normalizeKey;
  3970. /**
  3971. * isNavigationEvent returns whether the event is a navigation event
  3972. */
  3973. function isNavigationEvent(evt) {
  3974. return navigationKeys.has(normalizeKey(evt));
  3975. }
  3976. exports.isNavigationEvent = isNavigationEvent;
  3977. /***/ }),
  3978. /***/ "./packages/mdc-dom/ponyfill.ts":
  3979. /*!**************************************!*\
  3980. !*** ./packages/mdc-dom/ponyfill.ts ***!
  3981. \**************************************/
  3982. /*! no static exports found */
  3983. /***/ (function(module, exports, __webpack_require__) {
  3984. "use strict";
  3985. /**
  3986. * @license
  3987. * Copyright 2018 Google Inc.
  3988. *
  3989. * Permission is hereby granted, free of charge, to any person obtaining a copy
  3990. * of this software and associated documentation files (the "Software"), to deal
  3991. * in the Software without restriction, including without limitation the rights
  3992. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  3993. * copies of the Software, and to permit persons to whom the Software is
  3994. * furnished to do so, subject to the following conditions:
  3995. *
  3996. * The above copyright notice and this permission notice shall be included in
  3997. * all copies or substantial portions of the Software.
  3998. *
  3999. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4000. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4001. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4002. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4003. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4004. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4005. * THE SOFTWARE.
  4006. */
  4007. Object.defineProperty(exports, "__esModule", { value: true });
  4008. exports.estimateScrollWidth = exports.matches = exports.closest = void 0;
  4009. /**
  4010. * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global
  4011. * prototype chain. This makes ponyfills safer than traditional polyfills,
  4012. * especially for libraries like MDC.
  4013. */
  4014. function closest(element, selector) {
  4015. if (element.closest) {
  4016. return element.closest(selector);
  4017. }
  4018. var el = element;
  4019. while (el) {
  4020. if (matches(el, selector)) {
  4021. return el;
  4022. }
  4023. el = el.parentElement;
  4024. }
  4025. return null;
  4026. }
  4027. exports.closest = closest;
  4028. /** Element.matches with support for webkit and IE. */
  4029. function matches(element, selector) {
  4030. var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
  4031. return nativeMatches.call(element, selector);
  4032. }
  4033. exports.matches = matches;
  4034. /**
  4035. * Used to compute the estimated scroll width of elements. When an element is
  4036. * hidden due to display: none; being applied to a parent element, the width is
  4037. * returned as 0. However, the element will have a true width once no longer
  4038. * inside a display: none context. This method computes an estimated width when
  4039. * the element is hidden or returns the true width when the element is visble.
  4040. * @param {Element} element the element whose width to estimate
  4041. */
  4042. function estimateScrollWidth(element) {
  4043. // Check the offsetParent. If the element inherits display: none from any
  4044. // parent, the offsetParent property will be null (see
  4045. // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
  4046. // This check ensures we only clone the node when necessary.
  4047. var htmlEl = element;
  4048. if (htmlEl.offsetParent !== null) {
  4049. return htmlEl.scrollWidth;
  4050. }
  4051. var clone = htmlEl.cloneNode(true);
  4052. clone.style.setProperty('position', 'absolute');
  4053. clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
  4054. document.documentElement.appendChild(clone);
  4055. var scrollWidth = clone.scrollWidth;
  4056. document.documentElement.removeChild(clone);
  4057. return scrollWidth;
  4058. }
  4059. exports.estimateScrollWidth = estimateScrollWidth;
  4060. /***/ }),
  4061. /***/ "./packages/mdc-floating-label/component.ts":
  4062. /*!**************************************************!*\
  4063. !*** ./packages/mdc-floating-label/component.ts ***!
  4064. \**************************************************/
  4065. /*! no static exports found */
  4066. /***/ (function(module, exports, __webpack_require__) {
  4067. "use strict";
  4068. /**
  4069. * @license
  4070. * Copyright 2016 Google Inc.
  4071. *
  4072. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4073. * of this software and associated documentation files (the "Software"), to deal
  4074. * in the Software without restriction, including without limitation the rights
  4075. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4076. * copies of the Software, and to permit persons to whom the Software is
  4077. * furnished to do so, subject to the following conditions:
  4078. *
  4079. * The above copyright notice and this permission notice shall be included in
  4080. * all copies or substantial portions of the Software.
  4081. *
  4082. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4083. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4084. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4085. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4086. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4087. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4088. * THE SOFTWARE.
  4089. */
  4090. var __extends = this && this.__extends || function () {
  4091. var _extendStatics = function extendStatics(d, b) {
  4092. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4093. d.__proto__ = b;
  4094. } || function (d, b) {
  4095. for (var p in b) {
  4096. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4097. }
  4098. };
  4099. return _extendStatics(d, b);
  4100. };
  4101. return function (d, b) {
  4102. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4103. _extendStatics(d, b);
  4104. function __() {
  4105. this.constructor = d;
  4106. }
  4107. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4108. };
  4109. }();
  4110. Object.defineProperty(exports, "__esModule", { value: true });
  4111. exports.MDCFloatingLabel = void 0;
  4112. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  4113. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  4114. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts");
  4115. /** MDC Floating Label */
  4116. var MDCFloatingLabel = /** @class */function (_super) {
  4117. __extends(MDCFloatingLabel, _super);
  4118. function MDCFloatingLabel() {
  4119. return _super !== null && _super.apply(this, arguments) || this;
  4120. }
  4121. MDCFloatingLabel.attachTo = function (root) {
  4122. return new MDCFloatingLabel(root);
  4123. };
  4124. /**
  4125. * Styles the label to produce the label shake for errors.
  4126. * @param shouldShake If true, shakes the label by adding a CSS class;
  4127. * otherwise, stops shaking by removing the class.
  4128. */
  4129. MDCFloatingLabel.prototype.shake = function (shouldShake) {
  4130. this.foundation.shake(shouldShake);
  4131. };
  4132. /**
  4133. * Styles the label to float/dock.
  4134. * @param shouldFloat If true, floats the label by adding a CSS class;
  4135. * otherwise, docks it by removing the class.
  4136. */
  4137. MDCFloatingLabel.prototype.float = function (shouldFloat) {
  4138. this.foundation.float(shouldFloat);
  4139. };
  4140. /**
  4141. * Styles the label as required.
  4142. * @param isRequired If true, adds an asterisk to the label, indicating that
  4143. * it is required.
  4144. */
  4145. MDCFloatingLabel.prototype.setRequired = function (isRequired) {
  4146. this.foundation.setRequired(isRequired);
  4147. };
  4148. MDCFloatingLabel.prototype.getWidth = function () {
  4149. return this.foundation.getWidth();
  4150. };
  4151. MDCFloatingLabel.prototype.getDefaultFoundation = function () {
  4152. var _this = this;
  4153. // DO NOT INLINE this variable. For backward compatibility, foundations take
  4154. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  4155. // methods, we need a separate, strongly typed adapter variable.
  4156. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  4157. var adapter = {
  4158. addClass: function addClass(className) {
  4159. _this.root.classList.add(className);
  4160. },
  4161. removeClass: function removeClass(className) {
  4162. _this.root.classList.remove(className);
  4163. },
  4164. hasClass: function hasClass(className) {
  4165. return _this.root.classList.contains(className);
  4166. },
  4167. getWidth: function getWidth() {
  4168. return ponyfill_1.estimateScrollWidth(_this.root);
  4169. },
  4170. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  4171. _this.listen(evtType, handler);
  4172. },
  4173. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  4174. _this.unlisten(evtType, handler);
  4175. }
  4176. };
  4177. // tslint:enable:object-literal-sort-keys
  4178. return new foundation_1.MDCFloatingLabelFoundation(adapter);
  4179. };
  4180. return MDCFloatingLabel;
  4181. }(component_1.MDCComponent);
  4182. exports.MDCFloatingLabel = MDCFloatingLabel;
  4183. /***/ }),
  4184. /***/ "./packages/mdc-floating-label/constants.ts":
  4185. /*!**************************************************!*\
  4186. !*** ./packages/mdc-floating-label/constants.ts ***!
  4187. \**************************************************/
  4188. /*! no static exports found */
  4189. /***/ (function(module, exports, __webpack_require__) {
  4190. "use strict";
  4191. /**
  4192. * @license
  4193. * Copyright 2016 Google Inc.
  4194. *
  4195. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4196. * of this software and associated documentation files (the "Software"), to deal
  4197. * in the Software without restriction, including without limitation the rights
  4198. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4199. * copies of the Software, and to permit persons to whom the Software is
  4200. * furnished to do so, subject to the following conditions:
  4201. *
  4202. * The above copyright notice and this permission notice shall be included in
  4203. * all copies or substantial portions of the Software.
  4204. *
  4205. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4206. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4207. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4208. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4209. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4210. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4211. * THE SOFTWARE.
  4212. */
  4213. Object.defineProperty(exports, "__esModule", { value: true });
  4214. exports.cssClasses = void 0;
  4215. exports.cssClasses = {
  4216. LABEL_FLOAT_ABOVE: 'mdc-floating-label--float-above',
  4217. LABEL_REQUIRED: 'mdc-floating-label--required',
  4218. LABEL_HIDE_REQUIRED_MARKER: 'mdc-floating-label--hide-required-marker',
  4219. LABEL_SHAKE: 'mdc-floating-label--shake',
  4220. ROOT: 'mdc-floating-label'
  4221. };
  4222. /***/ }),
  4223. /***/ "./packages/mdc-floating-label/foundation.ts":
  4224. /*!***************************************************!*\
  4225. !*** ./packages/mdc-floating-label/foundation.ts ***!
  4226. \***************************************************/
  4227. /*! no static exports found */
  4228. /***/ (function(module, exports, __webpack_require__) {
  4229. "use strict";
  4230. /**
  4231. * @license
  4232. * Copyright 2016 Google Inc.
  4233. *
  4234. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4235. * of this software and associated documentation files (the "Software"), to deal
  4236. * in the Software without restriction, including without limitation the rights
  4237. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4238. * copies of the Software, and to permit persons to whom the Software is
  4239. * furnished to do so, subject to the following conditions:
  4240. *
  4241. * The above copyright notice and this permission notice shall be included in
  4242. * all copies or substantial portions of the Software.
  4243. *
  4244. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4245. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4246. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4247. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4248. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4249. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4250. * THE SOFTWARE.
  4251. */
  4252. var __extends = this && this.__extends || function () {
  4253. var _extendStatics = function extendStatics(d, b) {
  4254. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4255. d.__proto__ = b;
  4256. } || function (d, b) {
  4257. for (var p in b) {
  4258. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4259. }
  4260. };
  4261. return _extendStatics(d, b);
  4262. };
  4263. return function (d, b) {
  4264. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4265. _extendStatics(d, b);
  4266. function __() {
  4267. this.constructor = d;
  4268. }
  4269. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4270. };
  4271. }();
  4272. var __assign = this && this.__assign || function () {
  4273. __assign = Object.assign || function (t) {
  4274. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4275. s = arguments[i];
  4276. for (var p in s) {
  4277. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  4278. }
  4279. }
  4280. return t;
  4281. };
  4282. return __assign.apply(this, arguments);
  4283. };
  4284. Object.defineProperty(exports, "__esModule", { value: true });
  4285. exports.MDCFloatingLabelFoundation = void 0;
  4286. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  4287. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts");
  4288. /** MDC Floating Label Foundation */
  4289. var MDCFloatingLabelFoundation = /** @class */function (_super) {
  4290. __extends(MDCFloatingLabelFoundation, _super);
  4291. function MDCFloatingLabelFoundation(adapter) {
  4292. var _this = _super.call(this, __assign(__assign({}, MDCFloatingLabelFoundation.defaultAdapter), adapter)) || this;
  4293. _this.shakeAnimationEndHandler = function () {
  4294. _this.handleShakeAnimationEnd();
  4295. };
  4296. return _this;
  4297. }
  4298. Object.defineProperty(MDCFloatingLabelFoundation, "cssClasses", {
  4299. get: function get() {
  4300. return constants_1.cssClasses;
  4301. },
  4302. enumerable: false,
  4303. configurable: true
  4304. });
  4305. Object.defineProperty(MDCFloatingLabelFoundation, "defaultAdapter", {
  4306. /**
  4307. * See {@link MDCFloatingLabelAdapter} for typing information on parameters
  4308. * and return types.
  4309. */
  4310. get: function get() {
  4311. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  4312. return {
  4313. addClass: function addClass() {
  4314. return undefined;
  4315. },
  4316. removeClass: function removeClass() {
  4317. return undefined;
  4318. },
  4319. hasClass: function hasClass() {
  4320. return false;
  4321. },
  4322. getWidth: function getWidth() {
  4323. return 0;
  4324. },
  4325. registerInteractionHandler: function registerInteractionHandler() {
  4326. return undefined;
  4327. },
  4328. deregisterInteractionHandler: function deregisterInteractionHandler() {
  4329. return undefined;
  4330. }
  4331. };
  4332. // tslint:enable:object-literal-sort-keys
  4333. },
  4334. enumerable: false,
  4335. configurable: true
  4336. });
  4337. MDCFloatingLabelFoundation.prototype.init = function () {
  4338. this.adapter.registerInteractionHandler('animationend', this.shakeAnimationEndHandler);
  4339. };
  4340. MDCFloatingLabelFoundation.prototype.destroy = function () {
  4341. this.adapter.deregisterInteractionHandler('animationend', this.shakeAnimationEndHandler);
  4342. };
  4343. /**
  4344. * Returns the width of the label element.
  4345. */
  4346. MDCFloatingLabelFoundation.prototype.getWidth = function () {
  4347. return this.adapter.getWidth();
  4348. };
  4349. /**
  4350. * Styles the label to produce a shake animation to indicate an error.
  4351. * @param shouldShake If true, adds the shake CSS class; otherwise, removes
  4352. * shake class.
  4353. */
  4354. MDCFloatingLabelFoundation.prototype.shake = function (shouldShake) {
  4355. var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
  4356. if (shouldShake) {
  4357. this.adapter.addClass(LABEL_SHAKE);
  4358. } else {
  4359. this.adapter.removeClass(LABEL_SHAKE);
  4360. }
  4361. };
  4362. /**
  4363. * Styles the label to float or dock.
  4364. * @param shouldFloat If true, adds the float CSS class; otherwise, removes
  4365. * float and shake classes to dock the label.
  4366. */
  4367. MDCFloatingLabelFoundation.prototype.float = function (shouldFloat) {
  4368. var _a = MDCFloatingLabelFoundation.cssClasses,
  4369. LABEL_FLOAT_ABOVE = _a.LABEL_FLOAT_ABOVE,
  4370. LABEL_SHAKE = _a.LABEL_SHAKE;
  4371. if (shouldFloat) {
  4372. this.adapter.addClass(LABEL_FLOAT_ABOVE);
  4373. } else {
  4374. this.adapter.removeClass(LABEL_FLOAT_ABOVE);
  4375. this.adapter.removeClass(LABEL_SHAKE);
  4376. }
  4377. };
  4378. /**
  4379. * Styles the label as required.
  4380. * @param isRequired If true, adds an asterisk to the label, indicating that
  4381. * it is required.
  4382. */
  4383. MDCFloatingLabelFoundation.prototype.setRequired = function (isRequired) {
  4384. var LABEL_REQUIRED = MDCFloatingLabelFoundation.cssClasses.LABEL_REQUIRED;
  4385. if (isRequired) {
  4386. this.adapter.addClass(LABEL_REQUIRED);
  4387. } else {
  4388. this.adapter.removeClass(LABEL_REQUIRED);
  4389. }
  4390. };
  4391. MDCFloatingLabelFoundation.prototype.setHideRequiredMarker = function (hideRequiredMarker) {
  4392. var LABEL_HIDE_REQUIRED_MARKER = MDCFloatingLabelFoundation.cssClasses.LABEL_HIDE_REQUIRED_MARKER;
  4393. if (hideRequiredMarker) {
  4394. this.adapter.addClass(LABEL_HIDE_REQUIRED_MARKER);
  4395. } else {
  4396. this.adapter.removeClass(LABEL_HIDE_REQUIRED_MARKER);
  4397. }
  4398. };
  4399. MDCFloatingLabelFoundation.prototype.getHideRequiredMarker = function () {
  4400. var LABEL_HIDE_REQUIRED_MARKER = MDCFloatingLabelFoundation.cssClasses.LABEL_HIDE_REQUIRED_MARKER;
  4401. return this.adapter.hasClass(LABEL_HIDE_REQUIRED_MARKER);
  4402. };
  4403. MDCFloatingLabelFoundation.prototype.handleShakeAnimationEnd = function () {
  4404. var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
  4405. this.adapter.removeClass(LABEL_SHAKE);
  4406. };
  4407. return MDCFloatingLabelFoundation;
  4408. }(foundation_1.MDCFoundation);
  4409. exports.MDCFloatingLabelFoundation = MDCFloatingLabelFoundation;
  4410. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  4411. exports.default = MDCFloatingLabelFoundation;
  4412. /***/ }),
  4413. /***/ "./packages/mdc-line-ripple/component.ts":
  4414. /*!***********************************************!*\
  4415. !*** ./packages/mdc-line-ripple/component.ts ***!
  4416. \***********************************************/
  4417. /*! no static exports found */
  4418. /***/ (function(module, exports, __webpack_require__) {
  4419. "use strict";
  4420. /**
  4421. * @license
  4422. * Copyright 2018 Google Inc.
  4423. *
  4424. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4425. * of this software and associated documentation files (the "Software"), to deal
  4426. * in the Software without restriction, including without limitation the rights
  4427. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4428. * copies of the Software, and to permit persons to whom the Software is
  4429. * furnished to do so, subject to the following conditions:
  4430. *
  4431. * The above copyright notice and this permission notice shall be included in
  4432. * all copies or substantial portions of the Software.
  4433. *
  4434. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4435. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4436. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4437. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4438. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4439. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4440. * THE SOFTWARE.
  4441. */
  4442. var __extends = this && this.__extends || function () {
  4443. var _extendStatics = function extendStatics(d, b) {
  4444. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4445. d.__proto__ = b;
  4446. } || function (d, b) {
  4447. for (var p in b) {
  4448. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4449. }
  4450. };
  4451. return _extendStatics(d, b);
  4452. };
  4453. return function (d, b) {
  4454. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4455. _extendStatics(d, b);
  4456. function __() {
  4457. this.constructor = d;
  4458. }
  4459. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4460. };
  4461. }();
  4462. Object.defineProperty(exports, "__esModule", { value: true });
  4463. exports.MDCLineRipple = void 0;
  4464. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  4465. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-line-ripple/foundation.ts");
  4466. /** MDC Line Ripple */
  4467. var MDCLineRipple = /** @class */function (_super) {
  4468. __extends(MDCLineRipple, _super);
  4469. function MDCLineRipple() {
  4470. return _super !== null && _super.apply(this, arguments) || this;
  4471. }
  4472. MDCLineRipple.attachTo = function (root) {
  4473. return new MDCLineRipple(root);
  4474. };
  4475. /**
  4476. * Activates the line ripple
  4477. */
  4478. MDCLineRipple.prototype.activate = function () {
  4479. this.foundation.activate();
  4480. };
  4481. /**
  4482. * Deactivates the line ripple
  4483. */
  4484. MDCLineRipple.prototype.deactivate = function () {
  4485. this.foundation.deactivate();
  4486. };
  4487. /**
  4488. * Sets the transform origin given a user's click location.
  4489. * The `rippleCenter` is the x-coordinate of the middle of the ripple.
  4490. */
  4491. MDCLineRipple.prototype.setRippleCenter = function (xCoordinate) {
  4492. this.foundation.setRippleCenter(xCoordinate);
  4493. };
  4494. MDCLineRipple.prototype.getDefaultFoundation = function () {
  4495. var _this = this;
  4496. // DO NOT INLINE this variable. For backward compatibility, foundations take
  4497. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  4498. // methods, we need a separate, strongly typed adapter variable.
  4499. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  4500. var adapter = {
  4501. addClass: function addClass(className) {
  4502. _this.root.classList.add(className);
  4503. },
  4504. removeClass: function removeClass(className) {
  4505. _this.root.classList.remove(className);
  4506. },
  4507. hasClass: function hasClass(className) {
  4508. return _this.root.classList.contains(className);
  4509. },
  4510. setStyle: function setStyle(propertyName, value) {
  4511. _this.root.style.setProperty(propertyName, value);
  4512. },
  4513. registerEventHandler: function registerEventHandler(evtType, handler) {
  4514. _this.listen(evtType, handler);
  4515. },
  4516. deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
  4517. _this.unlisten(evtType, handler);
  4518. }
  4519. };
  4520. // tslint:enable:object-literal-sort-keys
  4521. return new foundation_1.MDCLineRippleFoundation(adapter);
  4522. };
  4523. return MDCLineRipple;
  4524. }(component_1.MDCComponent);
  4525. exports.MDCLineRipple = MDCLineRipple;
  4526. /***/ }),
  4527. /***/ "./packages/mdc-line-ripple/constants.ts":
  4528. /*!***********************************************!*\
  4529. !*** ./packages/mdc-line-ripple/constants.ts ***!
  4530. \***********************************************/
  4531. /*! no static exports found */
  4532. /***/ (function(module, exports, __webpack_require__) {
  4533. "use strict";
  4534. /**
  4535. * @license
  4536. * Copyright 2018 Google Inc.
  4537. *
  4538. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4539. * of this software and associated documentation files (the "Software"), to deal
  4540. * in the Software without restriction, including without limitation the rights
  4541. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4542. * copies of the Software, and to permit persons to whom the Software is
  4543. * furnished to do so, subject to the following conditions:
  4544. *
  4545. * The above copyright notice and this permission notice shall be included in
  4546. * all copies or substantial portions of the Software.
  4547. *
  4548. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4549. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4550. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4551. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4552. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4553. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4554. * THE SOFTWARE.
  4555. */
  4556. Object.defineProperty(exports, "__esModule", { value: true });
  4557. exports.cssClasses = void 0;
  4558. var cssClasses = {
  4559. LINE_RIPPLE_ACTIVE: 'mdc-line-ripple--active',
  4560. LINE_RIPPLE_DEACTIVATING: 'mdc-line-ripple--deactivating'
  4561. };
  4562. exports.cssClasses = cssClasses;
  4563. /***/ }),
  4564. /***/ "./packages/mdc-line-ripple/foundation.ts":
  4565. /*!************************************************!*\
  4566. !*** ./packages/mdc-line-ripple/foundation.ts ***!
  4567. \************************************************/
  4568. /*! no static exports found */
  4569. /***/ (function(module, exports, __webpack_require__) {
  4570. "use strict";
  4571. /**
  4572. * @license
  4573. * Copyright 2018 Google Inc.
  4574. *
  4575. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4576. * of this software and associated documentation files (the "Software"), to deal
  4577. * in the Software without restriction, including without limitation the rights
  4578. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4579. * copies of the Software, and to permit persons to whom the Software is
  4580. * furnished to do so, subject to the following conditions:
  4581. *
  4582. * The above copyright notice and this permission notice shall be included in
  4583. * all copies or substantial portions of the Software.
  4584. *
  4585. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4586. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4587. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4588. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4589. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4590. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4591. * THE SOFTWARE.
  4592. */
  4593. var __extends = this && this.__extends || function () {
  4594. var _extendStatics = function extendStatics(d, b) {
  4595. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4596. d.__proto__ = b;
  4597. } || function (d, b) {
  4598. for (var p in b) {
  4599. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4600. }
  4601. };
  4602. return _extendStatics(d, b);
  4603. };
  4604. return function (d, b) {
  4605. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4606. _extendStatics(d, b);
  4607. function __() {
  4608. this.constructor = d;
  4609. }
  4610. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4611. };
  4612. }();
  4613. var __assign = this && this.__assign || function () {
  4614. __assign = Object.assign || function (t) {
  4615. for (var s, i = 1, n = arguments.length; i < n; i++) {
  4616. s = arguments[i];
  4617. for (var p in s) {
  4618. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  4619. }
  4620. }
  4621. return t;
  4622. };
  4623. return __assign.apply(this, arguments);
  4624. };
  4625. Object.defineProperty(exports, "__esModule", { value: true });
  4626. exports.MDCLineRippleFoundation = void 0;
  4627. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  4628. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-line-ripple/constants.ts");
  4629. /** MDC Line Ripple Foundation */
  4630. var MDCLineRippleFoundation = /** @class */function (_super) {
  4631. __extends(MDCLineRippleFoundation, _super);
  4632. function MDCLineRippleFoundation(adapter) {
  4633. var _this = _super.call(this, __assign(__assign({}, MDCLineRippleFoundation.defaultAdapter), adapter)) || this;
  4634. _this.transitionEndHandler = function (evt) {
  4635. _this.handleTransitionEnd(evt);
  4636. };
  4637. return _this;
  4638. }
  4639. Object.defineProperty(MDCLineRippleFoundation, "cssClasses", {
  4640. get: function get() {
  4641. return constants_1.cssClasses;
  4642. },
  4643. enumerable: false,
  4644. configurable: true
  4645. });
  4646. Object.defineProperty(MDCLineRippleFoundation, "defaultAdapter", {
  4647. /**
  4648. * See {@link MDCLineRippleAdapter} for typing information on parameters and
  4649. * return types.
  4650. */
  4651. get: function get() {
  4652. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  4653. return {
  4654. addClass: function addClass() {
  4655. return undefined;
  4656. },
  4657. removeClass: function removeClass() {
  4658. return undefined;
  4659. },
  4660. hasClass: function hasClass() {
  4661. return false;
  4662. },
  4663. setStyle: function setStyle() {
  4664. return undefined;
  4665. },
  4666. registerEventHandler: function registerEventHandler() {
  4667. return undefined;
  4668. },
  4669. deregisterEventHandler: function deregisterEventHandler() {
  4670. return undefined;
  4671. }
  4672. };
  4673. // tslint:enable:object-literal-sort-keys
  4674. },
  4675. enumerable: false,
  4676. configurable: true
  4677. });
  4678. MDCLineRippleFoundation.prototype.init = function () {
  4679. this.adapter.registerEventHandler('transitionend', this.transitionEndHandler);
  4680. };
  4681. MDCLineRippleFoundation.prototype.destroy = function () {
  4682. this.adapter.deregisterEventHandler('transitionend', this.transitionEndHandler);
  4683. };
  4684. MDCLineRippleFoundation.prototype.activate = function () {
  4685. this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  4686. this.adapter.addClass(constants_1.cssClasses.LINE_RIPPLE_ACTIVE);
  4687. };
  4688. MDCLineRippleFoundation.prototype.setRippleCenter = function (xCoordinate) {
  4689. this.adapter.setStyle('transform-origin', xCoordinate + "px center");
  4690. };
  4691. MDCLineRippleFoundation.prototype.deactivate = function () {
  4692. this.adapter.addClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  4693. };
  4694. MDCLineRippleFoundation.prototype.handleTransitionEnd = function (evt) {
  4695. // Wait for the line ripple to be either transparent or opaque
  4696. // before emitting the animation end event
  4697. var isDeactivating = this.adapter.hasClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  4698. if (evt.propertyName === 'opacity') {
  4699. if (isDeactivating) {
  4700. this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_ACTIVE);
  4701. this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
  4702. }
  4703. }
  4704. };
  4705. return MDCLineRippleFoundation;
  4706. }(foundation_1.MDCFoundation);
  4707. exports.MDCLineRippleFoundation = MDCLineRippleFoundation;
  4708. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  4709. exports.default = MDCLineRippleFoundation;
  4710. /***/ }),
  4711. /***/ "./packages/mdc-list/component.ts":
  4712. /*!****************************************!*\
  4713. !*** ./packages/mdc-list/component.ts ***!
  4714. \****************************************/
  4715. /*! no static exports found */
  4716. /***/ (function(module, exports, __webpack_require__) {
  4717. "use strict";
  4718. /**
  4719. * @license
  4720. * Copyright 2018 Google Inc.
  4721. *
  4722. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4723. * of this software and associated documentation files (the "Software"), to deal
  4724. * in the Software without restriction, including without limitation the rights
  4725. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  4726. * copies of the Software, and to permit persons to whom the Software is
  4727. * furnished to do so, subject to the following conditions:
  4728. *
  4729. * The above copyright notice and this permission notice shall be included in
  4730. * all copies or substantial portions of the Software.
  4731. *
  4732. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  4733. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  4734. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  4735. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  4736. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  4737. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  4738. * THE SOFTWARE.
  4739. */
  4740. var __extends = this && this.__extends || function () {
  4741. var _extendStatics = function extendStatics(d, b) {
  4742. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  4743. d.__proto__ = b;
  4744. } || function (d, b) {
  4745. for (var p in b) {
  4746. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  4747. }
  4748. };
  4749. return _extendStatics(d, b);
  4750. };
  4751. return function (d, b) {
  4752. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  4753. _extendStatics(d, b);
  4754. function __() {
  4755. this.constructor = d;
  4756. }
  4757. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4758. };
  4759. }();
  4760. Object.defineProperty(exports, "__esModule", { value: true });
  4761. exports.MDCList = void 0;
  4762. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  4763. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  4764. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  4765. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-list/foundation.ts");
  4766. /** MDC List */
  4767. var MDCList = /** @class */function (_super) {
  4768. __extends(MDCList, _super);
  4769. function MDCList() {
  4770. return _super !== null && _super.apply(this, arguments) || this;
  4771. }
  4772. Object.defineProperty(MDCList.prototype, "vertical", {
  4773. set: function set(value) {
  4774. this.foundation.setVerticalOrientation(value);
  4775. },
  4776. enumerable: false,
  4777. configurable: true
  4778. });
  4779. Object.defineProperty(MDCList.prototype, "listElements", {
  4780. get: function get() {
  4781. return Array.from(this.root.querySelectorAll("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]));
  4782. },
  4783. enumerable: false,
  4784. configurable: true
  4785. });
  4786. Object.defineProperty(MDCList.prototype, "wrapFocus", {
  4787. set: function set(value) {
  4788. this.foundation.setWrapFocus(value);
  4789. },
  4790. enumerable: false,
  4791. configurable: true
  4792. });
  4793. Object.defineProperty(MDCList.prototype, "typeaheadInProgress", {
  4794. /**
  4795. * @return Whether typeahead is currently matching a user-specified prefix.
  4796. */
  4797. get: function get() {
  4798. return this.foundation.isTypeaheadInProgress();
  4799. },
  4800. enumerable: false,
  4801. configurable: true
  4802. });
  4803. Object.defineProperty(MDCList.prototype, "hasTypeahead", {
  4804. /**
  4805. * Sets whether typeahead functionality is enabled on the list.
  4806. * @param hasTypeahead Whether typeahead is enabled.
  4807. */
  4808. set: function set(hasTypeahead) {
  4809. this.foundation.setHasTypeahead(hasTypeahead);
  4810. },
  4811. enumerable: false,
  4812. configurable: true
  4813. });
  4814. Object.defineProperty(MDCList.prototype, "singleSelection", {
  4815. set: function set(isSingleSelectionList) {
  4816. this.foundation.setSingleSelection(isSingleSelectionList);
  4817. },
  4818. enumerable: false,
  4819. configurable: true
  4820. });
  4821. Object.defineProperty(MDCList.prototype, "disabledItemsFocusable", {
  4822. set: function set(areDisabledItemsFocusable) {
  4823. this.foundation.setDisabledItemsFocusable(areDisabledItemsFocusable);
  4824. },
  4825. enumerable: false,
  4826. configurable: true
  4827. });
  4828. Object.defineProperty(MDCList.prototype, "selectedIndex", {
  4829. get: function get() {
  4830. return this.foundation.getSelectedIndex();
  4831. },
  4832. set: function set(index) {
  4833. this.foundation.setSelectedIndex(index);
  4834. },
  4835. enumerable: false,
  4836. configurable: true
  4837. });
  4838. MDCList.attachTo = function (root) {
  4839. return new MDCList(root);
  4840. };
  4841. MDCList.prototype.initialSyncWithDOM = function () {
  4842. this.isEvolutionEnabled = constants_1.evolutionAttribute in this.root.dataset;
  4843. if (this.isEvolutionEnabled) {
  4844. this.classNameMap = constants_1.evolutionClassNameMap;
  4845. } else if (ponyfill_1.matches(this.root, constants_1.strings.DEPRECATED_SELECTOR)) {
  4846. this.classNameMap = constants_1.deprecatedClassNameMap;
  4847. } else {
  4848. this.classNameMap = Object.values(constants_1.cssClasses).reduce(function (obj, className) {
  4849. obj[className] = className;
  4850. return obj;
  4851. }, {});
  4852. }
  4853. this.handleClick = this.handleClickEvent.bind(this);
  4854. this.handleKeydown = this.handleKeydownEvent.bind(this);
  4855. this.focusInEventListener = this.handleFocusInEvent.bind(this);
  4856. this.focusOutEventListener = this.handleFocusOutEvent.bind(this);
  4857. this.listen('keydown', this.handleKeydown);
  4858. this.listen('click', this.handleClick);
  4859. this.listen('focusin', this.focusInEventListener);
  4860. this.listen('focusout', this.focusOutEventListener);
  4861. this.layout();
  4862. this.initializeListType();
  4863. this.ensureFocusable();
  4864. };
  4865. MDCList.prototype.destroy = function () {
  4866. this.unlisten('keydown', this.handleKeydown);
  4867. this.unlisten('click', this.handleClick);
  4868. this.unlisten('focusin', this.focusInEventListener);
  4869. this.unlisten('focusout', this.focusOutEventListener);
  4870. };
  4871. MDCList.prototype.layout = function () {
  4872. var direction = this.root.getAttribute(constants_1.strings.ARIA_ORIENTATION);
  4873. this.vertical = direction !== constants_1.strings.ARIA_ORIENTATION_HORIZONTAL;
  4874. var itemSelector = "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not([tabindex])";
  4875. var childSelector = constants_1.strings.FOCUSABLE_CHILD_ELEMENTS;
  4876. // List items need to have at least tabindex=-1 to be focusable.
  4877. var itemEls = this.root.querySelectorAll(itemSelector);
  4878. if (itemEls.length) {
  4879. Array.prototype.forEach.call(itemEls, function (el) {
  4880. el.setAttribute('tabindex', '-1');
  4881. });
  4882. }
  4883. // Child button/a elements are not tabbable until the list item is focused.
  4884. var focusableChildEls = this.root.querySelectorAll(childSelector);
  4885. if (focusableChildEls.length) {
  4886. Array.prototype.forEach.call(focusableChildEls, function (el) {
  4887. el.setAttribute('tabindex', '-1');
  4888. });
  4889. }
  4890. if (this.isEvolutionEnabled) {
  4891. this.foundation.setUseSelectedAttribute(true);
  4892. }
  4893. this.foundation.layout();
  4894. };
  4895. /**
  4896. * Extracts the primary text from a list item.
  4897. * @param item The list item element.
  4898. * @return The primary text in the element.
  4899. */
  4900. MDCList.prototype.getPrimaryText = function (item) {
  4901. var _a;
  4902. var primaryText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS]);
  4903. if (this.isEvolutionEnabled || primaryText) {
  4904. return (_a = primaryText === null || primaryText === void 0 ? void 0 : primaryText.textContent) !== null && _a !== void 0 ? _a : '';
  4905. }
  4906. var singleLineText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_TEXT_CLASS]);
  4907. return singleLineText && singleLineText.textContent || '';
  4908. };
  4909. /**
  4910. * Initialize selectedIndex value based on pre-selected list items.
  4911. */
  4912. MDCList.prototype.initializeListType = function () {
  4913. var _this = this;
  4914. this.isInteractive = ponyfill_1.matches(this.root, constants_1.strings.ARIA_INTERACTIVE_ROLES_SELECTOR);
  4915. if (this.isEvolutionEnabled && this.isInteractive) {
  4916. var selection = Array.from(this.root.querySelectorAll(constants_1.strings.SELECTED_ITEM_SELECTOR), function (listItem) {
  4917. return _this.listElements.indexOf(listItem);
  4918. });
  4919. if (ponyfill_1.matches(this.root, constants_1.strings.ARIA_MULTI_SELECTABLE_SELECTOR)) {
  4920. this.selectedIndex = selection;
  4921. } else if (selection.length > 0) {
  4922. this.selectedIndex = selection[0];
  4923. }
  4924. return;
  4925. }
  4926. var checkboxListItems = this.root.querySelectorAll(constants_1.strings.ARIA_ROLE_CHECKBOX_SELECTOR);
  4927. var radioSelectedListItem = this.root.querySelector(constants_1.strings.ARIA_CHECKED_RADIO_SELECTOR);
  4928. if (checkboxListItems.length) {
  4929. var preselectedItems = this.root.querySelectorAll(constants_1.strings.ARIA_CHECKED_CHECKBOX_SELECTOR);
  4930. this.selectedIndex = Array.from(preselectedItems, function (listItem) {
  4931. return _this.listElements.indexOf(listItem);
  4932. });
  4933. } else if (radioSelectedListItem) {
  4934. this.selectedIndex = this.listElements.indexOf(radioSelectedListItem);
  4935. }
  4936. };
  4937. /**
  4938. * Updates the list item at itemIndex to the desired isEnabled state.
  4939. * @param itemIndex Index of the list item
  4940. * @param isEnabled Sets the list item to enabled or disabled.
  4941. */
  4942. MDCList.prototype.setEnabled = function (itemIndex, isEnabled) {
  4943. this.foundation.setEnabled(itemIndex, isEnabled);
  4944. };
  4945. /**
  4946. * Given the next desired character from the user, adds it to the typeahead
  4947. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  4948. * around if at the end of options.
  4949. *
  4950. * @param nextChar The next character to add to the prefix buffer.
  4951. * @param startingIndex The index from which to start matching. Defaults to
  4952. * the currently focused index.
  4953. * @return The index of the matched item.
  4954. */
  4955. MDCList.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
  4956. return this.foundation.typeaheadMatchItem(nextChar, startingIndex, /** skipFocus */true);
  4957. };
  4958. MDCList.prototype.getDefaultFoundation = function () {
  4959. var _this = this;
  4960. // DO NOT INLINE this variable. For backward compatibility, foundations take
  4961. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  4962. // methods, we need a separate, strongly typed adapter variable.
  4963. var adapter = {
  4964. addClassForElementIndex: function addClassForElementIndex(index, className) {
  4965. var element = _this.listElements[index];
  4966. if (element) {
  4967. element.classList.add(_this.classNameMap[className]);
  4968. }
  4969. },
  4970. focusItemAtIndex: function focusItemAtIndex(index) {
  4971. var _a;
  4972. (_a = _this.listElements[index]) === null || _a === void 0 ? void 0 : _a.focus();
  4973. },
  4974. getAttributeForElementIndex: function getAttributeForElementIndex(index, attr) {
  4975. return _this.listElements[index].getAttribute(attr);
  4976. },
  4977. getFocusedElementIndex: function getFocusedElementIndex() {
  4978. return _this.listElements.indexOf(document.activeElement);
  4979. },
  4980. getListItemCount: function getListItemCount() {
  4981. return _this.listElements.length;
  4982. },
  4983. getPrimaryTextAtIndex: function getPrimaryTextAtIndex(index) {
  4984. return _this.getPrimaryText(_this.listElements[index]);
  4985. },
  4986. hasCheckboxAtIndex: function hasCheckboxAtIndex(index) {
  4987. var listItem = _this.listElements[index];
  4988. return !!listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
  4989. },
  4990. hasRadioAtIndex: function hasRadioAtIndex(index) {
  4991. var listItem = _this.listElements[index];
  4992. return !!listItem.querySelector(constants_1.strings.RADIO_SELECTOR);
  4993. },
  4994. isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex(index) {
  4995. var listItem = _this.listElements[index];
  4996. var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
  4997. return toggleEl.checked;
  4998. },
  4999. isFocusInsideList: function isFocusInsideList() {
  5000. return _this.root !== document.activeElement && _this.root.contains(document.activeElement);
  5001. },
  5002. isRootFocused: function isRootFocused() {
  5003. return document.activeElement === _this.root;
  5004. },
  5005. listItemAtIndexHasClass: function listItemAtIndexHasClass(index, className) {
  5006. return _this.listElements[index].classList.contains(_this.classNameMap[className]);
  5007. },
  5008. notifyAction: function notifyAction(index) {
  5009. _this.emit(constants_1.strings.ACTION_EVENT, { index: index }, /** shouldBubble */true);
  5010. },
  5011. notifySelectionChange: function notifySelectionChange(changedIndices) {
  5012. _this.emit(constants_1.strings.SELECTION_CHANGE_EVENT, { changedIndices: changedIndices },
  5013. /** shouldBubble */true);
  5014. },
  5015. removeClassForElementIndex: function removeClassForElementIndex(index, className) {
  5016. var element = _this.listElements[index];
  5017. if (element) {
  5018. element.classList.remove(_this.classNameMap[className]);
  5019. }
  5020. },
  5021. setAttributeForElementIndex: function setAttributeForElementIndex(index, attr, value) {
  5022. var element = _this.listElements[index];
  5023. if (element) {
  5024. _this.safeSetAttribute(element, attr, value);
  5025. }
  5026. },
  5027. setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex(index, isChecked) {
  5028. var listItem = _this.listElements[index];
  5029. var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_RADIO_SELECTOR);
  5030. toggleEl.checked = isChecked;
  5031. var event = document.createEvent('Event');
  5032. event.initEvent('change', true, true);
  5033. toggleEl.dispatchEvent(event);
  5034. },
  5035. setTabIndexForListItemChildren: function setTabIndexForListItemChildren(listItemIndex, tabIndexValue) {
  5036. var element = _this.listElements[listItemIndex];
  5037. var selector = constants_1.strings.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX;
  5038. Array.prototype.forEach.call(element.querySelectorAll(selector), function (el) {
  5039. el.tabIndex = Number(tabIndexValue);
  5040. });
  5041. }
  5042. };
  5043. return new foundation_1.MDCListFoundation(adapter);
  5044. };
  5045. /**
  5046. * Ensures that at least one item is focusable if the list is interactive and
  5047. * doesn't specify a suitable tabindex.
  5048. */
  5049. MDCList.prototype.ensureFocusable = function () {
  5050. if (this.isEvolutionEnabled && this.isInteractive) {
  5051. if (!this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + "[tabindex=\"0\"]")) {
  5052. var index = this.initialFocusIndex();
  5053. if (index !== -1) {
  5054. this.listElements[index].tabIndex = 0;
  5055. }
  5056. }
  5057. }
  5058. };
  5059. MDCList.prototype.initialFocusIndex = function () {
  5060. if (this.selectedIndex instanceof Array && this.selectedIndex.length > 0) {
  5061. return this.selectedIndex[0];
  5062. }
  5063. if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  5064. return this.selectedIndex;
  5065. }
  5066. var el = this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not(." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS] + ")");
  5067. if (el === null) {
  5068. return -1;
  5069. }
  5070. return this.getListItemIndex(el);
  5071. };
  5072. /**
  5073. * Used to figure out which list item this event is targeting. Or returns -1
  5074. * if there is no list item
  5075. */
  5076. MDCList.prototype.getListItemIndex = function (el) {
  5077. var nearestParent = ponyfill_1.closest(el, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ", ." + this.classNameMap[constants_1.cssClasses.ROOT]);
  5078. // Get the index of the element if it is a list item.
  5079. if (nearestParent && ponyfill_1.matches(nearestParent, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS])) {
  5080. return this.listElements.indexOf(nearestParent);
  5081. }
  5082. return -1;
  5083. };
  5084. /**
  5085. * Used to figure out which element was clicked before sending the event to
  5086. * the foundation.
  5087. */
  5088. MDCList.prototype.handleFocusInEvent = function (evt) {
  5089. var index = this.getListItemIndex(evt.target);
  5090. this.foundation.handleFocusIn(index);
  5091. };
  5092. /**
  5093. * Used to figure out which element was clicked before sending the event to
  5094. * the foundation.
  5095. */
  5096. MDCList.prototype.handleFocusOutEvent = function (evt) {
  5097. var index = this.getListItemIndex(evt.target);
  5098. this.foundation.handleFocusOut(index);
  5099. };
  5100. /**
  5101. * Used to figure out which element was focused when keydown event occurred
  5102. * before sending the event to the foundation.
  5103. */
  5104. MDCList.prototype.handleKeydownEvent = function (evt) {
  5105. var index = this.getListItemIndex(evt.target);
  5106. var target = evt.target;
  5107. this.foundation.handleKeydown(evt, target.classList.contains(this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]), index);
  5108. };
  5109. /**
  5110. * Used to figure out which element was clicked before sending the event to
  5111. * the foundation.
  5112. */
  5113. MDCList.prototype.handleClickEvent = function (evt) {
  5114. var index = this.getListItemIndex(evt.target);
  5115. var target = evt.target;
  5116. this.foundation.handleClick(index, ponyfill_1.matches(target, constants_1.strings.CHECKBOX_RADIO_SELECTOR), evt);
  5117. };
  5118. return MDCList;
  5119. }(component_1.MDCComponent);
  5120. exports.MDCList = MDCList;
  5121. /***/ }),
  5122. /***/ "./packages/mdc-list/constants.ts":
  5123. /*!****************************************!*\
  5124. !*** ./packages/mdc-list/constants.ts ***!
  5125. \****************************************/
  5126. /*! no static exports found */
  5127. /***/ (function(module, exports, __webpack_require__) {
  5128. "use strict";
  5129. /**
  5130. * @license
  5131. * Copyright 2018 Google Inc.
  5132. *
  5133. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5134. * of this software and associated documentation files (the "Software"), to deal
  5135. * in the Software without restriction, including without limitation the rights
  5136. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5137. * copies of the Software, and to permit persons to whom the Software is
  5138. * furnished to do so, subject to the following conditions:
  5139. *
  5140. * The above copyright notice and this permission notice shall be included in
  5141. * all copies or substantial portions of the Software.
  5142. *
  5143. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5144. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5145. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5146. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5147. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5148. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5149. * THE SOFTWARE.
  5150. */
  5151. var _a, _b;
  5152. Object.defineProperty(exports, "__esModule", { value: true });
  5153. exports.evolutionClassNameMap = exports.evolutionAttribute = exports.deprecatedClassNameMap = exports.numbers = exports.cssClasses = exports.strings = void 0;
  5154. var cssClasses = {
  5155. LIST_ITEM_ACTIVATED_CLASS: 'mdc-list-item--activated',
  5156. LIST_ITEM_CLASS: 'mdc-list-item',
  5157. LIST_ITEM_DISABLED_CLASS: 'mdc-list-item--disabled',
  5158. LIST_ITEM_SELECTED_CLASS: 'mdc-list-item--selected',
  5159. LIST_ITEM_TEXT_CLASS: 'mdc-list-item__text',
  5160. LIST_ITEM_PRIMARY_TEXT_CLASS: 'mdc-list-item__primary-text',
  5161. ROOT: 'mdc-list'
  5162. };
  5163. exports.cssClasses = cssClasses;
  5164. var evolutionClassNameMap = (_a = {}, _a["" + cssClasses.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-list-item--activated', _a["" + cssClasses.LIST_ITEM_CLASS] = 'mdc-list-item', _a["" + cssClasses.LIST_ITEM_DISABLED_CLASS] = 'mdc-list-item--disabled', _a["" + cssClasses.LIST_ITEM_SELECTED_CLASS] = 'mdc-list-item--selected', _a["" + cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-list-item__primary-text', _a["" + cssClasses.ROOT] = 'mdc-list', _a);
  5165. exports.evolutionClassNameMap = evolutionClassNameMap;
  5166. var deprecatedClassNameMap = (_b = {}, _b["" + cssClasses.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-deprecated-list-item--activated', _b["" + cssClasses.LIST_ITEM_CLASS] = 'mdc-deprecated-list-item', _b["" + cssClasses.LIST_ITEM_DISABLED_CLASS] = 'mdc-deprecated-list-item--disabled', _b["" + cssClasses.LIST_ITEM_SELECTED_CLASS] = 'mdc-deprecated-list-item--selected', _b["" + cssClasses.LIST_ITEM_TEXT_CLASS] = 'mdc-deprecated-list-item__text', _b["" + cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-deprecated-list-item__primary-text', _b["" + cssClasses.ROOT] = 'mdc-deprecated-list', _b);
  5167. exports.deprecatedClassNameMap = deprecatedClassNameMap;
  5168. var strings = {
  5169. ACTION_EVENT: 'MDCList:action',
  5170. SELECTION_CHANGE_EVENT: 'MDCList:selectionChange',
  5171. ARIA_CHECKED: 'aria-checked',
  5172. ARIA_CHECKED_CHECKBOX_SELECTOR: '[role="checkbox"][aria-checked="true"]',
  5173. ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]',
  5174. ARIA_CURRENT: 'aria-current',
  5175. ARIA_DISABLED: 'aria-disabled',
  5176. ARIA_ORIENTATION: 'aria-orientation',
  5177. ARIA_ORIENTATION_HORIZONTAL: 'horizontal',
  5178. ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]',
  5179. ARIA_SELECTED: 'aria-selected',
  5180. ARIA_INTERACTIVE_ROLES_SELECTOR: '[role="listbox"], [role="menu"]',
  5181. ARIA_MULTI_SELECTABLE_SELECTOR: '[aria-multiselectable="true"]',
  5182. CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"], input[type="radio"]',
  5183. CHECKBOX_SELECTOR: 'input[type="checkbox"]',
  5184. CHILD_ELEMENTS_TO_TOGGLE_TABINDEX: "\n ." + cssClasses.LIST_ITEM_CLASS + " button:not(:disabled),\n ." + cssClasses.LIST_ITEM_CLASS + " a,\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " button:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " a\n ",
  5185. DEPRECATED_SELECTOR: '.mdc-deprecated-list',
  5186. FOCUSABLE_CHILD_ELEMENTS: "\n ." + cssClasses.LIST_ITEM_CLASS + " button:not(:disabled),\n ." + cssClasses.LIST_ITEM_CLASS + " a,\n ." + cssClasses.LIST_ITEM_CLASS + " input[type=\"radio\"]:not(:disabled),\n ." + cssClasses.LIST_ITEM_CLASS + " input[type=\"checkbox\"]:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " button:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " a,\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " input[type=\"radio\"]:not(:disabled),\n ." + deprecatedClassNameMap[cssClasses.LIST_ITEM_CLASS] + " input[type=\"checkbox\"]:not(:disabled)\n ",
  5187. RADIO_SELECTOR: 'input[type="radio"]',
  5188. SELECTED_ITEM_SELECTOR: '[aria-selected="true"], [aria-current="true"]'
  5189. };
  5190. exports.strings = strings;
  5191. var numbers = {
  5192. UNSET_INDEX: -1,
  5193. TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS: 300
  5194. };
  5195. exports.numbers = numbers;
  5196. var evolutionAttribute = 'evolution';
  5197. exports.evolutionAttribute = evolutionAttribute;
  5198. /***/ }),
  5199. /***/ "./packages/mdc-list/events.ts":
  5200. /*!*************************************!*\
  5201. !*** ./packages/mdc-list/events.ts ***!
  5202. \*************************************/
  5203. /*! no static exports found */
  5204. /***/ (function(module, exports, __webpack_require__) {
  5205. "use strict";
  5206. /**
  5207. * @license
  5208. * Copyright 2020 Google Inc.
  5209. *
  5210. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5211. * of this software and associated documentation files (the "Software"), to deal
  5212. * in the Software without restriction, including without limitation the rights
  5213. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5214. * copies of the Software, and to permit persons to whom the Software is
  5215. * furnished to do so, subject to the following conditions:
  5216. *
  5217. * The above copyright notice and this permission notice shall be included in
  5218. * all copies or substantial portions of the Software.
  5219. *
  5220. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5221. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5222. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5223. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5224. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5225. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5226. * THE SOFTWARE.
  5227. */
  5228. Object.defineProperty(exports, "__esModule", { value: true });
  5229. exports.preventDefaultEvent = void 0;
  5230. var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select'];
  5231. /**
  5232. * Ensures that preventDefault is only called if the containing element
  5233. * doesn't consume the event, and it will cause an unintended scroll.
  5234. *
  5235. * @param evt keyboard event to be prevented.
  5236. */
  5237. var preventDefaultEvent = function preventDefaultEvent(evt) {
  5238. var target = evt.target;
  5239. if (!target) {
  5240. return;
  5241. }
  5242. var tagName = ("" + target.tagName).toLowerCase();
  5243. if (ELEMENTS_KEY_ALLOWED_IN.indexOf(tagName) === -1) {
  5244. evt.preventDefault();
  5245. }
  5246. };
  5247. exports.preventDefaultEvent = preventDefaultEvent;
  5248. /***/ }),
  5249. /***/ "./packages/mdc-list/foundation.ts":
  5250. /*!*****************************************!*\
  5251. !*** ./packages/mdc-list/foundation.ts ***!
  5252. \*****************************************/
  5253. /*! no static exports found */
  5254. /***/ (function(module, exports, __webpack_require__) {
  5255. "use strict";
  5256. /**
  5257. * @license
  5258. * Copyright 2018 Google Inc.
  5259. *
  5260. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5261. * of this software and associated documentation files (the "Software"), to deal
  5262. * in the Software without restriction, including without limitation the rights
  5263. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  5264. * copies of the Software, and to permit persons to whom the Software is
  5265. * furnished to do so, subject to the following conditions:
  5266. *
  5267. * The above copyright notice and this permission notice shall be included in
  5268. * all copies or substantial portions of the Software.
  5269. *
  5270. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  5271. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  5272. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  5273. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  5274. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  5275. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  5276. * THE SOFTWARE.
  5277. */
  5278. var __extends = this && this.__extends || function () {
  5279. var _extendStatics = function extendStatics(d, b) {
  5280. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  5281. d.__proto__ = b;
  5282. } || function (d, b) {
  5283. for (var p in b) {
  5284. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  5285. }
  5286. };
  5287. return _extendStatics(d, b);
  5288. };
  5289. return function (d, b) {
  5290. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  5291. _extendStatics(d, b);
  5292. function __() {
  5293. this.constructor = d;
  5294. }
  5295. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5296. };
  5297. }();
  5298. var __assign = this && this.__assign || function () {
  5299. __assign = Object.assign || function (t) {
  5300. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5301. s = arguments[i];
  5302. for (var p in s) {
  5303. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  5304. }
  5305. }
  5306. return t;
  5307. };
  5308. return __assign.apply(this, arguments);
  5309. };
  5310. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  5311. if (k2 === undefined) k2 = k;
  5312. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  5313. return m[k];
  5314. } });
  5315. } : function (o, m, k, k2) {
  5316. if (k2 === undefined) k2 = k;
  5317. o[k2] = m[k];
  5318. });
  5319. var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
  5320. Object.defineProperty(o, "default", { enumerable: true, value: v });
  5321. } : function (o, v) {
  5322. o["default"] = v;
  5323. });
  5324. var __importStar = this && this.__importStar || function (mod) {
  5325. if (mod && mod.__esModule) return mod;
  5326. var result = {};
  5327. if (mod != null) for (var k in mod) {
  5328. if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  5329. }__setModuleDefault(result, mod);
  5330. return result;
  5331. };
  5332. var __read = this && this.__read || function (o, n) {
  5333. var m = typeof Symbol === "function" && o[Symbol.iterator];
  5334. if (!m) return o;
  5335. var i = m.call(o),
  5336. r,
  5337. ar = [],
  5338. e;
  5339. try {
  5340. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  5341. ar.push(r.value);
  5342. }
  5343. } catch (error) {
  5344. e = { error: error };
  5345. } finally {
  5346. try {
  5347. if (r && !r.done && (m = i["return"])) m.call(i);
  5348. } finally {
  5349. if (e) throw e.error;
  5350. }
  5351. }
  5352. return ar;
  5353. };
  5354. var __spreadArray = this && this.__spreadArray || function (to, from) {
  5355. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
  5356. to[j] = from[i];
  5357. }return to;
  5358. };
  5359. var __values = this && this.__values || function (o) {
  5360. var s = typeof Symbol === "function" && Symbol.iterator,
  5361. m = s && o[s],
  5362. i = 0;
  5363. if (m) return m.call(o);
  5364. if (o && typeof o.length === "number") return {
  5365. next: function next() {
  5366. if (o && i >= o.length) o = void 0;
  5367. return { value: o && o[i++], done: !o };
  5368. }
  5369. };
  5370. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  5371. };
  5372. Object.defineProperty(exports, "__esModule", { value: true });
  5373. exports.MDCListFoundation = void 0;
  5374. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  5375. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  5376. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  5377. var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
  5378. var typeahead = __importStar(__webpack_require__(/*! ./typeahead */ "./packages/mdc-list/typeahead.ts"));
  5379. function isNumberArray(selectedIndex) {
  5380. return selectedIndex instanceof Array;
  5381. }
  5382. /** List of modifier keys to consider while handling keyboard events. */
  5383. var handledModifierKeys = ['Alt', 'Control', 'Meta', 'Shift'];
  5384. /** Checks if the event has the given modifier keys. */
  5385. function createModifierChecker(event) {
  5386. var eventModifiers = new Set(event ? handledModifierKeys.filter(function (m) {
  5387. return event.getModifierState(m);
  5388. }) : []);
  5389. return function (modifiers) {
  5390. return modifiers.every(function (m) {
  5391. return eventModifiers.has(m);
  5392. }) && modifiers.length === eventModifiers.size;
  5393. };
  5394. }
  5395. /** MDC List Foundation */
  5396. var MDCListFoundation = /** @class */function (_super) {
  5397. __extends(MDCListFoundation, _super);
  5398. function MDCListFoundation(adapter) {
  5399. var _this = _super.call(this, __assign(__assign({}, MDCListFoundation.defaultAdapter), adapter)) || this;
  5400. _this.wrapFocus = false;
  5401. _this.isVertical = true;
  5402. _this.isSingleSelectionList = false;
  5403. _this.areDisabledItemsFocusable = false;
  5404. _this.selectedIndex = constants_1.numbers.UNSET_INDEX;
  5405. _this.focusedItemIndex = constants_1.numbers.UNSET_INDEX;
  5406. _this.useActivatedClass = false;
  5407. _this.useSelectedAttr = false;
  5408. _this.ariaCurrentAttrValue = null;
  5409. _this.isCheckboxList = false;
  5410. _this.isRadioList = false;
  5411. _this.lastSelectedIndex = null;
  5412. _this.hasTypeahead = false;
  5413. // Transiently holds current typeahead prefix from user.
  5414. _this.typeaheadState = typeahead.initState();
  5415. _this.sortedIndexByFirstChar = new Map();
  5416. return _this;
  5417. }
  5418. Object.defineProperty(MDCListFoundation, "strings", {
  5419. get: function get() {
  5420. return constants_1.strings;
  5421. },
  5422. enumerable: false,
  5423. configurable: true
  5424. });
  5425. Object.defineProperty(MDCListFoundation, "cssClasses", {
  5426. get: function get() {
  5427. return constants_1.cssClasses;
  5428. },
  5429. enumerable: false,
  5430. configurable: true
  5431. });
  5432. Object.defineProperty(MDCListFoundation, "numbers", {
  5433. get: function get() {
  5434. return constants_1.numbers;
  5435. },
  5436. enumerable: false,
  5437. configurable: true
  5438. });
  5439. Object.defineProperty(MDCListFoundation, "defaultAdapter", {
  5440. get: function get() {
  5441. return {
  5442. addClassForElementIndex: function addClassForElementIndex() {
  5443. return undefined;
  5444. },
  5445. focusItemAtIndex: function focusItemAtIndex() {
  5446. return undefined;
  5447. },
  5448. getAttributeForElementIndex: function getAttributeForElementIndex() {
  5449. return null;
  5450. },
  5451. getFocusedElementIndex: function getFocusedElementIndex() {
  5452. return 0;
  5453. },
  5454. getListItemCount: function getListItemCount() {
  5455. return 0;
  5456. },
  5457. hasCheckboxAtIndex: function hasCheckboxAtIndex() {
  5458. return false;
  5459. },
  5460. hasRadioAtIndex: function hasRadioAtIndex() {
  5461. return false;
  5462. },
  5463. isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex() {
  5464. return false;
  5465. },
  5466. isFocusInsideList: function isFocusInsideList() {
  5467. return false;
  5468. },
  5469. isRootFocused: function isRootFocused() {
  5470. return false;
  5471. },
  5472. listItemAtIndexHasClass: function listItemAtIndexHasClass() {
  5473. return false;
  5474. },
  5475. notifyAction: function notifyAction() {
  5476. return undefined;
  5477. },
  5478. notifySelectionChange: function notifySelectionChange() {},
  5479. removeClassForElementIndex: function removeClassForElementIndex() {
  5480. return undefined;
  5481. },
  5482. setAttributeForElementIndex: function setAttributeForElementIndex() {
  5483. return undefined;
  5484. },
  5485. setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex() {
  5486. return undefined;
  5487. },
  5488. setTabIndexForListItemChildren: function setTabIndexForListItemChildren() {
  5489. return undefined;
  5490. },
  5491. getPrimaryTextAtIndex: function getPrimaryTextAtIndex() {
  5492. return '';
  5493. }
  5494. };
  5495. },
  5496. enumerable: false,
  5497. configurable: true
  5498. });
  5499. MDCListFoundation.prototype.layout = function () {
  5500. if (this.adapter.getListItemCount() === 0) {
  5501. return;
  5502. }
  5503. // TODO(b/172274142): consider all items when determining the list's type.
  5504. if (this.adapter.hasCheckboxAtIndex(0)) {
  5505. this.isCheckboxList = true;
  5506. this.selectedIndex = [];
  5507. } else if (this.adapter.hasRadioAtIndex(0)) {
  5508. this.isRadioList = true;
  5509. } else {
  5510. this.maybeInitializeSingleSelection();
  5511. }
  5512. if (this.hasTypeahead) {
  5513. this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
  5514. }
  5515. };
  5516. /** Returns the index of the item that was last focused. */
  5517. MDCListFoundation.prototype.getFocusedItemIndex = function () {
  5518. return this.focusedItemIndex;
  5519. };
  5520. /** Toggles focus wrapping with keyboard navigation. */
  5521. MDCListFoundation.prototype.setWrapFocus = function (value) {
  5522. this.wrapFocus = value;
  5523. };
  5524. /**
  5525. * Toggles orientation direction for keyboard navigation (true for vertical,
  5526. * false for horizontal).
  5527. */
  5528. MDCListFoundation.prototype.setVerticalOrientation = function (value) {
  5529. this.isVertical = value;
  5530. };
  5531. /** Toggles single-selection behavior. */
  5532. MDCListFoundation.prototype.setSingleSelection = function (value) {
  5533. this.isSingleSelectionList = value;
  5534. if (value) {
  5535. this.maybeInitializeSingleSelection();
  5536. this.selectedIndex = this.getSelectedIndexFromDOM();
  5537. }
  5538. };
  5539. MDCListFoundation.prototype.setDisabledItemsFocusable = function (value) {
  5540. this.areDisabledItemsFocusable = value;
  5541. };
  5542. /**
  5543. * Automatically determines whether the list is single selection list. If so,
  5544. * initializes the internal state to match the selected item.
  5545. */
  5546. MDCListFoundation.prototype.maybeInitializeSingleSelection = function () {
  5547. var selectedItemIndex = this.getSelectedIndexFromDOM();
  5548. if (selectedItemIndex === constants_1.numbers.UNSET_INDEX) return;
  5549. var hasActivatedClass = this.adapter.listItemAtIndexHasClass(selectedItemIndex, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
  5550. if (hasActivatedClass) {
  5551. this.setUseActivatedClass(true);
  5552. }
  5553. this.isSingleSelectionList = true;
  5554. this.selectedIndex = selectedItemIndex;
  5555. };
  5556. /** @return Index of the first selected item based on the DOM state. */
  5557. MDCListFoundation.prototype.getSelectedIndexFromDOM = function () {
  5558. var selectedIndex = constants_1.numbers.UNSET_INDEX;
  5559. var listItemsCount = this.adapter.getListItemCount();
  5560. for (var i = 0; i < listItemsCount; i++) {
  5561. var hasSelectedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS);
  5562. var hasActivatedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
  5563. if (!(hasSelectedClass || hasActivatedClass)) {
  5564. continue;
  5565. }
  5566. selectedIndex = i;
  5567. break;
  5568. }
  5569. return selectedIndex;
  5570. };
  5571. /**
  5572. * Sets whether typeahead is enabled on the list.
  5573. * @param hasTypeahead Whether typeahead is enabled.
  5574. */
  5575. MDCListFoundation.prototype.setHasTypeahead = function (hasTypeahead) {
  5576. this.hasTypeahead = hasTypeahead;
  5577. if (hasTypeahead) {
  5578. this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
  5579. }
  5580. };
  5581. /**
  5582. * @return Whether typeahead is currently matching a user-specified prefix.
  5583. */
  5584. MDCListFoundation.prototype.isTypeaheadInProgress = function () {
  5585. return this.hasTypeahead && typeahead.isTypingInProgress(this.typeaheadState);
  5586. };
  5587. /** Toggle use of the "activated" CSS class. */
  5588. MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) {
  5589. this.useActivatedClass = useActivated;
  5590. };
  5591. /**
  5592. * Toggles use of the selected attribute (true for aria-selected, false for
  5593. * aria-checked).
  5594. */
  5595. MDCListFoundation.prototype.setUseSelectedAttribute = function (useSelected) {
  5596. this.useSelectedAttr = useSelected;
  5597. };
  5598. MDCListFoundation.prototype.getSelectedIndex = function () {
  5599. return this.selectedIndex;
  5600. };
  5601. MDCListFoundation.prototype.setSelectedIndex = function (index, options) {
  5602. if (options === void 0) {
  5603. options = {};
  5604. }
  5605. if (!this.isIndexValid(index)) {
  5606. return;
  5607. }
  5608. if (this.isCheckboxList) {
  5609. this.setCheckboxAtIndex(index, options);
  5610. } else if (this.isRadioList) {
  5611. this.setRadioAtIndex(index, options);
  5612. } else {
  5613. this.setSingleSelectionAtIndex(index, options);
  5614. }
  5615. };
  5616. /**
  5617. * Focus in handler for the list items.
  5618. */
  5619. MDCListFoundation.prototype.handleFocusIn = function (listItemIndex) {
  5620. if (listItemIndex >= 0) {
  5621. this.focusedItemIndex = listItemIndex;
  5622. this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '0');
  5623. this.adapter.setTabIndexForListItemChildren(listItemIndex, '0');
  5624. }
  5625. };
  5626. /**
  5627. * Focus out handler for the list items.
  5628. */
  5629. MDCListFoundation.prototype.handleFocusOut = function (listItemIndex) {
  5630. var _this = this;
  5631. if (listItemIndex >= 0) {
  5632. this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '-1');
  5633. this.adapter.setTabIndexForListItemChildren(listItemIndex, '-1');
  5634. }
  5635. /**
  5636. * Between Focusout & Focusin some browsers do not have focus on any
  5637. * element. Setting a delay to wait till the focus is moved to next element.
  5638. */
  5639. setTimeout(function () {
  5640. if (!_this.adapter.isFocusInsideList()) {
  5641. _this.setTabindexToFirstSelectedOrFocusedItem();
  5642. }
  5643. }, 0);
  5644. };
  5645. MDCListFoundation.prototype.isIndexDisabled = function (index) {
  5646. return this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  5647. };
  5648. /**
  5649. * Key handler for the list.
  5650. */
  5651. MDCListFoundation.prototype.handleKeydown = function (event, isRootListItem, listItemIndex) {
  5652. var _this = this;
  5653. var _a;
  5654. var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
  5655. var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
  5656. var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
  5657. var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
  5658. var isHome = keyboard_1.normalizeKey(event) === 'Home';
  5659. var isEnd = keyboard_1.normalizeKey(event) === 'End';
  5660. var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
  5661. var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
  5662. // The keys for forward and back differ based on list orientation.
  5663. var isForward = this.isVertical && isArrowDown || !this.isVertical && isArrowRight;
  5664. var isBack = this.isVertical && isArrowUp || !this.isVertical && isArrowLeft;
  5665. // Have to check both upper and lower case, because having caps lock on
  5666. // affects the value.
  5667. var isLetterA = event.key === 'A' || event.key === 'a';
  5668. var eventHasModifiers = createModifierChecker(event);
  5669. if (this.adapter.isRootFocused()) {
  5670. if ((isBack || isEnd) && eventHasModifiers([])) {
  5671. event.preventDefault();
  5672. this.focusLastElement();
  5673. } else if ((isForward || isHome) && eventHasModifiers([])) {
  5674. event.preventDefault();
  5675. this.focusFirstElement();
  5676. } else if (isBack && eventHasModifiers(['Shift']) && this.isCheckboxList) {
  5677. event.preventDefault();
  5678. var focusedIndex = this.focusLastElement();
  5679. if (focusedIndex !== -1) {
  5680. this.setSelectedIndexOnAction(focusedIndex, false);
  5681. }
  5682. } else if (isForward && eventHasModifiers(['Shift']) && this.isCheckboxList) {
  5683. event.preventDefault();
  5684. var focusedIndex = this.focusFirstElement();
  5685. if (focusedIndex !== -1) {
  5686. this.setSelectedIndexOnAction(focusedIndex, false);
  5687. }
  5688. }
  5689. if (this.hasTypeahead) {
  5690. var handleKeydownOpts = {
  5691. event: event,
  5692. focusItemAtIndex: function focusItemAtIndex(index) {
  5693. _this.focusItemAtIndex(index);
  5694. },
  5695. focusedItemIndex: -1,
  5696. isTargetListItem: isRootListItem,
  5697. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  5698. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  5699. return _this.isIndexDisabled(index);
  5700. }
  5701. };
  5702. typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
  5703. }
  5704. return;
  5705. }
  5706. var currentIndex = this.adapter.getFocusedElementIndex();
  5707. if (currentIndex === -1) {
  5708. currentIndex = listItemIndex;
  5709. if (currentIndex < 0) {
  5710. // If this event doesn't have a mdc-list-item ancestor from the
  5711. // current list (not from a sublist), return early.
  5712. return;
  5713. }
  5714. }
  5715. if (isForward && eventHasModifiers([])) {
  5716. events_1.preventDefaultEvent(event);
  5717. this.focusNextElement(currentIndex);
  5718. } else if (isBack && eventHasModifiers([])) {
  5719. events_1.preventDefaultEvent(event);
  5720. this.focusPrevElement(currentIndex);
  5721. } else if (isForward && eventHasModifiers(['Shift']) && this.isCheckboxList) {
  5722. events_1.preventDefaultEvent(event);
  5723. var focusedIndex = this.focusNextElement(currentIndex);
  5724. if (focusedIndex !== -1) {
  5725. this.setSelectedIndexOnAction(focusedIndex, false);
  5726. }
  5727. } else if (isBack && eventHasModifiers(['Shift']) && this.isCheckboxList) {
  5728. events_1.preventDefaultEvent(event);
  5729. var focusedIndex = this.focusPrevElement(currentIndex);
  5730. if (focusedIndex !== -1) {
  5731. this.setSelectedIndexOnAction(focusedIndex, false);
  5732. }
  5733. } else if (isHome && eventHasModifiers([])) {
  5734. events_1.preventDefaultEvent(event);
  5735. this.focusFirstElement();
  5736. } else if (isEnd && eventHasModifiers([])) {
  5737. events_1.preventDefaultEvent(event);
  5738. this.focusLastElement();
  5739. } else if (isHome && eventHasModifiers(['Control', 'Shift']) && this.isCheckboxList) {
  5740. events_1.preventDefaultEvent(event);
  5741. if (this.isIndexDisabled(currentIndex)) {
  5742. return;
  5743. }
  5744. this.focusFirstElement();
  5745. this.toggleCheckboxRange(0, currentIndex, currentIndex);
  5746. } else if (isEnd && eventHasModifiers(['Control', 'Shift']) && this.isCheckboxList) {
  5747. events_1.preventDefaultEvent(event);
  5748. if (this.isIndexDisabled(currentIndex)) {
  5749. return;
  5750. }
  5751. this.focusLastElement();
  5752. this.toggleCheckboxRange(currentIndex, this.adapter.getListItemCount() - 1, currentIndex);
  5753. } else if (isLetterA && eventHasModifiers(['Control']) && this.isCheckboxList) {
  5754. event.preventDefault();
  5755. this.checkboxListToggleAll(this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex, true);
  5756. } else if ((isEnter || isSpace) && (eventHasModifiers([]) || eventHasModifiers(['Alt']))) {
  5757. if (isRootListItem) {
  5758. // Return early if enter key is pressed on anchor element which triggers
  5759. // synthetic MouseEvent event.
  5760. var target = event.target;
  5761. if (target && target.tagName === 'A' && isEnter) {
  5762. return;
  5763. }
  5764. events_1.preventDefaultEvent(event);
  5765. if (this.isIndexDisabled(currentIndex)) {
  5766. return;
  5767. }
  5768. if (!this.isTypeaheadInProgress()) {
  5769. if (this.isSelectableList()) {
  5770. this.setSelectedIndexOnAction(currentIndex, false);
  5771. }
  5772. this.adapter.notifyAction(currentIndex);
  5773. }
  5774. }
  5775. } else if ((isEnter || isSpace) && eventHasModifiers(['Shift']) && this.isCheckboxList) {
  5776. // Return early if enter key is pressed on anchor element which triggers
  5777. // synthetic MouseEvent event.
  5778. var target = event.target;
  5779. if (target && target.tagName === 'A' && isEnter) {
  5780. return;
  5781. }
  5782. events_1.preventDefaultEvent(event);
  5783. if (this.isIndexDisabled(currentIndex)) {
  5784. return;
  5785. }
  5786. if (!this.isTypeaheadInProgress()) {
  5787. this.toggleCheckboxRange((_a = this.lastSelectedIndex) !== null && _a !== void 0 ? _a : currentIndex, currentIndex, currentIndex);
  5788. this.adapter.notifyAction(currentIndex);
  5789. }
  5790. }
  5791. if (this.hasTypeahead) {
  5792. var handleKeydownOpts = {
  5793. event: event,
  5794. focusItemAtIndex: function focusItemAtIndex(index) {
  5795. _this.focusItemAtIndex(index);
  5796. },
  5797. focusedItemIndex: this.focusedItemIndex,
  5798. isTargetListItem: isRootListItem,
  5799. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  5800. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  5801. return _this.isIndexDisabled(index);
  5802. }
  5803. };
  5804. typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
  5805. }
  5806. };
  5807. /**
  5808. * Click handler for the list.
  5809. *
  5810. * @param index Index for the item that has been clicked.
  5811. * @param isCheckboxAlreadyUpdatedInAdapter Whether the checkbox for
  5812. * the list item has already been updated in the adapter. This attribute
  5813. * should be set to `true` when e.g. the click event directly landed on
  5814. * the underlying native checkbox element which would cause the checked
  5815. * state to be already toggled within `adapter.isCheckboxCheckedAtIndex`.
  5816. */
  5817. MDCListFoundation.prototype.handleClick = function (index, isCheckboxAlreadyUpdatedInAdapter, event) {
  5818. var _a;
  5819. var eventHasModifiers = createModifierChecker(event);
  5820. if (index === constants_1.numbers.UNSET_INDEX) {
  5821. return;
  5822. }
  5823. if (this.isIndexDisabled(index)) {
  5824. return;
  5825. }
  5826. if (eventHasModifiers([])) {
  5827. if (this.isSelectableList()) {
  5828. this.setSelectedIndexOnAction(index, isCheckboxAlreadyUpdatedInAdapter);
  5829. }
  5830. this.adapter.notifyAction(index);
  5831. } else if (this.isCheckboxList && eventHasModifiers(['Shift'])) {
  5832. this.toggleCheckboxRange((_a = this.lastSelectedIndex) !== null && _a !== void 0 ? _a : index, index, index);
  5833. this.adapter.notifyAction(index);
  5834. }
  5835. };
  5836. /**
  5837. * Focuses the next element on the list.
  5838. */
  5839. MDCListFoundation.prototype.focusNextElement = function (index) {
  5840. var count = this.adapter.getListItemCount();
  5841. var nextIndex = index;
  5842. var firstChecked = null;
  5843. do {
  5844. nextIndex++;
  5845. if (nextIndex >= count) {
  5846. if (this.wrapFocus) {
  5847. nextIndex = 0;
  5848. } else {
  5849. // Return early because last item is already focused.
  5850. return index;
  5851. }
  5852. }
  5853. if (nextIndex === firstChecked) {
  5854. return -1;
  5855. }
  5856. firstChecked = firstChecked !== null && firstChecked !== void 0 ? firstChecked : nextIndex;
  5857. } while (!this.areDisabledItemsFocusable && this.isIndexDisabled(nextIndex));
  5858. this.focusItemAtIndex(nextIndex);
  5859. return nextIndex;
  5860. };
  5861. /**
  5862. * Focuses the previous element on the list.
  5863. */
  5864. MDCListFoundation.prototype.focusPrevElement = function (index) {
  5865. var count = this.adapter.getListItemCount();
  5866. var prevIndex = index;
  5867. var firstChecked = null;
  5868. do {
  5869. prevIndex--;
  5870. if (prevIndex < 0) {
  5871. if (this.wrapFocus) {
  5872. prevIndex = count - 1;
  5873. } else {
  5874. // Return early because first item is already focused.
  5875. return index;
  5876. }
  5877. }
  5878. if (prevIndex === firstChecked) {
  5879. return -1;
  5880. }
  5881. firstChecked = firstChecked !== null && firstChecked !== void 0 ? firstChecked : prevIndex;
  5882. } while (!this.areDisabledItemsFocusable && this.isIndexDisabled(prevIndex));
  5883. this.focusItemAtIndex(prevIndex);
  5884. return prevIndex;
  5885. };
  5886. MDCListFoundation.prototype.focusFirstElement = function () {
  5887. // Pass -1 to `focusNextElement`, since it will incremement to 0 and focus
  5888. // the first element.
  5889. return this.focusNextElement(-1);
  5890. };
  5891. MDCListFoundation.prototype.focusLastElement = function () {
  5892. // Pass the length of the list to `focusNextElement` since it will decrement
  5893. // to length - 1 and focus the last element.
  5894. return this.focusPrevElement(this.adapter.getListItemCount());
  5895. };
  5896. MDCListFoundation.prototype.focusInitialElement = function () {
  5897. var initialIndex = this.getFirstSelectedOrFocusedItemIndex();
  5898. if (initialIndex !== constants_1.numbers.UNSET_INDEX) {
  5899. this.focusItemAtIndex(initialIndex);
  5900. }
  5901. return initialIndex;
  5902. };
  5903. /**
  5904. * @param itemIndex Index of the list item
  5905. * @param isEnabled Sets the list item to enabled or disabled.
  5906. */
  5907. MDCListFoundation.prototype.setEnabled = function (itemIndex, isEnabled) {
  5908. if (!this.isIndexValid(itemIndex, false)) {
  5909. return;
  5910. }
  5911. if (isEnabled) {
  5912. this.adapter.removeClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  5913. this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'false');
  5914. } else {
  5915. this.adapter.addClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  5916. this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'true');
  5917. }
  5918. };
  5919. MDCListFoundation.prototype.setSingleSelectionAtIndex = function (index, options) {
  5920. if (options === void 0) {
  5921. options = {};
  5922. }
  5923. if (this.selectedIndex === index && !options.forceUpdate) {
  5924. return;
  5925. }
  5926. var selectedClassName = constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS;
  5927. if (this.useActivatedClass) {
  5928. selectedClassName = constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS;
  5929. }
  5930. if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  5931. this.adapter.removeClassForElementIndex(this.selectedIndex, selectedClassName);
  5932. }
  5933. this.setAriaForSingleSelectionAtIndex(index);
  5934. this.setTabindexAtIndex(index);
  5935. if (index !== constants_1.numbers.UNSET_INDEX) {
  5936. this.adapter.addClassForElementIndex(index, selectedClassName);
  5937. }
  5938. this.selectedIndex = index;
  5939. // If the selected value has changed through user interaction,
  5940. // we want to notify the selection change to the adapter.
  5941. if (options.isUserInteraction && !options.forceUpdate) {
  5942. this.adapter.notifySelectionChange([index]);
  5943. }
  5944. };
  5945. /**
  5946. * Sets aria attribute for single selection at given index.
  5947. */
  5948. MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex = function (index) {
  5949. // Detect the presence of aria-current and get the value only during list
  5950. // initialization when it is in unset state.
  5951. if (this.selectedIndex === constants_1.numbers.UNSET_INDEX && index !== constants_1.numbers.UNSET_INDEX) {
  5952. this.ariaCurrentAttrValue = this.adapter.getAttributeForElementIndex(index, constants_1.strings.ARIA_CURRENT);
  5953. }
  5954. var isAriaCurrent = this.ariaCurrentAttrValue !== null;
  5955. var ariaAttribute = isAriaCurrent ? constants_1.strings.ARIA_CURRENT : constants_1.strings.ARIA_SELECTED;
  5956. if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  5957. this.adapter.setAttributeForElementIndex(this.selectedIndex, ariaAttribute, 'false');
  5958. }
  5959. if (index !== constants_1.numbers.UNSET_INDEX) {
  5960. var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue : 'true';
  5961. this.adapter.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
  5962. }
  5963. };
  5964. /**
  5965. * Returns the attribute to use for indicating selection status.
  5966. */
  5967. MDCListFoundation.prototype.getSelectionAttribute = function () {
  5968. return this.useSelectedAttr ? constants_1.strings.ARIA_SELECTED : constants_1.strings.ARIA_CHECKED;
  5969. };
  5970. /**
  5971. * Toggles radio at give index. Radio doesn't change the checked state if it
  5972. * is already checked.
  5973. */
  5974. MDCListFoundation.prototype.setRadioAtIndex = function (index, options) {
  5975. if (options === void 0) {
  5976. options = {};
  5977. }
  5978. var selectionAttribute = this.getSelectionAttribute();
  5979. this.adapter.setCheckedCheckboxOrRadioAtIndex(index, true);
  5980. if (this.selectedIndex === index && !options.forceUpdate) {
  5981. return;
  5982. }
  5983. if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  5984. this.adapter.setAttributeForElementIndex(this.selectedIndex, selectionAttribute, 'false');
  5985. }
  5986. this.adapter.setAttributeForElementIndex(index, selectionAttribute, 'true');
  5987. this.selectedIndex = index;
  5988. // If the selected value has changed through user interaction,
  5989. // we want to notify the selection change to the adapter.
  5990. if (options.isUserInteraction && !options.forceUpdate) {
  5991. this.adapter.notifySelectionChange([index]);
  5992. }
  5993. };
  5994. MDCListFoundation.prototype.setCheckboxAtIndex = function (indices, options) {
  5995. if (options === void 0) {
  5996. options = {};
  5997. }
  5998. var currentIndex = this.selectedIndex;
  5999. // If this update is not triggered by a user interaction, we do not
  6000. // need to know about the currently selected indices and can avoid
  6001. // constructing the `Set` for performance reasons.
  6002. var currentlySelected = options.isUserInteraction ? new Set(currentIndex === constants_1.numbers.UNSET_INDEX ? [] : currentIndex) : null;
  6003. var selectionAttribute = this.getSelectionAttribute();
  6004. var changedIndices = [];
  6005. for (var i = 0; i < this.adapter.getListItemCount(); i++) {
  6006. if (options.omitDisabledItems && this.isIndexDisabled(i)) {
  6007. continue;
  6008. }
  6009. var previousIsChecked = currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.has(i);
  6010. var newIsChecked = indices.indexOf(i) >= 0;
  6011. // If the selection has changed for this item, we keep track of it
  6012. // so that we can notify the adapter.
  6013. if (newIsChecked !== previousIsChecked) {
  6014. changedIndices.push(i);
  6015. }
  6016. this.adapter.setCheckedCheckboxOrRadioAtIndex(i, newIsChecked);
  6017. this.adapter.setAttributeForElementIndex(i, selectionAttribute, newIsChecked ? 'true' : 'false');
  6018. }
  6019. this.selectedIndex = options.omitDisabledItems ? this.resolveSelectedIndices(indices) : indices;
  6020. // If the selected value has changed through user interaction,
  6021. // we want to notify the selection change to the adapter.
  6022. if (options.isUserInteraction && changedIndices.length) {
  6023. this.adapter.notifySelectionChange(changedIndices);
  6024. }
  6025. };
  6026. /**
  6027. * Helper method for ensuring that the list of selected indices remains
  6028. * accurate when calling setCheckboxAtIndex with omitDisabledItems set to
  6029. * true.
  6030. */
  6031. MDCListFoundation.prototype.resolveSelectedIndices = function (setCheckedItems) {
  6032. var _this = this;
  6033. var currentlySelectedItems = this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex;
  6034. var currentlySelectedDisabledItems = currentlySelectedItems.filter(function (i) {
  6035. return _this.isIndexDisabled(i);
  6036. });
  6037. var enabledSetCheckedItems = setCheckedItems.filter(function (i) {
  6038. return !_this.isIndexDisabled(i);
  6039. });
  6040. // Updated selectedIndex should be the enabled setCheckedItems + any missing
  6041. // selected disabled items.
  6042. var updatedSelectedItems = __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(enabledSetCheckedItems)), __read(currentlySelectedDisabledItems)))));
  6043. return updatedSelectedItems.sort(function (a, b) {
  6044. return a - b;
  6045. });
  6046. };
  6047. /**
  6048. * Toggles the state of all checkboxes in the given range (inclusive) based
  6049. * on the state of the checkbox at the `toggleIndex`. To determine whether
  6050. * to set the given range to checked or unchecked, read the value of the
  6051. * checkbox at the `toggleIndex` and negate it. Then apply that new checked
  6052. * state to all checkboxes in the range.
  6053. * @param fromIndex The start of the range of checkboxes to toggle
  6054. * @param toIndex The end of the range of checkboxes to toggle
  6055. * @param toggleIndex The index that will be used to determine the new state
  6056. * of the given checkbox range.
  6057. */
  6058. MDCListFoundation.prototype.toggleCheckboxRange = function (fromIndex, toIndex, toggleIndex) {
  6059. this.lastSelectedIndex = toggleIndex;
  6060. var currentlySelected = new Set(this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex);
  6061. var newIsChecked = !(currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.has(toggleIndex));
  6062. var _a = __read([fromIndex, toIndex].sort(), 2),
  6063. startIndex = _a[0],
  6064. endIndex = _a[1];
  6065. var selectionAttribute = this.getSelectionAttribute();
  6066. var changedIndices = [];
  6067. for (var i = startIndex; i <= endIndex; i++) {
  6068. if (this.isIndexDisabled(i)) {
  6069. continue;
  6070. }
  6071. var previousIsChecked = currentlySelected.has(i);
  6072. // If the selection has changed for this item, we keep track of it
  6073. // so that we can notify the adapter.
  6074. if (newIsChecked !== previousIsChecked) {
  6075. changedIndices.push(i);
  6076. this.adapter.setCheckedCheckboxOrRadioAtIndex(i, newIsChecked);
  6077. this.adapter.setAttributeForElementIndex(i, selectionAttribute, "" + newIsChecked);
  6078. if (newIsChecked) {
  6079. currentlySelected.add(i);
  6080. } else {
  6081. currentlySelected.delete(i);
  6082. }
  6083. }
  6084. }
  6085. // If the selected value has changed, update and notify the selection
  6086. // change to the adapter.
  6087. if (changedIndices.length) {
  6088. this.selectedIndex = __spreadArray([], __read(currentlySelected));
  6089. this.adapter.notifySelectionChange(changedIndices);
  6090. }
  6091. };
  6092. MDCListFoundation.prototype.setTabindexAtIndex = function (index) {
  6093. if (this.focusedItemIndex === constants_1.numbers.UNSET_INDEX && index !== 0 && index !== constants_1.numbers.UNSET_INDEX) {
  6094. // If some list item was selected set first list item's tabindex to -1.
  6095. // Generally, tabindex is set to 0 on first list item of list that has
  6096. // no preselected items.
  6097. this.adapter.setAttributeForElementIndex(0, 'tabindex', '-1');
  6098. } else if (this.focusedItemIndex >= 0 && this.focusedItemIndex !== index) {
  6099. this.adapter.setAttributeForElementIndex(this.focusedItemIndex, 'tabindex', '-1');
  6100. }
  6101. // Set the previous selection's tabindex to -1. We need this because
  6102. // in selection menus that are not visible, programmatically setting an
  6103. // option will not change focus but will change where tabindex should be
  6104. // 0.
  6105. if (!(this.selectedIndex instanceof Array) && this.selectedIndex !== index && this.focusedItemIndex !== constants_1.numbers.UNSET_INDEX) {
  6106. this.adapter.setAttributeForElementIndex(this.selectedIndex, 'tabindex', '-1');
  6107. }
  6108. if (index !== constants_1.numbers.UNSET_INDEX) {
  6109. this.adapter.setAttributeForElementIndex(index, 'tabindex', '0');
  6110. }
  6111. };
  6112. /**
  6113. * @return Return true if it is single selectin list, checkbox list or radio
  6114. * list.
  6115. */
  6116. MDCListFoundation.prototype.isSelectableList = function () {
  6117. return this.isSingleSelectionList || this.isCheckboxList || this.isRadioList;
  6118. };
  6119. MDCListFoundation.prototype.setTabindexToFirstSelectedOrFocusedItem = function () {
  6120. var targetIndex = this.getFirstSelectedOrFocusedItemIndex();
  6121. this.setTabindexAtIndex(targetIndex);
  6122. };
  6123. MDCListFoundation.prototype.getFirstSelectedOrFocusedItemIndex = function () {
  6124. var e_1, _a;
  6125. var firstFocusableListItem = this.getFirstEnabledItem();
  6126. if (this.adapter.getListItemCount() === 0) {
  6127. return constants_1.numbers.UNSET_INDEX;
  6128. }
  6129. // Action lists retain focus on the most recently focused item.
  6130. if (!this.isSelectableList()) {
  6131. return Math.max(this.focusedItemIndex, firstFocusableListItem);
  6132. }
  6133. // Single-selection lists focus the selected item.
  6134. if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
  6135. return this.areDisabledItemsFocusable && this.isIndexDisabled(this.selectedIndex) ? firstFocusableListItem : this.selectedIndex;
  6136. }
  6137. // Multiple-selection lists focus the first enabled selected item.
  6138. if (isNumberArray(this.selectedIndex) && this.selectedIndex.length > 0) {
  6139. var sorted = __spreadArray([], __read(this.selectedIndex)).sort(function (a, b) {
  6140. return a - b;
  6141. });
  6142. try {
  6143. for (var sorted_1 = __values(sorted), sorted_1_1 = sorted_1.next(); !sorted_1_1.done; sorted_1_1 = sorted_1.next()) {
  6144. var index = sorted_1_1.value;
  6145. if (this.isIndexDisabled(index) && !this.areDisabledItemsFocusable) {
  6146. continue;
  6147. } else {
  6148. return index;
  6149. }
  6150. }
  6151. } catch (e_1_1) {
  6152. e_1 = { error: e_1_1 };
  6153. } finally {
  6154. try {
  6155. if (sorted_1_1 && !sorted_1_1.done && (_a = sorted_1.return)) _a.call(sorted_1);
  6156. } finally {
  6157. if (e_1) throw e_1.error;
  6158. }
  6159. }
  6160. }
  6161. // Selection lists without a selection focus the first item.
  6162. return firstFocusableListItem;
  6163. };
  6164. MDCListFoundation.prototype.getFirstEnabledItem = function () {
  6165. var listSize = this.adapter.getListItemCount();
  6166. var i = 0;
  6167. while (i < listSize) {
  6168. if (!this.isIndexDisabled(i)) {
  6169. break;
  6170. }
  6171. i++;
  6172. }
  6173. return i === listSize ? constants_1.numbers.UNSET_INDEX : i;
  6174. };
  6175. MDCListFoundation.prototype.isIndexValid = function (index, validateListType) {
  6176. var _this = this;
  6177. if (validateListType === void 0) {
  6178. validateListType = true;
  6179. }
  6180. if (index instanceof Array) {
  6181. if (!this.isCheckboxList && validateListType) {
  6182. throw new Error('MDCListFoundation: Array of index is only supported for checkbox based list');
  6183. }
  6184. if (index.length === 0) {
  6185. return true;
  6186. } else {
  6187. return index.some(function (i) {
  6188. return _this.isIndexInRange(i);
  6189. });
  6190. }
  6191. } else if (typeof index === 'number') {
  6192. if (this.isCheckboxList && validateListType) {
  6193. throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: " + index);
  6194. }
  6195. return this.isIndexInRange(index) || this.isSingleSelectionList && index === constants_1.numbers.UNSET_INDEX;
  6196. } else {
  6197. return false;
  6198. }
  6199. };
  6200. MDCListFoundation.prototype.isIndexInRange = function (index) {
  6201. var listSize = this.adapter.getListItemCount();
  6202. return index >= 0 && index < listSize;
  6203. };
  6204. /**
  6205. * Sets selected index on user action, toggles checkboxes in checkbox lists
  6206. * by default, unless `isCheckboxAlreadyUpdatedInAdapter` is set to `true`.
  6207. *
  6208. * In cases where `isCheckboxAlreadyUpdatedInAdapter` is set to `true`, the
  6209. * UI is just updated to reflect the value returned by the adapter.
  6210. *
  6211. * When calling this, make sure user interaction does not toggle disabled
  6212. * list items.
  6213. */
  6214. MDCListFoundation.prototype.setSelectedIndexOnAction = function (index, isCheckboxAlreadyUpdatedInAdapter) {
  6215. this.lastSelectedIndex = index;
  6216. if (this.isCheckboxList) {
  6217. this.toggleCheckboxAtIndex(index, isCheckboxAlreadyUpdatedInAdapter);
  6218. this.adapter.notifySelectionChange([index]);
  6219. } else {
  6220. this.setSelectedIndex(index, { isUserInteraction: true });
  6221. }
  6222. };
  6223. MDCListFoundation.prototype.toggleCheckboxAtIndex = function (index, isCheckboxAlreadyUpdatedInAdapter) {
  6224. var selectionAttribute = this.getSelectionAttribute();
  6225. var adapterIsChecked = this.adapter.isCheckboxCheckedAtIndex(index);
  6226. // By default the checked value from the adapter is toggled unless the
  6227. // checked state in the adapter has already been updated beforehand.
  6228. // This can be happen when the underlying native checkbox has already
  6229. // been updated through the native click event.
  6230. var newCheckedValue;
  6231. if (isCheckboxAlreadyUpdatedInAdapter) {
  6232. newCheckedValue = adapterIsChecked;
  6233. } else {
  6234. newCheckedValue = !adapterIsChecked;
  6235. this.adapter.setCheckedCheckboxOrRadioAtIndex(index, newCheckedValue);
  6236. }
  6237. this.adapter.setAttributeForElementIndex(index, selectionAttribute, newCheckedValue ? 'true' : 'false');
  6238. // If none of the checkbox items are selected and selectedIndex is not
  6239. // initialized then provide a default value.
  6240. var selectedIndexes = this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex.slice();
  6241. if (newCheckedValue) {
  6242. selectedIndexes.push(index);
  6243. } else {
  6244. selectedIndexes = selectedIndexes.filter(function (i) {
  6245. return i !== index;
  6246. });
  6247. }
  6248. this.selectedIndex = selectedIndexes;
  6249. };
  6250. MDCListFoundation.prototype.focusItemAtIndex = function (index) {
  6251. this.adapter.focusItemAtIndex(index);
  6252. this.focusedItemIndex = index;
  6253. };
  6254. MDCListFoundation.prototype.getEnabledListItemCount = function () {
  6255. var listSize = this.adapter.getListItemCount();
  6256. var adjustedCount = 0;
  6257. for (var i = 0; i < listSize; i++) {
  6258. if (!this.isIndexDisabled(i)) {
  6259. adjustedCount++;
  6260. }
  6261. }
  6262. return adjustedCount;
  6263. };
  6264. MDCListFoundation.prototype.checkboxListToggleAll = function (currentlySelectedIndices, isUserInteraction) {
  6265. var _this = this;
  6266. var enabledListItemCount = this.getEnabledListItemCount();
  6267. var totalListItemCount = this.adapter.getListItemCount();
  6268. var currentlyEnabledSelectedIndices = currentlySelectedIndices.filter(function (i) {
  6269. return !_this.isIndexDisabled(i);
  6270. });
  6271. // If all items are selected, deselect everything.
  6272. // We check >= rather than === to `enabledListItemCount` since a disabled
  6273. // item could be selected, and we don't take that into consideration when
  6274. // toggling the other checkbox values.
  6275. if (currentlyEnabledSelectedIndices.length >= enabledListItemCount) {
  6276. // Use omitDisabledItems option to ensure disabled selected items are not
  6277. // de-selected.
  6278. this.setCheckboxAtIndex([], { isUserInteraction: isUserInteraction, omitDisabledItems: true });
  6279. } else {
  6280. // Otherwise select all enabled options.
  6281. var allIndexes = [];
  6282. for (var i = 0; i < totalListItemCount; i++) {
  6283. if (!this.isIndexDisabled(i) || currentlySelectedIndices.indexOf(i) > -1) {
  6284. allIndexes.push(i);
  6285. }
  6286. }
  6287. // Use omitDisabledItems option to ensure disabled selected items are not
  6288. // de-selected.
  6289. this.setCheckboxAtIndex(allIndexes, { isUserInteraction: isUserInteraction, omitDisabledItems: true });
  6290. }
  6291. };
  6292. /**
  6293. * Given the next desired character from the user, adds it to the typeahead
  6294. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  6295. * around if at the end of options.
  6296. *
  6297. * @param nextChar The next character to add to the prefix buffer.
  6298. * @param startingIndex The index from which to start matching. Only
  6299. * relevant when starting a new match sequence. To start a new match
  6300. * sequence, clear the buffer using `clearTypeaheadBuffer`, or wait for
  6301. * the buffer to clear after a set interval defined in list foundation.
  6302. * Defaults to the currently focused index.
  6303. * @return The index of the matched item, or -1 if no match.
  6304. */
  6305. MDCListFoundation.prototype.typeaheadMatchItem = function (nextChar, startingIndex, skipFocus) {
  6306. var _this = this;
  6307. if (skipFocus === void 0) {
  6308. skipFocus = false;
  6309. }
  6310. var opts = {
  6311. focusItemAtIndex: function focusItemAtIndex(index) {
  6312. _this.focusItemAtIndex(index);
  6313. },
  6314. focusedItemIndex: startingIndex ? startingIndex : this.focusedItemIndex,
  6315. nextChar: nextChar,
  6316. sortedIndexByFirstChar: this.sortedIndexByFirstChar,
  6317. skipFocus: skipFocus,
  6318. isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
  6319. return _this.isIndexDisabled(index);
  6320. }
  6321. };
  6322. return typeahead.matchItem(opts, this.typeaheadState);
  6323. };
  6324. /**
  6325. * Initializes the MDCListTextAndIndex data structure by indexing the
  6326. * current list items by primary text.
  6327. *
  6328. * @return The primary texts of all the list items sorted by first
  6329. * character.
  6330. */
  6331. MDCListFoundation.prototype.typeaheadInitSortedIndex = function () {
  6332. return typeahead.initSortedIndex(this.adapter.getListItemCount(), this.adapter.getPrimaryTextAtIndex);
  6333. };
  6334. /**
  6335. * Clears the typeahead buffer.
  6336. */
  6337. MDCListFoundation.prototype.clearTypeaheadBuffer = function () {
  6338. typeahead.clearBuffer(this.typeaheadState);
  6339. };
  6340. return MDCListFoundation;
  6341. }(foundation_1.MDCFoundation);
  6342. exports.MDCListFoundation = MDCListFoundation;
  6343. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  6344. exports.default = MDCListFoundation;
  6345. /***/ }),
  6346. /***/ "./packages/mdc-list/typeahead.ts":
  6347. /*!****************************************!*\
  6348. !*** ./packages/mdc-list/typeahead.ts ***!
  6349. \****************************************/
  6350. /*! no static exports found */
  6351. /***/ (function(module, exports, __webpack_require__) {
  6352. "use strict";
  6353. /**
  6354. * @license
  6355. * Copyright 2020 Google Inc.
  6356. *
  6357. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6358. * of this software and associated documentation files (the "Software"), to deal
  6359. * in the Software without restriction, including without limitation the rights
  6360. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6361. * copies of the Software, and to permit persons to whom the Software is
  6362. * furnished to do so, subject to the following conditions:
  6363. *
  6364. * The above copyright notice and this permission notice shall be included in
  6365. * all copies or substantial portions of the Software.
  6366. *
  6367. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6368. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6369. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6370. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6371. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6372. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6373. * THE SOFTWARE.
  6374. */
  6375. Object.defineProperty(exports, "__esModule", { value: true });
  6376. exports.handleKeydown = exports.clearBuffer = exports.isTypingInProgress = exports.matchItem = exports.initSortedIndex = exports.initState = void 0;
  6377. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  6378. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
  6379. var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
  6380. /**
  6381. * Initializes a state object for typeahead. Use the same reference for calls to
  6382. * typeahead functions.
  6383. *
  6384. * @return The current state of the typeahead process. Each state reference
  6385. * represents a typeahead instance as the reference is typically mutated
  6386. * in-place.
  6387. */
  6388. function initState() {
  6389. var state = {
  6390. bufferClearTimeout: 0,
  6391. currentFirstChar: '',
  6392. sortedIndexCursor: 0,
  6393. typeaheadBuffer: ''
  6394. };
  6395. return state;
  6396. }
  6397. exports.initState = initState;
  6398. /**
  6399. * Initializes typeahead state by indexing the current list items by primary
  6400. * text into the sortedIndexByFirstChar data structure.
  6401. *
  6402. * @param listItemCount numer of items in the list
  6403. * @param getPrimaryTextByItemIndex function that returns the primary text at a
  6404. * given index
  6405. *
  6406. * @return Map that maps the first character of the primary text to the full
  6407. * list text and its index
  6408. */
  6409. function initSortedIndex(listItemCount, getPrimaryTextByItemIndex) {
  6410. var sortedIndexByFirstChar = new Map();
  6411. // Aggregate item text to index mapping
  6412. for (var i = 0; i < listItemCount; i++) {
  6413. var primaryText = getPrimaryTextByItemIndex(i).trim();
  6414. if (!primaryText) {
  6415. continue;
  6416. }
  6417. var firstChar = primaryText[0].toLowerCase();
  6418. if (!sortedIndexByFirstChar.has(firstChar)) {
  6419. sortedIndexByFirstChar.set(firstChar, []);
  6420. }
  6421. sortedIndexByFirstChar.get(firstChar).push({ text: primaryText.toLowerCase(), index: i });
  6422. }
  6423. // Sort the mapping
  6424. // TODO(b/157162694): Investigate replacing forEach with Map.values()
  6425. sortedIndexByFirstChar.forEach(function (values) {
  6426. values.sort(function (first, second) {
  6427. return first.index - second.index;
  6428. });
  6429. });
  6430. return sortedIndexByFirstChar;
  6431. }
  6432. exports.initSortedIndex = initSortedIndex;
  6433. /**
  6434. * Given the next desired character from the user, it attempts to find the next
  6435. * list option matching the buffer. Wraps around if at the end of options.
  6436. *
  6437. * @param opts Options and accessors
  6438. * - nextChar - the next character to match against items
  6439. * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
  6440. * - focusedItemIndex - the index of the currently focused item
  6441. * - focusItemAtIndex - function that focuses a list item at given index
  6442. * - skipFocus - whether or not to focus the matched item
  6443. * - isItemAtIndexDisabled - function that determines whether an item at a
  6444. * given index is disabled
  6445. * @param state The typeahead state instance. See `initState`.
  6446. *
  6447. * @return The index of the matched item, or -1 if no match.
  6448. */
  6449. function matchItem(opts, state) {
  6450. var nextChar = opts.nextChar,
  6451. focusItemAtIndex = opts.focusItemAtIndex,
  6452. sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
  6453. focusedItemIndex = opts.focusedItemIndex,
  6454. skipFocus = opts.skipFocus,
  6455. isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
  6456. clearTimeout(state.bufferClearTimeout);
  6457. state.bufferClearTimeout = setTimeout(function () {
  6458. clearBuffer(state);
  6459. }, constants_1.numbers.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS);
  6460. state.typeaheadBuffer = state.typeaheadBuffer + nextChar;
  6461. var index;
  6462. if (state.typeaheadBuffer.length === 1) {
  6463. index = matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state);
  6464. } else {
  6465. index = matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state);
  6466. }
  6467. if (index !== -1 && !skipFocus) {
  6468. focusItemAtIndex(index);
  6469. }
  6470. return index;
  6471. }
  6472. exports.matchItem = matchItem;
  6473. /**
  6474. * Matches the user's single input character in the buffer to the
  6475. * next option that begins with such character. Wraps around if at
  6476. * end of options. Returns -1 if no match is found.
  6477. */
  6478. function matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state) {
  6479. var firstChar = state.typeaheadBuffer[0];
  6480. var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
  6481. if (!itemsMatchingFirstChar) {
  6482. return -1;
  6483. }
  6484. // Has the same firstChar been recently matched?
  6485. // Also, did starting index remain the same between key presses?
  6486. // If both hold true, simply increment index.
  6487. if (firstChar === state.currentFirstChar && itemsMatchingFirstChar[state.sortedIndexCursor].index === focusedItemIndex) {
  6488. state.sortedIndexCursor = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
  6489. var newIndex = itemsMatchingFirstChar[state.sortedIndexCursor].index;
  6490. if (!isItemAtIndexDisabled(newIndex)) {
  6491. return newIndex;
  6492. }
  6493. }
  6494. // If we're here, it means one of the following happened:
  6495. // - either firstChar or startingIndex has changed, invalidating the
  6496. // cursor.
  6497. // - The next item of typeahead is disabled, so we have to look further.
  6498. state.currentFirstChar = firstChar;
  6499. var newCursorPosition = -1;
  6500. var cursorPosition;
  6501. // Find the first non-disabled item as a fallback.
  6502. for (cursorPosition = 0; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
  6503. if (!isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
  6504. newCursorPosition = cursorPosition;
  6505. break;
  6506. }
  6507. }
  6508. // Advance cursor to first item matching the firstChar that is positioned
  6509. // after starting item. Cursor is unchanged from fallback if there's no
  6510. // such item.
  6511. for (; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
  6512. if (itemsMatchingFirstChar[cursorPosition].index > focusedItemIndex && !isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
  6513. newCursorPosition = cursorPosition;
  6514. break;
  6515. }
  6516. }
  6517. if (newCursorPosition !== -1) {
  6518. state.sortedIndexCursor = newCursorPosition;
  6519. return itemsMatchingFirstChar[state.sortedIndexCursor].index;
  6520. }
  6521. return -1;
  6522. }
  6523. /**
  6524. * Attempts to find the next item that matches all of the typeahead buffer.
  6525. * Wraps around if at end of options. Returns -1 if no match is found.
  6526. */
  6527. function matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state) {
  6528. var firstChar = state.typeaheadBuffer[0];
  6529. var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
  6530. if (!itemsMatchingFirstChar) {
  6531. return -1;
  6532. }
  6533. // Do nothing if text already matches
  6534. var startingItem = itemsMatchingFirstChar[state.sortedIndexCursor];
  6535. if (startingItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0 && !isItemAtIndexDisabled(startingItem.index)) {
  6536. return startingItem.index;
  6537. }
  6538. // Find next item that matches completely; if no match, we'll eventually
  6539. // loop around to same position
  6540. var cursorPosition = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
  6541. var nextCursorPosition = -1;
  6542. while (cursorPosition !== state.sortedIndexCursor) {
  6543. var currentItem = itemsMatchingFirstChar[cursorPosition];
  6544. var matches = currentItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0;
  6545. var isEnabled = !isItemAtIndexDisabled(currentItem.index);
  6546. if (matches && isEnabled) {
  6547. nextCursorPosition = cursorPosition;
  6548. break;
  6549. }
  6550. cursorPosition = (cursorPosition + 1) % itemsMatchingFirstChar.length;
  6551. }
  6552. if (nextCursorPosition !== -1) {
  6553. state.sortedIndexCursor = nextCursorPosition;
  6554. return itemsMatchingFirstChar[state.sortedIndexCursor].index;
  6555. }
  6556. return -1;
  6557. }
  6558. /**
  6559. * Whether or not the given typeahead instaance state is currently typing.
  6560. *
  6561. * @param state The typeahead state instance. See `initState`.
  6562. */
  6563. function isTypingInProgress(state) {
  6564. return state.typeaheadBuffer.length > 0;
  6565. }
  6566. exports.isTypingInProgress = isTypingInProgress;
  6567. /**
  6568. * Clears the typeahaed buffer so that it resets item matching to the first
  6569. * character.
  6570. *
  6571. * @param state The typeahead state instance. See `initState`.
  6572. */
  6573. function clearBuffer(state) {
  6574. state.typeaheadBuffer = '';
  6575. }
  6576. exports.clearBuffer = clearBuffer;
  6577. /**
  6578. * Given a keydown event, it calculates whether or not to automatically focus a
  6579. * list item depending on what was typed mimicking the typeahead functionality
  6580. * of a standard <select> element that is open.
  6581. *
  6582. * @param opts Options and accessors
  6583. * - event - the KeyboardEvent to handle and parse
  6584. * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
  6585. * - focusedItemIndex - the index of the currently focused item
  6586. * - focusItemAtIndex - function that focuses a list item at given index
  6587. * - isItemAtFocusedIndexDisabled - whether or not the currently focused item
  6588. * is disabled
  6589. * - isTargetListItem - whether or not the event target is a list item
  6590. * @param state The typeahead state instance. See `initState`.
  6591. *
  6592. * @return index of the item matched by the keydown. -1 if not matched.
  6593. */
  6594. function handleKeydown(opts, state) {
  6595. var event = opts.event,
  6596. isTargetListItem = opts.isTargetListItem,
  6597. focusedItemIndex = opts.focusedItemIndex,
  6598. focusItemAtIndex = opts.focusItemAtIndex,
  6599. sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
  6600. isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
  6601. var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
  6602. var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
  6603. var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
  6604. var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
  6605. var isHome = keyboard_1.normalizeKey(event) === 'Home';
  6606. var isEnd = keyboard_1.normalizeKey(event) === 'End';
  6607. var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
  6608. var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
  6609. if (event.altKey || event.ctrlKey || event.metaKey || isArrowLeft || isArrowUp || isArrowRight || isArrowDown || isHome || isEnd || isEnter) {
  6610. return -1;
  6611. }
  6612. var isCharacterKey = !isSpace && event.key.length === 1;
  6613. if (isCharacterKey) {
  6614. events_1.preventDefaultEvent(event);
  6615. var matchItemOpts = {
  6616. focusItemAtIndex: focusItemAtIndex,
  6617. focusedItemIndex: focusedItemIndex,
  6618. nextChar: event.key.toLowerCase(),
  6619. sortedIndexByFirstChar: sortedIndexByFirstChar,
  6620. skipFocus: false,
  6621. isItemAtIndexDisabled: isItemAtIndexDisabled
  6622. };
  6623. return matchItem(matchItemOpts, state);
  6624. }
  6625. if (!isSpace) {
  6626. return -1;
  6627. }
  6628. if (isTargetListItem) {
  6629. events_1.preventDefaultEvent(event);
  6630. }
  6631. var typeaheadOnListItem = isTargetListItem && isTypingInProgress(state);
  6632. if (typeaheadOnListItem) {
  6633. var matchItemOpts = {
  6634. focusItemAtIndex: focusItemAtIndex,
  6635. focusedItemIndex: focusedItemIndex,
  6636. nextChar: ' ',
  6637. sortedIndexByFirstChar: sortedIndexByFirstChar,
  6638. skipFocus: false,
  6639. isItemAtIndexDisabled: isItemAtIndexDisabled
  6640. };
  6641. // space participates in typeahead matching if in rapid typing mode
  6642. return matchItem(matchItemOpts, state);
  6643. }
  6644. return -1;
  6645. }
  6646. exports.handleKeydown = handleKeydown;
  6647. /***/ }),
  6648. /***/ "./packages/mdc-menu-surface/component.ts":
  6649. /*!************************************************!*\
  6650. !*** ./packages/mdc-menu-surface/component.ts ***!
  6651. \************************************************/
  6652. /*! no static exports found */
  6653. /***/ (function(module, exports, __webpack_require__) {
  6654. "use strict";
  6655. /**
  6656. * @license
  6657. * Copyright 2018 Google Inc.
  6658. *
  6659. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6660. * of this software and associated documentation files (the "Software"), to deal
  6661. * in the Software without restriction, including without limitation the rights
  6662. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6663. * copies of the Software, and to permit persons to whom the Software is
  6664. * furnished to do so, subject to the following conditions:
  6665. *
  6666. * The above copyright notice and this permission notice shall be included in
  6667. * all copies or substantial portions of the Software.
  6668. *
  6669. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6670. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6671. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6672. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6673. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6674. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6675. * THE SOFTWARE.
  6676. */
  6677. var __extends = this && this.__extends || function () {
  6678. var _extendStatics = function extendStatics(d, b) {
  6679. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  6680. d.__proto__ = b;
  6681. } || function (d, b) {
  6682. for (var p in b) {
  6683. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  6684. }
  6685. };
  6686. return _extendStatics(d, b);
  6687. };
  6688. return function (d, b) {
  6689. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  6690. _extendStatics(d, b);
  6691. function __() {
  6692. this.constructor = d;
  6693. }
  6694. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6695. };
  6696. }();
  6697. Object.defineProperty(exports, "__esModule", { value: true });
  6698. exports.MDCMenuSurface = void 0;
  6699. var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
  6700. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  6701. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
  6702. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu-surface/foundation.ts");
  6703. /** MDC Menu Surface */
  6704. var MDCMenuSurface = /** @class */function (_super) {
  6705. __extends(MDCMenuSurface, _super);
  6706. function MDCMenuSurface() {
  6707. return _super !== null && _super.apply(this, arguments) || this;
  6708. }
  6709. MDCMenuSurface.attachTo = function (root) {
  6710. return new MDCMenuSurface(root);
  6711. };
  6712. MDCMenuSurface.prototype.initialSyncWithDOM = function () {
  6713. var _this = this;
  6714. var parentEl = this.root.parentElement;
  6715. this.anchorElement = parentEl && parentEl.classList.contains(constants_1.cssClasses.ANCHOR) ? parentEl : null;
  6716. if (this.root.classList.contains(constants_1.cssClasses.FIXED)) {
  6717. this.setFixedPosition(true);
  6718. }
  6719. this.handleKeydown = function (event) {
  6720. _this.foundation.handleKeydown(event);
  6721. };
  6722. this.handleBodyClick = function (event) {
  6723. _this.foundation.handleBodyClick(event);
  6724. };
  6725. // capture so that no race between handleBodyClick and quickOpen when
  6726. // menusurface opened on button click which registers this listener
  6727. this.registerBodyClickListener = function () {
  6728. document.body.addEventListener('click', _this.handleBodyClick, { capture: true });
  6729. };
  6730. this.deregisterBodyClickListener = function () {
  6731. document.body.removeEventListener('click', _this.handleBodyClick, { capture: true });
  6732. };
  6733. this.listen('keydown', this.handleKeydown);
  6734. this.listen(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
  6735. this.listen(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
  6736. };
  6737. MDCMenuSurface.prototype.destroy = function () {
  6738. this.unlisten('keydown', this.handleKeydown);
  6739. this.unlisten(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
  6740. this.unlisten(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
  6741. _super.prototype.destroy.call(this);
  6742. };
  6743. MDCMenuSurface.prototype.isOpen = function () {
  6744. return this.foundation.isOpen();
  6745. };
  6746. MDCMenuSurface.prototype.open = function () {
  6747. this.foundation.open();
  6748. };
  6749. MDCMenuSurface.prototype.close = function (skipRestoreFocus) {
  6750. if (skipRestoreFocus === void 0) {
  6751. skipRestoreFocus = false;
  6752. }
  6753. this.foundation.close(skipRestoreFocus);
  6754. };
  6755. Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", {
  6756. set: function set(quickOpen) {
  6757. this.foundation.setQuickOpen(quickOpen);
  6758. },
  6759. enumerable: false,
  6760. configurable: true
  6761. });
  6762. /**
  6763. * Sets the foundation to use page offsets for a positioning when the menu is
  6764. * hoisted to the body.
  6765. */
  6766. MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) {
  6767. this.foundation.setIsHoisted(isHoisted);
  6768. };
  6769. /** Sets the element that the menu-surface is anchored to. */
  6770. MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) {
  6771. this.anchorElement = element;
  6772. };
  6773. /** Sets the menu-surface to position: fixed. */
  6774. MDCMenuSurface.prototype.setFixedPosition = function (isFixed) {
  6775. if (isFixed) {
  6776. this.root.classList.add(constants_1.cssClasses.FIXED);
  6777. } else {
  6778. this.root.classList.remove(constants_1.cssClasses.FIXED);
  6779. }
  6780. this.foundation.setFixedPosition(isFixed);
  6781. };
  6782. /**
  6783. * Sets the absolute x/y position to position based on. Requires the menu to
  6784. * be hoisted.
  6785. */
  6786. MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) {
  6787. this.foundation.setAbsolutePosition(x, y);
  6788. this.setIsHoisted(true);
  6789. };
  6790. /**
  6791. * @param corner Default anchor corner alignment of top-left surface corner.
  6792. */
  6793. MDCMenuSurface.prototype.setAnchorCorner = function (corner) {
  6794. this.foundation.setAnchorCorner(corner);
  6795. };
  6796. MDCMenuSurface.prototype.setAnchorMargin = function (margin) {
  6797. this.foundation.setAnchorMargin(margin);
  6798. };
  6799. MDCMenuSurface.prototype.getDefaultFoundation = function () {
  6800. var _this = this;
  6801. // DO NOT INLINE this variable. For backward compatibility, foundations take
  6802. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  6803. // methods, we need a separate, strongly typed adapter variable.
  6804. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  6805. var adapter = {
  6806. addClass: function addClass(className) {
  6807. _this.root.classList.add(className);
  6808. },
  6809. removeClass: function removeClass(className) {
  6810. _this.root.classList.remove(className);
  6811. },
  6812. hasClass: function hasClass(className) {
  6813. return _this.root.classList.contains(className);
  6814. },
  6815. hasAnchor: function hasAnchor() {
  6816. return !!_this.anchorElement;
  6817. },
  6818. notifyClose: function notifyClose() {
  6819. _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {});
  6820. },
  6821. notifyClosing: function notifyClosing() {
  6822. _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSING_EVENT, {});
  6823. },
  6824. notifyOpen: function notifyOpen() {
  6825. _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {});
  6826. },
  6827. notifyOpening: function notifyOpening() {
  6828. _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENING_EVENT, {});
  6829. },
  6830. isElementInContainer: function isElementInContainer(el) {
  6831. return _this.root.contains(el);
  6832. },
  6833. isRtl: function isRtl() {
  6834. return getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
  6835. },
  6836. setTransformOrigin: function setTransformOrigin(origin) {
  6837. var propertyName = util_1.getCorrectPropertyName(window, 'transform') + "-origin";
  6838. _this.root.style.setProperty(propertyName, origin);
  6839. },
  6840. isFocused: function isFocused() {
  6841. return document.activeElement === _this.root;
  6842. },
  6843. saveFocus: function saveFocus() {
  6844. _this.previousFocus = document.activeElement;
  6845. },
  6846. restoreFocus: function restoreFocus() {
  6847. if (_this.root.contains(document.activeElement)) {
  6848. if (_this.previousFocus && _this.previousFocus.focus) {
  6849. _this.previousFocus.focus();
  6850. }
  6851. }
  6852. },
  6853. getInnerDimensions: function getInnerDimensions() {
  6854. return { width: _this.root.offsetWidth, height: _this.root.offsetHeight };
  6855. },
  6856. getAnchorDimensions: function getAnchorDimensions() {
  6857. return _this.anchorElement ? _this.anchorElement.getBoundingClientRect() : null;
  6858. },
  6859. getViewportDimensions: function getViewportDimensions() {
  6860. return { width: window.innerWidth, height: window.innerHeight };
  6861. },
  6862. getBodyDimensions: function getBodyDimensions() {
  6863. return {
  6864. width: document.body.clientWidth,
  6865. height: document.body.clientHeight
  6866. };
  6867. },
  6868. getWindowScroll: function getWindowScroll() {
  6869. return { x: window.pageXOffset, y: window.pageYOffset };
  6870. },
  6871. setPosition: function setPosition(position) {
  6872. var rootHTML = _this.root;
  6873. rootHTML.style.left = 'left' in position ? position.left + "px" : '';
  6874. rootHTML.style.right = 'right' in position ? position.right + "px" : '';
  6875. rootHTML.style.top = 'top' in position ? position.top + "px" : '';
  6876. rootHTML.style.bottom = 'bottom' in position ? position.bottom + "px" : '';
  6877. },
  6878. setMaxHeight: function setMaxHeight(height) {
  6879. _this.root.style.maxHeight = height;
  6880. },
  6881. registerWindowEventHandler: function registerWindowEventHandler(evtType, handler) {
  6882. window.addEventListener(evtType, handler);
  6883. },
  6884. deregisterWindowEventHandler: function deregisterWindowEventHandler(evtType, handler) {
  6885. window.removeEventListener(evtType, handler);
  6886. }
  6887. };
  6888. // tslint:enable:object-literal-sort-keys
  6889. return new foundation_1.MDCMenuSurfaceFoundation(adapter);
  6890. };
  6891. return MDCMenuSurface;
  6892. }(component_1.MDCComponent);
  6893. exports.MDCMenuSurface = MDCMenuSurface;
  6894. /***/ }),
  6895. /***/ "./packages/mdc-menu-surface/constants.ts":
  6896. /*!************************************************!*\
  6897. !*** ./packages/mdc-menu-surface/constants.ts ***!
  6898. \************************************************/
  6899. /*! no static exports found */
  6900. /***/ (function(module, exports, __webpack_require__) {
  6901. "use strict";
  6902. /**
  6903. * @license
  6904. * Copyright 2018 Google Inc.
  6905. *
  6906. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6907. * of this software and associated documentation files (the "Software"), to deal
  6908. * in the Software without restriction, including without limitation the rights
  6909. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  6910. * copies of the Software, and to permit persons to whom the Software is
  6911. * furnished to do so, subject to the following conditions:
  6912. *
  6913. * The above copyright notice and this permission notice shall be included in
  6914. * all copies or substantial portions of the Software.
  6915. *
  6916. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  6917. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  6918. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  6919. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  6920. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  6921. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  6922. * THE SOFTWARE.
  6923. */
  6924. Object.defineProperty(exports, "__esModule", { value: true });
  6925. exports.Corner = exports.CornerBit = exports.numbers = exports.strings = exports.cssClasses = void 0;
  6926. var cssClasses = {
  6927. ANCHOR: 'mdc-menu-surface--anchor',
  6928. ANIMATING_CLOSED: 'mdc-menu-surface--animating-closed',
  6929. ANIMATING_OPEN: 'mdc-menu-surface--animating-open',
  6930. FIXED: 'mdc-menu-surface--fixed',
  6931. IS_OPEN_BELOW: 'mdc-menu-surface--is-open-below',
  6932. OPEN: 'mdc-menu-surface--open',
  6933. ROOT: 'mdc-menu-surface'
  6934. };
  6935. exports.cssClasses = cssClasses;
  6936. // tslint:disable:object-literal-sort-keys
  6937. var strings = {
  6938. CLOSED_EVENT: 'MDCMenuSurface:closed',
  6939. CLOSING_EVENT: 'MDCMenuSurface:closing',
  6940. OPENED_EVENT: 'MDCMenuSurface:opened',
  6941. OPENING_EVENT: 'MDCMenuSurface:opening',
  6942. 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(', ')
  6943. };
  6944. exports.strings = strings;
  6945. // tslint:enable:object-literal-sort-keys
  6946. var numbers = {
  6947. /** Total duration of menu-surface open animation. */
  6948. TRANSITION_OPEN_DURATION: 120,
  6949. /** Total duration of menu-surface close animation. */
  6950. TRANSITION_CLOSE_DURATION: 75,
  6951. /**
  6952. * Margin left to the edge of the viewport when menu-surface is at maximum
  6953. * possible height. Also used as a viewport margin.
  6954. */
  6955. MARGIN_TO_EDGE: 32,
  6956. /**
  6957. * Ratio of anchor width to menu-surface width for switching from corner
  6958. * positioning to center positioning.
  6959. */
  6960. ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67,
  6961. /**
  6962. * Amount of time to wait before restoring focus when closing the menu
  6963. * surface. This is important because if a touch event triggered the menu
  6964. * close, and the subsequent mouse event occurs after focus is restored, then
  6965. * the restored focus would be lost.
  6966. */
  6967. TOUCH_EVENT_WAIT_MS: 30
  6968. };
  6969. exports.numbers = numbers;
  6970. /**
  6971. * Enum for bits in the {@see Corner) bitmap.
  6972. */
  6973. var CornerBit;
  6974. (function (CornerBit) {
  6975. CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM";
  6976. CornerBit[CornerBit["CENTER"] = 2] = "CENTER";
  6977. CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT";
  6978. CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL";
  6979. })(CornerBit || (CornerBit = {}));
  6980. exports.CornerBit = CornerBit;
  6981. /**
  6982. * Enum for representing an element corner for positioning the menu-surface.
  6983. *
  6984. * The START constants map to LEFT if element directionality is left
  6985. * to right and RIGHT if the directionality is right to left.
  6986. * Likewise END maps to RIGHT or LEFT depending on the directionality.
  6987. */
  6988. var Corner;
  6989. (function (Corner) {
  6990. Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT";
  6991. Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT";
  6992. Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT";
  6993. Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT";
  6994. Corner[Corner["TOP_START"] = 8] = "TOP_START";
  6995. Corner[Corner["TOP_END"] = 12] = "TOP_END";
  6996. Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START";
  6997. Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END";
  6998. })(Corner || (Corner = {}));
  6999. exports.Corner = Corner;
  7000. /***/ }),
  7001. /***/ "./packages/mdc-menu-surface/foundation.ts":
  7002. /*!*************************************************!*\
  7003. !*** ./packages/mdc-menu-surface/foundation.ts ***!
  7004. \*************************************************/
  7005. /*! no static exports found */
  7006. /***/ (function(module, exports, __webpack_require__) {
  7007. "use strict";
  7008. /**
  7009. * @license
  7010. * Copyright 2018 Google Inc.
  7011. *
  7012. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7013. * of this software and associated documentation files (the "Software"), to deal
  7014. * in the Software without restriction, including without limitation the rights
  7015. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7016. * copies of the Software, and to permit persons to whom the Software is
  7017. * furnished to do so, subject to the following conditions:
  7018. *
  7019. * The above copyright notice and this permission notice shall be included in
  7020. * all copies or substantial portions of the Software.
  7021. *
  7022. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7023. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7024. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7025. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7026. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7027. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7028. * THE SOFTWARE.
  7029. */
  7030. var __extends = this && this.__extends || function () {
  7031. var _extendStatics = function extendStatics(d, b) {
  7032. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7033. d.__proto__ = b;
  7034. } || function (d, b) {
  7035. for (var p in b) {
  7036. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  7037. }
  7038. };
  7039. return _extendStatics(d, b);
  7040. };
  7041. return function (d, b) {
  7042. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  7043. _extendStatics(d, b);
  7044. function __() {
  7045. this.constructor = d;
  7046. }
  7047. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7048. };
  7049. }();
  7050. var __assign = this && this.__assign || function () {
  7051. __assign = Object.assign || function (t) {
  7052. for (var s, i = 1, n = arguments.length; i < n; i++) {
  7053. s = arguments[i];
  7054. for (var p in s) {
  7055. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  7056. }
  7057. }
  7058. return t;
  7059. };
  7060. return __assign.apply(this, arguments);
  7061. };
  7062. var __values = this && this.__values || function (o) {
  7063. var s = typeof Symbol === "function" && Symbol.iterator,
  7064. m = s && o[s],
  7065. i = 0;
  7066. if (m) return m.call(o);
  7067. if (o && typeof o.length === "number") return {
  7068. next: function next() {
  7069. if (o && i >= o.length) o = void 0;
  7070. return { value: o && o[i++], done: !o };
  7071. }
  7072. };
  7073. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  7074. };
  7075. Object.defineProperty(exports, "__esModule", { value: true });
  7076. exports.MDCMenuSurfaceFoundation = void 0;
  7077. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  7078. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
  7079. /** MDC Menu Surface Foundation */
  7080. var MDCMenuSurfaceFoundation = /** @class */function (_super) {
  7081. __extends(MDCMenuSurfaceFoundation, _super);
  7082. function MDCMenuSurfaceFoundation(adapter) {
  7083. var _this = _super.call(this, __assign(__assign({}, MDCMenuSurfaceFoundation.defaultAdapter), adapter)) || this;
  7084. _this.isSurfaceOpen = false;
  7085. _this.isQuickOpen = false;
  7086. _this.isHoistedElement = false;
  7087. _this.isFixedPosition = false;
  7088. _this.isHorizontallyCenteredOnViewport = false;
  7089. _this.maxHeight = 0;
  7090. _this.openBottomBias = 0;
  7091. _this.openAnimationEndTimerId = 0;
  7092. _this.closeAnimationEndTimerId = 0;
  7093. _this.animationRequestId = 0;
  7094. _this.anchorCorner = constants_1.Corner.TOP_START;
  7095. /**
  7096. * Corner of the menu surface to which menu surface is attached to anchor.
  7097. *
  7098. * Anchor corner --->+----------+
  7099. * | ANCHOR |
  7100. * +----------+
  7101. * Origin corner --->+--------------+
  7102. * | |
  7103. * | |
  7104. * | MENU SURFACE |
  7105. * | |
  7106. * | |
  7107. * +--------------+
  7108. */
  7109. _this.originCorner = constants_1.Corner.TOP_START;
  7110. _this.anchorMargin = { top: 0, right: 0, bottom: 0, left: 0 };
  7111. _this.position = { x: 0, y: 0 };
  7112. return _this;
  7113. }
  7114. Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", {
  7115. get: function get() {
  7116. return constants_1.cssClasses;
  7117. },
  7118. enumerable: false,
  7119. configurable: true
  7120. });
  7121. Object.defineProperty(MDCMenuSurfaceFoundation, "strings", {
  7122. get: function get() {
  7123. return constants_1.strings;
  7124. },
  7125. enumerable: false,
  7126. configurable: true
  7127. });
  7128. Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", {
  7129. get: function get() {
  7130. return constants_1.numbers;
  7131. },
  7132. enumerable: false,
  7133. configurable: true
  7134. });
  7135. Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", {
  7136. get: function get() {
  7137. return constants_1.Corner;
  7138. },
  7139. enumerable: false,
  7140. configurable: true
  7141. });
  7142. Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", {
  7143. /**
  7144. * @see {@link MDCMenuSurfaceAdapter} for typing information on parameters and return types.
  7145. */
  7146. get: function get() {
  7147. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  7148. return {
  7149. addClass: function addClass() {
  7150. return undefined;
  7151. },
  7152. removeClass: function removeClass() {
  7153. return undefined;
  7154. },
  7155. hasClass: function hasClass() {
  7156. return false;
  7157. },
  7158. hasAnchor: function hasAnchor() {
  7159. return false;
  7160. },
  7161. isElementInContainer: function isElementInContainer() {
  7162. return false;
  7163. },
  7164. isFocused: function isFocused() {
  7165. return false;
  7166. },
  7167. isRtl: function isRtl() {
  7168. return false;
  7169. },
  7170. getInnerDimensions: function getInnerDimensions() {
  7171. return { height: 0, width: 0 };
  7172. },
  7173. getAnchorDimensions: function getAnchorDimensions() {
  7174. return null;
  7175. },
  7176. getViewportDimensions: function getViewportDimensions() {
  7177. return { height: 0, width: 0 };
  7178. },
  7179. getBodyDimensions: function getBodyDimensions() {
  7180. return { height: 0, width: 0 };
  7181. },
  7182. getWindowScroll: function getWindowScroll() {
  7183. return { x: 0, y: 0 };
  7184. },
  7185. setPosition: function setPosition() {
  7186. return undefined;
  7187. },
  7188. setMaxHeight: function setMaxHeight() {
  7189. return undefined;
  7190. },
  7191. setTransformOrigin: function setTransformOrigin() {
  7192. return undefined;
  7193. },
  7194. saveFocus: function saveFocus() {
  7195. return undefined;
  7196. },
  7197. restoreFocus: function restoreFocus() {
  7198. return undefined;
  7199. },
  7200. notifyClose: function notifyClose() {
  7201. return undefined;
  7202. },
  7203. notifyClosing: function notifyClosing() {
  7204. return undefined;
  7205. },
  7206. notifyOpen: function notifyOpen() {
  7207. return undefined;
  7208. },
  7209. notifyOpening: function notifyOpening() {
  7210. return undefined;
  7211. },
  7212. registerWindowEventHandler: function registerWindowEventHandler() {
  7213. return undefined;
  7214. },
  7215. deregisterWindowEventHandler: function deregisterWindowEventHandler() {
  7216. return undefined;
  7217. }
  7218. };
  7219. // tslint:enable:object-literal-sort-keys
  7220. },
  7221. enumerable: false,
  7222. configurable: true
  7223. });
  7224. MDCMenuSurfaceFoundation.prototype.init = function () {
  7225. var _a = MDCMenuSurfaceFoundation.cssClasses,
  7226. ROOT = _a.ROOT,
  7227. OPEN = _a.OPEN;
  7228. if (!this.adapter.hasClass(ROOT)) {
  7229. throw new Error(ROOT + " class required in root element.");
  7230. }
  7231. if (this.adapter.hasClass(OPEN)) {
  7232. this.isSurfaceOpen = true;
  7233. }
  7234. this.resizeListener = this.handleResize.bind(this);
  7235. this.adapter.registerWindowEventHandler('resize', this.resizeListener);
  7236. };
  7237. MDCMenuSurfaceFoundation.prototype.destroy = function () {
  7238. clearTimeout(this.openAnimationEndTimerId);
  7239. clearTimeout(this.closeAnimationEndTimerId);
  7240. // Cancel any currently running animations.
  7241. cancelAnimationFrame(this.animationRequestId);
  7242. this.adapter.deregisterWindowEventHandler('resize', this.resizeListener);
  7243. };
  7244. /**
  7245. * @param corner Default anchor corner alignment of top-left menu surface
  7246. * corner.
  7247. */
  7248. MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) {
  7249. this.anchorCorner = corner;
  7250. };
  7251. /**
  7252. * Flip menu corner horizontally.
  7253. */
  7254. MDCMenuSurfaceFoundation.prototype.flipCornerHorizontally = function () {
  7255. this.originCorner = this.originCorner ^ constants_1.CornerBit.RIGHT;
  7256. };
  7257. /**
  7258. * @param margin Set of margin values from anchor.
  7259. */
  7260. MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) {
  7261. this.anchorMargin.top = margin.top || 0;
  7262. this.anchorMargin.right = margin.right || 0;
  7263. this.anchorMargin.bottom = margin.bottom || 0;
  7264. this.anchorMargin.left = margin.left || 0;
  7265. };
  7266. /** Used to indicate if the menu-surface is hoisted to the body. */
  7267. MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) {
  7268. this.isHoistedElement = isHoisted;
  7269. };
  7270. /**
  7271. * Used to set the menu-surface calculations based on a fixed position menu.
  7272. */
  7273. MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) {
  7274. this.isFixedPosition = isFixedPosition;
  7275. };
  7276. /**
  7277. * @return Returns true if menu is in fixed (`position: fixed`) position.
  7278. */
  7279. MDCMenuSurfaceFoundation.prototype.isFixed = function () {
  7280. return this.isFixedPosition;
  7281. };
  7282. /** Sets the menu-surface position on the page. */
  7283. MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) {
  7284. this.position.x = this.isFinite(x) ? x : 0;
  7285. this.position.y = this.isFinite(y) ? y : 0;
  7286. };
  7287. /** Sets whether menu-surface should be horizontally centered to viewport. */
  7288. MDCMenuSurfaceFoundation.prototype.setIsHorizontallyCenteredOnViewport = function (isCentered) {
  7289. this.isHorizontallyCenteredOnViewport = isCentered;
  7290. };
  7291. MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) {
  7292. this.isQuickOpen = quickOpen;
  7293. };
  7294. /**
  7295. * Sets maximum menu-surface height on open.
  7296. * @param maxHeight The desired max-height. Set to 0 (default) to
  7297. * automatically calculate max height based on available viewport space.
  7298. */
  7299. MDCMenuSurfaceFoundation.prototype.setMaxHeight = function (maxHeight) {
  7300. this.maxHeight = maxHeight;
  7301. };
  7302. /**
  7303. * Set to a positive integer to influence the menu to preferentially open
  7304. * below the anchor instead of above.
  7305. * @param bias A value of `x` simulates an extra `x` pixels of available space
  7306. * below the menu during positioning calculations.
  7307. */
  7308. MDCMenuSurfaceFoundation.prototype.setOpenBottomBias = function (bias) {
  7309. this.openBottomBias = bias;
  7310. };
  7311. MDCMenuSurfaceFoundation.prototype.isOpen = function () {
  7312. return this.isSurfaceOpen;
  7313. };
  7314. /**
  7315. * Open the menu surface.
  7316. */
  7317. MDCMenuSurfaceFoundation.prototype.open = function () {
  7318. var _this = this;
  7319. if (this.isSurfaceOpen) {
  7320. return;
  7321. }
  7322. this.adapter.notifyOpening();
  7323. this.adapter.saveFocus();
  7324. if (this.isQuickOpen) {
  7325. this.isSurfaceOpen = true;
  7326. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  7327. this.dimensions = this.adapter.getInnerDimensions();
  7328. this.autoposition();
  7329. this.adapter.notifyOpen();
  7330. } else {
  7331. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
  7332. this.animationRequestId = requestAnimationFrame(function () {
  7333. _this.dimensions = _this.adapter.getInnerDimensions();
  7334. _this.autoposition();
  7335. _this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  7336. _this.openAnimationEndTimerId = setTimeout(function () {
  7337. _this.openAnimationEndTimerId = 0;
  7338. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
  7339. _this.adapter.notifyOpen();
  7340. }, constants_1.numbers.TRANSITION_OPEN_DURATION);
  7341. });
  7342. this.isSurfaceOpen = true;
  7343. }
  7344. this.adapter.registerWindowEventHandler('resize', this.resizeListener);
  7345. };
  7346. /**
  7347. * Closes the menu surface.
  7348. */
  7349. MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) {
  7350. var _this = this;
  7351. if (skipRestoreFocus === void 0) {
  7352. skipRestoreFocus = false;
  7353. }
  7354. if (!this.isSurfaceOpen) {
  7355. return;
  7356. }
  7357. this.adapter.notifyClosing();
  7358. this.adapter.deregisterWindowEventHandler('resize', this.resizeListener);
  7359. if (this.isQuickOpen) {
  7360. this.isSurfaceOpen = false;
  7361. if (!skipRestoreFocus) {
  7362. this.maybeRestoreFocus();
  7363. }
  7364. this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  7365. this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
  7366. this.adapter.notifyClose();
  7367. return;
  7368. }
  7369. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
  7370. requestAnimationFrame(function () {
  7371. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
  7372. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
  7373. _this.closeAnimationEndTimerId = setTimeout(function () {
  7374. _this.closeAnimationEndTimerId = 0;
  7375. _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
  7376. _this.adapter.notifyClose();
  7377. }, constants_1.numbers.TRANSITION_CLOSE_DURATION);
  7378. });
  7379. this.isSurfaceOpen = false;
  7380. if (!skipRestoreFocus) {
  7381. this.maybeRestoreFocus();
  7382. }
  7383. };
  7384. /** Handle clicks and close if not within menu-surface element. */
  7385. MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) {
  7386. var el = evt.target;
  7387. if (this.adapter.isElementInContainer(el)) {
  7388. return;
  7389. }
  7390. this.close();
  7391. };
  7392. /** Handle keys that close the surface. */
  7393. MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) {
  7394. var keyCode = evt.keyCode,
  7395. key = evt.key;
  7396. var isEscape = key === 'Escape' || keyCode === 27;
  7397. if (isEscape) {
  7398. this.close();
  7399. }
  7400. };
  7401. /** Handles resize events on the window. */
  7402. MDCMenuSurfaceFoundation.prototype.handleResize = function () {
  7403. this.dimensions = this.adapter.getInnerDimensions();
  7404. this.autoposition();
  7405. };
  7406. MDCMenuSurfaceFoundation.prototype.autoposition = function () {
  7407. var _a;
  7408. // Compute measurements for autoposition methods reuse.
  7409. this.measurements = this.getAutoLayoutmeasurements();
  7410. var corner = this.getoriginCorner();
  7411. var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight(corner);
  7412. var verticalAlignment = this.hasBit(corner, constants_1.CornerBit.BOTTOM) ? 'bottom' : 'top';
  7413. var horizontalAlignment = this.hasBit(corner, constants_1.CornerBit.RIGHT) ? 'right' : 'left';
  7414. var horizontalOffset = this.getHorizontalOriginOffset(corner);
  7415. var verticalOffset = this.getVerticalOriginOffset(corner);
  7416. var _b = this.measurements,
  7417. anchorSize = _b.anchorSize,
  7418. surfaceSize = _b.surfaceSize;
  7419. var position = (_a = {}, _a[horizontalAlignment] = horizontalOffset, _a[verticalAlignment] = verticalOffset, _a);
  7420. // Center align when anchor width is comparable or greater than menu
  7421. // surface, otherwise keep corner.
  7422. if (anchorSize.width / surfaceSize.width > constants_1.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) {
  7423. horizontalAlignment = 'center';
  7424. }
  7425. // If the menu-surface has been hoisted to the body, it's no longer relative
  7426. // to the anchor element
  7427. if (this.isHoistedElement || this.isFixedPosition) {
  7428. this.adjustPositionForHoistedElement(position);
  7429. }
  7430. this.adapter.setTransformOrigin(horizontalAlignment + " " + verticalAlignment);
  7431. this.adapter.setPosition(position);
  7432. this.adapter.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : '');
  7433. // If it is opened from the top then add is-open-below class
  7434. if (!this.hasBit(corner, constants_1.CornerBit.BOTTOM)) {
  7435. this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
  7436. }
  7437. };
  7438. /**
  7439. * @return Measurements used to position menu surface popup.
  7440. */
  7441. MDCMenuSurfaceFoundation.prototype.getAutoLayoutmeasurements = function () {
  7442. var anchorRect = this.adapter.getAnchorDimensions();
  7443. var bodySize = this.adapter.getBodyDimensions();
  7444. var viewportSize = this.adapter.getViewportDimensions();
  7445. var windowScroll = this.adapter.getWindowScroll();
  7446. if (!anchorRect) {
  7447. // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
  7448. anchorRect = {
  7449. top: this.position.y,
  7450. right: this.position.x,
  7451. bottom: this.position.y,
  7452. left: this.position.x,
  7453. width: 0,
  7454. height: 0
  7455. };
  7456. // tslint:enable:object-literal-sort-keys
  7457. }
  7458. return {
  7459. anchorSize: anchorRect,
  7460. bodySize: bodySize,
  7461. surfaceSize: this.dimensions,
  7462. viewportDistance: {
  7463. // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
  7464. top: anchorRect.top,
  7465. right: viewportSize.width - anchorRect.right,
  7466. bottom: viewportSize.height - anchorRect.bottom,
  7467. left: anchorRect.left
  7468. },
  7469. viewportSize: viewportSize,
  7470. windowScroll: windowScroll
  7471. };
  7472. };
  7473. /**
  7474. * Computes the corner of the anchor from which to animate and position the
  7475. * menu surface.
  7476. *
  7477. * Only LEFT or RIGHT bit is used to position the menu surface ignoring RTL
  7478. * context. E.g., menu surface will be positioned from right side on TOP_END.
  7479. */
  7480. MDCMenuSurfaceFoundation.prototype.getoriginCorner = function () {
  7481. var corner = this.originCorner;
  7482. var _a = this.measurements,
  7483. viewportDistance = _a.viewportDistance,
  7484. anchorSize = _a.anchorSize,
  7485. surfaceSize = _a.surfaceSize;
  7486. var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
  7487. var isAnchoredToBottom = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
  7488. var availableTop;
  7489. var availableBottom;
  7490. if (isAnchoredToBottom) {
  7491. availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.bottom;
  7492. availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE - this.anchorMargin.bottom;
  7493. } else {
  7494. availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.top;
  7495. availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE + anchorSize.height - this.anchorMargin.top;
  7496. }
  7497. var isAvailableBottom = availableBottom - surfaceSize.height > 0;
  7498. if (!isAvailableBottom && availableTop > availableBottom + this.openBottomBias) {
  7499. // Attach bottom side of surface to the anchor.
  7500. corner = this.setBit(corner, constants_1.CornerBit.BOTTOM);
  7501. }
  7502. var isRtl = this.adapter.isRtl();
  7503. var isFlipRtl = this.hasBit(this.anchorCorner, constants_1.CornerBit.FLIP_RTL);
  7504. var hasRightBit = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT) || this.hasBit(corner, constants_1.CornerBit.RIGHT);
  7505. // Whether surface attached to right side of anchor element.
  7506. var isAnchoredToRight = false;
  7507. // Anchored to start
  7508. if (isRtl && isFlipRtl) {
  7509. isAnchoredToRight = !hasRightBit;
  7510. } else {
  7511. // Anchored to right
  7512. isAnchoredToRight = hasRightBit;
  7513. }
  7514. var availableLeft;
  7515. var availableRight;
  7516. if (isAnchoredToRight) {
  7517. availableLeft = viewportDistance.left + anchorSize.width + this.anchorMargin.left;
  7518. availableRight = viewportDistance.right - this.anchorMargin.left;
  7519. } else {
  7520. availableLeft = viewportDistance.left + this.anchorMargin.left;
  7521. availableRight = viewportDistance.right + anchorSize.width - this.anchorMargin.left;
  7522. }
  7523. var isAvailableLeft = availableLeft - surfaceSize.width > 0;
  7524. var isAvailableRight = availableRight - surfaceSize.width > 0;
  7525. var isOriginCornerAlignedToEnd = this.hasBit(corner, constants_1.CornerBit.FLIP_RTL) && this.hasBit(corner, constants_1.CornerBit.RIGHT);
  7526. if (isAvailableRight && isOriginCornerAlignedToEnd && isRtl || !isAvailableLeft && isOriginCornerAlignedToEnd) {
  7527. // Attach left side of surface to the anchor.
  7528. corner = this.unsetBit(corner, constants_1.CornerBit.RIGHT);
  7529. } else if (isAvailableLeft && isAnchoredToRight && isRtl || isAvailableLeft && !isAnchoredToRight && hasRightBit || !isAvailableRight && availableLeft >= availableRight) {
  7530. // Attach right side of surface to the anchor.
  7531. corner = this.setBit(corner, constants_1.CornerBit.RIGHT);
  7532. }
  7533. return corner;
  7534. };
  7535. /**
  7536. * @param corner Origin corner of the menu surface.
  7537. * @return Maximum height of the menu surface, based on available space. 0
  7538. * indicates should not be set.
  7539. */
  7540. MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) {
  7541. if (this.maxHeight > 0) {
  7542. return this.maxHeight;
  7543. }
  7544. var viewportDistance = this.measurements.viewportDistance;
  7545. var maxHeight = 0;
  7546. var isBottomAligned = this.hasBit(corner, constants_1.CornerBit.BOTTOM);
  7547. var isBottomAnchored = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
  7548. var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
  7549. // When maximum height is not specified, it is handled from CSS.
  7550. if (isBottomAligned) {
  7551. maxHeight = viewportDistance.top + this.anchorMargin.top - MARGIN_TO_EDGE;
  7552. if (!isBottomAnchored) {
  7553. maxHeight += this.measurements.anchorSize.height;
  7554. }
  7555. } else {
  7556. maxHeight = viewportDistance.bottom - this.anchorMargin.bottom + this.measurements.anchorSize.height - MARGIN_TO_EDGE;
  7557. if (isBottomAnchored) {
  7558. maxHeight -= this.measurements.anchorSize.height;
  7559. }
  7560. }
  7561. return maxHeight;
  7562. };
  7563. /**
  7564. * @param corner Origin corner of the menu surface.
  7565. * @return Horizontal offset of menu surface origin corner from corresponding
  7566. * anchor corner.
  7567. */
  7568. MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset = function (corner) {
  7569. var anchorSize = this.measurements.anchorSize;
  7570. // isRightAligned corresponds to using the 'right' property on the surface.
  7571. var isRightAligned = this.hasBit(corner, constants_1.CornerBit.RIGHT);
  7572. var avoidHorizontalOverlap = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT);
  7573. if (isRightAligned) {
  7574. var rightOffset = avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.left : this.anchorMargin.right;
  7575. // For hoisted or fixed elements, adjust the offset by the difference
  7576. // between viewport width and body width so when we calculate the right
  7577. // value (`adjustPositionForHoistedElement`) based on the element
  7578. // position, the right property is correct.
  7579. if (this.isHoistedElement || this.isFixedPosition) {
  7580. return rightOffset - (this.measurements.viewportSize.width - this.measurements.bodySize.width);
  7581. }
  7582. return rightOffset;
  7583. }
  7584. return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.right : this.anchorMargin.left;
  7585. };
  7586. /**
  7587. * @param corner Origin corner of the menu surface.
  7588. * @return Vertical offset of menu surface origin corner from corresponding
  7589. * anchor corner.
  7590. */
  7591. MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset = function (corner) {
  7592. var anchorSize = this.measurements.anchorSize;
  7593. var isBottomAligned = this.hasBit(corner, constants_1.CornerBit.BOTTOM);
  7594. var avoidVerticalOverlap = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
  7595. var y = 0;
  7596. if (isBottomAligned) {
  7597. y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin.top : -this.anchorMargin.bottom;
  7598. } else {
  7599. y = avoidVerticalOverlap ? anchorSize.height + this.anchorMargin.bottom : this.anchorMargin.top;
  7600. }
  7601. return y;
  7602. };
  7603. /**
  7604. * Calculates the offsets for positioning the menu-surface when the
  7605. * menu-surface has been hoisted to the body.
  7606. */
  7607. MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement = function (position) {
  7608. var e_1, _a;
  7609. var _b = this.measurements,
  7610. windowScroll = _b.windowScroll,
  7611. viewportDistance = _b.viewportDistance,
  7612. surfaceSize = _b.surfaceSize,
  7613. viewportSize = _b.viewportSize;
  7614. var props = Object.keys(position);
  7615. try {
  7616. for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
  7617. var prop = props_1_1.value;
  7618. var value = position[prop] || 0;
  7619. if (this.isHorizontallyCenteredOnViewport && (prop === 'left' || prop === 'right')) {
  7620. position[prop] = (viewportSize.width - surfaceSize.width) / 2;
  7621. continue;
  7622. }
  7623. // Hoisted surfaces need to have the anchor elements location on the page
  7624. // added to the position properties for proper alignment on the body.
  7625. value += viewportDistance[prop];
  7626. // Surfaces that are absolutely positioned need to have additional
  7627. // calculations for scroll and bottom positioning.
  7628. if (!this.isFixedPosition) {
  7629. if (prop === 'top') {
  7630. value += windowScroll.y;
  7631. } else if (prop === 'bottom') {
  7632. value -= windowScroll.y;
  7633. } else if (prop === 'left') {
  7634. value += windowScroll.x;
  7635. } else {
  7636. // prop === 'right'
  7637. value -= windowScroll.x;
  7638. }
  7639. }
  7640. position[prop] = value;
  7641. }
  7642. } catch (e_1_1) {
  7643. e_1 = { error: e_1_1 };
  7644. } finally {
  7645. try {
  7646. if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
  7647. } finally {
  7648. if (e_1) throw e_1.error;
  7649. }
  7650. }
  7651. };
  7652. /**
  7653. * The last focused element when the menu surface was opened should regain
  7654. * focus, if the user is focused on or within the menu surface when it is
  7655. * closed.
  7656. */
  7657. MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus = function () {
  7658. var _this = this;
  7659. var isRootFocused = this.adapter.isFocused();
  7660. var ownerDocument = this.adapter.getOwnerDocument ? this.adapter.getOwnerDocument() : document;
  7661. var childHasFocus = ownerDocument.activeElement && this.adapter.isElementInContainer(ownerDocument.activeElement);
  7662. if (isRootFocused || childHasFocus) {
  7663. // Wait before restoring focus when closing the menu surface. This is
  7664. // important because if a touch event triggered the menu close, and the
  7665. // subsequent mouse event occurs after focus is restored, then the
  7666. // restored focus would be lost.
  7667. setTimeout(function () {
  7668. _this.adapter.restoreFocus();
  7669. }, constants_1.numbers.TOUCH_EVENT_WAIT_MS);
  7670. }
  7671. };
  7672. MDCMenuSurfaceFoundation.prototype.hasBit = function (corner, bit) {
  7673. return Boolean(corner & bit); // tslint:disable-line:no-bitwise
  7674. };
  7675. MDCMenuSurfaceFoundation.prototype.setBit = function (corner, bit) {
  7676. return corner | bit; // tslint:disable-line:no-bitwise
  7677. };
  7678. MDCMenuSurfaceFoundation.prototype.unsetBit = function (corner, bit) {
  7679. return corner ^ bit;
  7680. };
  7681. /**
  7682. * isFinite that doesn't force conversion to number type.
  7683. * Equivalent to Number.isFinite in ES2015, which is not supported in IE.
  7684. */
  7685. MDCMenuSurfaceFoundation.prototype.isFinite = function (num) {
  7686. return typeof num === 'number' && isFinite(num);
  7687. };
  7688. return MDCMenuSurfaceFoundation;
  7689. }(foundation_1.MDCFoundation);
  7690. exports.MDCMenuSurfaceFoundation = MDCMenuSurfaceFoundation;
  7691. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  7692. exports.default = MDCMenuSurfaceFoundation;
  7693. /***/ }),
  7694. /***/ "./packages/mdc-menu/component.ts":
  7695. /*!****************************************!*\
  7696. !*** ./packages/mdc-menu/component.ts ***!
  7697. \****************************************/
  7698. /*! no static exports found */
  7699. /***/ (function(module, exports, __webpack_require__) {
  7700. "use strict";
  7701. /**
  7702. * @license
  7703. * Copyright 2018 Google Inc.
  7704. *
  7705. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7706. * of this software and associated documentation files (the "Software"), to deal
  7707. * in the Software without restriction, including without limitation the rights
  7708. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7709. * copies of the Software, and to permit persons to whom the Software is
  7710. * furnished to do so, subject to the following conditions:
  7711. *
  7712. * The above copyright notice and this permission notice shall be included in
  7713. * all copies or substantial portions of the Software.
  7714. *
  7715. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  7716. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  7717. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  7718. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  7719. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  7720. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  7721. * THE SOFTWARE.
  7722. */
  7723. var __extends = this && this.__extends || function () {
  7724. var _extendStatics = function extendStatics(d, b) {
  7725. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  7726. d.__proto__ = b;
  7727. } || function (d, b) {
  7728. for (var p in b) {
  7729. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  7730. }
  7731. };
  7732. return _extendStatics(d, b);
  7733. };
  7734. return function (d, b) {
  7735. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  7736. _extendStatics(d, b);
  7737. function __() {
  7738. this.constructor = d;
  7739. }
  7740. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7741. };
  7742. }();
  7743. Object.defineProperty(exports, "__esModule", { value: true });
  7744. exports.MDCMenu = void 0;
  7745. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  7746. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  7747. var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
  7748. var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
  7749. var foundation_1 = __webpack_require__(/*! @material/list/foundation */ "./packages/mdc-list/foundation.ts");
  7750. var component_3 = __webpack_require__(/*! @material/menu-surface/component */ "./packages/mdc-menu-surface/component.ts");
  7751. var foundation_2 = __webpack_require__(/*! @material/menu-surface/foundation */ "./packages/mdc-menu-surface/foundation.ts");
  7752. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
  7753. var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts");
  7754. /** MDC Menu */
  7755. var MDCMenu = /** @class */function (_super) {
  7756. __extends(MDCMenu, _super);
  7757. function MDCMenu() {
  7758. return _super !== null && _super.apply(this, arguments) || this;
  7759. }
  7760. MDCMenu.attachTo = function (root) {
  7761. return new MDCMenu(root);
  7762. };
  7763. MDCMenu.prototype.initialize = function (menuSurfaceFactory, listFactory) {
  7764. if (menuSurfaceFactory === void 0) {
  7765. menuSurfaceFactory = function menuSurfaceFactory(el) {
  7766. return new component_3.MDCMenuSurface(el);
  7767. };
  7768. }
  7769. if (listFactory === void 0) {
  7770. listFactory = function listFactory(el) {
  7771. return new component_2.MDCList(el);
  7772. };
  7773. }
  7774. this.menuSurfaceFactory = menuSurfaceFactory;
  7775. this.listFactory = listFactory;
  7776. };
  7777. MDCMenu.prototype.initialSyncWithDOM = function () {
  7778. var _this = this;
  7779. this.menuSurface = this.menuSurfaceFactory(this.root);
  7780. var list = this.root.querySelector(constants_2.strings.LIST_SELECTOR);
  7781. if (list) {
  7782. this.list = this.listFactory(list);
  7783. this.list.wrapFocus = true;
  7784. } else {
  7785. this.list = null;
  7786. }
  7787. this.handleKeydown = function (evt) {
  7788. _this.foundation.handleKeydown(evt);
  7789. };
  7790. this.handleItemAction = function (evt) {
  7791. _this.foundation.handleItemAction(_this.items[evt.detail.index]);
  7792. };
  7793. this.handleMenuSurfaceOpened = function () {
  7794. _this.foundation.handleMenuSurfaceOpened();
  7795. };
  7796. this.menuSurface.listen(foundation_2.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened);
  7797. this.listen('keydown', this.handleKeydown);
  7798. this.listen(foundation_1.MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction);
  7799. };
  7800. MDCMenu.prototype.destroy = function () {
  7801. if (this.list) {
  7802. this.list.destroy();
  7803. }
  7804. this.menuSurface.destroy();
  7805. this.menuSurface.unlisten(foundation_2.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened);
  7806. this.unlisten('keydown', this.handleKeydown);
  7807. this.unlisten(foundation_1.MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction);
  7808. _super.prototype.destroy.call(this);
  7809. };
  7810. Object.defineProperty(MDCMenu.prototype, "open", {
  7811. get: function get() {
  7812. return this.menuSurface.isOpen();
  7813. },
  7814. set: function set(value) {
  7815. if (value) {
  7816. this.menuSurface.open();
  7817. } else {
  7818. this.menuSurface.close();
  7819. }
  7820. },
  7821. enumerable: false,
  7822. configurable: true
  7823. });
  7824. Object.defineProperty(MDCMenu.prototype, "wrapFocus", {
  7825. get: function get() {
  7826. return this.list ? this.list.wrapFocus : false;
  7827. },
  7828. set: function set(value) {
  7829. if (this.list) {
  7830. this.list.wrapFocus = value;
  7831. }
  7832. },
  7833. enumerable: false,
  7834. configurable: true
  7835. });
  7836. Object.defineProperty(MDCMenu.prototype, "hasTypeahead", {
  7837. /**
  7838. * Sets whether the menu has typeahead functionality.
  7839. * @param value Whether typeahead is enabled.
  7840. */
  7841. set: function set(value) {
  7842. if (this.list) {
  7843. this.list.hasTypeahead = value;
  7844. }
  7845. },
  7846. enumerable: false,
  7847. configurable: true
  7848. });
  7849. Object.defineProperty(MDCMenu.prototype, "typeaheadInProgress", {
  7850. /**
  7851. * @return Whether typeahead logic is currently matching some user prefix.
  7852. */
  7853. get: function get() {
  7854. return this.list ? this.list.typeaheadInProgress : false;
  7855. },
  7856. enumerable: false,
  7857. configurable: true
  7858. });
  7859. /**
  7860. * Given the next desired character from the user, adds it to the typeahead
  7861. * buffer. Then, attempts to find the next option matching the buffer. Wraps
  7862. * around if at the end of options.
  7863. *
  7864. * @param nextChar The next character to add to the prefix buffer.
  7865. * @param startingIndex The index from which to start matching. Only relevant
  7866. * when starting a new match sequence. To start a new match sequence,
  7867. * clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
  7868. * to clear after a set interval defined in list foundation. Defaults to
  7869. * the currently focused index.
  7870. * @return The index of the matched item, or -1 if no match.
  7871. */
  7872. MDCMenu.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
  7873. if (this.list) {
  7874. return this.list.typeaheadMatchItem(nextChar, startingIndex);
  7875. }
  7876. return -1;
  7877. };
  7878. /**
  7879. * Layout the underlying list element in the case of any dynamic updates
  7880. * to its structure.
  7881. */
  7882. MDCMenu.prototype.layout = function () {
  7883. if (this.list) {
  7884. this.list.layout();
  7885. }
  7886. };
  7887. Object.defineProperty(MDCMenu.prototype, "items", {
  7888. /**
  7889. * Return the items within the menu. Note that this only contains the set of
  7890. * elements within the items container that are proper list items, and not
  7891. * supplemental / presentational DOM elements.
  7892. */
  7893. get: function get() {
  7894. return this.list ? this.list.listElements : [];
  7895. },
  7896. enumerable: false,
  7897. configurable: true
  7898. });
  7899. Object.defineProperty(MDCMenu.prototype, "singleSelection", {
  7900. /**
  7901. * Turns on/off the underlying list's single selection mode. Used mainly
  7902. * by select menu.
  7903. *
  7904. * @param singleSelection Whether to enable single selection mode.
  7905. */
  7906. set: function set(singleSelection) {
  7907. if (this.list) {
  7908. this.list.singleSelection = singleSelection;
  7909. }
  7910. },
  7911. enumerable: false,
  7912. configurable: true
  7913. });
  7914. Object.defineProperty(MDCMenu.prototype, "selectedIndex", {
  7915. /**
  7916. * Retrieves the selected index. Only applicable to select menus.
  7917. * @return The selected index, which is a number for single selection and
  7918. * radio lists, and an array of numbers for checkbox lists.
  7919. */
  7920. get: function get() {
  7921. return this.list ? this.list.selectedIndex : constants_1.numbers.UNSET_INDEX;
  7922. },
  7923. /**
  7924. * Sets the selected index of the list. Only applicable to select menus.
  7925. * @param index The selected index, which is a number for single selection and
  7926. * radio lists, and an array of numbers for checkbox lists.
  7927. */
  7928. set: function set(index) {
  7929. if (this.list) {
  7930. this.list.selectedIndex = index;
  7931. }
  7932. },
  7933. enumerable: false,
  7934. configurable: true
  7935. });
  7936. Object.defineProperty(MDCMenu.prototype, "quickOpen", {
  7937. set: function set(quickOpen) {
  7938. this.menuSurface.quickOpen = quickOpen;
  7939. },
  7940. enumerable: false,
  7941. configurable: true
  7942. });
  7943. /**
  7944. * Sets default focus state where the menu should focus every time when menu
  7945. * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
  7946. * default.
  7947. * @param focusState Default focus state.
  7948. */
  7949. MDCMenu.prototype.setDefaultFocusState = function (focusState) {
  7950. this.foundation.setDefaultFocusState(focusState);
  7951. };
  7952. /**
  7953. * @param corner Default anchor corner alignment of top-left menu corner.
  7954. */
  7955. MDCMenu.prototype.setAnchorCorner = function (corner) {
  7956. this.menuSurface.setAnchorCorner(corner);
  7957. };
  7958. MDCMenu.prototype.setAnchorMargin = function (margin) {
  7959. this.menuSurface.setAnchorMargin(margin);
  7960. };
  7961. /**
  7962. * Sets the list item as the selected row at the specified index.
  7963. * @param index Index of list item within menu.
  7964. */
  7965. MDCMenu.prototype.setSelectedIndex = function (index) {
  7966. this.foundation.setSelectedIndex(index);
  7967. };
  7968. /**
  7969. * Sets the enabled state to isEnabled for the menu item at the given index.
  7970. * @param index Index of the menu item
  7971. * @param isEnabled The desired enabled state of the menu item.
  7972. */
  7973. MDCMenu.prototype.setEnabled = function (index, isEnabled) {
  7974. this.foundation.setEnabled(index, isEnabled);
  7975. };
  7976. /**
  7977. * @return The item within the menu at the index specified.
  7978. */
  7979. MDCMenu.prototype.getOptionByIndex = function (index) {
  7980. var items = this.items;
  7981. if (index < items.length) {
  7982. return this.items[index];
  7983. } else {
  7984. return null;
  7985. }
  7986. };
  7987. /**
  7988. * @param index A menu item's index.
  7989. * @return The primary text within the menu at the index specified.
  7990. */
  7991. MDCMenu.prototype.getPrimaryTextAtIndex = function (index) {
  7992. var item = this.getOptionByIndex(index);
  7993. if (item && this.list) {
  7994. return this.list.getPrimaryText(item) || '';
  7995. }
  7996. return '';
  7997. };
  7998. MDCMenu.prototype.setFixedPosition = function (isFixed) {
  7999. this.menuSurface.setFixedPosition(isFixed);
  8000. };
  8001. MDCMenu.prototype.setIsHoisted = function (isHoisted) {
  8002. this.menuSurface.setIsHoisted(isHoisted);
  8003. };
  8004. MDCMenu.prototype.setAbsolutePosition = function (x, y) {
  8005. this.menuSurface.setAbsolutePosition(x, y);
  8006. };
  8007. /**
  8008. * Sets the element that the menu-surface is anchored to.
  8009. */
  8010. MDCMenu.prototype.setAnchorElement = function (element) {
  8011. this.menuSurface.anchorElement = element;
  8012. };
  8013. MDCMenu.prototype.getDefaultFoundation = function () {
  8014. var _this = this;
  8015. // DO NOT INLINE this variable. For backward compatibility, foundations take
  8016. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  8017. // methods, we need a separate, strongly typed adapter variable.
  8018. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  8019. var adapter = {
  8020. addClassToElementAtIndex: function addClassToElementAtIndex(index, className) {
  8021. var list = _this.items;
  8022. list[index].classList.add(className);
  8023. },
  8024. removeClassFromElementAtIndex: function removeClassFromElementAtIndex(index, className) {
  8025. var list = _this.items;
  8026. list[index].classList.remove(className);
  8027. },
  8028. addAttributeToElementAtIndex: function addAttributeToElementAtIndex(index, attr, value) {
  8029. var list = _this.items;
  8030. _this.safeSetAttribute(list[index], attr, value);
  8031. },
  8032. removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex(index, attr) {
  8033. var list = _this.items;
  8034. list[index].removeAttribute(attr);
  8035. },
  8036. getAttributeFromElementAtIndex: function getAttributeFromElementAtIndex(index, attr) {
  8037. var list = _this.items;
  8038. return list[index].getAttribute(attr);
  8039. },
  8040. elementContainsClass: function elementContainsClass(element, className) {
  8041. return element.classList.contains(className);
  8042. },
  8043. closeSurface: function closeSurface(skipRestoreFocus) {
  8044. _this.menuSurface.close(skipRestoreFocus);
  8045. },
  8046. getElementIndex: function getElementIndex(element) {
  8047. return _this.items.indexOf(element);
  8048. },
  8049. notifySelected: function notifySelected(evtData) {
  8050. _this.emit(constants_2.strings.SELECTED_EVENT, {
  8051. index: evtData.index,
  8052. item: _this.items[evtData.index]
  8053. });
  8054. },
  8055. getMenuItemCount: function getMenuItemCount() {
  8056. return _this.items.length;
  8057. },
  8058. focusItemAtIndex: function focusItemAtIndex(index) {
  8059. _this.items[index].focus();
  8060. },
  8061. focusListRoot: function focusListRoot() {
  8062. _this.root.querySelector(constants_2.strings.LIST_SELECTOR).focus();
  8063. },
  8064. isSelectableItemAtIndex: function isSelectableItemAtIndex(index) {
  8065. return !!ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
  8066. },
  8067. getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex(index) {
  8068. var selectionGroupEl = ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
  8069. var selectedItemEl = selectionGroupEl.querySelector("." + constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
  8070. return selectedItemEl ? _this.items.indexOf(selectedItemEl) : -1;
  8071. }
  8072. };
  8073. // tslint:enable:object-literal-sort-keys
  8074. return new foundation_3.MDCMenuFoundation(adapter);
  8075. };
  8076. return MDCMenu;
  8077. }(component_1.MDCComponent);
  8078. exports.MDCMenu = MDCMenu;
  8079. /***/ }),
  8080. /***/ "./packages/mdc-menu/constants.ts":
  8081. /*!****************************************!*\
  8082. !*** ./packages/mdc-menu/constants.ts ***!
  8083. \****************************************/
  8084. /*! no static exports found */
  8085. /***/ (function(module, exports, __webpack_require__) {
  8086. "use strict";
  8087. /**
  8088. * @license
  8089. * Copyright 2018 Google Inc.
  8090. *
  8091. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8092. * of this software and associated documentation files (the "Software"), to deal
  8093. * in the Software without restriction, including without limitation the rights
  8094. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8095. * copies of the Software, and to permit persons to whom the Software is
  8096. * furnished to do so, subject to the following conditions:
  8097. *
  8098. * The above copyright notice and this permission notice shall be included in
  8099. * all copies or substantial portions of the Software.
  8100. *
  8101. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8102. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8103. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8104. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8105. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8106. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8107. * THE SOFTWARE.
  8108. */
  8109. Object.defineProperty(exports, "__esModule", { value: true });
  8110. exports.DefaultFocusState = exports.numbers = exports.strings = exports.cssClasses = void 0;
  8111. var cssClasses = {
  8112. MENU_SELECTED_LIST_ITEM: 'mdc-menu-item--selected',
  8113. MENU_SELECTION_GROUP: 'mdc-menu__selection-group',
  8114. ROOT: 'mdc-menu'
  8115. };
  8116. exports.cssClasses = cssClasses;
  8117. var strings = {
  8118. ARIA_CHECKED_ATTR: 'aria-checked',
  8119. ARIA_DISABLED_ATTR: 'aria-disabled',
  8120. CHECKBOX_SELECTOR: 'input[type="checkbox"]',
  8121. LIST_SELECTOR: '.mdc-list,.mdc-deprecated-list',
  8122. SELECTED_EVENT: 'MDCMenu:selected',
  8123. SKIP_RESTORE_FOCUS: 'data-menu-item-skip-restore-focus'
  8124. };
  8125. exports.strings = strings;
  8126. var numbers = {
  8127. FOCUS_ROOT_INDEX: -1
  8128. };
  8129. exports.numbers = numbers;
  8130. var DefaultFocusState;
  8131. (function (DefaultFocusState) {
  8132. DefaultFocusState[DefaultFocusState["NONE"] = 0] = "NONE";
  8133. DefaultFocusState[DefaultFocusState["LIST_ROOT"] = 1] = "LIST_ROOT";
  8134. DefaultFocusState[DefaultFocusState["FIRST_ITEM"] = 2] = "FIRST_ITEM";
  8135. DefaultFocusState[DefaultFocusState["LAST_ITEM"] = 3] = "LAST_ITEM";
  8136. })(DefaultFocusState || (DefaultFocusState = {}));
  8137. exports.DefaultFocusState = DefaultFocusState;
  8138. /***/ }),
  8139. /***/ "./packages/mdc-menu/foundation.ts":
  8140. /*!*****************************************!*\
  8141. !*** ./packages/mdc-menu/foundation.ts ***!
  8142. \*****************************************/
  8143. /*! no static exports found */
  8144. /***/ (function(module, exports, __webpack_require__) {
  8145. "use strict";
  8146. /**
  8147. * @license
  8148. * Copyright 2018 Google Inc.
  8149. *
  8150. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8151. * of this software and associated documentation files (the "Software"), to deal
  8152. * in the Software without restriction, including without limitation the rights
  8153. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8154. * copies of the Software, and to permit persons to whom the Software is
  8155. * furnished to do so, subject to the following conditions:
  8156. *
  8157. * The above copyright notice and this permission notice shall be included in
  8158. * all copies or substantial portions of the Software.
  8159. *
  8160. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8161. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8162. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8163. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8164. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8165. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8166. * THE SOFTWARE.
  8167. */
  8168. var __extends = this && this.__extends || function () {
  8169. var _extendStatics = function extendStatics(d, b) {
  8170. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8171. d.__proto__ = b;
  8172. } || function (d, b) {
  8173. for (var p in b) {
  8174. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  8175. }
  8176. };
  8177. return _extendStatics(d, b);
  8178. };
  8179. return function (d, b) {
  8180. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  8181. _extendStatics(d, b);
  8182. function __() {
  8183. this.constructor = d;
  8184. }
  8185. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8186. };
  8187. }();
  8188. var __assign = this && this.__assign || function () {
  8189. __assign = Object.assign || function (t) {
  8190. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8191. s = arguments[i];
  8192. for (var p in s) {
  8193. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  8194. }
  8195. }
  8196. return t;
  8197. };
  8198. return __assign.apply(this, arguments);
  8199. };
  8200. Object.defineProperty(exports, "__esModule", { value: true });
  8201. exports.MDCMenuFoundation = void 0;
  8202. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  8203. var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
  8204. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
  8205. /** MDC Menu Foundation */
  8206. var MDCMenuFoundation = /** @class */function (_super) {
  8207. __extends(MDCMenuFoundation, _super);
  8208. function MDCMenuFoundation(adapter) {
  8209. var _this = _super.call(this, __assign(__assign({}, MDCMenuFoundation.defaultAdapter), adapter)) || this;
  8210. _this.defaultFocusState = constants_2.DefaultFocusState.LIST_ROOT;
  8211. _this.selectedIndex = -1;
  8212. return _this;
  8213. }
  8214. Object.defineProperty(MDCMenuFoundation, "cssClasses", {
  8215. get: function get() {
  8216. return constants_2.cssClasses;
  8217. },
  8218. enumerable: false,
  8219. configurable: true
  8220. });
  8221. Object.defineProperty(MDCMenuFoundation, "strings", {
  8222. get: function get() {
  8223. return constants_2.strings;
  8224. },
  8225. enumerable: false,
  8226. configurable: true
  8227. });
  8228. Object.defineProperty(MDCMenuFoundation, "numbers", {
  8229. get: function get() {
  8230. return constants_2.numbers;
  8231. },
  8232. enumerable: false,
  8233. configurable: true
  8234. });
  8235. Object.defineProperty(MDCMenuFoundation, "defaultAdapter", {
  8236. /**
  8237. * @see {@link MDCMenuAdapter} for typing information on parameters and return types.
  8238. */
  8239. get: function get() {
  8240. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  8241. return {
  8242. addClassToElementAtIndex: function addClassToElementAtIndex() {
  8243. return undefined;
  8244. },
  8245. removeClassFromElementAtIndex: function removeClassFromElementAtIndex() {
  8246. return undefined;
  8247. },
  8248. addAttributeToElementAtIndex: function addAttributeToElementAtIndex() {
  8249. return undefined;
  8250. },
  8251. removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex() {
  8252. return undefined;
  8253. },
  8254. getAttributeFromElementAtIndex: function getAttributeFromElementAtIndex() {
  8255. return null;
  8256. },
  8257. elementContainsClass: function elementContainsClass() {
  8258. return false;
  8259. },
  8260. closeSurface: function closeSurface() {
  8261. return undefined;
  8262. },
  8263. getElementIndex: function getElementIndex() {
  8264. return -1;
  8265. },
  8266. notifySelected: function notifySelected() {
  8267. return undefined;
  8268. },
  8269. getMenuItemCount: function getMenuItemCount() {
  8270. return 0;
  8271. },
  8272. focusItemAtIndex: function focusItemAtIndex() {
  8273. return undefined;
  8274. },
  8275. focusListRoot: function focusListRoot() {
  8276. return undefined;
  8277. },
  8278. getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex() {
  8279. return -1;
  8280. },
  8281. isSelectableItemAtIndex: function isSelectableItemAtIndex() {
  8282. return false;
  8283. }
  8284. };
  8285. // tslint:enable:object-literal-sort-keys
  8286. },
  8287. enumerable: false,
  8288. configurable: true
  8289. });
  8290. MDCMenuFoundation.prototype.destroy = function () {
  8291. this.adapter.closeSurface();
  8292. };
  8293. MDCMenuFoundation.prototype.handleKeydown = function (evt) {
  8294. var key = evt.key,
  8295. keyCode = evt.keyCode;
  8296. var isTab = key === 'Tab' || keyCode === 9;
  8297. if (isTab) {
  8298. this.adapter.closeSurface( /** skipRestoreFocus */true);
  8299. }
  8300. };
  8301. MDCMenuFoundation.prototype.handleItemAction = function (listItem) {
  8302. var index = this.adapter.getElementIndex(listItem);
  8303. if (index < 0) {
  8304. return;
  8305. }
  8306. this.adapter.notifySelected({ index: index });
  8307. var skipRestoreFocus = this.adapter.getAttributeFromElementAtIndex(index, constants_2.strings.SKIP_RESTORE_FOCUS) === 'true';
  8308. this.adapter.closeSurface(skipRestoreFocus);
  8309. if (this.adapter.isSelectableItemAtIndex(index)) {
  8310. this.setSelectedIndex(index);
  8311. }
  8312. };
  8313. MDCMenuFoundation.prototype.handleMenuSurfaceOpened = function () {
  8314. switch (this.defaultFocusState) {
  8315. case constants_2.DefaultFocusState.FIRST_ITEM:
  8316. this.adapter.focusItemAtIndex(0);
  8317. break;
  8318. case constants_2.DefaultFocusState.LAST_ITEM:
  8319. this.adapter.focusItemAtIndex(this.adapter.getMenuItemCount() - 1);
  8320. break;
  8321. case constants_2.DefaultFocusState.NONE:
  8322. // Do nothing.
  8323. break;
  8324. default:
  8325. this.adapter.focusListRoot();
  8326. break;
  8327. }
  8328. };
  8329. /**
  8330. * Sets default focus state where the menu should focus every time when menu
  8331. * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
  8332. * default.
  8333. */
  8334. MDCMenuFoundation.prototype.setDefaultFocusState = function (focusState) {
  8335. this.defaultFocusState = focusState;
  8336. };
  8337. /** @return Index of the currently selected list item within the menu. */
  8338. MDCMenuFoundation.prototype.getSelectedIndex = function () {
  8339. return this.selectedIndex;
  8340. };
  8341. /**
  8342. * Selects the list item at `index` within the menu.
  8343. * @param index Index of list item within the menu.
  8344. */
  8345. MDCMenuFoundation.prototype.setSelectedIndex = function (index) {
  8346. this.validatedIndex(index);
  8347. if (!this.adapter.isSelectableItemAtIndex(index)) {
  8348. throw new Error('MDCMenuFoundation: No selection group at specified index.');
  8349. }
  8350. var prevSelectedIndex = this.adapter.getSelectedSiblingOfItemAtIndex(index);
  8351. if (prevSelectedIndex >= 0) {
  8352. this.adapter.removeAttributeFromElementAtIndex(prevSelectedIndex, constants_2.strings.ARIA_CHECKED_ATTR);
  8353. this.adapter.removeClassFromElementAtIndex(prevSelectedIndex, constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
  8354. }
  8355. this.adapter.addClassToElementAtIndex(index, constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
  8356. this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_CHECKED_ATTR, 'true');
  8357. this.selectedIndex = index;
  8358. };
  8359. /**
  8360. * Sets the enabled state to isEnabled for the menu item at the given index.
  8361. * @param index Index of the menu item
  8362. * @param isEnabled The desired enabled state of the menu item.
  8363. */
  8364. MDCMenuFoundation.prototype.setEnabled = function (index, isEnabled) {
  8365. this.validatedIndex(index);
  8366. if (isEnabled) {
  8367. this.adapter.removeClassFromElementAtIndex(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  8368. this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_DISABLED_ATTR, 'false');
  8369. } else {
  8370. this.adapter.addClassToElementAtIndex(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
  8371. this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_DISABLED_ATTR, 'true');
  8372. }
  8373. };
  8374. MDCMenuFoundation.prototype.validatedIndex = function (index) {
  8375. var menuSize = this.adapter.getMenuItemCount();
  8376. var isIndexInRange = index >= 0 && index < menuSize;
  8377. if (!isIndexInRange) {
  8378. throw new Error('MDCMenuFoundation: No list item at specified index.');
  8379. }
  8380. };
  8381. return MDCMenuFoundation;
  8382. }(foundation_1.MDCFoundation);
  8383. exports.MDCMenuFoundation = MDCMenuFoundation;
  8384. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  8385. exports.default = MDCMenuFoundation;
  8386. /***/ }),
  8387. /***/ "./packages/mdc-notched-outline/component.ts":
  8388. /*!***************************************************!*\
  8389. !*** ./packages/mdc-notched-outline/component.ts ***!
  8390. \***************************************************/
  8391. /*! no static exports found */
  8392. /***/ (function(module, exports, __webpack_require__) {
  8393. "use strict";
  8394. /**
  8395. * @license
  8396. * Copyright 2017 Google Inc.
  8397. *
  8398. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8399. * of this software and associated documentation files (the "Software"), to deal
  8400. * in the Software without restriction, including without limitation the rights
  8401. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8402. * copies of the Software, and to permit persons to whom the Software is
  8403. * furnished to do so, subject to the following conditions:
  8404. *
  8405. * The above copyright notice and this permission notice shall be included in
  8406. * all copies or substantial portions of the Software.
  8407. *
  8408. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8409. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8410. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8411. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8412. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8413. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8414. * THE SOFTWARE.
  8415. */
  8416. var __extends = this && this.__extends || function () {
  8417. var _extendStatics = function extendStatics(d, b) {
  8418. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8419. d.__proto__ = b;
  8420. } || function (d, b) {
  8421. for (var p in b) {
  8422. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  8423. }
  8424. };
  8425. return _extendStatics(d, b);
  8426. };
  8427. return function (d, b) {
  8428. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  8429. _extendStatics(d, b);
  8430. function __() {
  8431. this.constructor = d;
  8432. }
  8433. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8434. };
  8435. }();
  8436. Object.defineProperty(exports, "__esModule", { value: true });
  8437. exports.MDCNotchedOutline = void 0;
  8438. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  8439. var foundation_1 = __webpack_require__(/*! @material/floating-label/foundation */ "./packages/mdc-floating-label/foundation.ts");
  8440. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts");
  8441. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-notched-outline/foundation.ts");
  8442. /** MDC Notched Outline */
  8443. var MDCNotchedOutline = /** @class */function (_super) {
  8444. __extends(MDCNotchedOutline, _super);
  8445. function MDCNotchedOutline() {
  8446. return _super !== null && _super.apply(this, arguments) || this;
  8447. }
  8448. MDCNotchedOutline.attachTo = function (root) {
  8449. return new MDCNotchedOutline(root);
  8450. };
  8451. MDCNotchedOutline.prototype.initialSyncWithDOM = function () {
  8452. this.notchElement = this.root.querySelector(constants_1.strings.NOTCH_ELEMENT_SELECTOR);
  8453. var label = this.root.querySelector('.' + foundation_1.MDCFloatingLabelFoundation.cssClasses.ROOT);
  8454. if (label) {
  8455. label.style.transitionDuration = '0s';
  8456. this.root.classList.add(constants_1.cssClasses.OUTLINE_UPGRADED);
  8457. requestAnimationFrame(function () {
  8458. label.style.transitionDuration = '';
  8459. });
  8460. } else {
  8461. this.root.classList.add(constants_1.cssClasses.NO_LABEL);
  8462. }
  8463. };
  8464. /**
  8465. * Updates classes and styles to open the notch to the specified width.
  8466. * @param notchWidth The notch width in the outline.
  8467. */
  8468. MDCNotchedOutline.prototype.notch = function (notchWidth) {
  8469. this.foundation.notch(notchWidth);
  8470. };
  8471. /**
  8472. * Updates classes and styles to close the notch.
  8473. */
  8474. MDCNotchedOutline.prototype.closeNotch = function () {
  8475. this.foundation.closeNotch();
  8476. };
  8477. MDCNotchedOutline.prototype.getDefaultFoundation = function () {
  8478. var _this = this;
  8479. // DO NOT INLINE this variable. For backward compatibility, foundations take
  8480. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  8481. // 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. _this.root.classList.add(className);
  8486. },
  8487. removeClass: function removeClass(className) {
  8488. _this.root.classList.remove(className);
  8489. },
  8490. setNotchWidthProperty: function setNotchWidthProperty(width) {
  8491. _this.notchElement.style.setProperty('width', width + 'px');
  8492. },
  8493. removeNotchWidthProperty: function removeNotchWidthProperty() {
  8494. _this.notchElement.style.removeProperty('width');
  8495. }
  8496. };
  8497. // tslint:enable:object-literal-sort-keys
  8498. return new foundation_2.MDCNotchedOutlineFoundation(adapter);
  8499. };
  8500. return MDCNotchedOutline;
  8501. }(component_1.MDCComponent);
  8502. exports.MDCNotchedOutline = MDCNotchedOutline;
  8503. /***/ }),
  8504. /***/ "./packages/mdc-notched-outline/constants.ts":
  8505. /*!***************************************************!*\
  8506. !*** ./packages/mdc-notched-outline/constants.ts ***!
  8507. \***************************************************/
  8508. /*! no static exports found */
  8509. /***/ (function(module, exports, __webpack_require__) {
  8510. "use strict";
  8511. /**
  8512. * @license
  8513. * Copyright 2018 Google Inc.
  8514. *
  8515. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8516. * of this software and associated documentation files (the "Software"), to deal
  8517. * in the Software without restriction, including without limitation the rights
  8518. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8519. * copies of the Software, and to permit persons to whom the Software is
  8520. * furnished to do so, subject to the following conditions:
  8521. *
  8522. * The above copyright notice and this permission notice shall be included in
  8523. * all copies or substantial portions of the Software.
  8524. *
  8525. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8526. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8527. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8528. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8529. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8530. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8531. * THE SOFTWARE.
  8532. */
  8533. Object.defineProperty(exports, "__esModule", { value: true });
  8534. exports.strings = exports.numbers = exports.cssClasses = void 0;
  8535. var strings = {
  8536. NOTCH_ELEMENT_SELECTOR: '.mdc-notched-outline__notch'
  8537. };
  8538. exports.strings = strings;
  8539. var numbers = {
  8540. // This should stay in sync with $mdc-notched-outline-padding * 2.
  8541. NOTCH_ELEMENT_PADDING: 8
  8542. };
  8543. exports.numbers = numbers;
  8544. var cssClasses = {
  8545. NO_LABEL: 'mdc-notched-outline--no-label',
  8546. OUTLINE_NOTCHED: 'mdc-notched-outline--notched',
  8547. OUTLINE_UPGRADED: 'mdc-notched-outline--upgraded'
  8548. };
  8549. exports.cssClasses = cssClasses;
  8550. /***/ }),
  8551. /***/ "./packages/mdc-notched-outline/foundation.ts":
  8552. /*!****************************************************!*\
  8553. !*** ./packages/mdc-notched-outline/foundation.ts ***!
  8554. \****************************************************/
  8555. /*! no static exports found */
  8556. /***/ (function(module, exports, __webpack_require__) {
  8557. "use strict";
  8558. /**
  8559. * @license
  8560. * Copyright 2017 Google Inc.
  8561. *
  8562. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8563. * of this software and associated documentation files (the "Software"), to deal
  8564. * in the Software without restriction, including without limitation the rights
  8565. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8566. * copies of the Software, and to permit persons to whom the Software is
  8567. * furnished to do so, subject to the following conditions:
  8568. *
  8569. * The above copyright notice and this permission notice shall be included in
  8570. * all copies or substantial portions of the Software.
  8571. *
  8572. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8573. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8574. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8575. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8576. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8577. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8578. * THE SOFTWARE.
  8579. */
  8580. var __extends = this && this.__extends || function () {
  8581. var _extendStatics = function extendStatics(d, b) {
  8582. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8583. d.__proto__ = b;
  8584. } || function (d, b) {
  8585. for (var p in b) {
  8586. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  8587. }
  8588. };
  8589. return _extendStatics(d, b);
  8590. };
  8591. return function (d, b) {
  8592. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  8593. _extendStatics(d, b);
  8594. function __() {
  8595. this.constructor = d;
  8596. }
  8597. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8598. };
  8599. }();
  8600. var __assign = this && this.__assign || function () {
  8601. __assign = Object.assign || function (t) {
  8602. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8603. s = arguments[i];
  8604. for (var p in s) {
  8605. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  8606. }
  8607. }
  8608. return t;
  8609. };
  8610. return __assign.apply(this, arguments);
  8611. };
  8612. Object.defineProperty(exports, "__esModule", { value: true });
  8613. exports.MDCNotchedOutlineFoundation = void 0;
  8614. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  8615. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts");
  8616. /** MDC Notched Outline Foundation */
  8617. var MDCNotchedOutlineFoundation = /** @class */function (_super) {
  8618. __extends(MDCNotchedOutlineFoundation, _super);
  8619. function MDCNotchedOutlineFoundation(adapter) {
  8620. return _super.call(this, __assign(__assign({}, MDCNotchedOutlineFoundation.defaultAdapter), adapter)) || this;
  8621. }
  8622. Object.defineProperty(MDCNotchedOutlineFoundation, "strings", {
  8623. get: function get() {
  8624. return constants_1.strings;
  8625. },
  8626. enumerable: false,
  8627. configurable: true
  8628. });
  8629. Object.defineProperty(MDCNotchedOutlineFoundation, "cssClasses", {
  8630. get: function get() {
  8631. return constants_1.cssClasses;
  8632. },
  8633. enumerable: false,
  8634. configurable: true
  8635. });
  8636. Object.defineProperty(MDCNotchedOutlineFoundation, "numbers", {
  8637. get: function get() {
  8638. return constants_1.numbers;
  8639. },
  8640. enumerable: false,
  8641. configurable: true
  8642. });
  8643. Object.defineProperty(MDCNotchedOutlineFoundation, "defaultAdapter", {
  8644. /**
  8645. * See {@link MDCNotchedOutlineAdapter} for typing information on parameters
  8646. * and return types.
  8647. */
  8648. get: function get() {
  8649. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  8650. return {
  8651. addClass: function addClass() {
  8652. return undefined;
  8653. },
  8654. removeClass: function removeClass() {
  8655. return undefined;
  8656. },
  8657. setNotchWidthProperty: function setNotchWidthProperty() {
  8658. return undefined;
  8659. },
  8660. removeNotchWidthProperty: function removeNotchWidthProperty() {
  8661. return undefined;
  8662. }
  8663. };
  8664. // tslint:enable:object-literal-sort-keys
  8665. },
  8666. enumerable: false,
  8667. configurable: true
  8668. });
  8669. /**
  8670. * Adds the outline notched selector and updates the notch width calculated
  8671. * based off of notchWidth.
  8672. */
  8673. MDCNotchedOutlineFoundation.prototype.notch = function (notchWidth) {
  8674. var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED;
  8675. if (notchWidth > 0) {
  8676. notchWidth += constants_1.numbers.NOTCH_ELEMENT_PADDING; // Add padding from left/right.
  8677. }
  8678. this.adapter.setNotchWidthProperty(notchWidth);
  8679. this.adapter.addClass(OUTLINE_NOTCHED);
  8680. };
  8681. /**
  8682. * Removes notched outline selector to close the notch in the outline.
  8683. */
  8684. MDCNotchedOutlineFoundation.prototype.closeNotch = function () {
  8685. var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED;
  8686. this.adapter.removeClass(OUTLINE_NOTCHED);
  8687. this.adapter.removeNotchWidthProperty();
  8688. };
  8689. return MDCNotchedOutlineFoundation;
  8690. }(foundation_1.MDCFoundation);
  8691. exports.MDCNotchedOutlineFoundation = MDCNotchedOutlineFoundation;
  8692. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  8693. exports.default = MDCNotchedOutlineFoundation;
  8694. /***/ }),
  8695. /***/ "./packages/mdc-ripple/component.ts":
  8696. /*!******************************************!*\
  8697. !*** ./packages/mdc-ripple/component.ts ***!
  8698. \******************************************/
  8699. /*! no static exports found */
  8700. /***/ (function(module, exports, __webpack_require__) {
  8701. "use strict";
  8702. /**
  8703. * @license
  8704. * Copyright 2016 Google Inc.
  8705. *
  8706. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8707. * of this software and associated documentation files (the "Software"), to deal
  8708. * in the Software without restriction, including without limitation the rights
  8709. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8710. * copies of the Software, and to permit persons to whom the Software is
  8711. * furnished to do so, subject to the following conditions:
  8712. *
  8713. * The above copyright notice and this permission notice shall be included in
  8714. * all copies or substantial portions of the Software.
  8715. *
  8716. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8717. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8718. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8719. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8720. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8721. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8722. * THE SOFTWARE.
  8723. */
  8724. var __extends = this && this.__extends || function () {
  8725. var _extendStatics = function extendStatics(d, b) {
  8726. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8727. d.__proto__ = b;
  8728. } || function (d, b) {
  8729. for (var p in b) {
  8730. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  8731. }
  8732. };
  8733. return _extendStatics(d, b);
  8734. };
  8735. return function (d, b) {
  8736. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  8737. _extendStatics(d, b);
  8738. function __() {
  8739. this.constructor = d;
  8740. }
  8741. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8742. };
  8743. }();
  8744. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  8745. if (k2 === undefined) k2 = k;
  8746. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  8747. return m[k];
  8748. } });
  8749. } : function (o, m, k, k2) {
  8750. if (k2 === undefined) k2 = k;
  8751. o[k2] = m[k];
  8752. });
  8753. var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
  8754. Object.defineProperty(o, "default", { enumerable: true, value: v });
  8755. } : function (o, v) {
  8756. o["default"] = v;
  8757. });
  8758. var __importStar = this && this.__importStar || function (mod) {
  8759. if (mod && mod.__esModule) return mod;
  8760. var result = {};
  8761. if (mod != null) for (var k in mod) {
  8762. if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  8763. }__setModuleDefault(result, mod);
  8764. return result;
  8765. };
  8766. Object.defineProperty(exports, "__esModule", { value: true });
  8767. exports.MDCRipple = void 0;
  8768. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  8769. var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
  8770. var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
  8771. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
  8772. var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
  8773. /** MDC Ripple */
  8774. var MDCRipple = /** @class */function (_super) {
  8775. __extends(MDCRipple, _super);
  8776. function MDCRipple() {
  8777. var _this = _super !== null && _super.apply(this, arguments) || this;
  8778. _this.disabled = false;
  8779. return _this;
  8780. }
  8781. MDCRipple.attachTo = function (root, opts) {
  8782. if (opts === void 0) {
  8783. opts = {
  8784. isUnbounded: undefined
  8785. };
  8786. }
  8787. var ripple = new MDCRipple(root);
  8788. // Only override unbounded behavior if option is explicitly specified
  8789. if (opts.isUnbounded !== undefined) {
  8790. ripple.unbounded = opts.isUnbounded;
  8791. }
  8792. return ripple;
  8793. };
  8794. MDCRipple.createAdapter = function (instance) {
  8795. return {
  8796. addClass: function addClass(className) {
  8797. instance.root.classList.add(className);
  8798. },
  8799. browserSupportsCssVars: function browserSupportsCssVars() {
  8800. return util.supportsCssVariables(window);
  8801. },
  8802. computeBoundingRect: function computeBoundingRect() {
  8803. return instance.root.getBoundingClientRect();
  8804. },
  8805. containsEventTarget: function containsEventTarget(target) {
  8806. return instance.root.contains(target);
  8807. },
  8808. deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
  8809. document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
  8810. },
  8811. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  8812. instance.root.removeEventListener(evtType, handler, events_1.applyPassive());
  8813. },
  8814. deregisterResizeHandler: function deregisterResizeHandler(handler) {
  8815. window.removeEventListener('resize', handler);
  8816. },
  8817. getWindowPageOffset: function getWindowPageOffset() {
  8818. return { x: window.pageXOffset, y: window.pageYOffset };
  8819. },
  8820. isSurfaceActive: function isSurfaceActive() {
  8821. return ponyfill_1.matches(instance.root, ':active');
  8822. },
  8823. isSurfaceDisabled: function isSurfaceDisabled() {
  8824. return Boolean(instance.disabled);
  8825. },
  8826. isUnbounded: function isUnbounded() {
  8827. return Boolean(instance.unbounded);
  8828. },
  8829. registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
  8830. document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
  8831. },
  8832. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  8833. instance.root.addEventListener(evtType, handler, events_1.applyPassive());
  8834. },
  8835. registerResizeHandler: function registerResizeHandler(handler) {
  8836. window.addEventListener('resize', handler);
  8837. },
  8838. removeClass: function removeClass(className) {
  8839. instance.root.classList.remove(className);
  8840. },
  8841. updateCssVariable: function updateCssVariable(varName, value) {
  8842. instance.root.style.setProperty(varName, value);
  8843. }
  8844. };
  8845. };
  8846. Object.defineProperty(MDCRipple.prototype, "unbounded", {
  8847. get: function get() {
  8848. return Boolean(this.isUnbounded);
  8849. },
  8850. set: function set(unbounded) {
  8851. this.isUnbounded = Boolean(unbounded);
  8852. this.setUnbounded();
  8853. },
  8854. enumerable: false,
  8855. configurable: true
  8856. });
  8857. MDCRipple.prototype.activate = function () {
  8858. this.foundation.activate();
  8859. };
  8860. MDCRipple.prototype.deactivate = function () {
  8861. this.foundation.deactivate();
  8862. };
  8863. MDCRipple.prototype.layout = function () {
  8864. this.foundation.layout();
  8865. };
  8866. MDCRipple.prototype.getDefaultFoundation = function () {
  8867. return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
  8868. };
  8869. MDCRipple.prototype.initialSyncWithDOM = function () {
  8870. var root = this.root;
  8871. this.isUnbounded = 'mdcRippleIsUnbounded' in root.dataset;
  8872. };
  8873. /**
  8874. * Closure Compiler throws an access control error when directly accessing a
  8875. * protected or private property inside a getter/setter, like unbounded above.
  8876. * By accessing the protected property inside a method, we solve that problem.
  8877. * That's why this function exists.
  8878. */
  8879. MDCRipple.prototype.setUnbounded = function () {
  8880. this.foundation.setUnbounded(Boolean(this.isUnbounded));
  8881. };
  8882. return MDCRipple;
  8883. }(component_1.MDCComponent);
  8884. exports.MDCRipple = MDCRipple;
  8885. /***/ }),
  8886. /***/ "./packages/mdc-ripple/constants.ts":
  8887. /*!******************************************!*\
  8888. !*** ./packages/mdc-ripple/constants.ts ***!
  8889. \******************************************/
  8890. /*! no static exports found */
  8891. /***/ (function(module, exports, __webpack_require__) {
  8892. "use strict";
  8893. /**
  8894. * @license
  8895. * Copyright 2016 Google Inc.
  8896. *
  8897. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8898. * of this software and associated documentation files (the "Software"), to deal
  8899. * in the Software without restriction, including without limitation the rights
  8900. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8901. * copies of the Software, and to permit persons to whom the Software is
  8902. * furnished to do so, subject to the following conditions:
  8903. *
  8904. * The above copyright notice and this permission notice shall be included in
  8905. * all copies or substantial portions of the Software.
  8906. *
  8907. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8908. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8909. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8910. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8911. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8912. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8913. * THE SOFTWARE.
  8914. */
  8915. Object.defineProperty(exports, "__esModule", { value: true });
  8916. exports.numbers = exports.strings = exports.cssClasses = void 0;
  8917. exports.cssClasses = {
  8918. // Ripple is a special case where the "root" component is really a "mixin" of
  8919. // sorts,
  8920. // given that it's an 'upgrade' to an existing component. That being said it
  8921. // is the root
  8922. // CSS class that all other CSS classes derive from.
  8923. BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
  8924. FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
  8925. FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
  8926. ROOT: 'mdc-ripple-upgraded',
  8927. UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
  8928. };
  8929. exports.strings = {
  8930. VAR_FG_SCALE: '--mdc-ripple-fg-scale',
  8931. VAR_FG_SIZE: '--mdc-ripple-fg-size',
  8932. VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
  8933. VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
  8934. VAR_LEFT: '--mdc-ripple-left',
  8935. VAR_TOP: '--mdc-ripple-top'
  8936. };
  8937. exports.numbers = {
  8938. DEACTIVATION_TIMEOUT_MS: 225,
  8939. // animation duration)
  8940. FG_DEACTIVATION_MS: 150,
  8941. // (i.e. deactivation animation duration)
  8942. INITIAL_ORIGIN_SCALE: 0.6,
  8943. PADDING: 10,
  8944. TAP_DELAY_MS: 300 };
  8945. /***/ }),
  8946. /***/ "./packages/mdc-ripple/foundation.ts":
  8947. /*!*******************************************!*\
  8948. !*** ./packages/mdc-ripple/foundation.ts ***!
  8949. \*******************************************/
  8950. /*! no static exports found */
  8951. /***/ (function(module, exports, __webpack_require__) {
  8952. "use strict";
  8953. /**
  8954. * @license
  8955. * Copyright 2016 Google Inc.
  8956. *
  8957. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8958. * of this software and associated documentation files (the "Software"), to deal
  8959. * in the Software without restriction, including without limitation the rights
  8960. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8961. * copies of the Software, and to permit persons to whom the Software is
  8962. * furnished to do so, subject to the following conditions:
  8963. *
  8964. * The above copyright notice and this permission notice shall be included in
  8965. * all copies or substantial portions of the Software.
  8966. *
  8967. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  8968. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  8969. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  8970. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  8971. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  8972. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  8973. * THE SOFTWARE.
  8974. */
  8975. var __extends = this && this.__extends || function () {
  8976. var _extendStatics = function extendStatics(d, b) {
  8977. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  8978. d.__proto__ = b;
  8979. } || function (d, b) {
  8980. for (var p in b) {
  8981. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  8982. }
  8983. };
  8984. return _extendStatics(d, b);
  8985. };
  8986. return function (d, b) {
  8987. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  8988. _extendStatics(d, b);
  8989. function __() {
  8990. this.constructor = d;
  8991. }
  8992. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8993. };
  8994. }();
  8995. var __assign = this && this.__assign || function () {
  8996. __assign = Object.assign || function (t) {
  8997. for (var s, i = 1, n = arguments.length; i < n; i++) {
  8998. s = arguments[i];
  8999. for (var p in s) {
  9000. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  9001. }
  9002. }
  9003. return t;
  9004. };
  9005. return __assign.apply(this, arguments);
  9006. };
  9007. var __values = this && this.__values || function (o) {
  9008. var s = typeof Symbol === "function" && Symbol.iterator,
  9009. m = s && o[s],
  9010. i = 0;
  9011. if (m) return m.call(o);
  9012. if (o && typeof o.length === "number") return {
  9013. next: function next() {
  9014. if (o && i >= o.length) o = void 0;
  9015. return { value: o && o[i++], done: !o };
  9016. }
  9017. };
  9018. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  9019. };
  9020. Object.defineProperty(exports, "__esModule", { value: true });
  9021. exports.MDCRippleFoundation = void 0;
  9022. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  9023. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
  9024. var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
  9025. // Activation events registered on the root element of each instance for
  9026. // activation
  9027. var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
  9028. // Deactivation events registered on documentElement when a pointer-related down
  9029. // event occurs
  9030. var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
  9031. // simultaneous nested activations
  9032. var activatedTargets = [];
  9033. /** MDC Ripple Foundation */
  9034. var MDCRippleFoundation = /** @class */function (_super) {
  9035. __extends(MDCRippleFoundation, _super);
  9036. function MDCRippleFoundation(adapter) {
  9037. var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
  9038. _this.activationAnimationHasEnded = false;
  9039. _this.activationTimer = 0;
  9040. _this.fgDeactivationRemovalTimer = 0;
  9041. _this.fgScale = '0';
  9042. _this.frame = { width: 0, height: 0 };
  9043. _this.initialSize = 0;
  9044. _this.layoutFrame = 0;
  9045. _this.maxRadius = 0;
  9046. _this.unboundedCoords = { left: 0, top: 0 };
  9047. _this.activationState = _this.defaultActivationState();
  9048. _this.activationTimerCallback = function () {
  9049. _this.activationAnimationHasEnded = true;
  9050. _this.runDeactivationUXLogicIfReady();
  9051. };
  9052. _this.activateHandler = function (e) {
  9053. _this.activateImpl(e);
  9054. };
  9055. _this.deactivateHandler = function () {
  9056. _this.deactivateImpl();
  9057. };
  9058. _this.focusHandler = function () {
  9059. _this.handleFocus();
  9060. };
  9061. _this.blurHandler = function () {
  9062. _this.handleBlur();
  9063. };
  9064. _this.resizeHandler = function () {
  9065. _this.layout();
  9066. };
  9067. return _this;
  9068. }
  9069. Object.defineProperty(MDCRippleFoundation, "cssClasses", {
  9070. get: function get() {
  9071. return constants_1.cssClasses;
  9072. },
  9073. enumerable: false,
  9074. configurable: true
  9075. });
  9076. Object.defineProperty(MDCRippleFoundation, "strings", {
  9077. get: function get() {
  9078. return constants_1.strings;
  9079. },
  9080. enumerable: false,
  9081. configurable: true
  9082. });
  9083. Object.defineProperty(MDCRippleFoundation, "numbers", {
  9084. get: function get() {
  9085. return constants_1.numbers;
  9086. },
  9087. enumerable: false,
  9088. configurable: true
  9089. });
  9090. Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
  9091. get: function get() {
  9092. return {
  9093. addClass: function addClass() {
  9094. return undefined;
  9095. },
  9096. browserSupportsCssVars: function browserSupportsCssVars() {
  9097. return true;
  9098. },
  9099. computeBoundingRect: function computeBoundingRect() {
  9100. return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
  9101. },
  9102. containsEventTarget: function containsEventTarget() {
  9103. return true;
  9104. },
  9105. deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
  9106. return undefined;
  9107. },
  9108. deregisterInteractionHandler: function deregisterInteractionHandler() {
  9109. return undefined;
  9110. },
  9111. deregisterResizeHandler: function deregisterResizeHandler() {
  9112. return undefined;
  9113. },
  9114. getWindowPageOffset: function getWindowPageOffset() {
  9115. return { x: 0, y: 0 };
  9116. },
  9117. isSurfaceActive: function isSurfaceActive() {
  9118. return true;
  9119. },
  9120. isSurfaceDisabled: function isSurfaceDisabled() {
  9121. return true;
  9122. },
  9123. isUnbounded: function isUnbounded() {
  9124. return true;
  9125. },
  9126. registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
  9127. return undefined;
  9128. },
  9129. registerInteractionHandler: function registerInteractionHandler() {
  9130. return undefined;
  9131. },
  9132. registerResizeHandler: function registerResizeHandler() {
  9133. return undefined;
  9134. },
  9135. removeClass: function removeClass() {
  9136. return undefined;
  9137. },
  9138. updateCssVariable: function updateCssVariable() {
  9139. return undefined;
  9140. }
  9141. };
  9142. },
  9143. enumerable: false,
  9144. configurable: true
  9145. });
  9146. MDCRippleFoundation.prototype.init = function () {
  9147. var _this = this;
  9148. var supportsPressRipple = this.supportsPressRipple();
  9149. this.registerRootHandlers(supportsPressRipple);
  9150. if (supportsPressRipple) {
  9151. var _a = MDCRippleFoundation.cssClasses,
  9152. ROOT_1 = _a.ROOT,
  9153. UNBOUNDED_1 = _a.UNBOUNDED;
  9154. requestAnimationFrame(function () {
  9155. _this.adapter.addClass(ROOT_1);
  9156. if (_this.adapter.isUnbounded()) {
  9157. _this.adapter.addClass(UNBOUNDED_1);
  9158. // Unbounded ripples need layout logic applied immediately to set
  9159. // coordinates for both shade and ripple
  9160. _this.layoutInternal();
  9161. }
  9162. });
  9163. }
  9164. };
  9165. MDCRippleFoundation.prototype.destroy = function () {
  9166. var _this = this;
  9167. if (this.supportsPressRipple()) {
  9168. if (this.activationTimer) {
  9169. clearTimeout(this.activationTimer);
  9170. this.activationTimer = 0;
  9171. this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
  9172. }
  9173. if (this.fgDeactivationRemovalTimer) {
  9174. clearTimeout(this.fgDeactivationRemovalTimer);
  9175. this.fgDeactivationRemovalTimer = 0;
  9176. this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
  9177. }
  9178. var _a = MDCRippleFoundation.cssClasses,
  9179. ROOT_2 = _a.ROOT,
  9180. UNBOUNDED_2 = _a.UNBOUNDED;
  9181. requestAnimationFrame(function () {
  9182. _this.adapter.removeClass(ROOT_2);
  9183. _this.adapter.removeClass(UNBOUNDED_2);
  9184. _this.removeCssVars();
  9185. });
  9186. }
  9187. this.deregisterRootHandlers();
  9188. this.deregisterDeactivationHandlers();
  9189. };
  9190. /**
  9191. * @param evt Optional event containing position information.
  9192. */
  9193. MDCRippleFoundation.prototype.activate = function (evt) {
  9194. this.activateImpl(evt);
  9195. };
  9196. MDCRippleFoundation.prototype.deactivate = function () {
  9197. this.deactivateImpl();
  9198. };
  9199. MDCRippleFoundation.prototype.layout = function () {
  9200. var _this = this;
  9201. if (this.layoutFrame) {
  9202. cancelAnimationFrame(this.layoutFrame);
  9203. }
  9204. this.layoutFrame = requestAnimationFrame(function () {
  9205. _this.layoutInternal();
  9206. _this.layoutFrame = 0;
  9207. });
  9208. };
  9209. MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
  9210. var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
  9211. if (unbounded) {
  9212. this.adapter.addClass(UNBOUNDED);
  9213. } else {
  9214. this.adapter.removeClass(UNBOUNDED);
  9215. }
  9216. };
  9217. MDCRippleFoundation.prototype.handleFocus = function () {
  9218. var _this = this;
  9219. requestAnimationFrame(function () {
  9220. _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  9221. });
  9222. };
  9223. MDCRippleFoundation.prototype.handleBlur = function () {
  9224. var _this = this;
  9225. requestAnimationFrame(function () {
  9226. _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
  9227. });
  9228. };
  9229. /**
  9230. * We compute this property so that we are not querying information about the
  9231. * client until the point in time where the foundation requests it. This
  9232. * prevents scenarios where client-side feature-detection may happen too
  9233. * early, such as when components are rendered on the server and then
  9234. * initialized at mount time on the client.
  9235. */
  9236. MDCRippleFoundation.prototype.supportsPressRipple = function () {
  9237. return this.adapter.browserSupportsCssVars();
  9238. };
  9239. MDCRippleFoundation.prototype.defaultActivationState = function () {
  9240. return {
  9241. activationEvent: undefined,
  9242. hasDeactivationUXRun: false,
  9243. isActivated: false,
  9244. isProgrammatic: false,
  9245. wasActivatedByPointer: false,
  9246. wasElementMadeActive: false
  9247. };
  9248. };
  9249. /**
  9250. * supportsPressRipple Passed from init to save a redundant function call
  9251. */
  9252. MDCRippleFoundation.prototype.registerRootHandlers = function (supportsPressRipple) {
  9253. var e_1, _a;
  9254. if (supportsPressRipple) {
  9255. try {
  9256. for (var ACTIVATION_EVENT_TYPES_1 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next(); !ACTIVATION_EVENT_TYPES_1_1.done; ACTIVATION_EVENT_TYPES_1_1 = ACTIVATION_EVENT_TYPES_1.next()) {
  9257. var evtType = ACTIVATION_EVENT_TYPES_1_1.value;
  9258. this.adapter.registerInteractionHandler(evtType, this.activateHandler);
  9259. }
  9260. } catch (e_1_1) {
  9261. e_1 = { error: e_1_1 };
  9262. } finally {
  9263. try {
  9264. if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a = ACTIVATION_EVENT_TYPES_1.return)) _a.call(ACTIVATION_EVENT_TYPES_1);
  9265. } finally {
  9266. if (e_1) throw e_1.error;
  9267. }
  9268. }
  9269. if (this.adapter.isUnbounded()) {
  9270. this.adapter.registerResizeHandler(this.resizeHandler);
  9271. }
  9272. }
  9273. this.adapter.registerInteractionHandler('focus', this.focusHandler);
  9274. this.adapter.registerInteractionHandler('blur', this.blurHandler);
  9275. };
  9276. MDCRippleFoundation.prototype.registerDeactivationHandlers = function (evt) {
  9277. var e_2, _a;
  9278. if (evt.type === 'keydown') {
  9279. this.adapter.registerInteractionHandler('keyup', this.deactivateHandler);
  9280. } else {
  9281. try {
  9282. for (var POINTER_DEACTIVATION_EVENT_TYPES_1 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next(); !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done; POINTER_DEACTIVATION_EVENT_TYPES_1_1 = POINTER_DEACTIVATION_EVENT_TYPES_1.next()) {
  9283. var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value;
  9284. this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler);
  9285. }
  9286. } catch (e_2_1) {
  9287. e_2 = { error: e_2_1 };
  9288. } finally {
  9289. try {
  9290. if (POINTER_DEACTIVATION_EVENT_TYPES_1_1 && !POINTER_DEACTIVATION_EVENT_TYPES_1_1.done && (_a = POINTER_DEACTIVATION_EVENT_TYPES_1.return)) _a.call(POINTER_DEACTIVATION_EVENT_TYPES_1);
  9291. } finally {
  9292. if (e_2) throw e_2.error;
  9293. }
  9294. }
  9295. }
  9296. };
  9297. MDCRippleFoundation.prototype.deregisterRootHandlers = function () {
  9298. var e_3, _a;
  9299. try {
  9300. for (var ACTIVATION_EVENT_TYPES_2 = __values(ACTIVATION_EVENT_TYPES), ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next(); !ACTIVATION_EVENT_TYPES_2_1.done; ACTIVATION_EVENT_TYPES_2_1 = ACTIVATION_EVENT_TYPES_2.next()) {
  9301. var evtType = ACTIVATION_EVENT_TYPES_2_1.value;
  9302. this.adapter.deregisterInteractionHandler(evtType, this.activateHandler);
  9303. }
  9304. } catch (e_3_1) {
  9305. e_3 = { error: e_3_1 };
  9306. } finally {
  9307. try {
  9308. if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a = ACTIVATION_EVENT_TYPES_2.return)) _a.call(ACTIVATION_EVENT_TYPES_2);
  9309. } finally {
  9310. if (e_3) throw e_3.error;
  9311. }
  9312. }
  9313. this.adapter.deregisterInteractionHandler('focus', this.focusHandler);
  9314. this.adapter.deregisterInteractionHandler('blur', this.blurHandler);
  9315. if (this.adapter.isUnbounded()) {
  9316. this.adapter.deregisterResizeHandler(this.resizeHandler);
  9317. }
  9318. };
  9319. MDCRippleFoundation.prototype.deregisterDeactivationHandlers = function () {
  9320. var e_4, _a;
  9321. this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler);
  9322. try {
  9323. for (var POINTER_DEACTIVATION_EVENT_TYPES_2 = __values(POINTER_DEACTIVATION_EVENT_TYPES), POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next(); !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done; POINTER_DEACTIVATION_EVENT_TYPES_2_1 = POINTER_DEACTIVATION_EVENT_TYPES_2.next()) {
  9324. var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value;
  9325. this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler);
  9326. }
  9327. } catch (e_4_1) {
  9328. e_4 = { error: e_4_1 };
  9329. } finally {
  9330. try {
  9331. if (POINTER_DEACTIVATION_EVENT_TYPES_2_1 && !POINTER_DEACTIVATION_EVENT_TYPES_2_1.done && (_a = POINTER_DEACTIVATION_EVENT_TYPES_2.return)) _a.call(POINTER_DEACTIVATION_EVENT_TYPES_2);
  9332. } finally {
  9333. if (e_4) throw e_4.error;
  9334. }
  9335. }
  9336. };
  9337. MDCRippleFoundation.prototype.removeCssVars = function () {
  9338. var _this = this;
  9339. var rippleStrings = MDCRippleFoundation.strings;
  9340. var keys = Object.keys(rippleStrings);
  9341. keys.forEach(function (key) {
  9342. if (key.indexOf('VAR_') === 0) {
  9343. _this.adapter.updateCssVariable(rippleStrings[key], null);
  9344. }
  9345. });
  9346. };
  9347. MDCRippleFoundation.prototype.activateImpl = function (evt) {
  9348. var _this = this;
  9349. if (this.adapter.isSurfaceDisabled()) {
  9350. return;
  9351. }
  9352. var activationState = this.activationState;
  9353. if (activationState.isActivated) {
  9354. return;
  9355. }
  9356. // Avoid reacting to follow-on events fired by touch device after an
  9357. // already-processed user interaction
  9358. var previousActivationEvent = this.previousActivationEvent;
  9359. var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
  9360. if (isSameInteraction) {
  9361. return;
  9362. }
  9363. activationState.isActivated = true;
  9364. activationState.isProgrammatic = evt === undefined;
  9365. activationState.activationEvent = evt;
  9366. activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
  9367. var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
  9368. return _this.adapter.containsEventTarget(target);
  9369. });
  9370. if (hasActivatedChild) {
  9371. // Immediately reset activation state, while preserving logic that
  9372. // prevents touch follow-on events
  9373. this.resetActivationState();
  9374. return;
  9375. }
  9376. if (evt !== undefined) {
  9377. activatedTargets.push(evt.target);
  9378. this.registerDeactivationHandlers(evt);
  9379. }
  9380. activationState.wasElementMadeActive = this.checkElementMadeActive(evt);
  9381. if (activationState.wasElementMadeActive) {
  9382. this.animateActivation();
  9383. }
  9384. requestAnimationFrame(function () {
  9385. // Reset array on next frame after the current event has had a chance to
  9386. // bubble to prevent ancestor ripples
  9387. activatedTargets = [];
  9388. if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
  9389. // If space was pressed, try again within an rAF call to detect :active,
  9390. // because different UAs report active states inconsistently when
  9391. // they're called within event handling code:
  9392. // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
  9393. // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
  9394. // We try first outside rAF to support Edge, which does not exhibit this
  9395. // problem, but will crash if a CSS variable is set within a rAF
  9396. // callback for a submit button interaction (#2241).
  9397. activationState.wasElementMadeActive = _this.checkElementMadeActive(evt);
  9398. if (activationState.wasElementMadeActive) {
  9399. _this.animateActivation();
  9400. }
  9401. }
  9402. if (!activationState.wasElementMadeActive) {
  9403. // Reset activation state immediately if element was not made active.
  9404. _this.activationState = _this.defaultActivationState();
  9405. }
  9406. });
  9407. };
  9408. MDCRippleFoundation.prototype.checkElementMadeActive = function (evt) {
  9409. return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
  9410. };
  9411. MDCRippleFoundation.prototype.animateActivation = function () {
  9412. var _this = this;
  9413. var _a = MDCRippleFoundation.strings,
  9414. VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
  9415. VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
  9416. var _b = MDCRippleFoundation.cssClasses,
  9417. FG_DEACTIVATION = _b.FG_DEACTIVATION,
  9418. FG_ACTIVATION = _b.FG_ACTIVATION;
  9419. var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
  9420. this.layoutInternal();
  9421. var translateStart = '';
  9422. var translateEnd = '';
  9423. if (!this.adapter.isUnbounded()) {
  9424. var _c = this.getFgTranslationCoordinates(),
  9425. startPoint = _c.startPoint,
  9426. endPoint = _c.endPoint;
  9427. translateStart = startPoint.x + "px, " + startPoint.y + "px";
  9428. translateEnd = endPoint.x + "px, " + endPoint.y + "px";
  9429. }
  9430. this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
  9431. this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
  9432. // Cancel any ongoing activation/deactivation animations
  9433. clearTimeout(this.activationTimer);
  9434. clearTimeout(this.fgDeactivationRemovalTimer);
  9435. this.rmBoundedActivationClasses();
  9436. this.adapter.removeClass(FG_DEACTIVATION);
  9437. // Force layout in order to re-trigger the animation.
  9438. this.adapter.computeBoundingRect();
  9439. this.adapter.addClass(FG_ACTIVATION);
  9440. this.activationTimer = setTimeout(function () {
  9441. _this.activationTimerCallback();
  9442. }, DEACTIVATION_TIMEOUT_MS);
  9443. };
  9444. MDCRippleFoundation.prototype.getFgTranslationCoordinates = function () {
  9445. var _a = this.activationState,
  9446. activationEvent = _a.activationEvent,
  9447. wasActivatedByPointer = _a.wasActivatedByPointer;
  9448. var startPoint;
  9449. if (wasActivatedByPointer) {
  9450. startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
  9451. } else {
  9452. startPoint = {
  9453. x: this.frame.width / 2,
  9454. y: this.frame.height / 2
  9455. };
  9456. }
  9457. // Center the element around the start point.
  9458. startPoint = {
  9459. x: startPoint.x - this.initialSize / 2,
  9460. y: startPoint.y - this.initialSize / 2
  9461. };
  9462. var endPoint = {
  9463. x: this.frame.width / 2 - this.initialSize / 2,
  9464. y: this.frame.height / 2 - this.initialSize / 2
  9465. };
  9466. return { startPoint: startPoint, endPoint: endPoint };
  9467. };
  9468. MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady = function () {
  9469. var _this = this;
  9470. // This method is called both when a pointing device is released, and when
  9471. // the activation animation ends. The deactivation animation should only run
  9472. // after both of those occur.
  9473. var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
  9474. var _a = this.activationState,
  9475. hasDeactivationUXRun = _a.hasDeactivationUXRun,
  9476. isActivated = _a.isActivated;
  9477. var activationHasEnded = hasDeactivationUXRun || !isActivated;
  9478. if (activationHasEnded && this.activationAnimationHasEnded) {
  9479. this.rmBoundedActivationClasses();
  9480. this.adapter.addClass(FG_DEACTIVATION);
  9481. this.fgDeactivationRemovalTimer = setTimeout(function () {
  9482. _this.adapter.removeClass(FG_DEACTIVATION);
  9483. }, constants_1.numbers.FG_DEACTIVATION_MS);
  9484. }
  9485. };
  9486. MDCRippleFoundation.prototype.rmBoundedActivationClasses = function () {
  9487. var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
  9488. this.adapter.removeClass(FG_ACTIVATION);
  9489. this.activationAnimationHasEnded = false;
  9490. this.adapter.computeBoundingRect();
  9491. };
  9492. MDCRippleFoundation.prototype.resetActivationState = function () {
  9493. var _this = this;
  9494. this.previousActivationEvent = this.activationState.activationEvent;
  9495. this.activationState = this.defaultActivationState();
  9496. // Touch devices may fire additional events for the same interaction within
  9497. // a short time. Store the previous event until it's safe to assume that
  9498. // subsequent events are for new interactions.
  9499. setTimeout(function () {
  9500. return _this.previousActivationEvent = undefined;
  9501. }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
  9502. };
  9503. MDCRippleFoundation.prototype.deactivateImpl = function () {
  9504. var _this = this;
  9505. var activationState = this.activationState;
  9506. // This can happen in scenarios such as when you have a keyup event that
  9507. // blurs the element.
  9508. if (!activationState.isActivated) {
  9509. return;
  9510. }
  9511. var state = __assign({}, activationState);
  9512. if (activationState.isProgrammatic) {
  9513. requestAnimationFrame(function () {
  9514. _this.animateDeactivation(state);
  9515. });
  9516. this.resetActivationState();
  9517. } else {
  9518. this.deregisterDeactivationHandlers();
  9519. requestAnimationFrame(function () {
  9520. _this.activationState.hasDeactivationUXRun = true;
  9521. _this.animateDeactivation(state);
  9522. _this.resetActivationState();
  9523. });
  9524. }
  9525. };
  9526. MDCRippleFoundation.prototype.animateDeactivation = function (_a) {
  9527. var wasActivatedByPointer = _a.wasActivatedByPointer,
  9528. wasElementMadeActive = _a.wasElementMadeActive;
  9529. if (wasActivatedByPointer || wasElementMadeActive) {
  9530. this.runDeactivationUXLogicIfReady();
  9531. }
  9532. };
  9533. MDCRippleFoundation.prototype.layoutInternal = function () {
  9534. var _this = this;
  9535. this.frame = this.adapter.computeBoundingRect();
  9536. var maxDim = Math.max(this.frame.height, this.frame.width);
  9537. // Surface diameter is treated differently for unbounded vs. bounded
  9538. // ripples. Unbounded ripple diameter is calculated smaller since the
  9539. // surface is expected to already be padded appropriately to extend the
  9540. // hitbox, and the ripple is expected to meet the edges of the padded hitbox
  9541. // (which is typically square). Bounded ripples, on the other hand, are
  9542. // fully expected to expand beyond the surface's longest diameter
  9543. // (calculated based on the diagonal plus a constant padding), and are
  9544. // clipped at the surface's border via `overflow: hidden`.
  9545. var getBoundedRadius = function getBoundedRadius() {
  9546. var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2));
  9547. return hypotenuse + MDCRippleFoundation.numbers.PADDING;
  9548. };
  9549. this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
  9550. // Ripple is sized as a fraction of the largest dimension of the surface,
  9551. // then scales up using a CSS scale transform
  9552. var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
  9553. // Unbounded ripple size should always be even number to equally center
  9554. // align.
  9555. if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
  9556. this.initialSize = initialSize - 1;
  9557. } else {
  9558. this.initialSize = initialSize;
  9559. }
  9560. this.fgScale = "" + this.maxRadius / this.initialSize;
  9561. this.updateLayoutCssVars();
  9562. };
  9563. MDCRippleFoundation.prototype.updateLayoutCssVars = function () {
  9564. var _a = MDCRippleFoundation.strings,
  9565. VAR_FG_SIZE = _a.VAR_FG_SIZE,
  9566. VAR_LEFT = _a.VAR_LEFT,
  9567. VAR_TOP = _a.VAR_TOP,
  9568. VAR_FG_SCALE = _a.VAR_FG_SCALE;
  9569. this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px");
  9570. this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale);
  9571. if (this.adapter.isUnbounded()) {
  9572. this.unboundedCoords = {
  9573. left: Math.round(this.frame.width / 2 - this.initialSize / 2),
  9574. top: Math.round(this.frame.height / 2 - this.initialSize / 2)
  9575. };
  9576. this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px");
  9577. this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px");
  9578. }
  9579. };
  9580. return MDCRippleFoundation;
  9581. }(foundation_1.MDCFoundation);
  9582. exports.MDCRippleFoundation = MDCRippleFoundation;
  9583. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  9584. exports.default = MDCRippleFoundation;
  9585. /***/ }),
  9586. /***/ "./packages/mdc-ripple/util.ts":
  9587. /*!*************************************!*\
  9588. !*** ./packages/mdc-ripple/util.ts ***!
  9589. \*************************************/
  9590. /*! no static exports found */
  9591. /***/ (function(module, exports, __webpack_require__) {
  9592. "use strict";
  9593. Object.defineProperty(exports, "__esModule", { value: true });
  9594. exports.getNormalizedEventCoords = exports.supportsCssVariables = void 0;
  9595. /**
  9596. * Stores result from supportsCssVariables to avoid redundant processing to
  9597. * detect CSS custom variable support.
  9598. */
  9599. var supportsCssVariables_;
  9600. function supportsCssVariables(windowObj, forceRefresh) {
  9601. if (forceRefresh === void 0) {
  9602. forceRefresh = false;
  9603. }
  9604. var CSS = windowObj.CSS;
  9605. var supportsCssVars = supportsCssVariables_;
  9606. if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
  9607. return supportsCssVariables_;
  9608. }
  9609. var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
  9610. if (!supportsFunctionPresent) {
  9611. return false;
  9612. }
  9613. var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
  9614. // See: https://bugs.webkit.org/show_bug.cgi?id=154669
  9615. // See: README section on Safari
  9616. var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
  9617. supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
  9618. if (!forceRefresh) {
  9619. supportsCssVariables_ = supportsCssVars;
  9620. }
  9621. return supportsCssVars;
  9622. }
  9623. exports.supportsCssVariables = supportsCssVariables;
  9624. function getNormalizedEventCoords(evt, pageOffset, clientRect) {
  9625. if (!evt) {
  9626. return { x: 0, y: 0 };
  9627. }
  9628. var x = pageOffset.x,
  9629. y = pageOffset.y;
  9630. var documentX = x + clientRect.left;
  9631. var documentY = y + clientRect.top;
  9632. var normalizedX;
  9633. var normalizedY;
  9634. // Determine touch point relative to the ripple container.
  9635. if (evt.type === 'touchstart') {
  9636. var touchEvent = evt;
  9637. normalizedX = touchEvent.changedTouches[0].pageX - documentX;
  9638. normalizedY = touchEvent.changedTouches[0].pageY - documentY;
  9639. } else {
  9640. var mouseEvent = evt;
  9641. normalizedX = mouseEvent.pageX - documentX;
  9642. normalizedY = mouseEvent.pageY - documentY;
  9643. }
  9644. return { x: normalizedX, y: normalizedY };
  9645. }
  9646. exports.getNormalizedEventCoords = getNormalizedEventCoords;
  9647. /***/ }),
  9648. /***/ "./packages/mdc-select/adapter.ts":
  9649. /*!****************************************!*\
  9650. !*** ./packages/mdc-select/adapter.ts ***!
  9651. \****************************************/
  9652. /*! no static exports found */
  9653. /***/ (function(module, exports, __webpack_require__) {
  9654. "use strict";
  9655. /**
  9656. * @license
  9657. * Copyright 2018 Google Inc.
  9658. *
  9659. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9660. * of this software and associated documentation files (the "Software"), to deal
  9661. * in the Software without restriction, including without limitation the rights
  9662. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9663. * copies of the Software, and to permit persons to whom the Software is
  9664. * furnished to do so, subject to the following conditions:
  9665. *
  9666. * The above copyright notice and this permission notice shall be included in
  9667. * all copies or substantial portions of the Software.
  9668. *
  9669. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9670. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9671. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9672. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9673. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9674. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9675. * THE SOFTWARE.
  9676. */
  9677. Object.defineProperty(exports, "__esModule", { value: true });
  9678. /***/ }),
  9679. /***/ "./packages/mdc-select/component.ts":
  9680. /*!******************************************!*\
  9681. !*** ./packages/mdc-select/component.ts ***!
  9682. \******************************************/
  9683. /*! no static exports found */
  9684. /***/ (function(module, exports, __webpack_require__) {
  9685. "use strict";
  9686. /**
  9687. * @license
  9688. * Copyright 2016 Google Inc.
  9689. *
  9690. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9691. * of this software and associated documentation files (the "Software"), to deal
  9692. * in the Software without restriction, including without limitation the rights
  9693. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9694. * copies of the Software, and to permit persons to whom the Software is
  9695. * furnished to do so, subject to the following conditions:
  9696. *
  9697. * The above copyright notice and this permission notice shall be included in
  9698. * all copies or substantial portions of the Software.
  9699. *
  9700. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  9701. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  9702. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  9703. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  9704. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  9705. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  9706. * THE SOFTWARE.
  9707. */
  9708. var __extends = this && this.__extends || function () {
  9709. var _extendStatics = function extendStatics(d, b) {
  9710. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  9711. d.__proto__ = b;
  9712. } || function (d, b) {
  9713. for (var p in b) {
  9714. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  9715. }
  9716. };
  9717. return _extendStatics(d, b);
  9718. };
  9719. return function (d, b) {
  9720. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  9721. _extendStatics(d, b);
  9722. function __() {
  9723. this.constructor = d;
  9724. }
  9725. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9726. };
  9727. }();
  9728. var __assign = this && this.__assign || function () {
  9729. __assign = Object.assign || function (t) {
  9730. for (var s, i = 1, n = arguments.length; i < n; i++) {
  9731. s = arguments[i];
  9732. for (var p in s) {
  9733. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  9734. }
  9735. }
  9736. return t;
  9737. };
  9738. return __assign.apply(this, arguments);
  9739. };
  9740. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  9741. if (k2 === undefined) k2 = k;
  9742. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  9743. return m[k];
  9744. } });
  9745. } : function (o, m, k, k2) {
  9746. if (k2 === undefined) k2 = k;
  9747. o[k2] = m[k];
  9748. });
  9749. var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
  9750. Object.defineProperty(o, "default", { enumerable: true, value: v });
  9751. } : function (o, v) {
  9752. o["default"] = v;
  9753. });
  9754. var __importStar = this && this.__importStar || function (mod) {
  9755. if (mod && mod.__esModule) return mod;
  9756. var result = {};
  9757. if (mod != null) for (var k in mod) {
  9758. if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  9759. }__setModuleDefault(result, mod);
  9760. return result;
  9761. };
  9762. Object.defineProperty(exports, "__esModule", { value: true });
  9763. exports.MDCSelect = void 0;
  9764. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  9765. var component_2 = __webpack_require__(/*! @material/floating-label/component */ "./packages/mdc-floating-label/component.ts");
  9766. var component_3 = __webpack_require__(/*! @material/line-ripple/component */ "./packages/mdc-line-ripple/component.ts");
  9767. var menuSurfaceConstants = __importStar(__webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts"));
  9768. var component_4 = __webpack_require__(/*! @material/menu/component */ "./packages/mdc-menu/component.ts");
  9769. var menuConstants = __importStar(__webpack_require__(/*! @material/menu/constants */ "./packages/mdc-menu/constants.ts"));
  9770. var component_5 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
  9771. var component_6 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
  9772. var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
  9773. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
  9774. var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts");
  9775. var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-select/helper-text/component.ts");
  9776. var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-select/icon/component.ts");
  9777. /** MDC Select */
  9778. var MDCSelect = /** @class */function (_super) {
  9779. __extends(MDCSelect, _super);
  9780. function MDCSelect() {
  9781. return _super !== null && _super.apply(this, arguments) || this;
  9782. }
  9783. MDCSelect.attachTo = function (root) {
  9784. return new MDCSelect(root);
  9785. };
  9786. MDCSelect.prototype.initialize = function (labelFactory, lineRippleFactory, outlineFactory, menuFactory, iconFactory, helperTextFactory) {
  9787. if (labelFactory === void 0) {
  9788. labelFactory = function labelFactory(el) {
  9789. return new component_2.MDCFloatingLabel(el);
  9790. };
  9791. }
  9792. if (lineRippleFactory === void 0) {
  9793. lineRippleFactory = function lineRippleFactory(el) {
  9794. return new component_3.MDCLineRipple(el);
  9795. };
  9796. }
  9797. if (outlineFactory === void 0) {
  9798. outlineFactory = function outlineFactory(el) {
  9799. return new component_5.MDCNotchedOutline(el);
  9800. };
  9801. }
  9802. if (menuFactory === void 0) {
  9803. menuFactory = function menuFactory(el) {
  9804. return new component_4.MDCMenu(el);
  9805. };
  9806. }
  9807. if (iconFactory === void 0) {
  9808. iconFactory = function iconFactory(el) {
  9809. return new component_8.MDCSelectIcon(el);
  9810. };
  9811. }
  9812. if (helperTextFactory === void 0) {
  9813. helperTextFactory = function helperTextFactory(el) {
  9814. return new component_7.MDCSelectHelperText(el);
  9815. };
  9816. }
  9817. this.selectAnchor = this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
  9818. this.selectedText = this.root.querySelector(constants_1.strings.SELECTED_TEXT_SELECTOR);
  9819. this.hiddenInput = this.root.querySelector(constants_1.strings.HIDDEN_INPUT_SELECTOR);
  9820. if (!this.selectedText) {
  9821. throw new Error('MDCSelect: Missing required element: The following selector must be present: ' + ("'" + constants_1.strings.SELECTED_TEXT_SELECTOR + "'"));
  9822. }
  9823. if (this.selectAnchor.hasAttribute(constants_1.strings.ARIA_CONTROLS)) {
  9824. var helperTextElement = document.getElementById(this.selectAnchor.getAttribute(constants_1.strings.ARIA_CONTROLS));
  9825. if (helperTextElement) {
  9826. this.helperText = helperTextFactory(helperTextElement);
  9827. }
  9828. }
  9829. this.menuSetup(menuFactory);
  9830. var labelElement = this.root.querySelector(constants_1.strings.LABEL_SELECTOR);
  9831. this.label = labelElement ? labelFactory(labelElement) : null;
  9832. var lineRippleElement = this.root.querySelector(constants_1.strings.LINE_RIPPLE_SELECTOR);
  9833. this.lineRipple = lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
  9834. var outlineElement = this.root.querySelector(constants_1.strings.OUTLINE_SELECTOR);
  9835. this.outline = outlineElement ? outlineFactory(outlineElement) : null;
  9836. var leadingIcon = this.root.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
  9837. if (leadingIcon) {
  9838. this.leadingIcon = iconFactory(leadingIcon);
  9839. }
  9840. if (!this.root.classList.contains(constants_1.cssClasses.OUTLINED)) {
  9841. this.ripple = this.createRipple();
  9842. }
  9843. };
  9844. /**
  9845. * Initializes the select's event listeners and internal state based
  9846. * on the environment's state.
  9847. */
  9848. MDCSelect.prototype.initialSyncWithDOM = function () {
  9849. var _this = this;
  9850. this.handleFocus = function () {
  9851. _this.foundation.handleFocus();
  9852. };
  9853. this.handleBlur = function () {
  9854. _this.foundation.handleBlur();
  9855. };
  9856. this.handleClick = function (evt) {
  9857. _this.selectAnchor.focus();
  9858. _this.foundation.handleClick(_this.getNormalizedXCoordinate(evt));
  9859. };
  9860. this.handleKeydown = function (evt) {
  9861. _this.foundation.handleKeydown(evt);
  9862. };
  9863. this.handleMenuItemAction = function (evt) {
  9864. _this.foundation.handleMenuItemAction(evt.detail.index);
  9865. };
  9866. this.handleMenuOpened = function () {
  9867. _this.foundation.handleMenuOpened();
  9868. };
  9869. this.handleMenuClosed = function () {
  9870. _this.foundation.handleMenuClosed();
  9871. };
  9872. this.handleMenuClosing = function () {
  9873. _this.foundation.handleMenuClosing();
  9874. };
  9875. this.selectAnchor.addEventListener('focus', this.handleFocus);
  9876. this.selectAnchor.addEventListener('blur', this.handleBlur);
  9877. this.selectAnchor.addEventListener('click', this.handleClick);
  9878. this.selectAnchor.addEventListener('keydown', this.handleKeydown);
  9879. this.menu.listen(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
  9880. this.menu.listen(menuSurfaceConstants.strings.CLOSING_EVENT, this.handleMenuClosing);
  9881. this.menu.listen(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
  9882. this.menu.listen(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
  9883. if (this.hiddenInput) {
  9884. if (this.hiddenInput.value) {
  9885. // If the hidden input already has a value, use it to restore the
  9886. // select's value. This can happen e.g. if the user goes back or (in
  9887. // some browsers) refreshes the page.
  9888. this.foundation.setValue(this.hiddenInput.value, /** skipNotify */true);
  9889. this.foundation.layout();
  9890. return;
  9891. }
  9892. this.hiddenInput.value = this.value;
  9893. }
  9894. };
  9895. MDCSelect.prototype.destroy = function () {
  9896. this.selectAnchor.removeEventListener('focus', this.handleFocus);
  9897. this.selectAnchor.removeEventListener('blur', this.handleBlur);
  9898. this.selectAnchor.removeEventListener('keydown', this.handleKeydown);
  9899. this.selectAnchor.removeEventListener('click', this.handleClick);
  9900. this.menu.unlisten(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
  9901. this.menu.unlisten(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
  9902. this.menu.unlisten(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
  9903. this.menu.destroy();
  9904. if (this.ripple) {
  9905. this.ripple.destroy();
  9906. }
  9907. if (this.outline) {
  9908. this.outline.destroy();
  9909. }
  9910. if (this.leadingIcon) {
  9911. this.leadingIcon.destroy();
  9912. }
  9913. if (this.helperText) {
  9914. this.helperText.destroy();
  9915. }
  9916. _super.prototype.destroy.call(this);
  9917. };
  9918. Object.defineProperty(MDCSelect.prototype, "value", {
  9919. get: function get() {
  9920. return this.foundation.getValue();
  9921. },
  9922. set: function set(value) {
  9923. this.foundation.setValue(value);
  9924. },
  9925. enumerable: false,
  9926. configurable: true
  9927. });
  9928. MDCSelect.prototype.setValue = function (value, skipNotify) {
  9929. if (skipNotify === void 0) {
  9930. skipNotify = false;
  9931. }
  9932. this.foundation.setValue(value, skipNotify);
  9933. };
  9934. Object.defineProperty(MDCSelect.prototype, "selectedIndex", {
  9935. get: function get() {
  9936. return this.foundation.getSelectedIndex();
  9937. },
  9938. set: function set(selectedIndex) {
  9939. this.foundation.setSelectedIndex(selectedIndex, /* closeMenu */true);
  9940. },
  9941. enumerable: false,
  9942. configurable: true
  9943. });
  9944. MDCSelect.prototype.setSelectedIndex = function (selectedIndex, skipNotify) {
  9945. if (skipNotify === void 0) {
  9946. skipNotify = false;
  9947. }
  9948. this.foundation.setSelectedIndex(selectedIndex, /* closeMenu */true, skipNotify);
  9949. };
  9950. Object.defineProperty(MDCSelect.prototype, "disabled", {
  9951. get: function get() {
  9952. return this.foundation.getDisabled();
  9953. },
  9954. set: function set(disabled) {
  9955. this.foundation.setDisabled(disabled);
  9956. if (this.hiddenInput) {
  9957. this.hiddenInput.disabled = disabled;
  9958. }
  9959. },
  9960. enumerable: false,
  9961. configurable: true
  9962. });
  9963. Object.defineProperty(MDCSelect.prototype, "leadingIconAriaLabel", {
  9964. set: function set(label) {
  9965. this.foundation.setLeadingIconAriaLabel(label);
  9966. },
  9967. enumerable: false,
  9968. configurable: true
  9969. });
  9970. Object.defineProperty(MDCSelect.prototype, "leadingIconContent", {
  9971. /**
  9972. * Sets the text content of the leading icon.
  9973. */
  9974. set: function set(content) {
  9975. this.foundation.setLeadingIconContent(content);
  9976. },
  9977. enumerable: false,
  9978. configurable: true
  9979. });
  9980. Object.defineProperty(MDCSelect.prototype, "helperTextContent", {
  9981. /**
  9982. * Sets the text content of the helper text.
  9983. */
  9984. set: function set(content) {
  9985. this.foundation.setHelperTextContent(content);
  9986. },
  9987. enumerable: false,
  9988. configurable: true
  9989. });
  9990. Object.defineProperty(MDCSelect.prototype, "useDefaultValidation", {
  9991. /**
  9992. * Enables or disables the default validation scheme where a required select
  9993. * must be non-empty. Set to false for custom validation.
  9994. * @param useDefaultValidation Set this to false to ignore default
  9995. * validation scheme.
  9996. */
  9997. set: function set(useDefaultValidation) {
  9998. this.foundation.setUseDefaultValidation(useDefaultValidation);
  9999. },
  10000. enumerable: false,
  10001. configurable: true
  10002. });
  10003. Object.defineProperty(MDCSelect.prototype, "valid", {
  10004. /**
  10005. * Checks if the select is in a valid state.
  10006. */
  10007. get: function get() {
  10008. return this.foundation.isValid();
  10009. },
  10010. /**
  10011. * Sets the current invalid state of the select.
  10012. */
  10013. set: function set(isValid) {
  10014. this.foundation.setValid(isValid);
  10015. },
  10016. enumerable: false,
  10017. configurable: true
  10018. });
  10019. Object.defineProperty(MDCSelect.prototype, "required", {
  10020. /**
  10021. * Returns whether the select is required.
  10022. */
  10023. get: function get() {
  10024. return this.foundation.getRequired();
  10025. },
  10026. /**
  10027. * Sets the control to the required state.
  10028. */
  10029. set: function set(isRequired) {
  10030. this.foundation.setRequired(isRequired);
  10031. },
  10032. enumerable: false,
  10033. configurable: true
  10034. });
  10035. /**
  10036. * Re-calculates if the notched outline should be notched and if the label
  10037. * should float.
  10038. */
  10039. MDCSelect.prototype.layout = function () {
  10040. this.foundation.layout();
  10041. };
  10042. /**
  10043. * Synchronizes the list of options with the state of the foundation. Call
  10044. * this whenever menu options are dynamically updated.
  10045. */
  10046. MDCSelect.prototype.layoutOptions = function () {
  10047. this.foundation.layoutOptions();
  10048. this.menu.layout();
  10049. // Update cached menuItemValues for adapter.
  10050. this.menuItemValues = this.menu.items.map(function (el) {
  10051. return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
  10052. });
  10053. if (this.hiddenInput) {
  10054. this.hiddenInput.value = this.value;
  10055. }
  10056. };
  10057. MDCSelect.prototype.getDefaultFoundation = function () {
  10058. // DO NOT INLINE this variable. For backward compatibility, foundations take
  10059. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  10060. // methods, we need a separate, strongly typed adapter variable.
  10061. var adapter = __assign(__assign(__assign(__assign({}, this.getSelectAdapterMethods()), this.getCommonAdapterMethods()), this.getOutlineAdapterMethods()), this.getLabelAdapterMethods());
  10062. return new foundation_2.MDCSelectFoundation(adapter, this.getFoundationMap());
  10063. };
  10064. /**
  10065. * Handles setup for the menu.
  10066. */
  10067. MDCSelect.prototype.menuSetup = function (menuFactory) {
  10068. this.menuElement = this.root.querySelector(constants_1.strings.MENU_SELECTOR);
  10069. this.menu = menuFactory(this.menuElement);
  10070. this.menu.hasTypeahead = true;
  10071. this.menu.singleSelection = true;
  10072. this.menuItemValues = this.menu.items.map(function (el) {
  10073. return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
  10074. });
  10075. };
  10076. MDCSelect.prototype.createRipple = function () {
  10077. var _this = this;
  10078. // DO NOT INLINE this variable. For backward compatibility, foundations take
  10079. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  10080. // methods, we need a separate, strongly typed adapter variable.
  10081. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  10082. var adapter = __assign(__assign({}, component_6.MDCRipple.createAdapter({ root: this.selectAnchor })), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  10083. _this.selectAnchor.addEventListener(evtType, handler);
  10084. }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  10085. _this.selectAnchor.removeEventListener(evtType, handler);
  10086. } });
  10087. // tslint:enable:object-literal-sort-keys
  10088. return new component_6.MDCRipple(this.selectAnchor, new foundation_1.MDCRippleFoundation(adapter));
  10089. };
  10090. MDCSelect.prototype.getSelectAdapterMethods = function () {
  10091. var _this = this;
  10092. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  10093. return {
  10094. getMenuItemAttr: function getMenuItemAttr(menuItem, attr) {
  10095. return menuItem.getAttribute(attr);
  10096. },
  10097. setSelectedText: function setSelectedText(text) {
  10098. _this.selectedText.textContent = text;
  10099. var index = _this.menu.selectedIndex;
  10100. if (index === -1) return;
  10101. index = index instanceof Array ? index[0] : index;
  10102. var selectedItem = _this.menu.items[index];
  10103. if (!selectedItem) return;
  10104. _this.selectedText.setAttribute('aria-label', selectedItem.getAttribute('aria-label') || '');
  10105. },
  10106. isSelectAnchorFocused: function isSelectAnchorFocused() {
  10107. return document.activeElement === _this.selectAnchor;
  10108. },
  10109. getSelectAnchorAttr: function getSelectAnchorAttr(attr) {
  10110. return _this.selectAnchor.getAttribute(attr);
  10111. },
  10112. setSelectAnchorAttr: function setSelectAnchorAttr(attr, value) {
  10113. _this.safeSetAttribute(_this.selectAnchor, attr, value);
  10114. },
  10115. removeSelectAnchorAttr: function removeSelectAnchorAttr(attr) {
  10116. _this.selectAnchor.removeAttribute(attr);
  10117. },
  10118. addMenuClass: function addMenuClass(className) {
  10119. _this.menuElement.classList.add(className);
  10120. },
  10121. removeMenuClass: function removeMenuClass(className) {
  10122. _this.menuElement.classList.remove(className);
  10123. },
  10124. openMenu: function openMenu() {
  10125. _this.menu.open = true;
  10126. },
  10127. closeMenu: function closeMenu() {
  10128. _this.menu.open = false;
  10129. },
  10130. getAnchorElement: function getAnchorElement() {
  10131. return _this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
  10132. },
  10133. setMenuAnchorElement: function setMenuAnchorElement(anchorEl) {
  10134. _this.menu.setAnchorElement(anchorEl);
  10135. },
  10136. setMenuAnchorCorner: function setMenuAnchorCorner(anchorCorner) {
  10137. _this.menu.setAnchorCorner(anchorCorner);
  10138. },
  10139. setMenuWrapFocus: function setMenuWrapFocus(wrapFocus) {
  10140. _this.menu.wrapFocus = wrapFocus;
  10141. },
  10142. getSelectedIndex: function getSelectedIndex() {
  10143. var index = _this.menu.selectedIndex;
  10144. return index instanceof Array ? index[0] : index;
  10145. },
  10146. setSelectedIndex: function setSelectedIndex(index) {
  10147. _this.menu.selectedIndex = index;
  10148. },
  10149. focusMenuItemAtIndex: function focusMenuItemAtIndex(index) {
  10150. var _a;
  10151. (_a = _this.menu.items[index]) === null || _a === void 0 ? void 0 : _a.focus();
  10152. },
  10153. getMenuItemCount: function getMenuItemCount() {
  10154. return _this.menu.items.length;
  10155. },
  10156. // Cache menu item values. layoutOptions() updates this cache.
  10157. getMenuItemValues: function getMenuItemValues() {
  10158. return _this.menuItemValues;
  10159. },
  10160. getMenuItemTextAtIndex: function getMenuItemTextAtIndex(index) {
  10161. return _this.menu.getPrimaryTextAtIndex(index);
  10162. },
  10163. isTypeaheadInProgress: function isTypeaheadInProgress() {
  10164. return _this.menu.typeaheadInProgress;
  10165. },
  10166. typeaheadMatchItem: function typeaheadMatchItem(nextChar, startingIndex) {
  10167. return _this.menu.typeaheadMatchItem(nextChar, startingIndex);
  10168. }
  10169. };
  10170. // tslint:enable:object-literal-sort-keys
  10171. };
  10172. MDCSelect.prototype.getCommonAdapterMethods = function () {
  10173. var _this = this;
  10174. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  10175. return {
  10176. addClass: function addClass(className) {
  10177. _this.root.classList.add(className);
  10178. },
  10179. removeClass: function removeClass(className) {
  10180. _this.root.classList.remove(className);
  10181. },
  10182. hasClass: function hasClass(className) {
  10183. return _this.root.classList.contains(className);
  10184. },
  10185. setRippleCenter: function setRippleCenter(normalizedX) {
  10186. _this.lineRipple && _this.lineRipple.setRippleCenter(normalizedX);
  10187. },
  10188. activateBottomLine: function activateBottomLine() {
  10189. _this.lineRipple && _this.lineRipple.activate();
  10190. },
  10191. deactivateBottomLine: function deactivateBottomLine() {
  10192. _this.lineRipple && _this.lineRipple.deactivate();
  10193. },
  10194. notifyChange: function notifyChange(value) {
  10195. if (_this.hiddenInput) {
  10196. _this.hiddenInput.value = value;
  10197. }
  10198. var index = _this.selectedIndex;
  10199. _this.emit(constants_1.strings.CHANGE_EVENT, { value: value, index: index }, true /* shouldBubble */);
  10200. }
  10201. };
  10202. // tslint:enable:object-literal-sort-keys
  10203. };
  10204. MDCSelect.prototype.getOutlineAdapterMethods = function () {
  10205. var _this = this;
  10206. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  10207. return {
  10208. hasOutline: function hasOutline() {
  10209. return Boolean(_this.outline);
  10210. },
  10211. notchOutline: function notchOutline(labelWidth) {
  10212. _this.outline && _this.outline.notch(labelWidth);
  10213. },
  10214. closeOutline: function closeOutline() {
  10215. _this.outline && _this.outline.closeNotch();
  10216. }
  10217. };
  10218. // tslint:enable:object-literal-sort-keys
  10219. };
  10220. MDCSelect.prototype.getLabelAdapterMethods = function () {
  10221. var _this = this;
  10222. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  10223. return {
  10224. hasLabel: function hasLabel() {
  10225. return !!_this.label;
  10226. },
  10227. floatLabel: function floatLabel(shouldFloat) {
  10228. _this.label && _this.label.float(shouldFloat);
  10229. },
  10230. getLabelWidth: function getLabelWidth() {
  10231. return _this.label ? _this.label.getWidth() : 0;
  10232. },
  10233. setLabelRequired: function setLabelRequired(isRequired) {
  10234. _this.label && _this.label.setRequired(isRequired);
  10235. }
  10236. };
  10237. // tslint:enable:object-literal-sort-keys
  10238. };
  10239. /**
  10240. * Calculates where the line ripple should start based on the x coordinate
  10241. * within the component.
  10242. */
  10243. MDCSelect.prototype.getNormalizedXCoordinate = function (evt) {
  10244. var targetClientRect = evt.target.getBoundingClientRect();
  10245. var xCoordinate = this.isTouchEvent(evt) ? evt.touches[0].clientX : evt.clientX;
  10246. return xCoordinate - targetClientRect.left;
  10247. };
  10248. MDCSelect.prototype.isTouchEvent = function (evt) {
  10249. return Boolean(evt.touches);
  10250. };
  10251. /**
  10252. * Returns a map of all subcomponents to subfoundations.
  10253. */
  10254. MDCSelect.prototype.getFoundationMap = function () {
  10255. return {
  10256. helperText: this.helperText ? this.helperText.foundationForSelect : undefined,
  10257. leadingIcon: this.leadingIcon ? this.leadingIcon.foundationForSelect : undefined
  10258. };
  10259. };
  10260. return MDCSelect;
  10261. }(component_1.MDCComponent);
  10262. exports.MDCSelect = MDCSelect;
  10263. /***/ }),
  10264. /***/ "./packages/mdc-select/constants.ts":
  10265. /*!******************************************!*\
  10266. !*** ./packages/mdc-select/constants.ts ***!
  10267. \******************************************/
  10268. /*! no static exports found */
  10269. /***/ (function(module, exports, __webpack_require__) {
  10270. "use strict";
  10271. /**
  10272. * @license
  10273. * Copyright 2016 Google Inc.
  10274. *
  10275. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10276. * of this software and associated documentation files (the "Software"), to deal
  10277. * in the Software without restriction, including without limitation the rights
  10278. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10279. * copies of the Software, and to permit persons to whom the Software is
  10280. * furnished to do so, subject to the following conditions:
  10281. *
  10282. * The above copyright notice and this permission notice shall be included in
  10283. * all copies or substantial portions of the Software.
  10284. *
  10285. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10286. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10287. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10288. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10289. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10290. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  10291. * THE SOFTWARE.
  10292. */
  10293. Object.defineProperty(exports, "__esModule", { value: true });
  10294. exports.numbers = exports.strings = exports.cssClasses = void 0;
  10295. var cssClasses = {
  10296. ACTIVATED: 'mdc-select--activated',
  10297. DISABLED: 'mdc-select--disabled',
  10298. FOCUSED: 'mdc-select--focused',
  10299. INVALID: 'mdc-select--invalid',
  10300. MENU_INVALID: 'mdc-select__menu--invalid',
  10301. OUTLINED: 'mdc-select--outlined',
  10302. REQUIRED: 'mdc-select--required',
  10303. ROOT: 'mdc-select',
  10304. WITH_LEADING_ICON: 'mdc-select--with-leading-icon'
  10305. };
  10306. exports.cssClasses = cssClasses;
  10307. var strings = {
  10308. ARIA_CONTROLS: 'aria-controls',
  10309. ARIA_DESCRIBEDBY: 'aria-describedby',
  10310. ARIA_SELECTED_ATTR: 'aria-selected',
  10311. CHANGE_EVENT: 'MDCSelect:change',
  10312. HIDDEN_INPUT_SELECTOR: 'input[type="hidden"]',
  10313. LABEL_SELECTOR: '.mdc-floating-label',
  10314. LEADING_ICON_SELECTOR: '.mdc-select__icon',
  10315. LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
  10316. MENU_SELECTOR: '.mdc-select__menu',
  10317. OUTLINE_SELECTOR: '.mdc-notched-outline',
  10318. SELECTED_TEXT_SELECTOR: '.mdc-select__selected-text',
  10319. SELECT_ANCHOR_SELECTOR: '.mdc-select__anchor',
  10320. VALUE_ATTR: 'data-value'
  10321. };
  10322. exports.strings = strings;
  10323. var numbers = {
  10324. LABEL_SCALE: 0.75,
  10325. UNSET_INDEX: -1,
  10326. CLICK_DEBOUNCE_TIMEOUT_MS: 330
  10327. };
  10328. exports.numbers = numbers;
  10329. /***/ }),
  10330. /***/ "./packages/mdc-select/foundation.ts":
  10331. /*!*******************************************!*\
  10332. !*** ./packages/mdc-select/foundation.ts ***!
  10333. \*******************************************/
  10334. /*! no static exports found */
  10335. /***/ (function(module, exports, __webpack_require__) {
  10336. "use strict";
  10337. /**
  10338. * @license
  10339. * Copyright 2016 Google Inc.
  10340. *
  10341. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10342. * of this software and associated documentation files (the "Software"), to deal
  10343. * in the Software without restriction, including without limitation the rights
  10344. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10345. * copies of the Software, and to permit persons to whom the Software is
  10346. * furnished to do so, subject to the following conditions:
  10347. *
  10348. * The above copyright notice and this permission notice shall be included in
  10349. * all copies or substantial portions of the Software.
  10350. *
  10351. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10352. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10353. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10354. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10355. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10356. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  10357. * THE SOFTWARE.
  10358. */
  10359. var __extends = this && this.__extends || function () {
  10360. var _extendStatics = function extendStatics(d, b) {
  10361. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  10362. d.__proto__ = b;
  10363. } || function (d, b) {
  10364. for (var p in b) {
  10365. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  10366. }
  10367. };
  10368. return _extendStatics(d, b);
  10369. };
  10370. return function (d, b) {
  10371. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  10372. _extendStatics(d, b);
  10373. function __() {
  10374. this.constructor = d;
  10375. }
  10376. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10377. };
  10378. }();
  10379. var __assign = this && this.__assign || function () {
  10380. __assign = Object.assign || function (t) {
  10381. for (var s, i = 1, n = arguments.length; i < n; i++) {
  10382. s = arguments[i];
  10383. for (var p in s) {
  10384. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  10385. }
  10386. }
  10387. return t;
  10388. };
  10389. return __assign.apply(this, arguments);
  10390. };
  10391. var __read = this && this.__read || function (o, n) {
  10392. var m = typeof Symbol === "function" && o[Symbol.iterator];
  10393. if (!m) return o;
  10394. var i = m.call(o),
  10395. r,
  10396. ar = [],
  10397. e;
  10398. try {
  10399. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
  10400. ar.push(r.value);
  10401. }
  10402. } catch (error) {
  10403. e = { error: error };
  10404. } finally {
  10405. try {
  10406. if (r && !r.done && (m = i["return"])) m.call(i);
  10407. } finally {
  10408. if (e) throw e.error;
  10409. }
  10410. }
  10411. return ar;
  10412. };
  10413. var __spreadArray = this && this.__spreadArray || function (to, from) {
  10414. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
  10415. to[j] = from[i];
  10416. }return to;
  10417. };
  10418. Object.defineProperty(exports, "__esModule", { value: true });
  10419. exports.MDCSelectFoundation = void 0;
  10420. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  10421. var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
  10422. var constants_1 = __webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts");
  10423. var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
  10424. /** MDC Select Foundation */
  10425. var MDCSelectFoundation = /** @class */function (_super) {
  10426. __extends(MDCSelectFoundation, _super);
  10427. /* istanbul ignore next: optional argument is not a branch statement */
  10428. /**
  10429. * @param adapter
  10430. * @param foundationMap Map from subcomponent names to their subfoundations.
  10431. */
  10432. function MDCSelectFoundation(adapter, foundationMap) {
  10433. if (foundationMap === void 0) {
  10434. foundationMap = {};
  10435. }
  10436. var _a, _b;
  10437. var _this = _super.call(this, __assign(__assign({}, MDCSelectFoundation.defaultAdapter), adapter)) || this;
  10438. // Disabled state
  10439. _this.disabled = false;
  10440. // isMenuOpen is used to track the state of the menu by listening to the
  10441. // MDCMenuSurface:closed event For reference, menu.open will return false if
  10442. // the menu is still closing, but isMenuOpen returns false only after the menu
  10443. // has closed
  10444. _this.isMenuOpen = false;
  10445. // By default, select is invalid if it is required but no value is selected.
  10446. _this.useDefaultValidation = true;
  10447. _this.customValidity = true;
  10448. _this.lastSelectedIndex = constants_2.numbers.UNSET_INDEX;
  10449. _this.clickDebounceTimeout = 0;
  10450. _this.recentlyClicked = false;
  10451. _this.leadingIcon = foundationMap.leadingIcon;
  10452. _this.helperText = foundationMap.helperText;
  10453. _this.ariaDescribedbyIds = ((_b = (_a = _this.adapter.getSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY)) === null || _a === void 0 ? void 0 : _a.split(' ')) === null || _b === void 0 ? void 0 : _b.filter(function (id) {
  10454. var _a;return id !== ((_a = _this.helperText) === null || _a === void 0 ? void 0 : _a.getId()) && id !== '';
  10455. })) || [];
  10456. return _this;
  10457. }
  10458. Object.defineProperty(MDCSelectFoundation, "cssClasses", {
  10459. get: function get() {
  10460. return constants_2.cssClasses;
  10461. },
  10462. enumerable: false,
  10463. configurable: true
  10464. });
  10465. Object.defineProperty(MDCSelectFoundation, "numbers", {
  10466. get: function get() {
  10467. return constants_2.numbers;
  10468. },
  10469. enumerable: false,
  10470. configurable: true
  10471. });
  10472. Object.defineProperty(MDCSelectFoundation, "strings", {
  10473. get: function get() {
  10474. return constants_2.strings;
  10475. },
  10476. enumerable: false,
  10477. configurable: true
  10478. });
  10479. Object.defineProperty(MDCSelectFoundation, "defaultAdapter", {
  10480. /**
  10481. * See {@link MDCSelectAdapter} for typing information on parameters and
  10482. * return types.
  10483. */
  10484. get: function get() {
  10485. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  10486. return {
  10487. addClass: function addClass() {
  10488. return undefined;
  10489. },
  10490. removeClass: function removeClass() {
  10491. return undefined;
  10492. },
  10493. hasClass: function hasClass() {
  10494. return false;
  10495. },
  10496. activateBottomLine: function activateBottomLine() {
  10497. return undefined;
  10498. },
  10499. deactivateBottomLine: function deactivateBottomLine() {
  10500. return undefined;
  10501. },
  10502. getSelectedIndex: function getSelectedIndex() {
  10503. return -1;
  10504. },
  10505. setSelectedIndex: function setSelectedIndex() {
  10506. return undefined;
  10507. },
  10508. hasLabel: function hasLabel() {
  10509. return false;
  10510. },
  10511. floatLabel: function floatLabel() {
  10512. return undefined;
  10513. },
  10514. getLabelWidth: function getLabelWidth() {
  10515. return 0;
  10516. },
  10517. setLabelRequired: function setLabelRequired() {
  10518. return undefined;
  10519. },
  10520. hasOutline: function hasOutline() {
  10521. return false;
  10522. },
  10523. notchOutline: function notchOutline() {
  10524. return undefined;
  10525. },
  10526. closeOutline: function closeOutline() {
  10527. return undefined;
  10528. },
  10529. setRippleCenter: function setRippleCenter() {
  10530. return undefined;
  10531. },
  10532. notifyChange: function notifyChange() {
  10533. return undefined;
  10534. },
  10535. setSelectedText: function setSelectedText() {
  10536. return undefined;
  10537. },
  10538. isSelectAnchorFocused: function isSelectAnchorFocused() {
  10539. return false;
  10540. },
  10541. getSelectAnchorAttr: function getSelectAnchorAttr() {
  10542. return '';
  10543. },
  10544. setSelectAnchorAttr: function setSelectAnchorAttr() {
  10545. return undefined;
  10546. },
  10547. removeSelectAnchorAttr: function removeSelectAnchorAttr() {
  10548. return undefined;
  10549. },
  10550. addMenuClass: function addMenuClass() {
  10551. return undefined;
  10552. },
  10553. removeMenuClass: function removeMenuClass() {
  10554. return undefined;
  10555. },
  10556. openMenu: function openMenu() {
  10557. return undefined;
  10558. },
  10559. closeMenu: function closeMenu() {
  10560. return undefined;
  10561. },
  10562. getAnchorElement: function getAnchorElement() {
  10563. return null;
  10564. },
  10565. setMenuAnchorElement: function setMenuAnchorElement() {
  10566. return undefined;
  10567. },
  10568. setMenuAnchorCorner: function setMenuAnchorCorner() {
  10569. return undefined;
  10570. },
  10571. setMenuWrapFocus: function setMenuWrapFocus() {
  10572. return undefined;
  10573. },
  10574. focusMenuItemAtIndex: function focusMenuItemAtIndex() {
  10575. return undefined;
  10576. },
  10577. getMenuItemCount: function getMenuItemCount() {
  10578. return 0;
  10579. },
  10580. getMenuItemValues: function getMenuItemValues() {
  10581. return [];
  10582. },
  10583. getMenuItemTextAtIndex: function getMenuItemTextAtIndex() {
  10584. return '';
  10585. },
  10586. isTypeaheadInProgress: function isTypeaheadInProgress() {
  10587. return false;
  10588. },
  10589. typeaheadMatchItem: function typeaheadMatchItem() {
  10590. return -1;
  10591. }
  10592. };
  10593. // tslint:enable:object-literal-sort-keys
  10594. },
  10595. enumerable: false,
  10596. configurable: true
  10597. });
  10598. /** Returns the index of the currently selected menu item, or -1 if none. */
  10599. MDCSelectFoundation.prototype.getSelectedIndex = function () {
  10600. return this.adapter.getSelectedIndex();
  10601. };
  10602. MDCSelectFoundation.prototype.setSelectedIndex = function (index, closeMenu, skipNotify) {
  10603. if (closeMenu === void 0) {
  10604. closeMenu = false;
  10605. }
  10606. if (skipNotify === void 0) {
  10607. skipNotify = false;
  10608. }
  10609. if (index >= this.adapter.getMenuItemCount()) {
  10610. return;
  10611. }
  10612. this.adapter.setSelectedIndex(index);
  10613. if (index === constants_2.numbers.UNSET_INDEX) {
  10614. this.adapter.setSelectedText('');
  10615. } else {
  10616. this.adapter.setSelectedText(this.adapter.getMenuItemTextAtIndex(index).trim());
  10617. }
  10618. if (closeMenu) {
  10619. this.adapter.closeMenu();
  10620. }
  10621. if (!skipNotify && this.lastSelectedIndex !== index) {
  10622. this.handleChange();
  10623. }
  10624. this.lastSelectedIndex = index;
  10625. };
  10626. MDCSelectFoundation.prototype.setValue = function (value, skipNotify) {
  10627. if (skipNotify === void 0) {
  10628. skipNotify = false;
  10629. }
  10630. var index = this.adapter.getMenuItemValues().indexOf(value);
  10631. this.setSelectedIndex(index, /** closeMenu */false, skipNotify);
  10632. };
  10633. MDCSelectFoundation.prototype.getValue = function () {
  10634. var index = this.adapter.getSelectedIndex();
  10635. var menuItemValues = this.adapter.getMenuItemValues();
  10636. return index !== constants_2.numbers.UNSET_INDEX ? menuItemValues[index] : '';
  10637. };
  10638. MDCSelectFoundation.prototype.getDisabled = function () {
  10639. return this.disabled;
  10640. };
  10641. MDCSelectFoundation.prototype.setDisabled = function (isDisabled) {
  10642. this.disabled = isDisabled;
  10643. if (this.disabled) {
  10644. this.adapter.addClass(constants_2.cssClasses.DISABLED);
  10645. this.adapter.closeMenu();
  10646. } else {
  10647. this.adapter.removeClass(constants_2.cssClasses.DISABLED);
  10648. }
  10649. if (this.leadingIcon) {
  10650. this.leadingIcon.setDisabled(this.disabled);
  10651. }
  10652. if (this.disabled) {
  10653. // Prevent click events from focusing select. Simply pointer-events: none
  10654. // is not enough since screenreader clicks may bypass this.
  10655. this.adapter.removeSelectAnchorAttr('tabindex');
  10656. } else {
  10657. this.adapter.setSelectAnchorAttr('tabindex', '0');
  10658. }
  10659. this.adapter.setSelectAnchorAttr('aria-disabled', this.disabled.toString());
  10660. };
  10661. /** Opens the menu. */
  10662. MDCSelectFoundation.prototype.openMenu = function () {
  10663. this.adapter.addClass(constants_2.cssClasses.ACTIVATED);
  10664. this.adapter.openMenu();
  10665. this.isMenuOpen = true;
  10666. this.adapter.setSelectAnchorAttr('aria-expanded', 'true');
  10667. };
  10668. /**
  10669. * @param content Sets the content of the helper text.
  10670. */
  10671. MDCSelectFoundation.prototype.setHelperTextContent = function (content) {
  10672. if (this.helperText) {
  10673. this.helperText.setContent(content);
  10674. }
  10675. };
  10676. /**
  10677. * Re-calculates if the notched outline should be notched and if the label
  10678. * should float.
  10679. */
  10680. MDCSelectFoundation.prototype.layout = function () {
  10681. if (this.adapter.hasLabel()) {
  10682. var optionHasValue = this.getValue().length > 0;
  10683. var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
  10684. var shouldFloatAndNotch = optionHasValue || isFocused;
  10685. var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
  10686. this.notchOutline(shouldFloatAndNotch);
  10687. this.adapter.floatLabel(shouldFloatAndNotch);
  10688. this.adapter.setLabelRequired(isRequired);
  10689. }
  10690. };
  10691. /**
  10692. * Synchronizes the list of options with the state of the foundation. Call
  10693. * this whenever menu options are dynamically updated.
  10694. */
  10695. MDCSelectFoundation.prototype.layoutOptions = function () {
  10696. var menuItemValues = this.adapter.getMenuItemValues();
  10697. var selectedIndex = menuItemValues.indexOf(this.getValue());
  10698. this.setSelectedIndex(selectedIndex, /** closeMenu */false, /** skipNotify */true);
  10699. };
  10700. MDCSelectFoundation.prototype.handleMenuOpened = function () {
  10701. if (this.adapter.getMenuItemValues().length === 0) {
  10702. return;
  10703. }
  10704. // Menu should open to the last selected element, should open to first menu
  10705. // item otherwise.
  10706. var selectedIndex = this.getSelectedIndex();
  10707. var focusItemIndex = selectedIndex >= 0 ? selectedIndex : 0;
  10708. this.adapter.focusMenuItemAtIndex(focusItemIndex);
  10709. };
  10710. MDCSelectFoundation.prototype.handleMenuClosing = function () {
  10711. this.adapter.setSelectAnchorAttr('aria-expanded', 'false');
  10712. };
  10713. MDCSelectFoundation.prototype.handleMenuClosed = function () {
  10714. this.adapter.removeClass(constants_2.cssClasses.ACTIVATED);
  10715. this.isMenuOpen = false;
  10716. // Unfocus the select if menu is closed without a selection
  10717. if (!this.adapter.isSelectAnchorFocused()) {
  10718. this.blur();
  10719. }
  10720. };
  10721. /**
  10722. * Handles value changes, via change event or programmatic updates.
  10723. */
  10724. MDCSelectFoundation.prototype.handleChange = function () {
  10725. this.layout();
  10726. this.adapter.notifyChange(this.getValue());
  10727. var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
  10728. if (isRequired && this.useDefaultValidation) {
  10729. this.setValid(this.isValid());
  10730. }
  10731. };
  10732. MDCSelectFoundation.prototype.handleMenuItemAction = function (index) {
  10733. this.setSelectedIndex(index, /** closeMenu */true);
  10734. };
  10735. /**
  10736. * Handles focus events from select element.
  10737. */
  10738. MDCSelectFoundation.prototype.handleFocus = function () {
  10739. this.adapter.addClass(constants_2.cssClasses.FOCUSED);
  10740. this.layout();
  10741. this.adapter.activateBottomLine();
  10742. };
  10743. /**
  10744. * Handles blur events from select element.
  10745. */
  10746. MDCSelectFoundation.prototype.handleBlur = function () {
  10747. if (this.isMenuOpen) {
  10748. return;
  10749. }
  10750. this.blur();
  10751. };
  10752. MDCSelectFoundation.prototype.handleClick = function (normalizedX) {
  10753. if (this.disabled || this.recentlyClicked) {
  10754. return;
  10755. }
  10756. this.setClickDebounceTimeout();
  10757. if (this.isMenuOpen) {
  10758. this.adapter.closeMenu();
  10759. return;
  10760. }
  10761. this.adapter.setRippleCenter(normalizedX);
  10762. this.openMenu();
  10763. };
  10764. /**
  10765. * Handles keydown events on select element. Depending on the type of
  10766. * character typed, does typeahead matching or opens menu.
  10767. */
  10768. MDCSelectFoundation.prototype.handleKeydown = function (event) {
  10769. if (this.isMenuOpen || !this.adapter.hasClass(constants_2.cssClasses.FOCUSED)) {
  10770. return;
  10771. }
  10772. var isEnter = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ENTER;
  10773. var isSpace = keyboard_1.normalizeKey(event) === keyboard_1.KEY.SPACEBAR;
  10774. var arrowUp = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_UP;
  10775. var arrowDown = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_DOWN;
  10776. var isModifier = event.ctrlKey || event.metaKey;
  10777. // Typeahead
  10778. if (!isModifier && (!isSpace && event.key && event.key.length === 1 || isSpace && this.adapter.isTypeaheadInProgress())) {
  10779. var key = isSpace ? ' ' : event.key;
  10780. var typeaheadNextIndex = this.adapter.typeaheadMatchItem(key, this.getSelectedIndex());
  10781. if (typeaheadNextIndex >= 0) {
  10782. this.setSelectedIndex(typeaheadNextIndex);
  10783. }
  10784. event.preventDefault();
  10785. return;
  10786. }
  10787. if (!isEnter && !isSpace && !arrowUp && !arrowDown) {
  10788. return;
  10789. }
  10790. this.openMenu();
  10791. event.preventDefault();
  10792. };
  10793. /**
  10794. * Opens/closes the notched outline.
  10795. */
  10796. MDCSelectFoundation.prototype.notchOutline = function (openNotch) {
  10797. if (!this.adapter.hasOutline()) {
  10798. return;
  10799. }
  10800. var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
  10801. if (openNotch) {
  10802. var labelScale = constants_2.numbers.LABEL_SCALE;
  10803. var labelWidth = this.adapter.getLabelWidth() * labelScale;
  10804. this.adapter.notchOutline(labelWidth);
  10805. } else if (!isFocused) {
  10806. this.adapter.closeOutline();
  10807. }
  10808. };
  10809. /**
  10810. * Sets the aria label of the leading icon.
  10811. */
  10812. MDCSelectFoundation.prototype.setLeadingIconAriaLabel = function (label) {
  10813. if (this.leadingIcon) {
  10814. this.leadingIcon.setAriaLabel(label);
  10815. }
  10816. };
  10817. /**
  10818. * Sets the text content of the leading icon.
  10819. */
  10820. MDCSelectFoundation.prototype.setLeadingIconContent = function (content) {
  10821. if (this.leadingIcon) {
  10822. this.leadingIcon.setContent(content);
  10823. }
  10824. };
  10825. MDCSelectFoundation.prototype.getUseDefaultValidation = function () {
  10826. return this.useDefaultValidation;
  10827. };
  10828. MDCSelectFoundation.prototype.setUseDefaultValidation = function (useDefaultValidation) {
  10829. this.useDefaultValidation = useDefaultValidation;
  10830. };
  10831. MDCSelectFoundation.prototype.setValid = function (isValid) {
  10832. if (!this.useDefaultValidation) {
  10833. this.customValidity = isValid;
  10834. }
  10835. this.adapter.setSelectAnchorAttr('aria-invalid', (!isValid).toString());
  10836. if (isValid) {
  10837. this.adapter.removeClass(constants_2.cssClasses.INVALID);
  10838. this.adapter.removeMenuClass(constants_2.cssClasses.MENU_INVALID);
  10839. } else {
  10840. this.adapter.addClass(constants_2.cssClasses.INVALID);
  10841. this.adapter.addMenuClass(constants_2.cssClasses.MENU_INVALID);
  10842. }
  10843. this.syncHelperTextValidity(isValid);
  10844. };
  10845. MDCSelectFoundation.prototype.isValid = function () {
  10846. if (this.useDefaultValidation && this.adapter.hasClass(constants_2.cssClasses.REQUIRED) && !this.adapter.hasClass(constants_2.cssClasses.DISABLED)) {
  10847. // See notes for required attribute under
  10848. // https://www.w3.org/TR/html52/sec-forms.html#the-select-element TL;DR:
  10849. // Invalid if no index is selected, or if the first index is selected and
  10850. // has an empty value.
  10851. return this.getSelectedIndex() !== constants_2.numbers.UNSET_INDEX && (this.getSelectedIndex() !== 0 || Boolean(this.getValue()));
  10852. }
  10853. return this.customValidity;
  10854. };
  10855. MDCSelectFoundation.prototype.setRequired = function (isRequired) {
  10856. if (isRequired) {
  10857. this.adapter.addClass(constants_2.cssClasses.REQUIRED);
  10858. } else {
  10859. this.adapter.removeClass(constants_2.cssClasses.REQUIRED);
  10860. }
  10861. this.adapter.setSelectAnchorAttr('aria-required', isRequired.toString());
  10862. this.adapter.setLabelRequired(isRequired);
  10863. };
  10864. MDCSelectFoundation.prototype.getRequired = function () {
  10865. return this.adapter.getSelectAnchorAttr('aria-required') === 'true';
  10866. };
  10867. MDCSelectFoundation.prototype.init = function () {
  10868. var anchorEl = this.adapter.getAnchorElement();
  10869. if (anchorEl) {
  10870. this.adapter.setMenuAnchorElement(anchorEl);
  10871. this.adapter.setMenuAnchorCorner(constants_1.Corner.BOTTOM_START);
  10872. }
  10873. this.adapter.setMenuWrapFocus(false);
  10874. this.setDisabled(this.adapter.hasClass(constants_2.cssClasses.DISABLED));
  10875. this.syncHelperTextValidity(!this.adapter.hasClass(constants_2.cssClasses.INVALID));
  10876. this.layout();
  10877. this.layoutOptions();
  10878. };
  10879. /**
  10880. * Unfocuses the select component.
  10881. */
  10882. MDCSelectFoundation.prototype.blur = function () {
  10883. this.adapter.removeClass(constants_2.cssClasses.FOCUSED);
  10884. this.layout();
  10885. this.adapter.deactivateBottomLine();
  10886. var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
  10887. if (isRequired && this.useDefaultValidation) {
  10888. this.setValid(this.isValid());
  10889. }
  10890. };
  10891. MDCSelectFoundation.prototype.syncHelperTextValidity = function (isValid) {
  10892. if (!this.helperText) {
  10893. return;
  10894. }
  10895. this.helperText.setValidity(isValid);
  10896. var helperTextVisible = this.helperText.isVisible();
  10897. var helperTextId = this.helperText.getId();
  10898. if (helperTextVisible && helperTextId) {
  10899. this.adapter.setSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY, __spreadArray(__spreadArray([], __read(this.ariaDescribedbyIds)), [helperTextId]).join(' '));
  10900. } else {
  10901. // Remove helptext from list of describedby ids. Needed because
  10902. // screenreaders will read labels pointed to by `aria-describedby` even if
  10903. // they are `aria-hidden`.
  10904. if (this.ariaDescribedbyIds.length > 0) {
  10905. this.adapter.setSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY, this.ariaDescribedbyIds.join(' '));
  10906. } else {
  10907. // helper text is the only describedby element
  10908. this.adapter.removeSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY);
  10909. }
  10910. }
  10911. };
  10912. MDCSelectFoundation.prototype.setClickDebounceTimeout = function () {
  10913. var _this = this;
  10914. clearTimeout(this.clickDebounceTimeout);
  10915. this.clickDebounceTimeout = setTimeout(function () {
  10916. _this.recentlyClicked = false;
  10917. }, constants_2.numbers.CLICK_DEBOUNCE_TIMEOUT_MS);
  10918. this.recentlyClicked = true;
  10919. };
  10920. return MDCSelectFoundation;
  10921. }(foundation_1.MDCFoundation);
  10922. exports.MDCSelectFoundation = MDCSelectFoundation;
  10923. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  10924. exports.default = MDCSelectFoundation;
  10925. /***/ }),
  10926. /***/ "./packages/mdc-select/helper-text/adapter.ts":
  10927. /*!****************************************************!*\
  10928. !*** ./packages/mdc-select/helper-text/adapter.ts ***!
  10929. \****************************************************/
  10930. /*! no static exports found */
  10931. /***/ (function(module, exports, __webpack_require__) {
  10932. "use strict";
  10933. /**
  10934. * @license
  10935. * Copyright 2018 Google Inc.
  10936. *
  10937. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10938. * of this software and associated documentation files (the "Software"), to deal
  10939. * in the Software without restriction, including without limitation the rights
  10940. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10941. * copies of the Software, and to permit persons to whom the Software is
  10942. * furnished to do so, subject to the following conditions:
  10943. *
  10944. * The above copyright notice and this permission notice shall be included in
  10945. * all copies or substantial portions of the Software.
  10946. *
  10947. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10948. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10949. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10950. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10951. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10952. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  10953. * THE SOFTWARE.
  10954. */
  10955. Object.defineProperty(exports, "__esModule", { value: true });
  10956. /***/ }),
  10957. /***/ "./packages/mdc-select/helper-text/component.ts":
  10958. /*!******************************************************!*\
  10959. !*** ./packages/mdc-select/helper-text/component.ts ***!
  10960. \******************************************************/
  10961. /*! no static exports found */
  10962. /***/ (function(module, exports, __webpack_require__) {
  10963. "use strict";
  10964. /**
  10965. * @license
  10966. * Copyright 2018 Google Inc.
  10967. *
  10968. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10969. * of this software and associated documentation files (the "Software"), to deal
  10970. * in the Software without restriction, including without limitation the rights
  10971. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10972. * copies of the Software, and to permit persons to whom the Software is
  10973. * furnished to do so, subject to the following conditions:
  10974. *
  10975. * The above copyright notice and this permission notice shall be included in
  10976. * all copies or substantial portions of the Software.
  10977. *
  10978. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  10979. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  10980. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  10981. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  10982. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  10983. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  10984. * THE SOFTWARE.
  10985. */
  10986. var __extends = this && this.__extends || function () {
  10987. var _extendStatics = function extendStatics(d, b) {
  10988. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  10989. d.__proto__ = b;
  10990. } || function (d, b) {
  10991. for (var p in b) {
  10992. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  10993. }
  10994. };
  10995. return _extendStatics(d, b);
  10996. };
  10997. return function (d, b) {
  10998. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  10999. _extendStatics(d, b);
  11000. function __() {
  11001. this.constructor = d;
  11002. }
  11003. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11004. };
  11005. }();
  11006. Object.defineProperty(exports, "__esModule", { value: true });
  11007. exports.MDCSelectHelperText = void 0;
  11008. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  11009. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts");
  11010. /** MDC Select Helper Text */
  11011. var MDCSelectHelperText = /** @class */function (_super) {
  11012. __extends(MDCSelectHelperText, _super);
  11013. function MDCSelectHelperText() {
  11014. return _super !== null && _super.apply(this, arguments) || this;
  11015. }
  11016. MDCSelectHelperText.attachTo = function (root) {
  11017. return new MDCSelectHelperText(root);
  11018. };
  11019. Object.defineProperty(MDCSelectHelperText.prototype, "foundationForSelect", {
  11020. // Provided for access by MDCSelect component
  11021. get: function get() {
  11022. return this.foundation;
  11023. },
  11024. enumerable: false,
  11025. configurable: true
  11026. });
  11027. MDCSelectHelperText.prototype.getDefaultFoundation = function () {
  11028. var _this = this;
  11029. // DO NOT INLINE this variable. For backward compatibility, foundations take
  11030. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  11031. // methods, we need a separate, strongly typed adapter variable.
  11032. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  11033. var adapter = {
  11034. addClass: function addClass(className) {
  11035. _this.root.classList.add(className);
  11036. },
  11037. removeClass: function removeClass(className) {
  11038. _this.root.classList.remove(className);
  11039. },
  11040. hasClass: function hasClass(className) {
  11041. return _this.root.classList.contains(className);
  11042. },
  11043. getAttr: function getAttr(attr) {
  11044. return _this.root.getAttribute(attr);
  11045. },
  11046. setAttr: function setAttr(attr, value) {
  11047. _this.safeSetAttribute(_this.root, attr, value);
  11048. },
  11049. removeAttr: function removeAttr(attr) {
  11050. _this.root.removeAttribute(attr);
  11051. },
  11052. setContent: function setContent(content) {
  11053. _this.root.textContent = content;
  11054. }
  11055. };
  11056. // tslint:enable:object-literal-sort-keys
  11057. return new foundation_1.MDCSelectHelperTextFoundation(adapter);
  11058. };
  11059. return MDCSelectHelperText;
  11060. }(component_1.MDCComponent);
  11061. exports.MDCSelectHelperText = MDCSelectHelperText;
  11062. /***/ }),
  11063. /***/ "./packages/mdc-select/helper-text/constants.ts":
  11064. /*!******************************************************!*\
  11065. !*** ./packages/mdc-select/helper-text/constants.ts ***!
  11066. \******************************************************/
  11067. /*! no static exports found */
  11068. /***/ (function(module, exports, __webpack_require__) {
  11069. "use strict";
  11070. /**
  11071. * @license
  11072. * Copyright 2018 Google Inc.
  11073. *
  11074. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11075. * of this software and associated documentation files (the "Software"), to deal
  11076. * in the Software without restriction, including without limitation the rights
  11077. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11078. * copies of the Software, and to permit persons to whom the Software is
  11079. * furnished to do so, subject to the following conditions:
  11080. *
  11081. * The above copyright notice and this permission notice shall be included in
  11082. * all copies or substantial portions of the Software.
  11083. *
  11084. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11085. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11086. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11087. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11088. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11089. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11090. * THE SOFTWARE.
  11091. */
  11092. Object.defineProperty(exports, "__esModule", { value: true });
  11093. exports.cssClasses = exports.strings = void 0;
  11094. var strings = {
  11095. ARIA_HIDDEN: 'aria-hidden',
  11096. ROLE: 'role'
  11097. };
  11098. exports.strings = strings;
  11099. var cssClasses = {
  11100. HELPER_TEXT_VALIDATION_MSG: 'mdc-select-helper-text--validation-msg',
  11101. HELPER_TEXT_VALIDATION_MSG_PERSISTENT: 'mdc-select-helper-text--validation-msg-persistent'
  11102. };
  11103. exports.cssClasses = cssClasses;
  11104. /***/ }),
  11105. /***/ "./packages/mdc-select/helper-text/foundation.ts":
  11106. /*!*******************************************************!*\
  11107. !*** ./packages/mdc-select/helper-text/foundation.ts ***!
  11108. \*******************************************************/
  11109. /*! no static exports found */
  11110. /***/ (function(module, exports, __webpack_require__) {
  11111. "use strict";
  11112. /**
  11113. * @license
  11114. * Copyright 2018 Google Inc.
  11115. *
  11116. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11117. * of this software and associated documentation files (the "Software"), to deal
  11118. * in the Software without restriction, including without limitation the rights
  11119. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11120. * copies of the Software, and to permit persons to whom the Software is
  11121. * furnished to do so, subject to the following conditions:
  11122. *
  11123. * The above copyright notice and this permission notice shall be included in
  11124. * all copies or substantial portions of the Software.
  11125. *
  11126. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11127. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11128. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11129. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11130. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11131. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11132. * THE SOFTWARE.
  11133. */
  11134. var __extends = this && this.__extends || function () {
  11135. var _extendStatics = function extendStatics(d, b) {
  11136. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  11137. d.__proto__ = b;
  11138. } || function (d, b) {
  11139. for (var p in b) {
  11140. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  11141. }
  11142. };
  11143. return _extendStatics(d, b);
  11144. };
  11145. return function (d, b) {
  11146. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  11147. _extendStatics(d, b);
  11148. function __() {
  11149. this.constructor = d;
  11150. }
  11151. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11152. };
  11153. }();
  11154. var __assign = this && this.__assign || function () {
  11155. __assign = Object.assign || function (t) {
  11156. for (var s, i = 1, n = arguments.length; i < n; i++) {
  11157. s = arguments[i];
  11158. for (var p in s) {
  11159. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  11160. }
  11161. }
  11162. return t;
  11163. };
  11164. return __assign.apply(this, arguments);
  11165. };
  11166. Object.defineProperty(exports, "__esModule", { value: true });
  11167. exports.MDCSelectHelperTextFoundation = void 0;
  11168. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  11169. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
  11170. /** MDC Select Helper Text Foundation */
  11171. var MDCSelectHelperTextFoundation = /** @class */function (_super) {
  11172. __extends(MDCSelectHelperTextFoundation, _super);
  11173. function MDCSelectHelperTextFoundation(adapter) {
  11174. return _super.call(this, __assign(__assign({}, MDCSelectHelperTextFoundation.defaultAdapter), adapter)) || this;
  11175. }
  11176. Object.defineProperty(MDCSelectHelperTextFoundation, "cssClasses", {
  11177. get: function get() {
  11178. return constants_1.cssClasses;
  11179. },
  11180. enumerable: false,
  11181. configurable: true
  11182. });
  11183. Object.defineProperty(MDCSelectHelperTextFoundation, "strings", {
  11184. get: function get() {
  11185. return constants_1.strings;
  11186. },
  11187. enumerable: false,
  11188. configurable: true
  11189. });
  11190. Object.defineProperty(MDCSelectHelperTextFoundation, "defaultAdapter", {
  11191. /**
  11192. * See {@link MDCSelectHelperTextAdapter} for typing information on parameters
  11193. * and return types.
  11194. */
  11195. get: function get() {
  11196. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  11197. return {
  11198. addClass: function addClass() {
  11199. return undefined;
  11200. },
  11201. removeClass: function removeClass() {
  11202. return undefined;
  11203. },
  11204. hasClass: function hasClass() {
  11205. return false;
  11206. },
  11207. setAttr: function setAttr() {
  11208. return undefined;
  11209. },
  11210. getAttr: function getAttr() {
  11211. return null;
  11212. },
  11213. removeAttr: function removeAttr() {
  11214. return undefined;
  11215. },
  11216. setContent: function setContent() {
  11217. return undefined;
  11218. }
  11219. };
  11220. // tslint:enable:object-literal-sort-keys
  11221. },
  11222. enumerable: false,
  11223. configurable: true
  11224. });
  11225. /**
  11226. * @return The ID of the helper text, or null if none is set.
  11227. */
  11228. MDCSelectHelperTextFoundation.prototype.getId = function () {
  11229. return this.adapter.getAttr('id');
  11230. };
  11231. /**
  11232. * @return Whether the helper text is currently visible.
  11233. */
  11234. MDCSelectHelperTextFoundation.prototype.isVisible = function () {
  11235. return this.adapter.getAttr(constants_1.strings.ARIA_HIDDEN) !== 'true';
  11236. };
  11237. /**
  11238. * Sets the content of the helper text field.
  11239. */
  11240. MDCSelectHelperTextFoundation.prototype.setContent = function (content) {
  11241. this.adapter.setContent(content);
  11242. };
  11243. /**
  11244. * Sets the helper text to act as a validation message.
  11245. * By default, validation messages are hidden when the select is valid and
  11246. * visible when the select is invalid.
  11247. *
  11248. * @param isValidation True to make the helper text act as an error validation
  11249. * message.
  11250. */
  11251. MDCSelectHelperTextFoundation.prototype.setValidation = function (isValidation) {
  11252. if (isValidation) {
  11253. this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  11254. } else {
  11255. this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  11256. }
  11257. };
  11258. /**
  11259. * Sets the persistency of the validation helper text.
  11260. * This keeps the validation message visible even if the select is valid,
  11261. * though it will be displayed in the normal (grey) color.
  11262. */
  11263. MDCSelectHelperTextFoundation.prototype.setValidationMsgPersistent = function (isPersistent) {
  11264. if (isPersistent) {
  11265. this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
  11266. } else {
  11267. this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
  11268. }
  11269. };
  11270. /**
  11271. * @return Whether the helper text acts as a validation message.
  11272. * By default, validation messages are hidden when the select is valid and
  11273. * visible when the select is invalid.
  11274. */
  11275. MDCSelectHelperTextFoundation.prototype.getIsValidation = function () {
  11276. return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  11277. };
  11278. /**
  11279. * @return Whether the validation helper text persists even if the input is
  11280. * valid. If it is, it will be displayed in the normal (grey) color.
  11281. */
  11282. MDCSelectHelperTextFoundation.prototype.getIsValidationMsgPersistent = function () {
  11283. return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
  11284. };
  11285. /**
  11286. * When acting as a validation message, shows/hides the helper text and
  11287. * triggers alerts as necessary based on the select's validity.
  11288. */
  11289. MDCSelectHelperTextFoundation.prototype.setValidity = function (selectIsValid) {
  11290. var isValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
  11291. if (!isValidationMsg) {
  11292. // Non-validating helper-text is always displayed and does not participate
  11293. // in validation logic.
  11294. return;
  11295. }
  11296. var isPersistentValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
  11297. // Validating helper text is displayed if select is invalid, unless it is
  11298. // set as persistent, in which case it always displays.
  11299. var msgShouldDisplay = !selectIsValid || isPersistentValidationMsg;
  11300. if (msgShouldDisplay) {
  11301. this.showToScreenReader();
  11302. // In addition to displaying, also trigger an alert if the select
  11303. // has become invalid.
  11304. if (!selectIsValid) {
  11305. this.adapter.setAttr(constants_1.strings.ROLE, 'alert');
  11306. } else {
  11307. this.adapter.removeAttr(constants_1.strings.ROLE);
  11308. }
  11309. return;
  11310. }
  11311. // Hide everything.
  11312. this.adapter.removeAttr(constants_1.strings.ROLE);
  11313. this.hide();
  11314. };
  11315. /**
  11316. * Makes the helper text visible to screen readers.
  11317. */
  11318. MDCSelectHelperTextFoundation.prototype.showToScreenReader = function () {
  11319. this.adapter.removeAttr(constants_1.strings.ARIA_HIDDEN);
  11320. };
  11321. /**
  11322. * Hides the help text from screen readers.
  11323. */
  11324. MDCSelectHelperTextFoundation.prototype.hide = function () {
  11325. this.adapter.setAttr(constants_1.strings.ARIA_HIDDEN, 'true');
  11326. };
  11327. return MDCSelectHelperTextFoundation;
  11328. }(foundation_1.MDCFoundation);
  11329. exports.MDCSelectHelperTextFoundation = MDCSelectHelperTextFoundation;
  11330. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  11331. exports.default = MDCSelectHelperTextFoundation;
  11332. /***/ }),
  11333. /***/ "./packages/mdc-select/helper-text/index.ts":
  11334. /*!**************************************************!*\
  11335. !*** ./packages/mdc-select/helper-text/index.ts ***!
  11336. \**************************************************/
  11337. /*! no static exports found */
  11338. /***/ (function(module, exports, __webpack_require__) {
  11339. "use strict";
  11340. /**
  11341. * @license
  11342. * Copyright 2019 Google Inc.
  11343. *
  11344. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11345. * of this software and associated documentation files (the "Software"), to deal
  11346. * in the Software without restriction, including without limitation the rights
  11347. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11348. * copies of the Software, and to permit persons to whom the Software is
  11349. * furnished to do so, subject to the following conditions:
  11350. *
  11351. * The above copyright notice and this permission notice shall be included in
  11352. * all copies or substantial portions of the Software.
  11353. *
  11354. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11355. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11356. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11357. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11358. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11359. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11360. * THE SOFTWARE.
  11361. */
  11362. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  11363. if (k2 === undefined) k2 = k;
  11364. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  11365. return m[k];
  11366. } });
  11367. } : function (o, m, k, k2) {
  11368. if (k2 === undefined) k2 = k;
  11369. o[k2] = m[k];
  11370. });
  11371. var __exportStar = this && this.__exportStar || function (m, exports) {
  11372. for (var p in m) {
  11373. if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  11374. }
  11375. };
  11376. Object.defineProperty(exports, "__esModule", { value: true });
  11377. exports.helperTextStrings = exports.helperTextCssClasses = void 0;
  11378. __exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-select/helper-text/adapter.ts"), exports);
  11379. __exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-select/helper-text/component.ts"), exports);
  11380. __exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts"), exports);
  11381. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
  11382. Object.defineProperty(exports, "helperTextCssClasses", { enumerable: true, get: function get() {
  11383. return constants_1.cssClasses;
  11384. } });
  11385. Object.defineProperty(exports, "helperTextStrings", { enumerable: true, get: function get() {
  11386. return constants_1.strings;
  11387. } });
  11388. /***/ }),
  11389. /***/ "./packages/mdc-select/icon/adapter.ts":
  11390. /*!*********************************************!*\
  11391. !*** ./packages/mdc-select/icon/adapter.ts ***!
  11392. \*********************************************/
  11393. /*! no static exports found */
  11394. /***/ (function(module, exports, __webpack_require__) {
  11395. "use strict";
  11396. /**
  11397. * @license
  11398. * Copyright 2018 Google Inc.
  11399. *
  11400. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11401. * of this software and associated documentation files (the "Software"), to deal
  11402. * in the Software without restriction, including without limitation the rights
  11403. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11404. * copies of the Software, and to permit persons to whom the Software is
  11405. * furnished to do so, subject to the following conditions:
  11406. *
  11407. * The above copyright notice and this permission notice shall be included in
  11408. * all copies or substantial portions of the Software.
  11409. *
  11410. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11411. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11412. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11413. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11414. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11415. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11416. * THE SOFTWARE.
  11417. */
  11418. Object.defineProperty(exports, "__esModule", { value: true });
  11419. /***/ }),
  11420. /***/ "./packages/mdc-select/icon/component.ts":
  11421. /*!***********************************************!*\
  11422. !*** ./packages/mdc-select/icon/component.ts ***!
  11423. \***********************************************/
  11424. /*! no static exports found */
  11425. /***/ (function(module, exports, __webpack_require__) {
  11426. "use strict";
  11427. /**
  11428. * @license
  11429. * Copyright 2018 Google Inc.
  11430. *
  11431. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11432. * of this software and associated documentation files (the "Software"), to deal
  11433. * in the Software without restriction, including without limitation the rights
  11434. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11435. * copies of the Software, and to permit persons to whom the Software is
  11436. * furnished to do so, subject to the following conditions:
  11437. *
  11438. * The above copyright notice and this permission notice shall be included in
  11439. * all copies or substantial portions of the Software.
  11440. *
  11441. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11442. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11443. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11444. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11445. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11446. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11447. * THE SOFTWARE.
  11448. */
  11449. var __extends = this && this.__extends || function () {
  11450. var _extendStatics = function extendStatics(d, b) {
  11451. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  11452. d.__proto__ = b;
  11453. } || function (d, b) {
  11454. for (var p in b) {
  11455. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  11456. }
  11457. };
  11458. return _extendStatics(d, b);
  11459. };
  11460. return function (d, b) {
  11461. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  11462. _extendStatics(d, b);
  11463. function __() {
  11464. this.constructor = d;
  11465. }
  11466. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11467. };
  11468. }();
  11469. Object.defineProperty(exports, "__esModule", { value: true });
  11470. exports.MDCSelectIcon = void 0;
  11471. var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
  11472. var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts");
  11473. /** MDC Select Icon */
  11474. var MDCSelectIcon = /** @class */function (_super) {
  11475. __extends(MDCSelectIcon, _super);
  11476. function MDCSelectIcon() {
  11477. return _super !== null && _super.apply(this, arguments) || this;
  11478. }
  11479. MDCSelectIcon.attachTo = function (root) {
  11480. return new MDCSelectIcon(root);
  11481. };
  11482. Object.defineProperty(MDCSelectIcon.prototype, "foundationForSelect", {
  11483. // Provided for access by MDCSelect component
  11484. get: function get() {
  11485. return this.foundation;
  11486. },
  11487. enumerable: false,
  11488. configurable: true
  11489. });
  11490. MDCSelectIcon.prototype.getDefaultFoundation = function () {
  11491. var _this = this;
  11492. // DO NOT INLINE this variable. For backward compatibility, foundations take
  11493. // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
  11494. // methods, we need a separate, strongly typed adapter variable.
  11495. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  11496. var adapter = {
  11497. getAttr: function getAttr(attr) {
  11498. return _this.root.getAttribute(attr);
  11499. },
  11500. setAttr: function setAttr(attr, value) {
  11501. _this.safeSetAttribute(_this.root, attr, value);
  11502. },
  11503. removeAttr: function removeAttr(attr) {
  11504. _this.root.removeAttribute(attr);
  11505. },
  11506. setContent: function setContent(content) {
  11507. _this.root.textContent = content;
  11508. },
  11509. registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
  11510. _this.listen(evtType, handler);
  11511. },
  11512. deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
  11513. _this.unlisten(evtType, handler);
  11514. },
  11515. notifyIconAction: function notifyIconAction() {
  11516. _this.emit(foundation_1.MDCSelectIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */);
  11517. }
  11518. };
  11519. // tslint:enable:object-literal-sort-keys
  11520. return new foundation_1.MDCSelectIconFoundation(adapter);
  11521. };
  11522. return MDCSelectIcon;
  11523. }(component_1.MDCComponent);
  11524. exports.MDCSelectIcon = MDCSelectIcon;
  11525. /***/ }),
  11526. /***/ "./packages/mdc-select/icon/constants.ts":
  11527. /*!***********************************************!*\
  11528. !*** ./packages/mdc-select/icon/constants.ts ***!
  11529. \***********************************************/
  11530. /*! no static exports found */
  11531. /***/ (function(module, exports, __webpack_require__) {
  11532. "use strict";
  11533. /**
  11534. * @license
  11535. * Copyright 2018 Google Inc.
  11536. *
  11537. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11538. * of this software and associated documentation files (the "Software"), to deal
  11539. * in the Software without restriction, including without limitation the rights
  11540. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11541. * copies of the Software, and to permit persons to whom the Software is
  11542. * furnished to do so, subject to the following conditions:
  11543. *
  11544. * The above copyright notice and this permission notice shall be included in
  11545. * all copies or substantial portions of the Software.
  11546. *
  11547. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11548. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11549. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11550. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11551. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11552. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11553. * THE SOFTWARE.
  11554. */
  11555. Object.defineProperty(exports, "__esModule", { value: true });
  11556. exports.strings = void 0;
  11557. var strings = {
  11558. ICON_EVENT: 'MDCSelect:icon',
  11559. ICON_ROLE: 'button'
  11560. };
  11561. exports.strings = strings;
  11562. /***/ }),
  11563. /***/ "./packages/mdc-select/icon/foundation.ts":
  11564. /*!************************************************!*\
  11565. !*** ./packages/mdc-select/icon/foundation.ts ***!
  11566. \************************************************/
  11567. /*! no static exports found */
  11568. /***/ (function(module, exports, __webpack_require__) {
  11569. "use strict";
  11570. /**
  11571. * @license
  11572. * Copyright 2018 Google Inc.
  11573. *
  11574. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11575. * of this software and associated documentation files (the "Software"), to deal
  11576. * in the Software without restriction, including without limitation the rights
  11577. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11578. * copies of the Software, and to permit persons to whom the Software is
  11579. * furnished to do so, subject to the following conditions:
  11580. *
  11581. * The above copyright notice and this permission notice shall be included in
  11582. * all copies or substantial portions of the Software.
  11583. *
  11584. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11585. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11586. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11587. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11588. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11589. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11590. * THE SOFTWARE.
  11591. */
  11592. var __extends = this && this.__extends || function () {
  11593. var _extendStatics = function extendStatics(d, b) {
  11594. _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
  11595. d.__proto__ = b;
  11596. } || function (d, b) {
  11597. for (var p in b) {
  11598. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  11599. }
  11600. };
  11601. return _extendStatics(d, b);
  11602. };
  11603. return function (d, b) {
  11604. if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  11605. _extendStatics(d, b);
  11606. function __() {
  11607. this.constructor = d;
  11608. }
  11609. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  11610. };
  11611. }();
  11612. var __assign = this && this.__assign || function () {
  11613. __assign = Object.assign || function (t) {
  11614. for (var s, i = 1, n = arguments.length; i < n; i++) {
  11615. s = arguments[i];
  11616. for (var p in s) {
  11617. if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  11618. }
  11619. }
  11620. return t;
  11621. };
  11622. return __assign.apply(this, arguments);
  11623. };
  11624. var __values = this && this.__values || function (o) {
  11625. var s = typeof Symbol === "function" && Symbol.iterator,
  11626. m = s && o[s],
  11627. i = 0;
  11628. if (m) return m.call(o);
  11629. if (o && typeof o.length === "number") return {
  11630. next: function next() {
  11631. if (o && i >= o.length) o = void 0;
  11632. return { value: o && o[i++], done: !o };
  11633. }
  11634. };
  11635. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  11636. };
  11637. Object.defineProperty(exports, "__esModule", { value: true });
  11638. exports.MDCSelectIconFoundation = void 0;
  11639. var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
  11640. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
  11641. var INTERACTION_EVENTS = ['click', 'keydown'];
  11642. /** MDC Select Icon Foundation */
  11643. var MDCSelectIconFoundation = /** @class */function (_super) {
  11644. __extends(MDCSelectIconFoundation, _super);
  11645. function MDCSelectIconFoundation(adapter) {
  11646. var _this = _super.call(this, __assign(__assign({}, MDCSelectIconFoundation.defaultAdapter), adapter)) || this;
  11647. _this.savedTabIndex = null;
  11648. _this.interactionHandler = function (evt) {
  11649. _this.handleInteraction(evt);
  11650. };
  11651. return _this;
  11652. }
  11653. Object.defineProperty(MDCSelectIconFoundation, "strings", {
  11654. get: function get() {
  11655. return constants_1.strings;
  11656. },
  11657. enumerable: false,
  11658. configurable: true
  11659. });
  11660. Object.defineProperty(MDCSelectIconFoundation, "defaultAdapter", {
  11661. /**
  11662. * See {@link MDCSelectIconAdapter} for typing information on parameters and
  11663. * return types.
  11664. */
  11665. get: function get() {
  11666. // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
  11667. return {
  11668. getAttr: function getAttr() {
  11669. return null;
  11670. },
  11671. setAttr: function setAttr() {
  11672. return undefined;
  11673. },
  11674. removeAttr: function removeAttr() {
  11675. return undefined;
  11676. },
  11677. setContent: function setContent() {
  11678. return undefined;
  11679. },
  11680. registerInteractionHandler: function registerInteractionHandler() {
  11681. return undefined;
  11682. },
  11683. deregisterInteractionHandler: function deregisterInteractionHandler() {
  11684. return undefined;
  11685. },
  11686. notifyIconAction: function notifyIconAction() {
  11687. return undefined;
  11688. }
  11689. };
  11690. // tslint:enable:object-literal-sort-keys
  11691. },
  11692. enumerable: false,
  11693. configurable: true
  11694. });
  11695. MDCSelectIconFoundation.prototype.init = function () {
  11696. var e_1, _a;
  11697. this.savedTabIndex = this.adapter.getAttr('tabindex');
  11698. try {
  11699. for (var INTERACTION_EVENTS_1 = __values(INTERACTION_EVENTS), INTERACTION_EVENTS_1_1 = INTERACTION_EVENTS_1.next(); !INTERACTION_EVENTS_1_1.done; INTERACTION_EVENTS_1_1 = INTERACTION_EVENTS_1.next()) {
  11700. var evtType = INTERACTION_EVENTS_1_1.value;
  11701. this.adapter.registerInteractionHandler(evtType, this.interactionHandler);
  11702. }
  11703. } catch (e_1_1) {
  11704. e_1 = { error: e_1_1 };
  11705. } finally {
  11706. try {
  11707. if (INTERACTION_EVENTS_1_1 && !INTERACTION_EVENTS_1_1.done && (_a = INTERACTION_EVENTS_1.return)) _a.call(INTERACTION_EVENTS_1);
  11708. } finally {
  11709. if (e_1) throw e_1.error;
  11710. }
  11711. }
  11712. };
  11713. MDCSelectIconFoundation.prototype.destroy = function () {
  11714. var e_2, _a;
  11715. try {
  11716. for (var INTERACTION_EVENTS_2 = __values(INTERACTION_EVENTS), INTERACTION_EVENTS_2_1 = INTERACTION_EVENTS_2.next(); !INTERACTION_EVENTS_2_1.done; INTERACTION_EVENTS_2_1 = INTERACTION_EVENTS_2.next()) {
  11717. var evtType = INTERACTION_EVENTS_2_1.value;
  11718. this.adapter.deregisterInteractionHandler(evtType, this.interactionHandler);
  11719. }
  11720. } catch (e_2_1) {
  11721. e_2 = { error: e_2_1 };
  11722. } finally {
  11723. try {
  11724. if (INTERACTION_EVENTS_2_1 && !INTERACTION_EVENTS_2_1.done && (_a = INTERACTION_EVENTS_2.return)) _a.call(INTERACTION_EVENTS_2);
  11725. } finally {
  11726. if (e_2) throw e_2.error;
  11727. }
  11728. }
  11729. };
  11730. MDCSelectIconFoundation.prototype.setDisabled = function (disabled) {
  11731. if (!this.savedTabIndex) {
  11732. return;
  11733. }
  11734. if (disabled) {
  11735. this.adapter.setAttr('tabindex', '-1');
  11736. this.adapter.removeAttr('role');
  11737. } else {
  11738. this.adapter.setAttr('tabindex', this.savedTabIndex);
  11739. this.adapter.setAttr('role', constants_1.strings.ICON_ROLE);
  11740. }
  11741. };
  11742. MDCSelectIconFoundation.prototype.setAriaLabel = function (label) {
  11743. this.adapter.setAttr('aria-label', label);
  11744. };
  11745. MDCSelectIconFoundation.prototype.setContent = function (content) {
  11746. this.adapter.setContent(content);
  11747. };
  11748. MDCSelectIconFoundation.prototype.handleInteraction = function (evt) {
  11749. var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
  11750. if (evt.type === 'click' || isEnterKey) {
  11751. this.adapter.notifyIconAction();
  11752. }
  11753. };
  11754. return MDCSelectIconFoundation;
  11755. }(foundation_1.MDCFoundation);
  11756. exports.MDCSelectIconFoundation = MDCSelectIconFoundation;
  11757. // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  11758. exports.default = MDCSelectIconFoundation;
  11759. /***/ }),
  11760. /***/ "./packages/mdc-select/icon/index.ts":
  11761. /*!*******************************************!*\
  11762. !*** ./packages/mdc-select/icon/index.ts ***!
  11763. \*******************************************/
  11764. /*! no static exports found */
  11765. /***/ (function(module, exports, __webpack_require__) {
  11766. "use strict";
  11767. /**
  11768. * @license
  11769. * Copyright 2019 Google Inc.
  11770. *
  11771. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11772. * of this software and associated documentation files (the "Software"), to deal
  11773. * in the Software without restriction, including without limitation the rights
  11774. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11775. * copies of the Software, and to permit persons to whom the Software is
  11776. * furnished to do so, subject to the following conditions:
  11777. *
  11778. * The above copyright notice and this permission notice shall be included in
  11779. * all copies or substantial portions of the Software.
  11780. *
  11781. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11782. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11783. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11784. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11785. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11786. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11787. * THE SOFTWARE.
  11788. */
  11789. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  11790. if (k2 === undefined) k2 = k;
  11791. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  11792. return m[k];
  11793. } });
  11794. } : function (o, m, k, k2) {
  11795. if (k2 === undefined) k2 = k;
  11796. o[k2] = m[k];
  11797. });
  11798. var __exportStar = this && this.__exportStar || function (m, exports) {
  11799. for (var p in m) {
  11800. if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  11801. }
  11802. };
  11803. Object.defineProperty(exports, "__esModule", { value: true });
  11804. exports.iconStrings = void 0;
  11805. __exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-select/icon/adapter.ts"), exports);
  11806. __exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-select/icon/component.ts"), exports);
  11807. __exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts"), exports);
  11808. var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
  11809. Object.defineProperty(exports, "iconStrings", { enumerable: true, get: function get() {
  11810. return constants_1.strings;
  11811. } });
  11812. /***/ }),
  11813. /***/ "./packages/mdc-select/index.ts":
  11814. /*!**************************************!*\
  11815. !*** ./packages/mdc-select/index.ts ***!
  11816. \**************************************/
  11817. /*! no static exports found */
  11818. /***/ (function(module, exports, __webpack_require__) {
  11819. "use strict";
  11820. /**
  11821. * @license
  11822. * Copyright 2019 Google Inc.
  11823. *
  11824. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11825. * of this software and associated documentation files (the "Software"), to deal
  11826. * in the Software without restriction, including without limitation the rights
  11827. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11828. * copies of the Software, and to permit persons to whom the Software is
  11829. * furnished to do so, subject to the following conditions:
  11830. *
  11831. * The above copyright notice and this permission notice shall be included in
  11832. * all copies or substantial portions of the Software.
  11833. *
  11834. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11835. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11836. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11837. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11838. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11839. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11840. * THE SOFTWARE.
  11841. */
  11842. var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
  11843. if (k2 === undefined) k2 = k;
  11844. Object.defineProperty(o, k2, { enumerable: true, get: function get() {
  11845. return m[k];
  11846. } });
  11847. } : function (o, m, k, k2) {
  11848. if (k2 === undefined) k2 = k;
  11849. o[k2] = m[k];
  11850. });
  11851. var __exportStar = this && this.__exportStar || function (m, exports) {
  11852. for (var p in m) {
  11853. if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
  11854. }
  11855. };
  11856. Object.defineProperty(exports, "__esModule", { value: true });
  11857. __exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-select/adapter.ts"), exports);
  11858. __exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-select/component.ts"), exports);
  11859. __exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts"), exports);
  11860. __exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts"), exports);
  11861. __exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-select/types.ts"), exports);
  11862. __exportStar(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-select/helper-text/index.ts"), exports);
  11863. __exportStar(__webpack_require__(/*! ./icon/index */ "./packages/mdc-select/icon/index.ts"), exports);
  11864. /***/ }),
  11865. /***/ "./packages/mdc-select/types.ts":
  11866. /*!**************************************!*\
  11867. !*** ./packages/mdc-select/types.ts ***!
  11868. \**************************************/
  11869. /*! no static exports found */
  11870. /***/ (function(module, exports, __webpack_require__) {
  11871. "use strict";
  11872. /**
  11873. * @license
  11874. * Copyright 2019 Google Inc.
  11875. *
  11876. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11877. * of this software and associated documentation files (the "Software"), to deal
  11878. * in the Software without restriction, including without limitation the rights
  11879. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11880. * copies of the Software, and to permit persons to whom the Software is
  11881. * furnished to do so, subject to the following conditions:
  11882. *
  11883. * The above copyright notice and this permission notice shall be included in
  11884. * all copies or substantial portions of the Software.
  11885. *
  11886. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11887. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11888. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  11889. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  11890. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  11891. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  11892. * THE SOFTWARE.
  11893. */
  11894. Object.defineProperty(exports, "__esModule", { value: true });
  11895. /***/ })
  11896. /******/ });
  11897. });
  11898. //# sourceMappingURL=mdc.select.js.map