| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380 |
- /**
- * @license
- * Copyright Google LLC All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
- */
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory();
- else if(typeof define === 'function' && define.amd)
- define("@material/select", [], factory);
- else if(typeof exports === 'object')
- exports["select"] = factory();
- else
- root["mdc"] = root["mdc"] || {}, root["mdc"]["select"] = factory();
- })(this, function() {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
- /******/ }
- /******/ };
- /******/
- /******/ // define __esModule on exports
- /******/ __webpack_require__.r = function(exports) {
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
- /******/ }
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
- /******/ };
- /******/
- /******/ // create a fake namespace object
- /******/ // mode & 1: value is a module id, require it
- /******/ // mode & 2: merge all properties of value into the ns
- /******/ // mode & 4: return value when already ns object
- /******/ // mode & 8|1: behave like require
- /******/ __webpack_require__.t = function(value, mode) {
- /******/ if(mode & 1) value = __webpack_require__(value);
- /******/ if(mode & 8) return value;
- /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
- /******/ var ns = Object.create(null);
- /******/ __webpack_require__.r(ns);
- /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
- /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
- /******/ return ns;
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = "./packages/mdc-select/index.ts");
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ "./node_modules/process/browser.js":
- /*!*****************************************!*\
- !*** ./node_modules/process/browser.js ***!
- \*****************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- // shim for using process in browser
- var process = module.exports = {};
- // cached from whatever global is present so that test runners that stub it
- // don't break things. But we need to wrap it in a try catch in case it is
- // wrapped in strict mode code which doesn't define any globals. It's inside a
- // function because try/catches deoptimize in certain engines.
- var cachedSetTimeout;
- var cachedClearTimeout;
- function defaultSetTimout() {
- throw new Error('setTimeout has not been defined');
- }
- function defaultClearTimeout () {
- throw new Error('clearTimeout has not been defined');
- }
- (function () {
- try {
- if (typeof setTimeout === 'function') {
- cachedSetTimeout = setTimeout;
- } else {
- cachedSetTimeout = defaultSetTimout;
- }
- } catch (e) {
- cachedSetTimeout = defaultSetTimout;
- }
- try {
- if (typeof clearTimeout === 'function') {
- cachedClearTimeout = clearTimeout;
- } else {
- cachedClearTimeout = defaultClearTimeout;
- }
- } catch (e) {
- cachedClearTimeout = defaultClearTimeout;
- }
- } ())
- function runTimeout(fun) {
- if (cachedSetTimeout === setTimeout) {
- //normal enviroments in sane situations
- return setTimeout(fun, 0);
- }
- // if setTimeout wasn't available but was latter defined
- if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
- cachedSetTimeout = setTimeout;
- return setTimeout(fun, 0);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedSetTimeout(fun, 0);
- } catch(e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedSetTimeout.call(null, fun, 0);
- } catch(e){
- // 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
- return cachedSetTimeout.call(this, fun, 0);
- }
- }
- }
- function runClearTimeout(marker) {
- if (cachedClearTimeout === clearTimeout) {
- //normal enviroments in sane situations
- return clearTimeout(marker);
- }
- // if clearTimeout wasn't available but was latter defined
- if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
- cachedClearTimeout = clearTimeout;
- return clearTimeout(marker);
- }
- try {
- // when when somebody has screwed with setTimeout but no I.E. maddness
- return cachedClearTimeout(marker);
- } catch (e){
- try {
- // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
- return cachedClearTimeout.call(null, marker);
- } catch (e){
- // 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.
- // Some versions of I.E. have different rules for clearTimeout vs setTimeout
- return cachedClearTimeout.call(this, marker);
- }
- }
- }
- var queue = [];
- var draining = false;
- var currentQueue;
- var queueIndex = -1;
- function cleanUpNextTick() {
- if (!draining || !currentQueue) {
- return;
- }
- draining = false;
- if (currentQueue.length) {
- queue = currentQueue.concat(queue);
- } else {
- queueIndex = -1;
- }
- if (queue.length) {
- drainQueue();
- }
- }
- function drainQueue() {
- if (draining) {
- return;
- }
- var timeout = runTimeout(cleanUpNextTick);
- draining = true;
- var len = queue.length;
- while(len) {
- currentQueue = queue;
- queue = [];
- while (++queueIndex < len) {
- if (currentQueue) {
- currentQueue[queueIndex].run();
- }
- }
- queueIndex = -1;
- len = queue.length;
- }
- currentQueue = null;
- draining = false;
- runClearTimeout(timeout);
- }
- process.nextTick = function (fun) {
- var args = new Array(arguments.length - 1);
- if (arguments.length > 1) {
- for (var i = 1; i < arguments.length; i++) {
- args[i - 1] = arguments[i];
- }
- }
- queue.push(new Item(fun, args));
- if (queue.length === 1 && !draining) {
- runTimeout(drainQueue);
- }
- };
- // v8 likes predictible objects
- function Item(fun, array) {
- this.fun = fun;
- this.array = array;
- }
- Item.prototype.run = function () {
- this.fun.apply(null, this.array);
- };
- process.title = 'browser';
- process.browser = true;
- process.env = {};
- process.argv = [];
- process.version = ''; // empty string to avoid regexp issues
- process.versions = {};
- function noop() {}
- process.on = noop;
- process.addListener = noop;
- process.once = noop;
- process.off = noop;
- process.removeListener = noop;
- process.removeAllListeners = noop;
- process.emit = noop;
- process.prependListener = noop;
- process.prependOnceListener = noop;
- process.listeners = function (name) { return [] }
- process.binding = function (name) {
- throw new Error('process.binding is not supported');
- };
- process.cwd = function () { return '/' };
- process.chdir = function (dir) {
- throw new Error('process.chdir is not supported');
- };
- process.umask = function() { return 0; };
- /***/ }),
- /***/ "./node_modules/safevalues/builders/attribute_builders.js":
- /*!****************************************************************!*\
- !*** ./node_modules/safevalues/builders/attribute_builders.js ***!
- \****************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.safeAttrPrefix = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- var attribute_impl_1 = __webpack_require__(/*! ../internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
- var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
- var sensitive_attributes_1 = __webpack_require__(/*! ./sensitive_attributes */ "./node_modules/safevalues/builders/sensitive_attributes.js");
- /**
- * Creates a SafeAttributePrefix object from a template literal with no
- * interpolations for attributes that share a common prefix guaranteed to be not
- * security sensitive.
- *
- * The template literal is a prefix that makes it obvious this attribute is not
- * security sensitive. If it doesn't, this function will throw.
- */
- function safeAttrPrefix(templ) {
- if (true) {
- (0, string_literal_1.assertIsTemplateObject)(templ, true, 'safeAttr is a template literal tag function ' +
- 'and should be called using the tagged template syntax. ' +
- 'For example, safeAttr`foo`;');
- }
- var attrPrefix = templ[0].toLowerCase();
- if (true) {
- if (attrPrefix.indexOf('on') === 0 || 'on'.indexOf(attrPrefix) === 0) {
- throw new Error("Prefix '".concat(templ[0], "' does not guarantee the attribute ") +
- "to be safe as it is also a prefix for event handler attributes" +
- "Please use 'addEventListener' to set event handlers.");
- }
- sensitive_attributes_1.SECURITY_SENSITIVE_ATTRIBUTES.forEach(function (sensitiveAttr) {
- if (sensitiveAttr.indexOf(attrPrefix) === 0) {
- throw new Error("Prefix '".concat(templ[0], "' does not guarantee the attribute ") +
- "to be safe as it is also a prefix for " +
- "the security sensitive attribute '".concat(sensitiveAttr, "'. ") +
- "Please use native or safe DOM APIs to set the attribute.");
- }
- });
- }
- return (0, attribute_impl_1.createAttributePrefix)(attrPrefix);
- }
- exports.safeAttrPrefix = safeAttrPrefix;
- /***/ }),
- /***/ "./node_modules/safevalues/builders/html_builders.js":
- /*!***********************************************************!*\
- !*** ./node_modules/safevalues/builders/html_builders.js ***!
- \***********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.concatHtmls = exports.createScriptSrc = exports.createScript = exports.htmlEscape = void 0;
- var html_impl_1 = __webpack_require__(/*! ../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
- var resource_url_impl_1 = __webpack_require__(/*! ../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
- var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
- /**
- * Returns HTML-escaped text as a `SafeHtml` object.
- *
- * Available options:
- * - `preserveSpaces` turns every second consecutive space character into its
- * HTML entity representation (` `).
- * - `preserveNewlines` turns newline characters into breaks (`<br>`).
- * - `preserveTabs` wraps tab characters in a span with style=white-space:pre.
- */
- function htmlEscape(text, options) {
- if (options === void 0) { options = {}; }
- var htmlEscapedString = htmlEscapeToString(text);
- if (options.preserveSpaces) {
- // Do this first to ensure we preserve spaces after newlines and tabs.
- htmlEscapedString =
- htmlEscapedString.replace(/(^|[\r\n\t ]) /g, '$1 ');
- }
- if (options.preserveNewlines) {
- htmlEscapedString = htmlEscapedString.replace(/(\r\n|\n|\r)/g, '<br>');
- }
- if (options.preserveTabs) {
- htmlEscapedString = htmlEscapedString.replace(/(\t+)/g, '<span style="white-space:pre">$1</span>');
- }
- return (0, html_impl_1.createHtml)(htmlEscapedString);
- }
- exports.htmlEscape = htmlEscape;
- /**
- * Creates a `SafeHtml` representing a script tag with inline script content.
- */
- function createScript(script, options) {
- if (options === void 0) { options = {}; }
- var unwrappedScript = (0, script_impl_1.unwrapScript)(script).toString();
- var stringTag = "<script";
- if (options.id) {
- stringTag += " id=\"".concat(htmlEscapeToString(options.id), "\"");
- }
- if (options.nonce) {
- stringTag += " nonce=\"".concat(htmlEscapeToString(options.nonce), "\"");
- }
- if (options.type) {
- stringTag += " type=\"".concat(htmlEscapeToString(options.type), "\"");
- }
- stringTag += ">".concat(unwrappedScript, "</script>");
- return (0, html_impl_1.createHtml)(stringTag);
- }
- exports.createScript = createScript;
- /**
- * Creates a `SafeHtml` representing a script tag with the src attribute.
- * This also supports CSP nonces and async loading.
- */
- function createScriptSrc(src, async, nonce) {
- var unwrappedSrc = (0, resource_url_impl_1.unwrapResourceUrl)(src).toString();
- var stringTag = "<script src=\"".concat(htmlEscapeToString(unwrappedSrc), "\"");
- if (async) {
- stringTag += ' async';
- }
- if (nonce) {
- stringTag += " nonce=\"".concat(htmlEscapeToString(nonce), "\"");
- }
- stringTag += '>\x3c/script>';
- return (0, html_impl_1.createHtml)(stringTag);
- }
- exports.createScriptSrc = createScriptSrc;
- /**
- * HTML-escapes the given text (`&`, `<`, `>`, `"` and `'`).
- */
- function htmlEscapeToString(text) {
- var escaped = text.replace(/&/g, '&')
- .replace(/</g, '<')
- .replace(/>/g, '>')
- .replace(/"/g, '"')
- .replace(/'/g, ''');
- return escaped;
- }
- /** Creates a `SafeHtml` value by concatenating multiple `SafeHtml`s. */
- function concatHtmls(htmls) {
- return (0, html_impl_1.createHtml)(htmls.map(html_impl_1.unwrapHtml).join(''));
- }
- exports.concatHtmls = concatHtmls;
- /***/ }),
- /***/ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js":
- /*!***************************************************************************!*\
- !*** ./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js ***!
- \***************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- var __values = (this && this.__values) || function(o) {
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function () {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- var __read = (this && this.__read) || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o), r, ar = [], e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
- }
- catch (error) { e = { error: error }; }
- finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- }
- finally { if (e) throw e.error; }
- }
- return ar;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.sanitizeHtmlToFragment = exports.sanitizeHtmlAssertUnchanged = exports.sanitizeHtml = exports.HtmlSanitizerImpl = void 0;
- __webpack_require__(/*! ../../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
- /* g3_import_pure from '../../internals/pure' */
- var secrets_1 = __webpack_require__(/*! ../../internals/secrets */ "./node_modules/safevalues/internals/secrets.js");
- var url_sanitizer_1 = __webpack_require__(/*! ../url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
- var inert_fragment_1 = __webpack_require__(/*! ./inert_fragment */ "./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js");
- var no_clobber_1 = __webpack_require__(/*! ./no_clobber */ "./node_modules/safevalues/builders/html_sanitizer/no_clobber.js");
- var default_sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/default_sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js");
- var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
- /** Implementation for `HtmlSanitizer` */
- var HtmlSanitizerImpl = /** @class */ (function () {
- function HtmlSanitizerImpl(sanitizerTable, token) {
- this.sanitizerTable = sanitizerTable;
- this.changes = [];
- (0, secrets_1.ensureTokenIsValid)(token);
- }
- HtmlSanitizerImpl.prototype.sanitizeAssertUnchanged = function (html) {
- this.changes = [];
- var sanitizedHtml = this.sanitize(html);
- if (this.changes.length !== 0) {
- var message = '';
- if (true) {
- message =
- "Unexpected change to HTML value as a result of sanitization. " +
- "Input: \"".concat(html, "\", sanitized output: \"").concat(sanitizedHtml, "\"\n") +
- "List of changes:".concat(this.changes.join('\n'));
- }
- throw new Error(message);
- }
- return sanitizedHtml;
- };
- HtmlSanitizerImpl.prototype.sanitize = function (html) {
- var fakeRoot = document.createElement('span');
- fakeRoot.appendChild(this.sanitizeToFragment(html));
- // XML serialization is preferred over HTML serialization as it is
- // stricter and makes sure all attributes are properly escaped, avoiding
- // cases where the tree might mutate when parsed again later due to the
- // complexities of the HTML parsing algorithm
- var serializedNewTree = new XMLSerializer().serializeToString(fakeRoot);
- // We remove the outer most element as this is the span node created as
- // the root for the sanitized tree and contains a spurious xmlns attribute
- // from the XML serialization step.
- serializedNewTree = serializedNewTree.slice(serializedNewTree.indexOf('>') + 1, serializedNewTree.lastIndexOf('</'));
- return (0, html_impl_1.createHtml)(serializedNewTree);
- };
- HtmlSanitizerImpl.prototype.sanitizeToFragment = function (html) {
- var _this = this;
- var dirtyFragment = (0, inert_fragment_1.createInertFragment)(html);
- var treeWalker = document.createTreeWalker(dirtyFragment, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
- // IE10 and IE11 won't accept a proper `NodeFilter` interface, and
- // expect the filtering function to be passed directly. It seems that
- // other browsers also do not mind getting the function directly. see
- // https://stackoverflow.com/q/38245898
- (function (n) { return _this.nodeFilter(n); }),
- // @ts-ignore: error TS2554: Expected 1-3 arguments, but got 4.
- false);
- // `nextNode` is called so we skip the root `DocumentFragment`.
- var currentNode = treeWalker.nextNode();
- // We create a root element to attach all the children of the body to. We
- // use div as it as a semantic-free, generic container and does not
- // represent anything. This is removed when we serialize the tree back
- // into a string.
- var sanitizedFragment = document.createDocumentFragment();
- var sanitizedParent = sanitizedFragment;
- while (currentNode !== null) {
- var sanitizedNode = void 0;
- if ((0, no_clobber_1.isText)(currentNode)) {
- sanitizedNode = this.sanitizeTextNode(currentNode);
- }
- else if ((0, no_clobber_1.isElement)(currentNode)) {
- sanitizedNode = this.sanitizeElementNode(currentNode);
- }
- else {
- throw new Error('Node is not of type text or element');
- }
- sanitizedParent.appendChild(sanitizedNode);
- // Advance iterator while keeping track of the sanitized parent for the
- // current node
- currentNode = treeWalker.firstChild();
- if (currentNode) {
- sanitizedParent = sanitizedNode;
- }
- else {
- while (!(currentNode = treeWalker.nextSibling())) {
- if (!(currentNode = treeWalker.parentNode())) {
- break;
- }
- sanitizedParent = sanitizedParent.parentNode;
- }
- }
- }
- return sanitizedFragment;
- };
- HtmlSanitizerImpl.prototype.sanitizeTextNode = function (textNode) {
- return document.createTextNode(textNode.data);
- };
- HtmlSanitizerImpl.prototype.sanitizeElementNode = function (elementNode) {
- var e_1, _a;
- var elementName = (0, no_clobber_1.getNodeName)(elementNode);
- var newNode = document.createElement(elementName);
- var dirtyAttributes = elementNode.attributes;
- try {
- for (var dirtyAttributes_1 = __values(dirtyAttributes), dirtyAttributes_1_1 = dirtyAttributes_1.next(); !dirtyAttributes_1_1.done; dirtyAttributes_1_1 = dirtyAttributes_1.next()) {
- var _b = dirtyAttributes_1_1.value, name_1 = _b.name, value = _b.value;
- var policy = this.sanitizerTable.getAttributePolicy(name_1, elementName);
- if (!this.satisfiesAllConditions(policy.conditions, dirtyAttributes)) {
- this.recordChange("Not all conditions satisfied for attribute: ".concat(name_1, "."));
- continue;
- }
- switch (policy.policyAction) {
- case sanitizer_table_1.AttributePolicyAction.KEEP:
- newNode.setAttribute(name_1, value);
- break;
- case sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL:
- var sanitizedAttrUrl = (0, url_sanitizer_1.restrictivelySanitizeUrl)(value);
- if (sanitizedAttrUrl !== value) {
- this.recordChange("Url in attribute ".concat(name_1, " was modified during sanitization. Original url:\"").concat(value, "\" was sanitized to: \"").concat(sanitizedAttrUrl, "\""));
- }
- newNode.setAttribute(name_1, sanitizedAttrUrl);
- break;
- case sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE:
- // We don't consider changing the case of an attribute value to be a
- // semantic change
- newNode.setAttribute(name_1, value.toLowerCase());
- break;
- case sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_STYLE:
- newNode.setAttribute(name_1, value);
- break;
- case sanitizer_table_1.AttributePolicyAction.DROP:
- this.recordChange("Attribute: ".concat(name_1, " was dropped"));
- break;
- default:
- checkExhaustive(policy.policyAction, 'Unhandled AttributePolicyAction case');
- }
- }
- }
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
- finally {
- try {
- if (dirtyAttributes_1_1 && !dirtyAttributes_1_1.done && (_a = dirtyAttributes_1.return)) _a.call(dirtyAttributes_1);
- }
- finally { if (e_1) throw e_1.error; }
- }
- return newNode;
- };
- HtmlSanitizerImpl.prototype.nodeFilter = function (node) {
- if ((0, no_clobber_1.isText)(node)) {
- return NodeFilter.FILTER_ACCEPT;
- }
- else if (!(0, no_clobber_1.isElement)(node)) {
- // Getting a node that is neither an `Element` or a `Text` node. This is
- // likely due to something that is not supposed to be an element in user
- // code but recognized as such by the TreeWalker (e.g. a polyfill for
- // other kind of nodes). Since we can't recognize it as an element, we
- // drop the node, but we don't record it as a meaningful change.
- return NodeFilter.FILTER_REJECT;
- }
- var nodeName = (0, no_clobber_1.getNodeName)(node);
- if (nodeName === null) {
- this.recordChange("Node name was null for node: ".concat(node));
- return NodeFilter.FILTER_REJECT;
- }
- if (this.sanitizerTable.isAllowedElement(nodeName)) {
- return NodeFilter.FILTER_ACCEPT;
- }
- this.recordChange("Element: ".concat(nodeName, " was dropped"));
- return NodeFilter.FILTER_REJECT;
- };
- HtmlSanitizerImpl.prototype.recordChange = function (errorMessage) {
- if (true) {
- this.changes.push(errorMessage);
- }
- else {}
- };
- HtmlSanitizerImpl.prototype.satisfiesAllConditions = function (conditions, attrs) {
- var e_2, _a;
- var _b;
- if (!conditions) {
- return true;
- }
- try {
- for (var conditions_1 = __values(conditions), conditions_1_1 = conditions_1.next(); !conditions_1_1.done; conditions_1_1 = conditions_1.next()) {
- var _c = __read(conditions_1_1.value, 2), attrName = _c[0], expectedValues = _c[1];
- var value = (_b = attrs.getNamedItem(attrName)) === null || _b === void 0 ? void 0 : _b.value;
- if (value && !expectedValues.has(value)) {
- return false;
- }
- }
- }
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
- finally {
- try {
- if (conditions_1_1 && !conditions_1_1.done && (_a = conditions_1.return)) _a.call(conditions_1);
- }
- finally { if (e_2) throw e_2.error; }
- }
- return true;
- };
- return HtmlSanitizerImpl;
- }());
- exports.HtmlSanitizerImpl = HtmlSanitizerImpl;
- var defaultHtmlSanitizer =
- /* #__PURE__ */ (function () { return new HtmlSanitizerImpl(default_sanitizer_table_1.defaultSanitizerTable, secrets_1.secretToken); })();
- /** Sanitizes untrusted html using the default sanitizer configuration. */
- function sanitizeHtml(html) {
- return defaultHtmlSanitizer.sanitize(html);
- }
- exports.sanitizeHtml = sanitizeHtml;
- /**
- * Sanitizes untrusted html using the default sanitizer configuration. Throws
- * an error if the html was changed.
- */
- function sanitizeHtmlAssertUnchanged(html) {
- return defaultHtmlSanitizer.sanitizeAssertUnchanged(html);
- }
- exports.sanitizeHtmlAssertUnchanged = sanitizeHtmlAssertUnchanged;
- /**
- * Sanitizes untrusted html using the default sanitizer configuration. Throws
- * an error if the html was changed.
- */
- function sanitizeHtmlToFragment(html) {
- return defaultHtmlSanitizer.sanitizeToFragment(html);
- }
- exports.sanitizeHtmlToFragment = sanitizeHtmlToFragment;
- function checkExhaustive(value, msg) {
- if (msg === void 0) { msg = "unexpected value ".concat(value, "!"); }
- throw new Error(msg);
- }
- /***/ }),
- /***/ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js":
- /*!***********************************************************************************!*\
- !*** ./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js ***!
- \***********************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- var __values = (this && this.__values) || function(o) {
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function () {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- var __read = (this && this.__read) || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o), r, ar = [], e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
- }
- catch (error) { e = { error: error }; }
- finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- }
- finally { if (e) throw e.error; }
- }
- return ar;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.HtmlSanitizerBuilder = void 0;
- var secrets_1 = __webpack_require__(/*! ../../internals/secrets */ "./node_modules/safevalues/internals/secrets.js");
- var html_sanitizer_1 = __webpack_require__(/*! ./html_sanitizer */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js");
- var default_sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/default_sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js");
- var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table/sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
- /** This class allows modifications to the default sanitizer configuration. */
- var HtmlSanitizerBuilder = /** @class */ (function () {
- function HtmlSanitizerBuilder() {
- // To denote if the builder has called build() and therefore should make no
- // further changes to the sanitizer table.
- this.calledBuild = false;
- this.sanitizerTable = default_sanitizer_table_1.defaultSanitizerTable;
- }
- /** Builder option to restrict allowed elements to a smaller subset. */
- HtmlSanitizerBuilder.prototype.onlyAllowElements = function (elementSet) {
- var e_1, _a;
- var allowedElements = new Set();
- var allowedElementPolicies = new Map();
- try {
- for (var elementSet_1 = __values(elementSet), elementSet_1_1 = elementSet_1.next(); !elementSet_1_1.done; elementSet_1_1 = elementSet_1.next()) {
- var element = elementSet_1_1.value;
- element = element.toUpperCase();
- if (!this.sanitizerTable.isAllowedElement(element)) {
- throw new Error("Element: ".concat(element, ", is not allowed by html5_contract.textpb"));
- }
- var elementPolicy = this.sanitizerTable.elementPolicies.get(element);
- if (elementPolicy !== undefined) {
- allowedElementPolicies.set(element, elementPolicy);
- }
- else {
- allowedElements.add(element);
- }
- }
- }
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
- finally {
- try {
- if (elementSet_1_1 && !elementSet_1_1.done && (_a = elementSet_1.return)) _a.call(elementSet_1);
- }
- finally { if (e_1) throw e_1.error; }
- }
- this.sanitizerTable = new sanitizer_table_1.SanitizerTable(allowedElements, allowedElementPolicies, this.sanitizerTable.allowedGlobalAttributes, this.sanitizerTable.globalAttributePolicies);
- return this;
- };
- /**
- * Builder option to restrict allowed attributes to a smaller subset.
- *
- * If the attribute isn't currently allowed then it won't be added.
- */
- HtmlSanitizerBuilder.prototype.onlyAllowAttributes = function (attributeSet) {
- var e_2, _a, e_3, _b, e_4, _c;
- var allowedGlobalAttributes = new Set();
- var globalAttributePolicies = new Map();
- var elementPolicies = new Map();
- try {
- for (var attributeSet_1 = __values(attributeSet), attributeSet_1_1 = attributeSet_1.next(); !attributeSet_1_1.done; attributeSet_1_1 = attributeSet_1.next()) {
- var attribute = attributeSet_1_1.value;
- if (this.sanitizerTable.allowedGlobalAttributes.has(attribute)) {
- allowedGlobalAttributes.add(attribute);
- }
- if (this.sanitizerTable.globalAttributePolicies.has(attribute)) {
- globalAttributePolicies.set(attribute, this.sanitizerTable.globalAttributePolicies.get(attribute));
- }
- }
- }
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
- finally {
- try {
- if (attributeSet_1_1 && !attributeSet_1_1.done && (_a = attributeSet_1.return)) _a.call(attributeSet_1);
- }
- finally { if (e_2) throw e_2.error; }
- }
- try {
- for (var _d = __values(this.sanitizerTable
- .elementPolicies.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
- var _f = __read(_e.value, 2), elementName = _f[0], originalElementPolicy = _f[1];
- var newElementPolicy = new Map();
- try {
- for (var _g = (e_4 = void 0, __values(originalElementPolicy
- .entries())), _h = _g.next(); !_h.done; _h = _g.next()) {
- var _j = __read(_h.value, 2), attribute = _j[0], attributePolicy = _j[1];
- if (attributeSet.has(attribute)) {
- newElementPolicy.set(attribute, attributePolicy);
- }
- }
- }
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
- finally {
- try {
- if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
- }
- finally { if (e_4) throw e_4.error; }
- }
- elementPolicies.set(elementName, newElementPolicy);
- }
- }
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
- finally {
- try {
- if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
- }
- finally { if (e_3) throw e_3.error; }
- }
- this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, elementPolicies, allowedGlobalAttributes, globalAttributePolicies);
- return this;
- };
- /**
- * Allows the set of data attributes passed.
- *
- * These values must be prefixed with "data-"
- *
- * If called with onlyAllowElements or onlyAllowAttributes, those methods must
- * be called first.
- */
- HtmlSanitizerBuilder.prototype.allowDataAttributes = function (attributes) {
- var e_5, _a;
- var allowedGlobalAttributes = new Set(this.sanitizerTable.allowedGlobalAttributes);
- try {
- for (var attributes_1 = __values(attributes), attributes_1_1 = attributes_1.next(); !attributes_1_1.done; attributes_1_1 = attributes_1.next()) {
- var attribute = attributes_1_1.value;
- if (attribute.indexOf('data-') !== 0) {
- throw new Error("data attribute: ".concat(attribute, " does not begin with the prefix \"data-\""));
- }
- allowedGlobalAttributes.add(attribute);
- }
- }
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
- finally {
- try {
- if (attributes_1_1 && !attributes_1_1.done && (_a = attributes_1.return)) _a.call(attributes_1);
- }
- finally { if (e_5) throw e_5.error; }
- }
- this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, allowedGlobalAttributes, this.sanitizerTable.globalAttributePolicies);
- return this;
- };
- /**
- * Preserves style attributes. Note that the sanitizer won't parse and
- * sanitize the values but keep them as they are. In particular this means
- * that the code will be able to call functions that could do undesirable
- * things (e.g. `url` to trigger a network request), as well as any custom
- * properties or functions defined by the application.
- */
- HtmlSanitizerBuilder.prototype.allowStyleAttributes = function () {
- var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
- globalAttributePolicies.set('style', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_STYLE });
- this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
- return this;
- };
- /**
- * Preserves the class attribute on all elements. This means contents can
- * adopt CSS styles from other page elements and possibly mask themselves as
- * legitimate UI elements, which can lead to phishing.
- */
- HtmlSanitizerBuilder.prototype.allowClassAttributes = function () {
- var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
- globalAttributePolicies.set('class', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP });
- this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
- return this;
- };
- /**
- * Preserves id attributes. This carries moderate risk as it allows an
- * element to override other elements with the same ID.
- */
- HtmlSanitizerBuilder.prototype.allowIdAttributes = function () {
- var globalAttributePolicies = new Map(this.sanitizerTable.globalAttributePolicies);
- globalAttributePolicies.set('id', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP });
- this.sanitizerTable = new sanitizer_table_1.SanitizerTable(this.sanitizerTable.allowedElements, this.sanitizerTable.elementPolicies, this.sanitizerTable.allowedGlobalAttributes, globalAttributePolicies);
- return this;
- };
- HtmlSanitizerBuilder.prototype.build = function () {
- if (this.calledBuild) {
- throw new Error('this sanitizer has already called build');
- }
- this.calledBuild = true;
- return new html_sanitizer_1.HtmlSanitizerImpl(this.sanitizerTable, secrets_1.secretToken);
- };
- return HtmlSanitizerBuilder;
- }());
- exports.HtmlSanitizerBuilder = HtmlSanitizerBuilder;
- /***/ }),
- /***/ "./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js":
- /*!***************************************************************************!*\
- !*** ./node_modules/safevalues/builders/html_sanitizer/inert_fragment.js ***!
- \***************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.createInertFragment = void 0;
- var element_1 = __webpack_require__(/*! ../../dom/elements/element */ "./node_modules/safevalues/dom/elements/element.js");
- var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
- /**
- * Returns a fragment that contains the parsed HTML for `dirtyHtml` without
- * executing any of the potential payload.
- */
- function createInertFragment(dirtyHtml) {
- var template = document.createElement('template');
- // This call is only used to create an inert tree for the sanitizer to
- // further process and is never returned directly to the caller. We can't use
- // a reviewed conversion in order to avoid an import loop.
- var temporarySafeHtml = (0, html_impl_1.createHtml)(dirtyHtml);
- (0, element_1.setInnerHtml)(template, temporarySafeHtml);
- return template.content;
- }
- exports.createInertFragment = createInertFragment;
- /***/ }),
- /***/ "./node_modules/safevalues/builders/html_sanitizer/no_clobber.js":
- /*!***********************************************************************!*\
- !*** ./node_modules/safevalues/builders/html_sanitizer/no_clobber.js ***!
- \***********************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.isElement = exports.isText = exports.getNodeName = void 0;
- /**
- * Library that provides safe getters for different node properties and
- * checks for clobbering.
- */
- /** Gets a reasonable nodeName, even for clobbered nodes. */
- function getNodeName(node) {
- var nodeName = node.nodeName;
- // If the property is clobbered, assume it is an `HTMLFormElement`.
- return (typeof nodeName === 'string') ? nodeName : 'FORM';
- }
- exports.getNodeName = getNodeName;
- /** Returns true if the object passed is a Text node. */
- function isText(node) {
- // The property cannot get clobbered on Text nodes.
- return node.nodeType === Node.TEXT_NODE;
- }
- exports.isText = isText;
- /** Returns true if the object passed is an Element node. */
- function isElement(node) {
- var nodeType = node.nodeType;
- // If the property is clobbered, we can assume it is an `HTMLFormElement`, and
- // thus an `Element`.
- return (nodeType === Node.ELEMENT_NODE) || (typeof nodeType !== 'number');
- }
- exports.isElement = isElement;
- /***/ }),
- /***/ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js":
- /*!****************************************************************************************************!*\
- !*** ./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/default_sanitizer_table.js ***!
- \****************************************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.defaultSanitizerTable = void 0;
- var sanitizer_table_1 = __webpack_require__(/*! ./sanitizer_table */ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js");
- /**
- * GENERATED CODE, DO NOT MODIFY
- * This SanitizerTable was generated from the checked in html contract:
- * webutil/html/types/codegen/html5_contract.textpb
- *
- * You can regenerate this file with:
- * webutil/html/types/codegen/update_generated_source_files.sh
- */
- exports.defaultSanitizerTable = new sanitizer_table_1.SanitizerTable(new Set([
- 'ARTICLE', 'SECTION', 'NAV', 'ASIDE', 'H1', 'H2',
- 'H3', 'H4', 'H5', 'H6', 'HEADER', 'FOOTER',
- 'ADDRESS', 'P', 'HR', 'PRE', 'BLOCKQUOTE', 'OL',
- 'UL', 'LH', 'LI', 'DL', 'DT', 'DD',
- 'FIGURE', 'FIGCAPTION', 'MAIN', 'DIV', 'EM', 'STRONG',
- 'SMALL', 'S', 'CITE', 'Q', 'DFN', 'ABBR',
- 'RUBY', 'RB', 'RT', 'RTC', 'RP', 'DATA',
- 'TIME', 'CODE', 'VAR', 'SAMP', 'KBD', 'SUB',
- 'SUP', 'I', 'B', 'U', 'MARK', 'BDI',
- 'BDO', 'SPAN', 'BR', 'WBR', 'INS', 'DEL',
- 'PICTURE', 'PARAM', 'TRACK', 'MAP', 'TABLE', 'CAPTION',
- 'COLGROUP', 'COL', 'TBODY', 'THEAD', 'TFOOT', 'TR',
- 'TD', 'TH', 'SELECT', 'DATALIST', 'OPTGROUP', 'OPTION',
- 'OUTPUT', 'PROGRESS', 'METER', 'FIELDSET', 'LEGEND', 'DETAILS',
- 'SUMMARY', 'MENU', 'DIALOG', 'SLOT', 'CANVAS', 'FONT',
- 'CENTER',
- ]), new Map([
- [
- 'A', new Map([
- ['href', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
- ])
- ],
- [
- 'AREA', new Map([
- ['href', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
- ])
- ],
- [
- 'LINK', new Map([
- [
- 'href', {
- policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL,
- conditions: new Map([[
- 'rel', new Set([
- 'alternate',
- 'author',
- 'bookmark',
- 'canonical',
- 'cite',
- 'help',
- 'icon',
- 'license',
- 'next',
- 'prefetch',
- 'dns-prefetch',
- 'prerender',
- 'preconnect',
- 'preload',
- 'prev',
- 'search',
- 'subresource',
- ])
- ]])
- }
- ],
- ])
- ],
- [
- 'SOURCE', new Map([
- ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
- ])
- ],
- [
- 'IMG', new Map([
- ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
- ])
- ],
- [
- 'VIDEO', new Map([
- ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
- ])
- ],
- [
- 'AUDIO', new Map([
- ['src', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
- ])
- ],
- ]), new Set([
- 'title',
- 'aria-atomic',
- 'aria-autocomplete',
- 'aria-busy',
- 'aria-checked',
- 'aria-current',
- 'aria-disabled',
- 'aria-dropeffect',
- 'aria-expanded',
- 'aria-haspopup',
- 'aria-hidden',
- 'aria-invalid',
- 'aria-label',
- 'aria-level',
- 'aria-live',
- 'aria-multiline',
- 'aria-multiselectable',
- 'aria-orientation',
- 'aria-posinset',
- 'aria-pressed',
- 'aria-readonly',
- 'aria-relevant',
- 'aria-required',
- 'aria-selected',
- 'aria-setsize',
- 'aria-sort',
- 'aria-valuemax',
- 'aria-valuemin',
- 'aria-valuenow',
- 'aria-valuetext',
- 'alt',
- 'align',
- 'autocapitalize',
- 'autocomplete',
- 'autocorrect',
- 'autofocus',
- 'autoplay',
- 'bgcolor',
- 'border',
- 'cellpadding',
- 'cellspacing',
- 'checked',
- 'color',
- 'cols',
- 'colspan',
- 'controls',
- 'datetime',
- 'disabled',
- 'download',
- 'draggable',
- 'enctype',
- 'face',
- 'formenctype',
- 'frameborder',
- 'height',
- 'hreflang',
- 'hidden',
- 'ismap',
- 'label',
- 'lang',
- 'loop',
- 'max',
- 'maxlength',
- 'media',
- 'minlength',
- 'min',
- 'multiple',
- 'muted',
- 'nonce',
- 'open',
- 'placeholder',
- 'preload',
- 'rel',
- 'required',
- 'reversed',
- 'role',
- 'rows',
- 'rowspan',
- 'selected',
- 'shape',
- 'size',
- 'sizes',
- 'slot',
- 'span',
- 'spellcheck',
- 'start',
- 'step',
- 'summary',
- 'translate',
- 'type',
- 'valign',
- 'value',
- 'width',
- 'wrap',
- 'itemscope',
- 'itemtype',
- 'itemid',
- 'itemprop',
- 'itemref',
- ]), new Map([
- [
- 'dir', {
- policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
- conditions: new Map([[
- 'dir', new Set([
- 'auto',
- 'ltr',
- 'rtl',
- ])
- ]])
- }
- ],
- [
- 'async', {
- policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
- conditions: new Map([[
- 'async', new Set([
- 'async',
- ])
- ]])
- }
- ],
- ['cite', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
- [
- 'loading', {
- policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
- conditions: new Map([[
- 'loading', new Set([
- 'eager',
- 'lazy',
- ])
- ]])
- }
- ],
- ['poster', { policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_SANITIZE_URL }],
- [
- 'target', {
- policyAction: sanitizer_table_1.AttributePolicyAction.KEEP_AND_NORMALIZE,
- conditions: new Map([[
- 'target', new Set([
- '_self',
- '_blank',
- ])
- ]])
- }
- ],
- ]));
- /***/ }),
- /***/ "./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js":
- /*!********************************************************************************************!*\
- !*** ./node_modules/safevalues/builders/html_sanitizer/sanitizer_table/sanitizer_table.js ***!
- \********************************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.AttributePolicyAction = exports.SanitizerTable = void 0;
- /** Class for holding element and attribute policies used for sanitization. */
- var SanitizerTable = /** @class */ (function () {
- function SanitizerTable(allowedElements, elementPolicies, allowedGlobalAttributes, globalAttributePolicies) {
- this.allowedElements = allowedElements;
- this.elementPolicies = elementPolicies;
- this.allowedGlobalAttributes = allowedGlobalAttributes;
- this.globalAttributePolicies = globalAttributePolicies;
- }
- SanitizerTable.prototype.isAllowedElement = function (elementName) {
- // Note: `HTMLFormElement`s are always dropped, supporting them is very
- // costly because of the DOM clobberring they can cause. The additional code
- // size required to properly work around DOM clobberring issues is large and
- // shouldn't be put on every user of the sanitizer. Thoroughly review
- // b/210975025 and the CLs linked there before you start allowing form
- // elements.
- return elementName.toLowerCase() !== 'form' &&
- (this.allowedElements.has(elementName) ||
- this.elementPolicies.has(elementName));
- };
- SanitizerTable.prototype.getAttributePolicy = function (attributeName, elementName) {
- var elementPolicy = this.elementPolicies.get(elementName);
- if (elementPolicy === null || elementPolicy === void 0 ? void 0 : elementPolicy.has(attributeName)) {
- return elementPolicy.get(attributeName);
- }
- if (this.allowedGlobalAttributes.has(attributeName)) {
- return { policyAction: AttributePolicyAction.KEEP };
- }
- var globalPolicy = this.globalAttributePolicies.get(attributeName);
- return globalPolicy || { policyAction: AttributePolicyAction.DROP };
- };
- return SanitizerTable;
- }());
- exports.SanitizerTable = SanitizerTable;
- /**
- * Values derived from
- * https://godoc.corp.google.com/pkg/google3/third_party/safehtml/sanitizer/policy#AttributePolicy
- */
- var AttributePolicyAction;
- (function (AttributePolicyAction) {
- AttributePolicyAction[AttributePolicyAction["DROP"] = 0] = "DROP";
- AttributePolicyAction[AttributePolicyAction["KEEP"] = 1] = "KEEP";
- AttributePolicyAction[AttributePolicyAction["KEEP_AND_SANITIZE_URL"] = 2] = "KEEP_AND_SANITIZE_URL";
- AttributePolicyAction[AttributePolicyAction["KEEP_AND_NORMALIZE"] = 3] = "KEEP_AND_NORMALIZE";
- AttributePolicyAction[AttributePolicyAction["KEEP_AND_SANITIZE_STYLE"] = 4] = "KEEP_AND_SANITIZE_STYLE";
- })(AttributePolicyAction = exports.AttributePolicyAction || (exports.AttributePolicyAction = {}));
- /***/ }),
- /***/ "./node_modules/safevalues/builders/resource_url_builders.js":
- /*!*******************************************************************!*\
- !*** ./node_modules/safevalues/builders/resource_url_builders.js ***!
- \*******************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.blobUrlFromScript = exports.replaceFragment = exports.appendParams = exports.trustedResourceUrl = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- var resource_url_impl_1 = __webpack_require__(/*! ../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
- var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
- var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
- /**
- * Check whether the base url contains a valid origin,
- *
- * A string for an origin must contain only alphanumeric or any of the
- * following: `-.:`, and must not be an IP address. Remember that, as per the
- * documentation for TrustedResourceUrl, the origin must be trustworthy.
- *
- * @param base The base url that contains an origin.
- */
- function hasValidOrigin(base) {
- if (!(/^https:\/\//.test(base) || /^\/\//.test(base))) {
- return false;
- }
- var originStart = base.indexOf('//') + 2;
- var originEnd = base.indexOf('/', originStart);
- // If the base url only contains the prefix (e.g. //), or the slash
- // for the origin is right after the prefix (e.g. ///), the origin is
- // missing.
- if (originEnd <= originStart) {
- throw new Error("Can't interpolate data in a url's origin, " +
- "Please make sure to fully specify the origin, terminated with '/'.");
- }
- var origin = base.substring(originStart, originEnd);
- if (!/^[0-9a-z.:-]+$/i.test(origin)) {
- throw new Error('The origin contains unsupported characters.');
- }
- if (!/^[^:]*(:[0-9]+)?$/i.test(origin)) {
- throw new Error('Invalid port number.');
- }
- if (!/(^|\.)[a-z][^.]*$/i.test(origin)) {
- throw new Error('The top-level domain must start with a letter.');
- }
- return true;
- }
- /**
- * Check whether the base url contains a valid about url at its beginning.
- *
- * An about url is either exactly 'about:blank' or 'about:blank#<str>' where
- * <str> can be an arbitrary string.
- *
- * @param base The base url.
- */
- function isValidAboutUrl(base) {
- if (!/^about:blank/.test(base)) {
- return false;
- }
- if (base !== 'about:blank' && !/^about:blank#/.test(base)) {
- throw new Error('The about url is invalid.');
- }
- return true;
- }
- /**
- * Check whether the base url contains a valid path start at its beginning.
- *
- * A valid path start is either a '/' or a '/' followed by at least one
- * character that is not '/' or '\'.
- *
- * @param base The base url.
- */
- function isValidPathStart(base) {
- if (!/^\//.test(base)) {
- return false;
- }
- if ((base === '/') ||
- (base.length > 1 && base[1] !== '/' && base[1] !== '\\')) {
- return true;
- }
- throw new Error('The path start in the url is invalid.');
- }
- /**
- * Builds TrustedResourceUrl from a template literal.
- *
- * This factory is a template literal tag function. It should be called with
- * a template literal, with or without embedded expressions. For example,
- * trustedResourceUrl`//example.com/${bar}`;
- * or
- * trustedResourceUrl`//example.com`;
- *
- * When this function is called with a template literal without any embedded
- * expressions, the template string may contain anything as the whole URL is
- * a compile-time string constant.
- *
- * When this function is called with a template literal that contains embedded
- * expressions, the template must start with one of the following:
- * - `https://<origin>/`
- * - `//<origin>/`
- * - `/<pathStart>`
- * - `about:blank`
- * - `data:`
- *
- * `<origin>` must contain only alphanumeric or any of the following: `-.:`.
- * Remember that, as per the documentation for TrustedResourceUrl, the origin
- * must be trustworthy. An origin of "example.com" could be set with this
- * method, but would tie the security of your site to the security of
- * example.com. Similarly, formats that potentially cover redirects hosted
- * on a trusted origin are problematic, since that could lead to untrusted
- * origins.
- *
- * `<pathStart>` is either an empty string, or a non empty string that does not
- * start with '/' or '\'.
- * In other words, `/<pathStart>` is either a '/' or a
- * '/' followed by at least one character that is not '/' or '\'.
- *
- * `data:` (data URL) does not allow embedded expressions in the template
- * literal input.
- *
- * All embedded expressions are URL encoded when they are interpolated. Do not
- * embed expressions that are already URL encoded as they will be double encoded
- * by the builder.
- *
- * @param templateObj This contains the literal part of the template literal.
- * @param rest This represents the template's embedded expressions.
- */
- function trustedResourceUrl(templateObj) {
- var rest = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- rest[_i - 1] = arguments[_i];
- }
- // Check if templateObj is actually from a template literal.
- if (true) {
- (0, string_literal_1.assertIsTemplateObject)(templateObj, true, 'trustedResourceUrl is a template literal tag function and ' +
- 'can only be called as such (e.g. trustedResourceUrl`/somepath.js`)');
- }
- if (rest.length === 0) {
- return (0, resource_url_impl_1.createResourceUrl)(templateObj[0]);
- }
- var base = templateObj[0].toLowerCase();
- if (true) {
- if (/^data:/.test(base)) {
- throw new Error('Data URLs cannot have expressions in the template literal input.');
- }
- if (!hasValidOrigin(base) && !isValidPathStart(base) &&
- !isValidAboutUrl(base)) {
- throw new Error('Trying to interpolate expressions in an unsupported url format.');
- }
- }
- var urlParts = [templateObj[0]];
- for (var i = 0; i < rest.length; i++) {
- urlParts.push(encodeURIComponent(rest[i]));
- urlParts.push(templateObj[i + 1]);
- }
- return (0, resource_url_impl_1.createResourceUrl)(urlParts.join(''));
- }
- exports.trustedResourceUrl = trustedResourceUrl;
- /**
- * Creates a new TrustedResourceUrl with params added to the URL's search
- * parameters.
- *
- * @param params What to add to the URL. Parameters with value `null` or
- * `undefined` are skipped. Both keys and values will be encoded. Do not pass
- * pre-encoded values as this will result them being double encoded. If the
- * value is an array then the same parameter is added for every element in the
- * array.
- */
- function appendParams(trustedUrl, params) {
- var url = (0, resource_url_impl_1.unwrapResourceUrl)(trustedUrl).toString();
- if (/#/.test(url)) {
- var message = '';
- if (true) {
- message = "Found a hash in url (".concat(url, "), appending not supported");
- }
- throw new Error(message);
- }
- var separator = /\?/.test(url) ? '&' : '?';
- // for-of has a big polyfill.
- // tslint:disable-next-line:ban-iterable-foreach
- params.forEach(function (value, key) {
- var values = (value instanceof Array) ? value : [value];
- for (var i = 0; i < values.length; i++) {
- var v = values[i];
- if (v === null || v === undefined) {
- continue;
- }
- url += separator + encodeURIComponent(key) + '=' +
- encodeURIComponent(String(v));
- separator = '&';
- }
- });
- return (0, resource_url_impl_1.createResourceUrl)(url);
- }
- exports.appendParams = appendParams;
- var BEFORE_FRAGMENT_REGEXP = /[^#]*/;
- /**
- * Creates a new TrustedResourceUrl based on an existing one but with the
- * addition of a fragment (the part after `#`). If the URL already has a
- * fragment, it is replaced with the new one.
- * @param fragment The fragment to add to the URL, verbatim, without the leading
- * `#`. No additional escaping is applied.
- */
- function replaceFragment(trustedUrl, fragment) {
- var urlString = (0, resource_url_impl_1.unwrapResourceUrl)(trustedUrl).toString();
- return (0, resource_url_impl_1.createResourceUrl)(BEFORE_FRAGMENT_REGEXP.exec(urlString)[0] + '#' + fragment);
- }
- exports.replaceFragment = replaceFragment;
- /**
- * Creates a `TrustedResourceUrl` by generating a `Blob` from a
- * `SafeScript` and then calling `URL.createObjectURL` with that `Blob`.
- *
- * Caller must call `URL.revokeObjectUrl()` on the stringified url to
- * release the underlying `Blob`.
- */
- function blobUrlFromScript(safeScript) {
- var scriptContent = (0, script_impl_1.unwrapScript)(safeScript).toString();
- var blob = new Blob([scriptContent], { type: 'text/javascript' });
- return (0, resource_url_impl_1.createResourceUrl)(URL.createObjectURL(blob));
- }
- exports.blobUrlFromScript = blobUrlFromScript;
- /***/ }),
- /***/ "./node_modules/safevalues/builders/script_builders.js":
- /*!*************************************************************!*\
- !*** ./node_modules/safevalues/builders/script_builders.js ***!
- \*************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.safeScriptWithArgs = exports.scriptFromJson = exports.concatScripts = exports.safeScript = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- var script_impl_1 = __webpack_require__(/*! ../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
- var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
- /**
- * Creates a SafeScript object from a template literal (without any embedded
- * expressions).
- *
- * This function is a template literal tag function. It should be called with
- * a template literal that does not contain any expressions. For example,
- * safeScript`foo`;
- *
- * @param templateObj This contains the literal part of the template literal.
- */
- function safeScript(templateObj) {
- if (true) {
- (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeScript is a template literal tag function ' +
- 'that only accepts template literals without expressions. ' +
- 'For example, safeScript`foo`;');
- }
- return (0, script_impl_1.createScript)(templateObj[0]);
- }
- exports.safeScript = safeScript;
- /** Creates a `SafeScript` value by concatenating multiple `SafeScript`s. */
- function concatScripts(scripts) {
- return (0, script_impl_1.createScript)(scripts.map(script_impl_1.unwrapScript).join(''));
- }
- exports.concatScripts = concatScripts;
- /**
- * Converts a serializable value into JSON that is safe to interpolate into a
- * script context. In particular it escapes < characters so that a value of
- * "</script>" doesn't break out of the context.
- * @param value The value to serialize.
- */
- function scriptFromJson(value) {
- return (0, script_impl_1.createScript)(JSON.stringify(value).replace(/</g, '\\x3c'));
- }
- exports.scriptFromJson = scriptFromJson;
- /**
- * Creates a `SafeScript` object from a template literal (without any embedded
- * expressions) along with additional arguments that the script should have
- * access to. These arguments will be JSON-encoded and passed to the script as
- * a function call.
- * @example
- * ```ts
- * safeScriptWithArgs`function (name, props) {
- * console.log(name + ' is ' + props.age);
- * }`('Bob', { 'age': 42 })
- * ```
- * would return a `SafeScript` that represents the following code:
- * ```js
- * (function (name, props) {
- * console.log(name + ' is ' + props.age);
- * })("Bob",{"age":42})
- * ```
- * @note Be careful when passing objects as arguments, as unquoted property
- * names may be changed during compilation.
- * @param templateObj This contains the literal part of the template literal.
- * @param emptyArgs Expressions that evaluate to the empty string to enable
- * inline comments.
- */
- function safeScriptWithArgs(templateObj) {
- var emptyArgs = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- emptyArgs[_i - 1] = arguments[_i];
- }
- if (true) {
- if (emptyArgs.some(function (a) { return a !== ''; })) {
- throw new Error('safeScriptWithArgs only allows empty string expressions ' +
- 'to enable inline comments.');
- }
- (0, string_literal_1.assertIsTemplateObject)(templateObj, true, 'safeScriptWithArgs is a template literal tag function ' +
- 'that only accepts template literals. ' +
- 'For example, safeScriptWithArgs`foo`;');
- }
- return function () {
- var argValues = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- argValues[_i] = arguments[_i];
- }
- var values = argValues.map(function (v) { return scriptFromJson(v).toString(); });
- return (0, script_impl_1.createScript)("(".concat(templateObj.join(''), ")(").concat(values.join(','), ")"));
- };
- }
- exports.safeScriptWithArgs = safeScriptWithArgs;
- /***/ }),
- /***/ "./node_modules/safevalues/builders/sensitive_attributes.js":
- /*!******************************************************************!*\
- !*** ./node_modules/safevalues/builders/sensitive_attributes.js ***!
- \******************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.SECURITY_SENSITIVE_ATTRIBUTES = void 0;
- // AUTOGENERATED. DO NOT EDIT.
- /**
- * Security sensitive attribute names that should not be set through
- * `setAttribute` or similar functions.
- */
- exports.SECURITY_SENSITIVE_ATTRIBUTES = [
- 'href',
- 'rel',
- 'src',
- 'srcdoc',
- 'action',
- 'formaction',
- 'sandbox',
- 'cite',
- 'poster',
- 'icon',
- ];
- /***/ }),
- /***/ "./node_modules/safevalues/builders/style_builders.js":
- /*!************************************************************!*\
- !*** ./node_modules/safevalues/builders/style_builders.js ***!
- \************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.concatStyles = exports.safeStyle = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
- var style_impl_1 = __webpack_require__(/*! ../internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
- /**
- * Creates a SafeStyle object from a template literal (without any embedded
- * expressions).
- *
- * ` style` should be in the format
- * ` name: value; [name: value; ...]` and must not have any < or >
- * characters in it. This is so that SafeStyle's contract is preserved,
- * allowing the SafeStyle to correctly be interpreted as a sequence of CSS
- * declarations and without affecting the syntactic structure of any
- * surrounding CSS and HTML.
- *
- * This function is a template literal tag function. It should be called with
- * a template literal that does not contain any expressions. For example,
- * safeStyle`foo`;
- * This function first checks if it is called with a literal template, and
- * then performs basic sanity checks on the format of ` style`
- * but does not constrain the format of ` name} and {@code value`, except
- * for disallowing tag characters.
- *
- * @param templateObj This contains the literal part of the template literal.
- */
- function safeStyle(templateObj) {
- if (true) {
- (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeStyle is a template literal tag function ' +
- 'that only accepts template literals without expressions. ' +
- 'For example, safeStyle`foo`;');
- }
- var style = templateObj[0];
- if (true) {
- if (/[<>]/.test(style)) {
- throw new Error('Forbidden characters in style string: ' + style);
- }
- if (!/;$/.test(style)) {
- throw new Error('Style string does not end with ";": ' + style);
- }
- if (!/:/.test(style)) {
- throw new Error('Style string should contain one or more ":": ' + style);
- }
- }
- return (0, style_impl_1.createStyle)(style);
- }
- exports.safeStyle = safeStyle;
- /** Creates a `SafeStyle` value by concatenating multiple `SafeStyle`s. */
- function concatStyles(styles) {
- return (0, style_impl_1.createStyle)(styles.map(style_impl_1.unwrapStyle).join(''));
- }
- exports.concatStyles = concatStyles;
- /***/ }),
- /***/ "./node_modules/safevalues/builders/style_sheet_builders.js":
- /*!******************************************************************!*\
- !*** ./node_modules/safevalues/builders/style_sheet_builders.js ***!
- \******************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.concatStyleSheets = exports.safeStyleSheet = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- var string_literal_1 = __webpack_require__(/*! ../internals/string_literal */ "./node_modules/safevalues/internals/string_literal.js");
- var style_sheet_impl_1 = __webpack_require__(/*! ../internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
- /**
- * Creates a SafeStyleSheet object from a template literal (without any
- * embedded expressions).
- *
- * This function is a template literal tag function. It should be called with
- * a template literal that does not contain any expressions. For example,
- * safeStyleSheet`foo`;
- * The argument must not have any < or > characters in it. This is so that
- * SafeStyleSheet's contract is preserved, allowing the SafeStyleSheet to
- * correctly be interpreted as a sequence of CSS declarations and without
- * affecting the syntactic structure of any surrounding CSS and HTML.
- *
- * @param templateObj This contains the literal part of the template literal.
- */
- function safeStyleSheet(templateObj) {
- if (true) {
- (0, string_literal_1.assertIsTemplateObject)(templateObj, false, 'safeStyleSheet is a template literal tag ' +
- 'function that only accepts template literals without ' +
- 'expressions. For example, safeStyleSheet`foo`;');
- }
- var styleSheet = templateObj[0];
- if (true) {
- if (/[<>]/.test(styleSheet)) {
- throw new Error('Forbidden characters in styleSheet string: ' + styleSheet);
- }
- }
- return (0, style_sheet_impl_1.createStyleSheet)(styleSheet);
- }
- exports.safeStyleSheet = safeStyleSheet;
- /**
- * Creates a `SafeStyleSheet` value by concatenating multiple `SafeStyleSheet`s.
- */
- function concatStyleSheets(sheets) {
- return (0, style_sheet_impl_1.createStyleSheet)(sheets.map(style_sheet_impl_1.unwrapStyleSheet).join(''));
- }
- exports.concatStyleSheets = concatStyleSheets;
- /***/ }),
- /***/ "./node_modules/safevalues/builders/url_sanitizer.js":
- /*!***********************************************************!*\
- !*** ./node_modules/safevalues/builders/url_sanitizer.js ***!
- \***********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.restrictivelySanitizeUrl = exports.unwrapUrlOrSanitize = exports.sanitizeJavascriptUrl = void 0;
- /**
- * @fileoverview Provides functions to enforce the SafeUrl contract at the sink
- * level.
- */
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- function extractScheme(url) {
- var parsedUrl;
- try {
- parsedUrl = new URL(url);
- }
- catch (e) {
- // According to https://url.spec.whatwg.org/#constructors, the URL
- // constructor with one parameter throws if `url` is not absolute. In this
- // case, we are sure that no explicit scheme (javascript: ) is set.
- // This can also be a URL parsing error, but in this case the URL won't be
- // run anyway.
- return 'https:';
- }
- return parsedUrl.protocol;
- }
- // We can't use an ES6 Set here because gws somehow depends on this code and
- // doesn't want to pay the cost of a polyfill.
- var ALLOWED_SCHEMES = ['data:', 'http:', 'https:', 'mailto:', 'ftp:'];
- /**
- * Checks that the URL scheme is not javascript.
- * The URL parsing relies on the URL API in browsers that support it.
- * @param url The URL to sanitize for a SafeUrl sink.
- * @return undefined if url has a javascript: scheme, the original URL
- * otherwise.
- */
- function sanitizeJavascriptUrl(url) {
- var parsedScheme = extractScheme(url);
- if (parsedScheme === 'javascript:') {
- if (true) {
- console.error("A URL with content '".concat(url, "' was sanitized away."));
- }
- return undefined;
- }
- return url;
- }
- exports.sanitizeJavascriptUrl = sanitizeJavascriptUrl;
- /**
- * Adapter to sanitize string URLs in DOM sink wrappers.
- * @return undefined if the URL was sanitized.
- */
- function unwrapUrlOrSanitize(url) {
- return sanitizeJavascriptUrl(url);
- }
- exports.unwrapUrlOrSanitize = unwrapUrlOrSanitize;
- /**
- * Sanitizes a URL restrictively.
- * This sanitizer protects against XSS and potentially other uncommon and
- * undesirable schemes that an attacker could use for e.g. phishing (tel:,
- * callto: ssh: etc schemes). This sanitizer is primarily meant to be used by
- * the HTML sanitizer.
- */
- function restrictivelySanitizeUrl(url) {
- var parsedScheme = extractScheme(url);
- if (parsedScheme !== undefined &&
- ALLOWED_SCHEMES.indexOf(parsedScheme.toLowerCase()) !== -1) {
- return url;
- }
- return 'about:invalid#zClosurez';
- }
- exports.restrictivelySanitizeUrl = restrictivelySanitizeUrl;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/anchor.js":
- /*!********************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/anchor.js ***!
- \********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setHref = void 0;
- var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
- /**
- * Sets the Href attribute from the given Url.
- */
- function setHref(anchor, url) {
- var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
- if (sanitizedUrl !== undefined) {
- anchor.href = sanitizedUrl;
- }
- }
- exports.setHref = setHref;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/area.js":
- /*!******************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/area.js ***!
- \******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setHref = void 0;
- var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
- /**
- * Sets the Href attribute from the given Url.
- */
- function setHref(area, url) {
- var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
- if (sanitizedUrl !== undefined) {
- area.href = sanitizedUrl;
- }
- }
- exports.setHref = setHref;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/button.js":
- /*!********************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/button.js ***!
- \********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setFormaction = void 0;
- var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
- /**
- * Sets the Formaction attribute from the given Url.
- */
- function setFormaction(button, url) {
- var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
- if (sanitizedUrl !== undefined) {
- button.formAction = sanitizedUrl;
- }
- }
- exports.setFormaction = setFormaction;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/element.js":
- /*!*********************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/element.js ***!
- \*********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- var __read = (this && this.__read) || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o), r, ar = [], e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
- }
- catch (error) { e = { error: error }; }
- finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- }
- finally { if (e) throw e.error; }
- }
- return ar;
- };
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
- if (ar || !(i in from)) {
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
- ar[i] = from[i];
- }
- }
- return to.concat(ar || Array.prototype.slice.call(from));
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setPrefixedAttribute = exports.buildPrefixedAttributeSetter = exports.insertAdjacentHtml = exports.setCssText = exports.setOuterHtml = exports.setInnerHtml = void 0;
- /**
- * @fileoverview This contains safe wrappers for properties that aren't specific
- * to one kind of HTMLElement (like innerHTML), plus other setters and functions
- * that are not tied to elements (like location.href or Worker constructor).
- */
- var attribute_impl_1 = __webpack_require__(/*! ../../internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
- var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
- var style_impl_1 = __webpack_require__(/*! ../../internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
- /**
- * Safely set {@link Element.innerHTML} on a given ShadowRoot or Element which
- * may not be a `<script>` element or a `<style>` element.
- */
- function setInnerHtml(elOrRoot, v) {
- if (isElement(elOrRoot)) {
- throwIfScriptOrStyle(elOrRoot);
- }
- elOrRoot.innerHTML = (0, html_impl_1.unwrapHtml)(v);
- }
- exports.setInnerHtml = setInnerHtml;
- /**
- * Safely set {@link Element.outerHTML} for the given Element.
- */
- function setOuterHtml(e, v) {
- var parent = e.parentElement;
- if (parent !== null) {
- throwIfScriptOrStyle(parent);
- }
- e.outerHTML = (0, html_impl_1.unwrapHtml)(v);
- }
- exports.setOuterHtml = setOuterHtml;
- /**
- * Set `ElementCSSInlineStyle.cssText` for the given `ElementCSSInlineStyle`.
- */
- function setCssText(e, v) {
- e.style.cssText = (0, style_impl_1.unwrapStyle)(v);
- }
- exports.setCssText = setCssText;
- /**
- * Safely call {@link Element.insertAdjacentHTML} for the given Element.
- */
- function insertAdjacentHtml(element, position, v) {
- var tagContext = (position === 'beforebegin' || position === 'afterend') ?
- element.parentElement :
- element;
- if (tagContext !== null) {
- throwIfScriptOrStyle(tagContext);
- }
- element.insertAdjacentHTML(position, (0, html_impl_1.unwrapHtml)(v));
- }
- exports.insertAdjacentHtml = insertAdjacentHtml;
- /**
- * Given a set of known-to-be-safe prefixes (e.g., "data-", "aria-", "js"),
- * return a setter function that allows you to set attributes on an element,
- * as long as the names of the attributes to be set has one of the prefixes.
- *
- * The returned setter ensures that setting any dangerous attribute, e.g.,
- * "src", "href" will cause an exception. This is intended to be used as the
- * safe alterantive of `Element#setAttribute`, when applications need to set
- * attributes that do not have security implications and do not have a
- * corresponding DOM property.
- */
- function buildPrefixedAttributeSetter(prefix) {
- var otherPrefixes = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- otherPrefixes[_i - 1] = arguments[_i];
- }
- var prefixes = __spreadArray([prefix], __read(otherPrefixes), false);
- return function (e, attr, value) {
- setPrefixedAttribute(prefixes, e, attr, value);
- };
- }
- exports.buildPrefixedAttributeSetter = buildPrefixedAttributeSetter;
- /**
- * The safe alternative to Element#setAttribute. The function takes a list of
- * `SafeAttributePrefix`, making developer intention explicit. The attribute
- * to be set must has one of the safe prefixes, otherwise the function throws
- * an Error.
- */
- function setPrefixedAttribute(attrPrefixes, e, attr, value) {
- if (attrPrefixes.length === 0) {
- throw new Error('No prefixes are provided');
- }
- var prefixes = attrPrefixes.map(function (s) { return (0, attribute_impl_1.unwrapAttributePrefix)(s); });
- var attrLower = attr.toLowerCase();
- if (prefixes.every(function (p) { return attrLower.indexOf(p) !== 0; })) {
- throw new Error("Attribute \"".concat(attr, "\" does not match any of the allowed prefixes."));
- }
- e.setAttribute(attr, value);
- }
- exports.setPrefixedAttribute = setPrefixedAttribute;
- function throwIfScriptOrStyle(element) {
- if (element.tagName.toLowerCase() === 'script') {
- throw new Error('Use setTextContent with a SafeScript.');
- }
- else if (element.tagName.toLowerCase() === 'style') {
- throw new Error('Use setTextContent with a SafeStyleSheet.');
- }
- }
- function isElement(elOrRoot) {
- return elOrRoot.tagName !== undefined;
- }
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/embed.js":
- /*!*******************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/embed.js ***!
- \*******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setSrc = void 0;
- var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
- /**
- * Sets the Src attribute from the given SafeUrl.
- */
- function setSrc(embedEl, url) {
- embedEl.src = (0, resource_url_impl_1.unwrapResourceUrl)(url);
- }
- exports.setSrc = setSrc;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/form.js":
- /*!******************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/form.js ***!
- \******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setAction = void 0;
- var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
- /**
- * Sets the Action attribute from the given Url.
- */
- function setAction(form, url) {
- var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
- if (sanitizedUrl !== undefined) {
- form.action = sanitizedUrl;
- }
- }
- exports.setAction = setAction;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/iframe.js":
- /*!********************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/iframe.js ***!
- \********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setSrcdoc = exports.setSrc = void 0;
- /**
- * @fileoverview Safe iframe helpers and go/intents-for-iframes-for-closure
- */
- var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
- var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
- /** Sets the Src attribute using a TrustedResourceUrl */
- function setSrc(iframe, v) {
- iframe.src = (0, resource_url_impl_1.unwrapResourceUrl)(v).toString();
- }
- exports.setSrc = setSrc;
- /** Sets the Srcdoc attribute using a SafeHtml */
- function setSrcdoc(iframe, v) {
- iframe.srcdoc = (0, html_impl_1.unwrapHtml)(v);
- }
- exports.setSrcdoc = setSrcdoc;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/input.js":
- /*!*******************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/input.js ***!
- \*******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setFormaction = void 0;
- var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
- /**
- * Sets the Formaction attribute from the given Url.
- */
- function setFormaction(input, url) {
- var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
- if (sanitizedUrl !== undefined) {
- input.formAction = sanitizedUrl;
- }
- }
- exports.setFormaction = setFormaction;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/link.js":
- /*!******************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/link.js ***!
- \******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setHrefAndRel = void 0;
- var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
- var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
- var SAFE_URL_REL_VALUES = [
- 'alternate',
- 'author',
- 'bookmark',
- 'canonical',
- 'cite',
- 'help',
- 'icon',
- 'license',
- 'next',
- 'prefetch',
- 'dns-prefetch',
- 'prerender',
- 'preconnect',
- 'preload',
- 'prev',
- 'search',
- 'subresource',
- ];
- function setHrefAndRel(link, url, rel) {
- if (url instanceof resource_url_impl_1.TrustedResourceUrl) {
- link.href = (0, resource_url_impl_1.unwrapResourceUrl)(url).toString();
- }
- else {
- if (SAFE_URL_REL_VALUES.indexOf(rel) === -1) {
- throw new Error("TrustedResourceUrl href attribute required with rel=\"".concat(rel, "\""));
- }
- var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
- if (sanitizedUrl === undefined) {
- return;
- }
- link.href = sanitizedUrl;
- }
- link.rel = rel;
- }
- exports.setHrefAndRel = setHrefAndRel;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/object.js":
- /*!********************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/object.js ***!
- \********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setData = void 0;
- var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
- /** Sets the data attribute using a TrustedResourceUrl */
- function setData(obj, v) {
- obj.data = (0, resource_url_impl_1.unwrapResourceUrl)(v);
- }
- exports.setData = setData;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/script.js":
- /*!********************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/script.js ***!
- \********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setSrc = exports.setTextContent = void 0;
- var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
- var script_impl_1 = __webpack_require__(/*! ../../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
- /** Returns CSP nonce, if set for any script tag. */
- function getScriptNonceFromWindow(win) {
- var _a;
- var doc = win.document;
- // document.querySelector can be undefined in non-browser environments.
- var script = (_a = doc.querySelector) === null || _a === void 0 ? void 0 : _a.call(doc, 'script[nonce]');
- if (script) {
- // Try to get the nonce from the IDL property first, because browsers that
- // implement additional nonce protection features (currently only Chrome) to
- // prevent nonce stealing via CSS do not expose the nonce via attributes.
- // See https://github.com/whatwg/html/issues/2369
- return script['nonce'] || script.getAttribute('nonce') || '';
- }
- return '';
- }
- /** Propagates CSP nonce to dynamically created scripts. */
- function setNonceForScriptElement(script) {
- var win = script.ownerDocument && script.ownerDocument.defaultView;
- var nonce = getScriptNonceFromWindow(win || window);
- if (nonce) {
- script.setAttribute('nonce', nonce);
- }
- }
- /** Sets textContent from the given SafeScript. */
- function setTextContent(script, v) {
- script.textContent = (0, script_impl_1.unwrapScript)(v);
- setNonceForScriptElement(script);
- }
- exports.setTextContent = setTextContent;
- /** Sets the Src attribute using a TrustedResourceUrl */
- function setSrc(script, v) {
- script.src = (0, resource_url_impl_1.unwrapResourceUrl)(v);
- setNonceForScriptElement(script);
- }
- exports.setSrc = setSrc;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/elements/style.js":
- /*!*******************************************************!*\
- !*** ./node_modules/safevalues/dom/elements/style.js ***!
- \*******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.setTextContent = void 0;
- var style_sheet_impl_1 = __webpack_require__(/*! ../../internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
- /** Safe setters for `HTMLStyleElement`s. */
- function setTextContent(elem, safeStyleSheet) {
- elem.textContent = (0, style_sheet_impl_1.unwrapStyleSheet)(safeStyleSheet);
- }
- exports.setTextContent = setTextContent;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/globals/document.js":
- /*!*********************************************************!*\
- !*** ./node_modules/safevalues/dom/globals/document.js ***!
- \*********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.execCommandInsertHtml = exports.execCommand = exports.write = void 0;
- var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
- /**
- * write safely calls {@link Document.write} on the given {@link Document} with
- * the given {@link SafeHtml}.
- */
- function write(doc, text) {
- doc.write((0, html_impl_1.unwrapHtml)(text));
- }
- exports.write = write;
- /**
- * Safely calls {@link Document.execCommand}. When command is insertHtml, a
- * SafeHtml must be passed in as value.
- */
- function execCommand(doc, command, value) {
- var commandString = String(command);
- var valueArgument = value;
- if (commandString.toLowerCase() === 'inserthtml') {
- valueArgument = (0, html_impl_1.unwrapHtml)(value);
- }
- return doc.execCommand(commandString, /* showUi= */ false, valueArgument);
- }
- exports.execCommand = execCommand;
- /**
- * Safely calls {@link Document.execCommand}('insertHtml').
- * @deprecated Use safeDocument.execCommand.
- */
- function execCommandInsertHtml(doc, html) {
- return doc.execCommand('insertHTML', /* showUi= */ false, (0, html_impl_1.unwrapHtml)(html));
- }
- exports.execCommandInsertHtml = execCommandInsertHtml;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/globals/dom_parser.js":
- /*!***********************************************************!*\
- !*** ./node_modules/safevalues/dom/globals/dom_parser.js ***!
- \***********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.parseFromString = exports.parseHtml = void 0;
- var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
- /** Safely parses a string using the HTML parser. */
- function parseHtml(parser, html) {
- return parseFromString(parser, html, 'text/html');
- }
- exports.parseHtml = parseHtml;
- /** Safely parses a string using the HTML or XML parser. */
- function parseFromString(parser, content, contentType) {
- return parser.parseFromString((0, html_impl_1.unwrapHtml)(content), contentType);
- }
- exports.parseFromString = parseFromString;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/globals/global.js":
- /*!*******************************************************!*\
- !*** ./node_modules/safevalues/dom/globals/global.js ***!
- \*******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.globalEval = void 0;
- var script_impl_1 = __webpack_require__(/*! ../../internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
- /**
- * Evaluates a SafeScript value in the given scope using eval.
- *
- * Strongly consider avoiding this, as eval blocks CSP adoption and does not
- * benefit from compiler optimizations.
- */
- function globalEval(win, script) {
- var trustedScript = (0, script_impl_1.unwrapScript)(script);
- var result = win.eval(trustedScript);
- if (result === trustedScript) {
- // https://crbug.com/1024786 manifesting in workers.
- result = win.eval(trustedScript.toString());
- }
- return result;
- }
- exports.globalEval = globalEval;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/globals/location.js":
- /*!*********************************************************!*\
- !*** ./node_modules/safevalues/dom/globals/location.js ***!
- \*********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.assign = exports.replace = exports.setHref = void 0;
- var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
- /**
- * setHref safely sets {@link Location.href} on the given {@link Location} with
- * given {@link Url}.
- */
- function setHref(loc, url) {
- var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
- if (sanitizedUrl !== undefined) {
- loc.href = sanitizedUrl;
- }
- }
- exports.setHref = setHref;
- /**
- * replace safely calls {@link Location.replace} on the given {@link Location}
- * with given {@link Url}.
- */
- function replace(loc, url) {
- var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
- if (sanitizedUrl !== undefined) {
- loc.replace(sanitizedUrl);
- }
- }
- exports.replace = replace;
- /**
- * assign safely calls {@link Location.assign} on the given {@link Location}
- * with given {@link Url}.
- */
- function assign(loc, url) {
- var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
- if (sanitizedUrl !== undefined) {
- loc.assign(sanitizedUrl);
- }
- }
- exports.assign = assign;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/globals/range.js":
- /*!******************************************************!*\
- !*** ./node_modules/safevalues/dom/globals/range.js ***!
- \******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.createContextualFragment = void 0;
- var html_impl_1 = __webpack_require__(/*! ../../internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
- /** Safely creates a contextualFragment. */
- function createContextualFragment(range, html) {
- return range.createContextualFragment((0, html_impl_1.unwrapHtml)(html));
- }
- exports.createContextualFragment = createContextualFragment;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/globals/service_worker_container.js":
- /*!*************************************************************************!*\
- !*** ./node_modules/safevalues/dom/globals/service_worker_container.js ***!
- \*************************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.register = void 0;
- var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
- /** Safely registers a service worker by URL */
- function register(container, scriptURL, options) {
- return container.register((0, resource_url_impl_1.unwrapResourceUrl)(scriptURL), options);
- }
- exports.register = register;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/globals/window.js":
- /*!*******************************************************!*\
- !*** ./node_modules/safevalues/dom/globals/window.js ***!
- \*******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.open = void 0;
- var url_sanitizer_1 = __webpack_require__(/*! ../../builders/url_sanitizer */ "./node_modules/safevalues/builders/url_sanitizer.js");
- /**
- * open calls {@link Window.open} on the given {@link Window}, given a
- * target {@link Url}.
- */
- function open(win, url, target, features) {
- var sanitizedUrl = (0, url_sanitizer_1.unwrapUrlOrSanitize)(url);
- if (sanitizedUrl !== undefined) {
- return win.open(sanitizedUrl, target, features);
- }
- return null;
- }
- exports.open = open;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/globals/worker.js":
- /*!*******************************************************!*\
- !*** ./node_modules/safevalues/dom/globals/worker.js ***!
- \*******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- var __read = (this && this.__read) || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o), r, ar = [], e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
- }
- catch (error) { e = { error: error }; }
- finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- }
- finally { if (e) throw e.error; }
- }
- return ar;
- };
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
- if (ar || !(i in from)) {
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
- ar[i] = from[i];
- }
- }
- return to.concat(ar || Array.prototype.slice.call(from));
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.importScripts = exports.createShared = exports.create = void 0;
- var resource_url_impl_1 = __webpack_require__(/*! ../../internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
- /**
- * Safely creates a Web Worker.
- *
- * Example usage:
- * const trustedResourceUrl = trustedResourceUrl`/safe_script.js`;
- * safedom.safeWorker.create(trustedResourceUrl);
- * which is a safe alternative to
- * new Worker(url);
- * The latter can result in loading untrusted code.
- */
- function create(url, options) {
- return new Worker((0, resource_url_impl_1.unwrapResourceUrl)(url), options);
- }
- exports.create = create;
- /** Safely creates a shared Web Worker. */
- function createShared(url, options) {
- return new SharedWorker((0, resource_url_impl_1.unwrapResourceUrl)(url), options);
- }
- exports.createShared = createShared;
- /** Safely calls importScripts */
- function importScripts(scope) {
- var urls = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- urls[_i - 1] = arguments[_i];
- }
- scope.importScripts.apply(scope, __spreadArray([], __read(urls.map(function (url) { return (0, resource_url_impl_1.unwrapResourceUrl)(url); })), false));
- }
- exports.importScripts = importScripts;
- /***/ }),
- /***/ "./node_modules/safevalues/dom/index.js":
- /*!**********************************************!*\
- !*** ./node_modules/safevalues/dom/index.js ***!
- \**********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- var desc = Object.getOwnPropertyDescriptor(m, k);
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
- desc = { enumerable: true, get: function() { return m[k]; } };
- }
- Object.defineProperty(o, k2, desc);
- }) : (function(o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- }));
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- }) : function(o, v) {
- o["default"] = v;
- });
- var __importStar = (this && this.__importStar) || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- __setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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;
- /**
- * @fileoverview This file re-exports all of the wrappers to ensure that we have
- * a clearly defined interface.
- */
- exports.safeAnchorEl = __importStar(__webpack_require__(/*! ./elements/anchor */ "./node_modules/safevalues/dom/elements/anchor.js"));
- exports.safeAreaEl = __importStar(__webpack_require__(/*! ./elements/area */ "./node_modules/safevalues/dom/elements/area.js"));
- exports.safeButtonEl = __importStar(__webpack_require__(/*! ./elements/button */ "./node_modules/safevalues/dom/elements/button.js"));
- exports.safeElement = __importStar(__webpack_require__(/*! ./elements/element */ "./node_modules/safevalues/dom/elements/element.js"));
- exports.safeEmbedEl = __importStar(__webpack_require__(/*! ./elements/embed */ "./node_modules/safevalues/dom/elements/embed.js"));
- exports.safeFormEl = __importStar(__webpack_require__(/*! ./elements/form */ "./node_modules/safevalues/dom/elements/form.js"));
- exports.safeIframeEl = __importStar(__webpack_require__(/*! ./elements/iframe */ "./node_modules/safevalues/dom/elements/iframe.js"));
- exports.safeInputEl = __importStar(__webpack_require__(/*! ./elements/input */ "./node_modules/safevalues/dom/elements/input.js"));
- exports.safeLinkEl = __importStar(__webpack_require__(/*! ./elements/link */ "./node_modules/safevalues/dom/elements/link.js"));
- exports.safeObjectEl = __importStar(__webpack_require__(/*! ./elements/object */ "./node_modules/safevalues/dom/elements/object.js"));
- exports.safeScriptEl = __importStar(__webpack_require__(/*! ./elements/script */ "./node_modules/safevalues/dom/elements/script.js"));
- exports.safeStyleEl = __importStar(__webpack_require__(/*! ./elements/style */ "./node_modules/safevalues/dom/elements/style.js"));
- exports.safeDocument = __importStar(__webpack_require__(/*! ./globals/document */ "./node_modules/safevalues/dom/globals/document.js"));
- exports.safeDomParser = __importStar(__webpack_require__(/*! ./globals/dom_parser */ "./node_modules/safevalues/dom/globals/dom_parser.js"));
- exports.safeGlobal = __importStar(__webpack_require__(/*! ./globals/global */ "./node_modules/safevalues/dom/globals/global.js"));
- exports.safeLocation = __importStar(__webpack_require__(/*! ./globals/location */ "./node_modules/safevalues/dom/globals/location.js"));
- exports.safeRange = __importStar(__webpack_require__(/*! ./globals/range */ "./node_modules/safevalues/dom/globals/range.js"));
- exports.safeServiceWorkerContainer = __importStar(__webpack_require__(/*! ./globals/service_worker_container */ "./node_modules/safevalues/dom/globals/service_worker_container.js"));
- exports.safeWindow = __importStar(__webpack_require__(/*! ./globals/window */ "./node_modules/safevalues/dom/globals/window.js"));
- exports.safeWorker = __importStar(__webpack_require__(/*! ./globals/worker */ "./node_modules/safevalues/dom/globals/worker.js"));
- /***/ }),
- /***/ "./node_modules/safevalues/environment/dev.js":
- /*!****************************************************!*\
- !*** ./node_modules/safevalues/environment/dev.js ***!
- \****************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /* WEBPACK VAR INJECTION */(function(process) {
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- /**
- * Ensure process.env.NODE_ENV is set even when not running under Webpack or
- * Node. Terser will strip this out of production binaries.
- */
- /*#__PURE__*/ (function () {
- if (typeof process === 'undefined') {
- window.process = { env: { NODE_ENV: 'development' } };
- }
- })();
- /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "./node_modules/process/browser.js")))
- /***/ }),
- /***/ "./node_modules/safevalues/index.js":
- /*!******************************************!*\
- !*** ./node_modules/safevalues/index.js ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- 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;
- /** Safe builders */
- var attribute_builders_1 = __webpack_require__(/*! ./builders/attribute_builders */ "./node_modules/safevalues/builders/attribute_builders.js");
- Object.defineProperty(exports, "safeAttrPrefix", { enumerable: true, get: function () { return attribute_builders_1.safeAttrPrefix; } });
- var html_builders_1 = __webpack_require__(/*! ./builders/html_builders */ "./node_modules/safevalues/builders/html_builders.js");
- Object.defineProperty(exports, "concatHtmls", { enumerable: true, get: function () { return html_builders_1.concatHtmls; } });
- Object.defineProperty(exports, "createScript", { enumerable: true, get: function () { return html_builders_1.createScript; } });
- Object.defineProperty(exports, "createScriptSrc", { enumerable: true, get: function () { return html_builders_1.createScriptSrc; } });
- Object.defineProperty(exports, "htmlEscape", { enumerable: true, get: function () { return html_builders_1.htmlEscape; } });
- var html_sanitizer_1 = __webpack_require__(/*! ./builders/html_sanitizer/html_sanitizer */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer.js");
- Object.defineProperty(exports, "sanitizeHtml", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtml; } });
- Object.defineProperty(exports, "sanitizeHtmlAssertUnchanged", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtmlAssertUnchanged; } });
- Object.defineProperty(exports, "sanitizeHtmlToFragment", { enumerable: true, get: function () { return html_sanitizer_1.sanitizeHtmlToFragment; } });
- var html_sanitizer_builder_1 = __webpack_require__(/*! ./builders/html_sanitizer/html_sanitizer_builder */ "./node_modules/safevalues/builders/html_sanitizer/html_sanitizer_builder.js");
- Object.defineProperty(exports, "HtmlSanitizerBuilder", { enumerable: true, get: function () { return html_sanitizer_builder_1.HtmlSanitizerBuilder; } });
- var resource_url_builders_1 = __webpack_require__(/*! ./builders/resource_url_builders */ "./node_modules/safevalues/builders/resource_url_builders.js");
- Object.defineProperty(exports, "appendParams", { enumerable: true, get: function () { return resource_url_builders_1.appendParams; } });
- Object.defineProperty(exports, "blobUrlFromScript", { enumerable: true, get: function () { return resource_url_builders_1.blobUrlFromScript; } });
- Object.defineProperty(exports, "replaceFragment", { enumerable: true, get: function () { return resource_url_builders_1.replaceFragment; } });
- Object.defineProperty(exports, "trustedResourceUrl", { enumerable: true, get: function () { return resource_url_builders_1.trustedResourceUrl; } });
- var script_builders_1 = __webpack_require__(/*! ./builders/script_builders */ "./node_modules/safevalues/builders/script_builders.js");
- Object.defineProperty(exports, "concatScripts", { enumerable: true, get: function () { return script_builders_1.concatScripts; } });
- Object.defineProperty(exports, "safeScript", { enumerable: true, get: function () { return script_builders_1.safeScript; } });
- Object.defineProperty(exports, "safeScriptWithArgs", { enumerable: true, get: function () { return script_builders_1.safeScriptWithArgs; } });
- Object.defineProperty(exports, "scriptFromJson", { enumerable: true, get: function () { return script_builders_1.scriptFromJson; } });
- var style_builders_1 = __webpack_require__(/*! ./builders/style_builders */ "./node_modules/safevalues/builders/style_builders.js");
- Object.defineProperty(exports, "concatStyles", { enumerable: true, get: function () { return style_builders_1.concatStyles; } });
- Object.defineProperty(exports, "safeStyle", { enumerable: true, get: function () { return style_builders_1.safeStyle; } });
- var style_sheet_builders_1 = __webpack_require__(/*! ./builders/style_sheet_builders */ "./node_modules/safevalues/builders/style_sheet_builders.js");
- Object.defineProperty(exports, "concatStyleSheets", { enumerable: true, get: function () { return style_sheet_builders_1.concatStyleSheets; } });
- Object.defineProperty(exports, "safeStyleSheet", { enumerable: true, get: function () { return style_sheet_builders_1.safeStyleSheet; } });
- /** Types, constants and unwrappers */
- var attribute_impl_1 = __webpack_require__(/*! ./internals/attribute_impl */ "./node_modules/safevalues/internals/attribute_impl.js");
- Object.defineProperty(exports, "SafeAttributePrefix", { enumerable: true, get: function () { return attribute_impl_1.SafeAttributePrefix; } });
- Object.defineProperty(exports, "unwrapAttributePrefix", { enumerable: true, get: function () { return attribute_impl_1.unwrapAttributePrefix; } });
- var html_impl_1 = __webpack_require__(/*! ./internals/html_impl */ "./node_modules/safevalues/internals/html_impl.js");
- Object.defineProperty(exports, "EMPTY_HTML", { enumerable: true, get: function () { return html_impl_1.EMPTY_HTML; } });
- Object.defineProperty(exports, "isHtml", { enumerable: true, get: function () { return html_impl_1.isHtml; } });
- Object.defineProperty(exports, "SafeHtml", { enumerable: true, get: function () { return html_impl_1.SafeHtml; } });
- Object.defineProperty(exports, "unwrapHtml", { enumerable: true, get: function () { return html_impl_1.unwrapHtml; } });
- var resource_url_impl_1 = __webpack_require__(/*! ./internals/resource_url_impl */ "./node_modules/safevalues/internals/resource_url_impl.js");
- Object.defineProperty(exports, "isResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.isResourceUrl; } });
- Object.defineProperty(exports, "TrustedResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.TrustedResourceUrl; } });
- Object.defineProperty(exports, "unwrapResourceUrl", { enumerable: true, get: function () { return resource_url_impl_1.unwrapResourceUrl; } });
- var script_impl_1 = __webpack_require__(/*! ./internals/script_impl */ "./node_modules/safevalues/internals/script_impl.js");
- Object.defineProperty(exports, "EMPTY_SCRIPT", { enumerable: true, get: function () { return script_impl_1.EMPTY_SCRIPT; } });
- Object.defineProperty(exports, "isScript", { enumerable: true, get: function () { return script_impl_1.isScript; } });
- Object.defineProperty(exports, "SafeScript", { enumerable: true, get: function () { return script_impl_1.SafeScript; } });
- Object.defineProperty(exports, "unwrapScript", { enumerable: true, get: function () { return script_impl_1.unwrapScript; } });
- var style_impl_1 = __webpack_require__(/*! ./internals/style_impl */ "./node_modules/safevalues/internals/style_impl.js");
- Object.defineProperty(exports, "isStyle", { enumerable: true, get: function () { return style_impl_1.isStyle; } });
- Object.defineProperty(exports, "SafeStyle", { enumerable: true, get: function () { return style_impl_1.SafeStyle; } });
- Object.defineProperty(exports, "unwrapStyle", { enumerable: true, get: function () { return style_impl_1.unwrapStyle; } });
- var style_sheet_impl_1 = __webpack_require__(/*! ./internals/style_sheet_impl */ "./node_modules/safevalues/internals/style_sheet_impl.js");
- Object.defineProperty(exports, "isStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.isStyleSheet; } });
- Object.defineProperty(exports, "SafeStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.SafeStyleSheet; } });
- Object.defineProperty(exports, "unwrapStyleSheet", { enumerable: true, get: function () { return style_sheet_impl_1.unwrapStyleSheet; } });
- /***/ }),
- /***/ "./node_modules/safevalues/internals/attribute_impl.js":
- /*!*************************************************************!*\
- !*** ./node_modules/safevalues/internals/attribute_impl.js ***!
- \*************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.unwrapAttributePrefix = exports.createAttributePrefix = exports.SafeAttributePrefix = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
- /** A prefix with which an attribute is safe to set using plain strings. */
- var SafeAttributePrefix = /** @class */ (function () {
- function SafeAttributePrefix() {
- }
- return SafeAttributePrefix;
- }());
- exports.SafeAttributePrefix = SafeAttributePrefix;
- /** Implementation for `SafeAttributePrefix` */
- var AttributePrefixImpl = /** @class */ (function (_super) {
- __extends(AttributePrefixImpl, _super);
- function AttributePrefixImpl(attrPrefix, token) {
- var _this = _super.call(this) || this;
- if (true) {
- (0, secrets_1.ensureTokenIsValid)(token);
- }
- _this.privateDoNotAccessOrElseWrappedAttrPrefix = attrPrefix;
- return _this;
- }
- AttributePrefixImpl.prototype.toString = function () {
- return this.privateDoNotAccessOrElseWrappedAttrPrefix;
- };
- return AttributePrefixImpl;
- }(SafeAttributePrefix));
- /**
- * Builds a new `SafeAttribute` from the given string, without enforcing
- * safety guarantees. This shouldn't be exposed to application developers, and
- * must only be used as a step towards safe builders or safe constants.
- */
- function createAttributePrefix(attrPrefix) {
- return new AttributePrefixImpl(attrPrefix, secrets_1.secretToken);
- }
- exports.createAttributePrefix = createAttributePrefix;
- /**
- * Returns the string value of the passed `SafeAttributePrefix` object while
- * ensuring it has the correct type.
- */
- function unwrapAttributePrefix(value) {
- if (value instanceof AttributePrefixImpl) {
- return value.privateDoNotAccessOrElseWrappedAttrPrefix;
- }
- else {
- var message = '';
- if (true) {
- message = 'Unexpected type when unwrapping SafeAttributePrefix';
- }
- throw new Error(message);
- }
- }
- exports.unwrapAttributePrefix = unwrapAttributePrefix;
- /***/ }),
- /***/ "./node_modules/safevalues/internals/html_impl.js":
- /*!********************************************************!*\
- !*** ./node_modules/safevalues/internals/html_impl.js ***!
- \********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.unwrapHtml = exports.isHtml = exports.EMPTY_HTML = exports.createHtml = exports.SafeHtml = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- /* g3_import_pure from './pure' */
- var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
- var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
- /**
- * Runtime implementation of `TrustedHTML` in browsers that don't support it.
- */
- var HtmlImpl = /** @class */ (function () {
- function HtmlImpl(html, token) {
- if (true) {
- (0, secrets_1.ensureTokenIsValid)(token);
- }
- this.privateDoNotAccessOrElseWrappedHtml = html;
- }
- HtmlImpl.prototype.toString = function () {
- return this.privateDoNotAccessOrElseWrappedHtml.toString();
- };
- return HtmlImpl;
- }());
- function createHtmlInternal(html, trusted) {
- return (trusted !== null && trusted !== void 0 ? trusted : new HtmlImpl(html, secrets_1.secretToken));
- }
- var GlobalTrustedHTML = (typeof window !== undefined) ? window.TrustedHTML : undefined;
- /**
- * Also exports the constructor so that instanceof checks work.
- */
- exports.SafeHtml = (GlobalTrustedHTML !== null && GlobalTrustedHTML !== void 0 ? GlobalTrustedHTML : HtmlImpl);
- /**
- * Builds a new `SafeHtml` from the given string, without enforcing safety
- * guarantees. It may cause side effects by creating a Trusted Types policy.
- * This shouldn't be exposed to application developers, and must only be used as
- * a step towards safe builders or safe constants.
- */
- function createHtml(html) {
- var _a;
- /** @noinline */
- var noinlineHtml = html;
- return createHtmlInternal(noinlineHtml, (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createHTML(noinlineHtml));
- }
- exports.createHtml = createHtml;
- /**
- * An empty `SafeHtml` constant.
- * Unlike the function above, using this will not create a policy.
- */
- exports.EMPTY_HTML =
- /* #__PURE__ */ (function () { var _a; return createHtmlInternal('', (_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.emptyHTML); })();
- /**
- * Checks if the given value is a `SafeHtml` instance.
- */
- function isHtml(value) {
- return value instanceof exports.SafeHtml;
- }
- exports.isHtml = isHtml;
- /**
- * Returns the value of the passed `SafeHtml` object while ensuring it
- * has the correct type.
- *
- * Returns a native `TrustedHTML` or a string if Trusted Types are disabled.
- */
- function unwrapHtml(value) {
- var _a;
- if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isHTML(value)) {
- return value;
- }
- else if (value instanceof HtmlImpl) {
- return value.privateDoNotAccessOrElseWrappedHtml;
- }
- else {
- var message = '';
- if (true) {
- message = 'Unexpected type when unwrapping SafeHtml';
- }
- throw new Error(message);
- }
- }
- exports.unwrapHtml = unwrapHtml;
- /***/ }),
- /***/ "./node_modules/safevalues/internals/resource_url_impl.js":
- /*!****************************************************************!*\
- !*** ./node_modules/safevalues/internals/resource_url_impl.js ***!
- \****************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.unwrapResourceUrl = exports.isResourceUrl = exports.createResourceUrl = exports.TrustedResourceUrl = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
- var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
- /**
- * Runtime implementation of `TrustedScriptURL` in browsers that don't support
- * it.
- */
- var ResourceUrlImpl = /** @class */ (function () {
- function ResourceUrlImpl(url, token) {
- if (true) {
- (0, secrets_1.ensureTokenIsValid)(token);
- }
- this.privateDoNotAccessOrElseWrappedResourceUrl = url;
- }
- ResourceUrlImpl.prototype.toString = function () {
- return this.privateDoNotAccessOrElseWrappedResourceUrl.toString();
- };
- return ResourceUrlImpl;
- }());
- var GlobalTrustedScriptURL = (typeof window !== undefined) ? window.TrustedScriptURL : undefined;
- /**
- * Also exports the constructor so that instanceof checks work.
- */
- exports.TrustedResourceUrl = (GlobalTrustedScriptURL !== null && GlobalTrustedScriptURL !== void 0 ? GlobalTrustedScriptURL : ResourceUrlImpl);
- /**
- * Builds a new `TrustedResourceUrl` from the given string, without
- * enforcing safety guarantees. It may cause side effects by creating a Trusted
- * Types policy. This shouldn't be exposed to application developers, and must
- * only be used as a step towards safe builders or safe constants.
- */
- function createResourceUrl(url) {
- var _a;
- /** @noinline */
- var noinlineUrl = url;
- var trustedScriptURL = (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createScriptURL(noinlineUrl);
- return (trustedScriptURL !== null && trustedScriptURL !== void 0 ? trustedScriptURL : new ResourceUrlImpl(noinlineUrl, secrets_1.secretToken));
- }
- exports.createResourceUrl = createResourceUrl;
- /**
- * Checks if the given value is a `TrustedResourceUrl` instance.
- */
- function isResourceUrl(value) {
- return value instanceof exports.TrustedResourceUrl;
- }
- exports.isResourceUrl = isResourceUrl;
- /**
- * Returns the value of the passed `TrustedResourceUrl` object while ensuring it
- * has the correct type.
- *
- * Returns a native `TrustedScriptURL` or a string if Trusted Types are
- * disabled.
- */
- function unwrapResourceUrl(value) {
- var _a;
- if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isScriptURL(value)) {
- return value;
- }
- else if (value instanceof ResourceUrlImpl) {
- return value.privateDoNotAccessOrElseWrappedResourceUrl;
- }
- else {
- var message = '';
- if (true) {
- message = 'Unexpected type when unwrapping TrustedResourceUrl';
- }
- throw new Error(message);
- }
- }
- exports.unwrapResourceUrl = unwrapResourceUrl;
- /***/ }),
- /***/ "./node_modules/safevalues/internals/script_impl.js":
- /*!**********************************************************!*\
- !*** ./node_modules/safevalues/internals/script_impl.js ***!
- \**********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.unwrapScript = exports.isScript = exports.EMPTY_SCRIPT = exports.createScript = exports.SafeScript = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- /* g3_import_pure from './pure' */
- var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
- var trusted_types_1 = __webpack_require__(/*! ./trusted_types */ "./node_modules/safevalues/internals/trusted_types.js");
- /**
- * Runtime implementation of `TrustedScript` in browswers that don't support it.
- * script element.
- */
- var ScriptImpl = /** @class */ (function () {
- function ScriptImpl(script, token) {
- if (true) {
- (0, secrets_1.ensureTokenIsValid)(token);
- }
- this.privateDoNotAccessOrElseWrappedScript = script;
- }
- ScriptImpl.prototype.toString = function () {
- return this.privateDoNotAccessOrElseWrappedScript.toString();
- };
- return ScriptImpl;
- }());
- function createScriptInternal(script, trusted) {
- return (trusted !== null && trusted !== void 0 ? trusted : new ScriptImpl(script, secrets_1.secretToken));
- }
- var GlobalTrustedScript = (typeof window !== undefined) ? window.TrustedScript : undefined;
- /**
- * Also exports the constructor so that instanceof checks work.
- */
- exports.SafeScript = (GlobalTrustedScript !== null && GlobalTrustedScript !== void 0 ? GlobalTrustedScript : ScriptImpl);
- /**
- * Builds a new `SafeScript` from the given string, without enforcing
- * safety guarantees. It may cause side effects by creating a Trusted Types
- * policy. This shouldn't be exposed to application developers, and must only be
- * used as a step towards safe builders or safe constants.
- */
- function createScript(script) {
- var _a;
- /** @noinline */
- var noinlineScript = script;
- return createScriptInternal(noinlineScript, (_a = (0, trusted_types_1.getTrustedTypesPolicy)()) === null || _a === void 0 ? void 0 : _a.createScript(noinlineScript));
- }
- exports.createScript = createScript;
- /**
- * An empty `SafeScript` constant.
- * Unlike the functions above, using this will not create a policy.
- */
- exports.EMPTY_SCRIPT =
- /* #__PURE__ */ (function () { var _a; return createScriptInternal('', (_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.emptyScript); })();
- /**
- * Checks if the given value is a `SafeScript` instance.
- */
- function isScript(value) {
- return value instanceof exports.SafeScript;
- }
- exports.isScript = isScript;
- /**
- * Returns the value of the passed `SafeScript` object while ensuring it
- * has the correct type.
- *
- * Returns a native `TrustedScript` or a string if Trusted Types are disabled.
- */
- function unwrapScript(value) {
- var _a;
- if ((_a = (0, trusted_types_1.getTrustedTypes)()) === null || _a === void 0 ? void 0 : _a.isScript(value)) {
- return value;
- }
- else if (value instanceof ScriptImpl) {
- return value.privateDoNotAccessOrElseWrappedScript;
- }
- else {
- var message = '';
- if (true) {
- message = 'Unexpected type when unwrapping SafeScript';
- }
- throw new Error(message);
- }
- }
- exports.unwrapScript = unwrapScript;
- /***/ }),
- /***/ "./node_modules/safevalues/internals/secrets.js":
- /*!******************************************************!*\
- !*** ./node_modules/safevalues/internals/secrets.js ***!
- \******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.ensureTokenIsValid = exports.secretToken = void 0;
- /**
- * A secret token that must be passed to safe type constructors. It is only
- * accessible from within safevalues, ensuring that unrestricted safe type
- * creation is only possible within safevalues. In particular, this prevents
- * forgery such as `safeHtmlValue.constructor('javascript:evil')`.
- */
- exports.secretToken = {};
- /**
- * Asserts that the given token matches the secret safevalues token. An
- * exception is thrown if that is not the case.
- */
- function ensureTokenIsValid(token) {
- if (token !== exports.secretToken) {
- throw new Error('Bad secret');
- }
- }
- exports.ensureTokenIsValid = ensureTokenIsValid;
- /***/ }),
- /***/ "./node_modules/safevalues/internals/string_literal.js":
- /*!*************************************************************!*\
- !*** ./node_modules/safevalues/internals/string_literal.js ***!
- \*************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.assertIsTemplateObject = void 0;
- /**
- * An object of type TemplateStringsArray represents the literal part(s) of a
- * template literal. This function checks if a TemplateStringsArray object is
- * actually from a template literal.
- *
- * @param templateObj This contains the literal part of the template literal.
- * @param hasExprs If true, the input template may contain embedded expressions.
- * @param errorMsg The custom error message in case any checks fail.
- */
- function assertIsTemplateObject(templateObj, hasExprs, errorMsg) {
- if (!Array.isArray(templateObj) || !Array.isArray(templateObj.raw) ||
- (!hasExprs && templateObj.length !== 1)) {
- throw new TypeError(errorMsg);
- }
- }
- exports.assertIsTemplateObject = assertIsTemplateObject;
- /***/ }),
- /***/ "./node_modules/safevalues/internals/style_impl.js":
- /*!*********************************************************!*\
- !*** ./node_modules/safevalues/internals/style_impl.js ***!
- \*********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.unwrapStyle = exports.isStyle = exports.createStyle = exports.SafeStyle = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
- /**
- * Sequence of CSS declarations safe to use in style contexts in an HTML
- * document or in DOM APIs.
- */
- var SafeStyle = /** @class */ (function () {
- function SafeStyle() {
- }
- return SafeStyle;
- }());
- exports.SafeStyle = SafeStyle;
- /** Implementation for `SafeStyle` */
- var StyleImpl = /** @class */ (function (_super) {
- __extends(StyleImpl, _super);
- function StyleImpl(style, token) {
- var _this = _super.call(this) || this;
- if (true) {
- (0, secrets_1.ensureTokenIsValid)(token);
- }
- _this.privateDoNotAccessOrElseWrappedStyle = style;
- return _this;
- }
- StyleImpl.prototype.toString = function () {
- return this.privateDoNotAccessOrElseWrappedStyle;
- };
- return StyleImpl;
- }(SafeStyle));
- /**
- * Builds a new `SafeStyle` from the given string, without enforcing
- * safety guarantees. This shouldn't be exposed to application developers, and
- * must only be used as a step towards safe builders or safe constants.
- */
- function createStyle(style) {
- return new StyleImpl(style, secrets_1.secretToken);
- }
- exports.createStyle = createStyle;
- /**
- * Checks if the given value is a `SafeStyle` instance.
- */
- function isStyle(value) {
- return value instanceof StyleImpl;
- }
- exports.isStyle = isStyle;
- /**
- * Returns the string value of the passed `SafeStyle` object while ensuring it
- * has the correct type.
- */
- function unwrapStyle(value) {
- if (value instanceof StyleImpl) {
- return value.privateDoNotAccessOrElseWrappedStyle;
- }
- else {
- var message = '';
- if (true) {
- message = 'Unexpected type when unwrapping SafeStyle';
- }
- throw new Error(message);
- }
- }
- exports.unwrapStyle = unwrapStyle;
- /***/ }),
- /***/ "./node_modules/safevalues/internals/style_sheet_impl.js":
- /*!***************************************************************!*\
- !*** ./node_modules/safevalues/internals/style_sheet_impl.js ***!
- \***************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null)
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.unwrapStyleSheet = exports.isStyleSheet = exports.createStyleSheet = exports.SafeStyleSheet = void 0;
- __webpack_require__(/*! ../environment/dev */ "./node_modules/safevalues/environment/dev.js");
- var secrets_1 = __webpack_require__(/*! ./secrets */ "./node_modules/safevalues/internals/secrets.js");
- /**
- * A complete CSS style sheet, safe to use in style contexts in an HTML document
- * or DOM APIs.
- */
- var SafeStyleSheet = /** @class */ (function () {
- function SafeStyleSheet() {
- }
- return SafeStyleSheet;
- }());
- exports.SafeStyleSheet = SafeStyleSheet;
- /** Implementation for `SafeStyleSheet` */
- var StyleSheetImpl = /** @class */ (function (_super) {
- __extends(StyleSheetImpl, _super);
- function StyleSheetImpl(styleSheet, token) {
- var _this = _super.call(this) || this;
- if (true) {
- (0, secrets_1.ensureTokenIsValid)(token);
- }
- _this.privateDoNotAccessOrElseWrappedStyleSheet = styleSheet;
- return _this;
- }
- StyleSheetImpl.prototype.toString = function () {
- return this.privateDoNotAccessOrElseWrappedStyleSheet;
- };
- return StyleSheetImpl;
- }(SafeStyleSheet));
- /**
- * Builds a new `SafeStyleSheet` from the given string, without enforcing
- * safety guarantees. This shouldn't be exposed to application developers, and
- * must only be used as a step towards safe builders or safe constants.
- */
- function createStyleSheet(styleSheet) {
- return new StyleSheetImpl(styleSheet, secrets_1.secretToken);
- }
- exports.createStyleSheet = createStyleSheet;
- /**
- * Checks if the given value is a `SafeStyleSheet` instance.
- */
- function isStyleSheet(value) {
- return value instanceof StyleSheetImpl;
- }
- exports.isStyleSheet = isStyleSheet;
- /**
- * Returns the string value of the passed `SafeStyleSheet` object while
- * ensuring it has the correct type.
- */
- function unwrapStyleSheet(value) {
- if (value instanceof StyleSheetImpl) {
- return value.privateDoNotAccessOrElseWrappedStyleSheet;
- }
- else {
- var message = '';
- if (true) {
- message = 'Unexpected type when unwrapping SafeStyleSheet';
- }
- throw new Error(message);
- }
- }
- exports.unwrapStyleSheet = unwrapStyleSheet;
- /***/ }),
- /***/ "./node_modules/safevalues/internals/trusted_types.js":
- /*!************************************************************!*\
- !*** ./node_modules/safevalues/internals/trusted_types.js ***!
- \************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * SPDX-License-Identifier: Apache-2.0
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.TEST_ONLY = exports.getTrustedTypesPolicy = exports.getTrustedTypes = void 0;
- /**
- * The name of the Trusted Types policy used by TS safevalues, or empty
- * to disable Trusted Types. This duplicates the 'google#safe', but
- * can be overridden in tests.
- */
- var trustedTypesPolicyName = 'google#safe';
- /** Helper to retrieve the value of `window.trustedTypes`. */
- function trustedTypes() {
- if (typeof window !== 'undefined') {
- return window.trustedTypes;
- }
- return undefined;
- }
- /**
- * Returns window.trustedTypes if Trusted Types are enabled and supported, or
- * null otherwise.
- */
- function getTrustedTypes() {
- var _a;
- return (trustedTypesPolicyName !== '') ? ((_a = trustedTypes()) !== null && _a !== void 0 ? _a : null) : null;
- }
- exports.getTrustedTypes = getTrustedTypes;
- /**
- * The Trusted Types policy used by TS safevalues, or null if Trusted Types
- * are not enabled/supported, or undefined if the policy has not been created
- * yet.
- */
- var trustedTypesPolicy;
- /**
- * Returns the Trusted Types policy used by TS safevalues, or null if Trusted
- * Types are not enabled/supported. The first call to this function will
- * create the policy.
- */
- function getTrustedTypesPolicy() {
- var _a, _b;
- if (trustedTypesPolicy === undefined) {
- try {
- trustedTypesPolicy =
- (_b = (_a = getTrustedTypes()) === null || _a === void 0 ? void 0 : _a.createPolicy(trustedTypesPolicyName, {
- createHTML: function (s) { return s; },
- createScript: function (s) { return s; },
- createScriptURL: function (s) { return s; }
- })) !== null && _b !== void 0 ? _b : null;
- }
- catch (_c) {
- // In Chromium versions before 81, trustedTypes.createPolicy throws if
- // called with a name that is already registered, even if no CSP is set.
- // Until users have largely migrated to 81 or above, catch the error not
- // to break the applications functionally. In such case, the code will
- // fall back to using regular Safe Types.
- trustedTypesPolicy = null;
- }
- }
- return trustedTypesPolicy;
- }
- exports.getTrustedTypesPolicy = getTrustedTypesPolicy;
- /** Helpers for tests. */
- exports.TEST_ONLY = {
- resetDefaults: function () {
- trustedTypesPolicy = undefined;
- trustedTypesPolicyName = 'google#safe';
- },
- setTrustedTypesPolicyName: function (name) {
- trustedTypesPolicyName = name;
- },
- };
- /***/ }),
- /***/ "./packages/mdc-animation/util.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-animation/util.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.getCorrectEventName = exports.getCorrectPropertyName = void 0;
- var cssPropertyNameMap = {
- animation: {
- prefixed: '-webkit-animation',
- standard: 'animation'
- },
- transform: {
- prefixed: '-webkit-transform',
- standard: 'transform'
- },
- transition: {
- prefixed: '-webkit-transition',
- standard: 'transition'
- }
- };
- var jsEventTypeMap = {
- animationend: {
- cssProperty: 'animation',
- prefixed: 'webkitAnimationEnd',
- standard: 'animationend'
- },
- animationiteration: {
- cssProperty: 'animation',
- prefixed: 'webkitAnimationIteration',
- standard: 'animationiteration'
- },
- animationstart: {
- cssProperty: 'animation',
- prefixed: 'webkitAnimationStart',
- standard: 'animationstart'
- },
- transitionend: {
- cssProperty: 'transition',
- prefixed: 'webkitTransitionEnd',
- standard: 'transitionend'
- }
- };
- function isWindow(windowObj) {
- return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function';
- }
- function getCorrectPropertyName(windowObj, cssProperty) {
- if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) {
- var el = windowObj.document.createElement('div');
- var _a = cssPropertyNameMap[cssProperty],
- standard = _a.standard,
- prefixed = _a.prefixed;
- var isStandard = standard in el.style;
- return isStandard ? standard : prefixed;
- }
- return cssProperty;
- }
- exports.getCorrectPropertyName = getCorrectPropertyName;
- function getCorrectEventName(windowObj, eventType) {
- if (isWindow(windowObj) && eventType in jsEventTypeMap) {
- var el = windowObj.document.createElement('div');
- var _a = jsEventTypeMap[eventType],
- standard = _a.standard,
- prefixed = _a.prefixed,
- cssProperty = _a.cssProperty;
- var isStandard = cssProperty in el.style;
- return isStandard ? standard : prefixed;
- }
- return eventType;
- }
- exports.getCorrectEventName = getCorrectEventName;
- /***/ }),
- /***/ "./packages/mdc-base/component.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-base/component.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __makeTemplateObject = this && this.__makeTemplateObject || function (cooked, raw) {
- if (Object.defineProperty) {
- Object.defineProperty(cooked, "raw", { value: raw });
- } else {
- cooked.raw = raw;
- }
- return cooked;
- };
- var __read = this && this.__read || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o),
- r,
- ar = [],
- e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
- ar.push(r.value);
- }
- } catch (error) {
- e = { error: error };
- } finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- } finally {
- if (e) throw e.error;
- }
- }
- return ar;
- };
- var __spreadArray = this && this.__spreadArray || function (to, from) {
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
- to[j] = from[i];
- }return to;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCComponent = void 0;
- var safevalues_1 = __webpack_require__(/*! safevalues */ "./node_modules/safevalues/index.js");
- var dom_1 = __webpack_require__(/*! safevalues/dom */ "./node_modules/safevalues/dom/index.js");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
- function toCamelCase(str) {
- // tslint:disable-next-line:enforce-name-casing
- return String(str).replace(/\-([a-z])/g, function (_, match) {
- return match.toUpperCase();
- });
- }
- /** MDC Component base */
- var MDCComponent = /** @class */function () {
- function MDCComponent(root, foundation) {
- var args = [];
- for (var _i = 2; _i < arguments.length; _i++) {
- args[_i - 2] = arguments[_i];
- }
- this.root = root;
- this.initialize.apply(this, __spreadArray([], __read(args)));
- // Note that we initialize foundation here and not within the constructor's
- // default param so that this.root is defined and can be used within the
- // foundation class.
- this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
- this.foundation.init();
- this.initialSyncWithDOM();
- }
- MDCComponent.attachTo = function (root) {
- // Subclasses which extend MDCBase should provide an attachTo() method that
- // takes a root element and returns an instantiated component with its root
- // set to that element. Also note that in the cases of subclasses, an
- // explicit foundation class will not have to be passed in; it will simply
- // be initialized from getDefaultFoundation().
- return new MDCComponent(root, new foundation_1.MDCFoundation({}));
- };
- /* istanbul ignore next: method param only exists for typing purposes; it does
- * not need to be unit tested */
- // tslint:disable-next-line:enforce-name-casing
- MDCComponent.prototype.initialize = function () {
- var _args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- _args[_i] = arguments[_i];
- }
- // Subclasses can override this to do any additional setup work that would
- // be considered part of a "constructor". Essentially, it is a hook into the
- // parent constructor before the foundation is initialized. Any additional
- // arguments besides root and foundation will be passed in here.
- };
- MDCComponent.prototype.getDefaultFoundation = function () {
- // Subclasses must override this method to return a properly configured
- // foundation class for the component.
- throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
- };
- MDCComponent.prototype.initialSyncWithDOM = function () {
- // Subclasses should override this method if they need to perform work to
- // synchronize with a host DOM object. An example of this would be a form
- // control wrapper that needs to synchronize its internal state to some
- // property or attribute of the host DOM. Please note: this is *not* the
- // place to perform DOM reads/writes that would cause layout / paint, as
- // this is called synchronously from within the constructor.
- };
- MDCComponent.prototype.destroy = function () {
- // Subclasses may implement this method to release any resources /
- // deregister any listeners they have attached. An example of this might be
- // deregistering a resize event from the window object.
- this.foundation.destroy();
- };
- MDCComponent.prototype.listen = function (evtType, handler, options) {
- this.root.addEventListener(evtType, handler, options);
- };
- MDCComponent.prototype.unlisten = function (evtType, handler, options) {
- this.root.removeEventListener(evtType, handler, options);
- };
- /**
- * Fires a cross-browser-compatible custom event from the component root of
- * the given type, with the given data.
- */
- MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
- if (shouldBubble === void 0) {
- shouldBubble = false;
- }
- var evt;
- if (typeof CustomEvent === 'function') {
- evt = new CustomEvent(evtType, {
- bubbles: shouldBubble,
- detail: evtData
- });
- } else {
- evt = document.createEvent('CustomEvent');
- evt.initCustomEvent(evtType, shouldBubble, false, evtData);
- }
- this.root.dispatchEvent(evt);
- };
- /**
- * This is a intermediate fix to allow components to use safevalues. This
- * limits setAttribute to setting tabindex, data attributes, and aria
- * attributes.
- *
- * TODO(b/263990206): remove this method and add these directly in each
- * component. This will remove this abstraction and make it clear that the
- * caller can't set any attribute.
- */
- MDCComponent.prototype.safeSetAttribute = function (element, attribute, value) {
- if (attribute.toLowerCase() === 'tabindex') {
- element.tabIndex = Number(value);
- } else if (attribute.indexOf('data-') === 0) {
- var dataKey = toCamelCase(attribute.replace(/^data-/, ''));
- element.dataset[dataKey] = value;
- } else {
- 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);
- }
- };
- return MDCComponent;
- }();
- exports.MDCComponent = MDCComponent;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCComponent;
- var templateObject_1, templateObject_2;
- /***/ }),
- /***/ "./packages/mdc-base/foundation.ts":
- /*!*****************************************!*\
- !*** ./packages/mdc-base/foundation.ts ***!
- \*****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCFoundation = void 0;
- /** MDC Foundation */
- var MDCFoundation = /** @class */function () {
- function MDCFoundation(adapter) {
- if (adapter === void 0) {
- adapter = {};
- }
- this.adapter = adapter;
- }
- Object.defineProperty(MDCFoundation, "cssClasses", {
- get: function get() {
- // Classes extending MDCFoundation should implement this method to return an
- // object which exports every CSS class the foundation class needs as a
- // property. e.g. {ACTIVE: 'mdc-component--active'}
- return {};
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCFoundation, "strings", {
- get: function get() {
- // Classes extending MDCFoundation should implement this method to return an
- // object which exports all semantic strings as constants. e.g. {ARIA_ROLE:
- // 'tablist'}
- return {};
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCFoundation, "numbers", {
- get: function get() {
- // Classes extending MDCFoundation should implement this method to return an
- // object which exports all of its semantic numbers as constants.
- // e.g. {ANIMATION_DELAY_MS: 350}
- return {};
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCFoundation, "defaultAdapter", {
- get: function get() {
- // Classes extending MDCFoundation may choose to implement this getter in
- // order to provide a convenient way of viewing the necessary methods of an
- // adapter. In the future, this could also be used for adapter validation.
- return {};
- },
- enumerable: false,
- configurable: true
- });
- MDCFoundation.prototype.init = function () {
- // Subclasses should override this method to perform initialization routines
- // (registering events, etc.)
- };
- MDCFoundation.prototype.destroy = function () {
- // Subclasses should override this method to perform de-initialization
- // routines (de-registering events, etc.)
- };
- return MDCFoundation;
- }();
- exports.MDCFoundation = MDCFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCFoundation;
- /***/ }),
- /***/ "./packages/mdc-dom/events.ts":
- /*!************************************!*\
- !*** ./packages/mdc-dom/events.ts ***!
- \************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.applyPassive = void 0;
- /**
- * Determine whether the current browser supports passive event listeners, and
- * if so, use them.
- */
- function applyPassive(globalObj) {
- if (globalObj === void 0) {
- globalObj = window;
- }
- return supportsPassiveOption(globalObj) ? { passive: true } : false;
- }
- exports.applyPassive = applyPassive;
- function supportsPassiveOption(globalObj) {
- if (globalObj === void 0) {
- globalObj = window;
- }
- // See
- // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
- var passiveSupported = false;
- try {
- var options = {
- // This function will be called when the browser
- // attempts to access the passive property.
- get passive() {
- passiveSupported = true;
- return false;
- }
- };
- var handler = function handler() {};
- globalObj.document.addEventListener('test', handler, options);
- globalObj.document.removeEventListener('test', handler, options);
- } catch (err) {
- passiveSupported = false;
- }
- return passiveSupported;
- }
- /***/ }),
- /***/ "./packages/mdc-dom/keyboard.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-dom/keyboard.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.isNavigationEvent = exports.normalizeKey = exports.KEY = void 0;
- /**
- * KEY provides normalized string values for keys.
- */
- exports.KEY = {
- UNKNOWN: 'Unknown',
- BACKSPACE: 'Backspace',
- ENTER: 'Enter',
- SPACEBAR: 'Spacebar',
- PAGE_UP: 'PageUp',
- PAGE_DOWN: 'PageDown',
- END: 'End',
- HOME: 'Home',
- ARROW_LEFT: 'ArrowLeft',
- ARROW_UP: 'ArrowUp',
- ARROW_RIGHT: 'ArrowRight',
- ARROW_DOWN: 'ArrowDown',
- DELETE: 'Delete',
- ESCAPE: 'Escape',
- TAB: 'Tab'
- };
- var normalizedKeys = new Set();
- // IE11 has no support for new Map with iterable so we need to initialize this
- // by hand.
- normalizedKeys.add(exports.KEY.BACKSPACE);
- normalizedKeys.add(exports.KEY.ENTER);
- normalizedKeys.add(exports.KEY.SPACEBAR);
- normalizedKeys.add(exports.KEY.PAGE_UP);
- normalizedKeys.add(exports.KEY.PAGE_DOWN);
- normalizedKeys.add(exports.KEY.END);
- normalizedKeys.add(exports.KEY.HOME);
- normalizedKeys.add(exports.KEY.ARROW_LEFT);
- normalizedKeys.add(exports.KEY.ARROW_UP);
- normalizedKeys.add(exports.KEY.ARROW_RIGHT);
- normalizedKeys.add(exports.KEY.ARROW_DOWN);
- normalizedKeys.add(exports.KEY.DELETE);
- normalizedKeys.add(exports.KEY.ESCAPE);
- normalizedKeys.add(exports.KEY.TAB);
- var KEY_CODE = {
- BACKSPACE: 8,
- ENTER: 13,
- SPACEBAR: 32,
- PAGE_UP: 33,
- PAGE_DOWN: 34,
- END: 35,
- HOME: 36,
- ARROW_LEFT: 37,
- ARROW_UP: 38,
- ARROW_RIGHT: 39,
- ARROW_DOWN: 40,
- DELETE: 46,
- ESCAPE: 27,
- TAB: 9
- };
- var mappedKeyCodes = new Map();
- // IE11 has no support for new Map with iterable so we need to initialize this
- // by hand.
- mappedKeyCodes.set(KEY_CODE.BACKSPACE, exports.KEY.BACKSPACE);
- mappedKeyCodes.set(KEY_CODE.ENTER, exports.KEY.ENTER);
- mappedKeyCodes.set(KEY_CODE.SPACEBAR, exports.KEY.SPACEBAR);
- mappedKeyCodes.set(KEY_CODE.PAGE_UP, exports.KEY.PAGE_UP);
- mappedKeyCodes.set(KEY_CODE.PAGE_DOWN, exports.KEY.PAGE_DOWN);
- mappedKeyCodes.set(KEY_CODE.END, exports.KEY.END);
- mappedKeyCodes.set(KEY_CODE.HOME, exports.KEY.HOME);
- mappedKeyCodes.set(KEY_CODE.ARROW_LEFT, exports.KEY.ARROW_LEFT);
- mappedKeyCodes.set(KEY_CODE.ARROW_UP, exports.KEY.ARROW_UP);
- mappedKeyCodes.set(KEY_CODE.ARROW_RIGHT, exports.KEY.ARROW_RIGHT);
- mappedKeyCodes.set(KEY_CODE.ARROW_DOWN, exports.KEY.ARROW_DOWN);
- mappedKeyCodes.set(KEY_CODE.DELETE, exports.KEY.DELETE);
- mappedKeyCodes.set(KEY_CODE.ESCAPE, exports.KEY.ESCAPE);
- mappedKeyCodes.set(KEY_CODE.TAB, exports.KEY.TAB);
- var navigationKeys = new Set();
- // IE11 has no support for new Set with iterable so we need to initialize this
- // by hand.
- navigationKeys.add(exports.KEY.PAGE_UP);
- navigationKeys.add(exports.KEY.PAGE_DOWN);
- navigationKeys.add(exports.KEY.END);
- navigationKeys.add(exports.KEY.HOME);
- navigationKeys.add(exports.KEY.ARROW_LEFT);
- navigationKeys.add(exports.KEY.ARROW_UP);
- navigationKeys.add(exports.KEY.ARROW_RIGHT);
- navigationKeys.add(exports.KEY.ARROW_DOWN);
- /**
- * normalizeKey returns the normalized string for a navigational action.
- */
- function normalizeKey(evt) {
- var key = evt.key;
- // If the event already has a normalized key, return it
- if (normalizedKeys.has(key)) {
- return key;
- }
- // tslint:disable-next-line:deprecation
- var mappedKey = mappedKeyCodes.get(evt.keyCode);
- if (mappedKey) {
- return mappedKey;
- }
- return exports.KEY.UNKNOWN;
- }
- exports.normalizeKey = normalizeKey;
- /**
- * isNavigationEvent returns whether the event is a navigation event
- */
- function isNavigationEvent(evt) {
- return navigationKeys.has(normalizeKey(evt));
- }
- exports.isNavigationEvent = isNavigationEvent;
- /***/ }),
- /***/ "./packages/mdc-dom/ponyfill.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-dom/ponyfill.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.estimateScrollWidth = exports.matches = exports.closest = void 0;
- /**
- * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global
- * prototype chain. This makes ponyfills safer than traditional polyfills,
- * especially for libraries like MDC.
- */
- function closest(element, selector) {
- if (element.closest) {
- return element.closest(selector);
- }
- var el = element;
- while (el) {
- if (matches(el, selector)) {
- return el;
- }
- el = el.parentElement;
- }
- return null;
- }
- exports.closest = closest;
- /** Element.matches with support for webkit and IE. */
- function matches(element, selector) {
- var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
- return nativeMatches.call(element, selector);
- }
- exports.matches = matches;
- /**
- * Used to compute the estimated scroll width of elements. When an element is
- * hidden due to display: none; being applied to a parent element, the width is
- * returned as 0. However, the element will have a true width once no longer
- * inside a display: none context. This method computes an estimated width when
- * the element is hidden or returns the true width when the element is visble.
- * @param {Element} element the element whose width to estimate
- */
- function estimateScrollWidth(element) {
- // Check the offsetParent. If the element inherits display: none from any
- // parent, the offsetParent property will be null (see
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
- // This check ensures we only clone the node when necessary.
- var htmlEl = element;
- if (htmlEl.offsetParent !== null) {
- return htmlEl.scrollWidth;
- }
- var clone = htmlEl.cloneNode(true);
- clone.style.setProperty('position', 'absolute');
- clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
- document.documentElement.appendChild(clone);
- var scrollWidth = clone.scrollWidth;
- document.documentElement.removeChild(clone);
- return scrollWidth;
- }
- exports.estimateScrollWidth = estimateScrollWidth;
- /***/ }),
- /***/ "./packages/mdc-floating-label/component.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-floating-label/component.ts ***!
- \**************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCFloatingLabel = void 0;
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts");
- /** MDC Floating Label */
- var MDCFloatingLabel = /** @class */function (_super) {
- __extends(MDCFloatingLabel, _super);
- function MDCFloatingLabel() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCFloatingLabel.attachTo = function (root) {
- return new MDCFloatingLabel(root);
- };
- /**
- * Styles the label to produce the label shake for errors.
- * @param shouldShake If true, shakes the label by adding a CSS class;
- * otherwise, stops shaking by removing the class.
- */
- MDCFloatingLabel.prototype.shake = function (shouldShake) {
- this.foundation.shake(shouldShake);
- };
- /**
- * Styles the label to float/dock.
- * @param shouldFloat If true, floats the label by adding a CSS class;
- * otherwise, docks it by removing the class.
- */
- MDCFloatingLabel.prototype.float = function (shouldFloat) {
- this.foundation.float(shouldFloat);
- };
- /**
- * Styles the label as required.
- * @param isRequired If true, adds an asterisk to the label, indicating that
- * it is required.
- */
- MDCFloatingLabel.prototype.setRequired = function (isRequired) {
- this.foundation.setRequired(isRequired);
- };
- MDCFloatingLabel.prototype.getWidth = function () {
- return this.foundation.getWidth();
- };
- MDCFloatingLabel.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- addClass: function addClass(className) {
- _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- getWidth: function getWidth() {
- return ponyfill_1.estimateScrollWidth(_this.root);
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- _this.listen(evtType, handler);
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- _this.unlisten(evtType, handler);
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCFloatingLabelFoundation(adapter);
- };
- return MDCFloatingLabel;
- }(component_1.MDCComponent);
- exports.MDCFloatingLabel = MDCFloatingLabel;
- /***/ }),
- /***/ "./packages/mdc-floating-label/constants.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-floating-label/constants.ts ***!
- \**************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.cssClasses = void 0;
- exports.cssClasses = {
- LABEL_FLOAT_ABOVE: 'mdc-floating-label--float-above',
- LABEL_REQUIRED: 'mdc-floating-label--required',
- LABEL_HIDE_REQUIRED_MARKER: 'mdc-floating-label--hide-required-marker',
- LABEL_SHAKE: 'mdc-floating-label--shake',
- ROOT: 'mdc-floating-label'
- };
- /***/ }),
- /***/ "./packages/mdc-floating-label/foundation.ts":
- /*!***************************************************!*\
- !*** ./packages/mdc-floating-label/foundation.ts ***!
- \***************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCFloatingLabelFoundation = void 0;
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts");
- /** MDC Floating Label Foundation */
- var MDCFloatingLabelFoundation = /** @class */function (_super) {
- __extends(MDCFloatingLabelFoundation, _super);
- function MDCFloatingLabelFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCFloatingLabelFoundation.defaultAdapter), adapter)) || this;
- _this.shakeAnimationEndHandler = function () {
- _this.handleShakeAnimationEnd();
- };
- return _this;
- }
- Object.defineProperty(MDCFloatingLabelFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCFloatingLabelFoundation, "defaultAdapter", {
- /**
- * See {@link MDCFloatingLabelAdapter} for typing information on parameters
- * and return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return false;
- },
- getWidth: function getWidth() {
- return 0;
- },
- registerInteractionHandler: function registerInteractionHandler() {
- return undefined;
- },
- deregisterInteractionHandler: function deregisterInteractionHandler() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: false,
- configurable: true
- });
- MDCFloatingLabelFoundation.prototype.init = function () {
- this.adapter.registerInteractionHandler('animationend', this.shakeAnimationEndHandler);
- };
- MDCFloatingLabelFoundation.prototype.destroy = function () {
- this.adapter.deregisterInteractionHandler('animationend', this.shakeAnimationEndHandler);
- };
- /**
- * Returns the width of the label element.
- */
- MDCFloatingLabelFoundation.prototype.getWidth = function () {
- return this.adapter.getWidth();
- };
- /**
- * Styles the label to produce a shake animation to indicate an error.
- * @param shouldShake If true, adds the shake CSS class; otherwise, removes
- * shake class.
- */
- MDCFloatingLabelFoundation.prototype.shake = function (shouldShake) {
- var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
- if (shouldShake) {
- this.adapter.addClass(LABEL_SHAKE);
- } else {
- this.adapter.removeClass(LABEL_SHAKE);
- }
- };
- /**
- * Styles the label to float or dock.
- * @param shouldFloat If true, adds the float CSS class; otherwise, removes
- * float and shake classes to dock the label.
- */
- MDCFloatingLabelFoundation.prototype.float = function (shouldFloat) {
- var _a = MDCFloatingLabelFoundation.cssClasses,
- LABEL_FLOAT_ABOVE = _a.LABEL_FLOAT_ABOVE,
- LABEL_SHAKE = _a.LABEL_SHAKE;
- if (shouldFloat) {
- this.adapter.addClass(LABEL_FLOAT_ABOVE);
- } else {
- this.adapter.removeClass(LABEL_FLOAT_ABOVE);
- this.adapter.removeClass(LABEL_SHAKE);
- }
- };
- /**
- * Styles the label as required.
- * @param isRequired If true, adds an asterisk to the label, indicating that
- * it is required.
- */
- MDCFloatingLabelFoundation.prototype.setRequired = function (isRequired) {
- var LABEL_REQUIRED = MDCFloatingLabelFoundation.cssClasses.LABEL_REQUIRED;
- if (isRequired) {
- this.adapter.addClass(LABEL_REQUIRED);
- } else {
- this.adapter.removeClass(LABEL_REQUIRED);
- }
- };
- MDCFloatingLabelFoundation.prototype.setHideRequiredMarker = function (hideRequiredMarker) {
- var LABEL_HIDE_REQUIRED_MARKER = MDCFloatingLabelFoundation.cssClasses.LABEL_HIDE_REQUIRED_MARKER;
- if (hideRequiredMarker) {
- this.adapter.addClass(LABEL_HIDE_REQUIRED_MARKER);
- } else {
- this.adapter.removeClass(LABEL_HIDE_REQUIRED_MARKER);
- }
- };
- MDCFloatingLabelFoundation.prototype.getHideRequiredMarker = function () {
- var LABEL_HIDE_REQUIRED_MARKER = MDCFloatingLabelFoundation.cssClasses.LABEL_HIDE_REQUIRED_MARKER;
- return this.adapter.hasClass(LABEL_HIDE_REQUIRED_MARKER);
- };
- MDCFloatingLabelFoundation.prototype.handleShakeAnimationEnd = function () {
- var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
- this.adapter.removeClass(LABEL_SHAKE);
- };
- return MDCFloatingLabelFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCFloatingLabelFoundation = MDCFloatingLabelFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCFloatingLabelFoundation;
- /***/ }),
- /***/ "./packages/mdc-line-ripple/component.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-line-ripple/component.ts ***!
- \***********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCLineRipple = void 0;
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-line-ripple/foundation.ts");
- /** MDC Line Ripple */
- var MDCLineRipple = /** @class */function (_super) {
- __extends(MDCLineRipple, _super);
- function MDCLineRipple() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCLineRipple.attachTo = function (root) {
- return new MDCLineRipple(root);
- };
- /**
- * Activates the line ripple
- */
- MDCLineRipple.prototype.activate = function () {
- this.foundation.activate();
- };
- /**
- * Deactivates the line ripple
- */
- MDCLineRipple.prototype.deactivate = function () {
- this.foundation.deactivate();
- };
- /**
- * Sets the transform origin given a user's click location.
- * The `rippleCenter` is the x-coordinate of the middle of the ripple.
- */
- MDCLineRipple.prototype.setRippleCenter = function (xCoordinate) {
- this.foundation.setRippleCenter(xCoordinate);
- };
- MDCLineRipple.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- addClass: function addClass(className) {
- _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- setStyle: function setStyle(propertyName, value) {
- _this.root.style.setProperty(propertyName, value);
- },
- registerEventHandler: function registerEventHandler(evtType, handler) {
- _this.listen(evtType, handler);
- },
- deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
- _this.unlisten(evtType, handler);
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCLineRippleFoundation(adapter);
- };
- return MDCLineRipple;
- }(component_1.MDCComponent);
- exports.MDCLineRipple = MDCLineRipple;
- /***/ }),
- /***/ "./packages/mdc-line-ripple/constants.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-line-ripple/constants.ts ***!
- \***********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.cssClasses = void 0;
- var cssClasses = {
- LINE_RIPPLE_ACTIVE: 'mdc-line-ripple--active',
- LINE_RIPPLE_DEACTIVATING: 'mdc-line-ripple--deactivating'
- };
- exports.cssClasses = cssClasses;
- /***/ }),
- /***/ "./packages/mdc-line-ripple/foundation.ts":
- /*!************************************************!*\
- !*** ./packages/mdc-line-ripple/foundation.ts ***!
- \************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCLineRippleFoundation = void 0;
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-line-ripple/constants.ts");
- /** MDC Line Ripple Foundation */
- var MDCLineRippleFoundation = /** @class */function (_super) {
- __extends(MDCLineRippleFoundation, _super);
- function MDCLineRippleFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCLineRippleFoundation.defaultAdapter), adapter)) || this;
- _this.transitionEndHandler = function (evt) {
- _this.handleTransitionEnd(evt);
- };
- return _this;
- }
- Object.defineProperty(MDCLineRippleFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCLineRippleFoundation, "defaultAdapter", {
- /**
- * See {@link MDCLineRippleAdapter} for typing information on parameters and
- * return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return false;
- },
- setStyle: function setStyle() {
- return undefined;
- },
- registerEventHandler: function registerEventHandler() {
- return undefined;
- },
- deregisterEventHandler: function deregisterEventHandler() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: false,
- configurable: true
- });
- MDCLineRippleFoundation.prototype.init = function () {
- this.adapter.registerEventHandler('transitionend', this.transitionEndHandler);
- };
- MDCLineRippleFoundation.prototype.destroy = function () {
- this.adapter.deregisterEventHandler('transitionend', this.transitionEndHandler);
- };
- MDCLineRippleFoundation.prototype.activate = function () {
- this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
- this.adapter.addClass(constants_1.cssClasses.LINE_RIPPLE_ACTIVE);
- };
- MDCLineRippleFoundation.prototype.setRippleCenter = function (xCoordinate) {
- this.adapter.setStyle('transform-origin', xCoordinate + "px center");
- };
- MDCLineRippleFoundation.prototype.deactivate = function () {
- this.adapter.addClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
- };
- MDCLineRippleFoundation.prototype.handleTransitionEnd = function (evt) {
- // Wait for the line ripple to be either transparent or opaque
- // before emitting the animation end event
- var isDeactivating = this.adapter.hasClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
- if (evt.propertyName === 'opacity') {
- if (isDeactivating) {
- this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_ACTIVE);
- this.adapter.removeClass(constants_1.cssClasses.LINE_RIPPLE_DEACTIVATING);
- }
- }
- };
- return MDCLineRippleFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCLineRippleFoundation = MDCLineRippleFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCLineRippleFoundation;
- /***/ }),
- /***/ "./packages/mdc-list/component.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-list/component.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCList = void 0;
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-list/foundation.ts");
- /** MDC List */
- var MDCList = /** @class */function (_super) {
- __extends(MDCList, _super);
- function MDCList() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- Object.defineProperty(MDCList.prototype, "vertical", {
- set: function set(value) {
- this.foundation.setVerticalOrientation(value);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "listElements", {
- get: function get() {
- return Array.from(this.root.querySelectorAll("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]));
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "wrapFocus", {
- set: function set(value) {
- this.foundation.setWrapFocus(value);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "typeaheadInProgress", {
- /**
- * @return Whether typeahead is currently matching a user-specified prefix.
- */
- get: function get() {
- return this.foundation.isTypeaheadInProgress();
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "hasTypeahead", {
- /**
- * Sets whether typeahead functionality is enabled on the list.
- * @param hasTypeahead Whether typeahead is enabled.
- */
- set: function set(hasTypeahead) {
- this.foundation.setHasTypeahead(hasTypeahead);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "singleSelection", {
- set: function set(isSingleSelectionList) {
- this.foundation.setSingleSelection(isSingleSelectionList);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "disabledItemsFocusable", {
- set: function set(areDisabledItemsFocusable) {
- this.foundation.setDisabledItemsFocusable(areDisabledItemsFocusable);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "selectedIndex", {
- get: function get() {
- return this.foundation.getSelectedIndex();
- },
- set: function set(index) {
- this.foundation.setSelectedIndex(index);
- },
- enumerable: false,
- configurable: true
- });
- MDCList.attachTo = function (root) {
- return new MDCList(root);
- };
- MDCList.prototype.initialSyncWithDOM = function () {
- this.isEvolutionEnabled = constants_1.evolutionAttribute in this.root.dataset;
- if (this.isEvolutionEnabled) {
- this.classNameMap = constants_1.evolutionClassNameMap;
- } else if (ponyfill_1.matches(this.root, constants_1.strings.DEPRECATED_SELECTOR)) {
- this.classNameMap = constants_1.deprecatedClassNameMap;
- } else {
- this.classNameMap = Object.values(constants_1.cssClasses).reduce(function (obj, className) {
- obj[className] = className;
- return obj;
- }, {});
- }
- this.handleClick = this.handleClickEvent.bind(this);
- this.handleKeydown = this.handleKeydownEvent.bind(this);
- this.focusInEventListener = this.handleFocusInEvent.bind(this);
- this.focusOutEventListener = this.handleFocusOutEvent.bind(this);
- this.listen('keydown', this.handleKeydown);
- this.listen('click', this.handleClick);
- this.listen('focusin', this.focusInEventListener);
- this.listen('focusout', this.focusOutEventListener);
- this.layout();
- this.initializeListType();
- this.ensureFocusable();
- };
- MDCList.prototype.destroy = function () {
- this.unlisten('keydown', this.handleKeydown);
- this.unlisten('click', this.handleClick);
- this.unlisten('focusin', this.focusInEventListener);
- this.unlisten('focusout', this.focusOutEventListener);
- };
- MDCList.prototype.layout = function () {
- var direction = this.root.getAttribute(constants_1.strings.ARIA_ORIENTATION);
- this.vertical = direction !== constants_1.strings.ARIA_ORIENTATION_HORIZONTAL;
- var itemSelector = "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not([tabindex])";
- var childSelector = constants_1.strings.FOCUSABLE_CHILD_ELEMENTS;
- // List items need to have at least tabindex=-1 to be focusable.
- var itemEls = this.root.querySelectorAll(itemSelector);
- if (itemEls.length) {
- Array.prototype.forEach.call(itemEls, function (el) {
- el.setAttribute('tabindex', '-1');
- });
- }
- // Child button/a elements are not tabbable until the list item is focused.
- var focusableChildEls = this.root.querySelectorAll(childSelector);
- if (focusableChildEls.length) {
- Array.prototype.forEach.call(focusableChildEls, function (el) {
- el.setAttribute('tabindex', '-1');
- });
- }
- if (this.isEvolutionEnabled) {
- this.foundation.setUseSelectedAttribute(true);
- }
- this.foundation.layout();
- };
- /**
- * Extracts the primary text from a list item.
- * @param item The list item element.
- * @return The primary text in the element.
- */
- MDCList.prototype.getPrimaryText = function (item) {
- var _a;
- var primaryText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS]);
- if (this.isEvolutionEnabled || primaryText) {
- return (_a = primaryText === null || primaryText === void 0 ? void 0 : primaryText.textContent) !== null && _a !== void 0 ? _a : '';
- }
- var singleLineText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_TEXT_CLASS]);
- return singleLineText && singleLineText.textContent || '';
- };
- /**
- * Initialize selectedIndex value based on pre-selected list items.
- */
- MDCList.prototype.initializeListType = function () {
- var _this = this;
- this.isInteractive = ponyfill_1.matches(this.root, constants_1.strings.ARIA_INTERACTIVE_ROLES_SELECTOR);
- if (this.isEvolutionEnabled && this.isInteractive) {
- var selection = Array.from(this.root.querySelectorAll(constants_1.strings.SELECTED_ITEM_SELECTOR), function (listItem) {
- return _this.listElements.indexOf(listItem);
- });
- if (ponyfill_1.matches(this.root, constants_1.strings.ARIA_MULTI_SELECTABLE_SELECTOR)) {
- this.selectedIndex = selection;
- } else if (selection.length > 0) {
- this.selectedIndex = selection[0];
- }
- return;
- }
- var checkboxListItems = this.root.querySelectorAll(constants_1.strings.ARIA_ROLE_CHECKBOX_SELECTOR);
- var radioSelectedListItem = this.root.querySelector(constants_1.strings.ARIA_CHECKED_RADIO_SELECTOR);
- if (checkboxListItems.length) {
- var preselectedItems = this.root.querySelectorAll(constants_1.strings.ARIA_CHECKED_CHECKBOX_SELECTOR);
- this.selectedIndex = Array.from(preselectedItems, function (listItem) {
- return _this.listElements.indexOf(listItem);
- });
- } else if (radioSelectedListItem) {
- this.selectedIndex = this.listElements.indexOf(radioSelectedListItem);
- }
- };
- /**
- * Updates the list item at itemIndex to the desired isEnabled state.
- * @param itemIndex Index of the list item
- * @param isEnabled Sets the list item to enabled or disabled.
- */
- MDCList.prototype.setEnabled = function (itemIndex, isEnabled) {
- this.foundation.setEnabled(itemIndex, isEnabled);
- };
- /**
- * Given the next desired character from the user, adds it to the typeahead
- * buffer. Then, attempts to find the next option matching the buffer. Wraps
- * around if at the end of options.
- *
- * @param nextChar The next character to add to the prefix buffer.
- * @param startingIndex The index from which to start matching. Defaults to
- * the currently focused index.
- * @return The index of the matched item.
- */
- MDCList.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
- return this.foundation.typeaheadMatchItem(nextChar, startingIndex, /** skipFocus */true);
- };
- MDCList.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- var adapter = {
- addClassForElementIndex: function addClassForElementIndex(index, className) {
- var element = _this.listElements[index];
- if (element) {
- element.classList.add(_this.classNameMap[className]);
- }
- },
- focusItemAtIndex: function focusItemAtIndex(index) {
- var _a;
- (_a = _this.listElements[index]) === null || _a === void 0 ? void 0 : _a.focus();
- },
- getAttributeForElementIndex: function getAttributeForElementIndex(index, attr) {
- return _this.listElements[index].getAttribute(attr);
- },
- getFocusedElementIndex: function getFocusedElementIndex() {
- return _this.listElements.indexOf(document.activeElement);
- },
- getListItemCount: function getListItemCount() {
- return _this.listElements.length;
- },
- getPrimaryTextAtIndex: function getPrimaryTextAtIndex(index) {
- return _this.getPrimaryText(_this.listElements[index]);
- },
- hasCheckboxAtIndex: function hasCheckboxAtIndex(index) {
- var listItem = _this.listElements[index];
- return !!listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
- },
- hasRadioAtIndex: function hasRadioAtIndex(index) {
- var listItem = _this.listElements[index];
- return !!listItem.querySelector(constants_1.strings.RADIO_SELECTOR);
- },
- isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex(index) {
- var listItem = _this.listElements[index];
- var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
- return toggleEl.checked;
- },
- isFocusInsideList: function isFocusInsideList() {
- return _this.root !== document.activeElement && _this.root.contains(document.activeElement);
- },
- isRootFocused: function isRootFocused() {
- return document.activeElement === _this.root;
- },
- listItemAtIndexHasClass: function listItemAtIndexHasClass(index, className) {
- return _this.listElements[index].classList.contains(_this.classNameMap[className]);
- },
- notifyAction: function notifyAction(index) {
- _this.emit(constants_1.strings.ACTION_EVENT, { index: index }, /** shouldBubble */true);
- },
- notifySelectionChange: function notifySelectionChange(changedIndices) {
- _this.emit(constants_1.strings.SELECTION_CHANGE_EVENT, { changedIndices: changedIndices },
- /** shouldBubble */true);
- },
- removeClassForElementIndex: function removeClassForElementIndex(index, className) {
- var element = _this.listElements[index];
- if (element) {
- element.classList.remove(_this.classNameMap[className]);
- }
- },
- setAttributeForElementIndex: function setAttributeForElementIndex(index, attr, value) {
- var element = _this.listElements[index];
- if (element) {
- _this.safeSetAttribute(element, attr, value);
- }
- },
- setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex(index, isChecked) {
- var listItem = _this.listElements[index];
- var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_RADIO_SELECTOR);
- toggleEl.checked = isChecked;
- var event = document.createEvent('Event');
- event.initEvent('change', true, true);
- toggleEl.dispatchEvent(event);
- },
- setTabIndexForListItemChildren: function setTabIndexForListItemChildren(listItemIndex, tabIndexValue) {
- var element = _this.listElements[listItemIndex];
- var selector = constants_1.strings.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX;
- Array.prototype.forEach.call(element.querySelectorAll(selector), function (el) {
- el.tabIndex = Number(tabIndexValue);
- });
- }
- };
- return new foundation_1.MDCListFoundation(adapter);
- };
- /**
- * Ensures that at least one item is focusable if the list is interactive and
- * doesn't specify a suitable tabindex.
- */
- MDCList.prototype.ensureFocusable = function () {
- if (this.isEvolutionEnabled && this.isInteractive) {
- if (!this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + "[tabindex=\"0\"]")) {
- var index = this.initialFocusIndex();
- if (index !== -1) {
- this.listElements[index].tabIndex = 0;
- }
- }
- }
- };
- MDCList.prototype.initialFocusIndex = function () {
- if (this.selectedIndex instanceof Array && this.selectedIndex.length > 0) {
- return this.selectedIndex[0];
- }
- if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
- return this.selectedIndex;
- }
- var el = this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not(." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS] + ")");
- if (el === null) {
- return -1;
- }
- return this.getListItemIndex(el);
- };
- /**
- * Used to figure out which list item this event is targeting. Or returns -1
- * if there is no list item
- */
- MDCList.prototype.getListItemIndex = function (el) {
- var nearestParent = ponyfill_1.closest(el, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ", ." + this.classNameMap[constants_1.cssClasses.ROOT]);
- // Get the index of the element if it is a list item.
- if (nearestParent && ponyfill_1.matches(nearestParent, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS])) {
- return this.listElements.indexOf(nearestParent);
- }
- return -1;
- };
- /**
- * Used to figure out which element was clicked before sending the event to
- * the foundation.
- */
- MDCList.prototype.handleFocusInEvent = function (evt) {
- var index = this.getListItemIndex(evt.target);
- this.foundation.handleFocusIn(index);
- };
- /**
- * Used to figure out which element was clicked before sending the event to
- * the foundation.
- */
- MDCList.prototype.handleFocusOutEvent = function (evt) {
- var index = this.getListItemIndex(evt.target);
- this.foundation.handleFocusOut(index);
- };
- /**
- * Used to figure out which element was focused when keydown event occurred
- * before sending the event to the foundation.
- */
- MDCList.prototype.handleKeydownEvent = function (evt) {
- var index = this.getListItemIndex(evt.target);
- var target = evt.target;
- this.foundation.handleKeydown(evt, target.classList.contains(this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]), index);
- };
- /**
- * Used to figure out which element was clicked before sending the event to
- * the foundation.
- */
- MDCList.prototype.handleClickEvent = function (evt) {
- var index = this.getListItemIndex(evt.target);
- var target = evt.target;
- this.foundation.handleClick(index, ponyfill_1.matches(target, constants_1.strings.CHECKBOX_RADIO_SELECTOR), evt);
- };
- return MDCList;
- }(component_1.MDCComponent);
- exports.MDCList = MDCList;
- /***/ }),
- /***/ "./packages/mdc-list/constants.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-list/constants.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var _a, _b;
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.evolutionClassNameMap = exports.evolutionAttribute = exports.deprecatedClassNameMap = exports.numbers = exports.cssClasses = exports.strings = void 0;
- var cssClasses = {
- LIST_ITEM_ACTIVATED_CLASS: 'mdc-list-item--activated',
- LIST_ITEM_CLASS: 'mdc-list-item',
- LIST_ITEM_DISABLED_CLASS: 'mdc-list-item--disabled',
- LIST_ITEM_SELECTED_CLASS: 'mdc-list-item--selected',
- LIST_ITEM_TEXT_CLASS: 'mdc-list-item__text',
- LIST_ITEM_PRIMARY_TEXT_CLASS: 'mdc-list-item__primary-text',
- ROOT: 'mdc-list'
- };
- exports.cssClasses = cssClasses;
- 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);
- exports.evolutionClassNameMap = evolutionClassNameMap;
- 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);
- exports.deprecatedClassNameMap = deprecatedClassNameMap;
- var strings = {
- ACTION_EVENT: 'MDCList:action',
- SELECTION_CHANGE_EVENT: 'MDCList:selectionChange',
- ARIA_CHECKED: 'aria-checked',
- ARIA_CHECKED_CHECKBOX_SELECTOR: '[role="checkbox"][aria-checked="true"]',
- ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]',
- ARIA_CURRENT: 'aria-current',
- ARIA_DISABLED: 'aria-disabled',
- ARIA_ORIENTATION: 'aria-orientation',
- ARIA_ORIENTATION_HORIZONTAL: 'horizontal',
- ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]',
- ARIA_SELECTED: 'aria-selected',
- ARIA_INTERACTIVE_ROLES_SELECTOR: '[role="listbox"], [role="menu"]',
- ARIA_MULTI_SELECTABLE_SELECTOR: '[aria-multiselectable="true"]',
- CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"], input[type="radio"]',
- CHECKBOX_SELECTOR: 'input[type="checkbox"]',
- 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 ",
- DEPRECATED_SELECTOR: '.mdc-deprecated-list',
- 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 ",
- RADIO_SELECTOR: 'input[type="radio"]',
- SELECTED_ITEM_SELECTOR: '[aria-selected="true"], [aria-current="true"]'
- };
- exports.strings = strings;
- var numbers = {
- UNSET_INDEX: -1,
- TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS: 300
- };
- exports.numbers = numbers;
- var evolutionAttribute = 'evolution';
- exports.evolutionAttribute = evolutionAttribute;
- /***/ }),
- /***/ "./packages/mdc-list/events.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-list/events.ts ***!
- \*************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.preventDefaultEvent = void 0;
- var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select'];
- /**
- * Ensures that preventDefault is only called if the containing element
- * doesn't consume the event, and it will cause an unintended scroll.
- *
- * @param evt keyboard event to be prevented.
- */
- var preventDefaultEvent = function preventDefaultEvent(evt) {
- var target = evt.target;
- if (!target) {
- return;
- }
- var tagName = ("" + target.tagName).toLowerCase();
- if (ELEMENTS_KEY_ALLOWED_IN.indexOf(tagName) === -1) {
- evt.preventDefault();
- }
- };
- exports.preventDefaultEvent = preventDefaultEvent;
- /***/ }),
- /***/ "./packages/mdc-list/foundation.ts":
- /*!*****************************************!*\
- !*** ./packages/mdc-list/foundation.ts ***!
- \*****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function get() {
- return m[k];
- } });
- } : function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- } : function (o, v) {
- o["default"] = v;
- });
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- }__setModuleDefault(result, mod);
- return result;
- };
- var __read = this && this.__read || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o),
- r,
- ar = [],
- e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
- ar.push(r.value);
- }
- } catch (error) {
- e = { error: error };
- } finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- } finally {
- if (e) throw e.error;
- }
- }
- return ar;
- };
- var __spreadArray = this && this.__spreadArray || function (to, from) {
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
- to[j] = from[i];
- }return to;
- };
- var __values = this && this.__values || function (o) {
- var s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCListFoundation = void 0;
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
- var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
- var typeahead = __importStar(__webpack_require__(/*! ./typeahead */ "./packages/mdc-list/typeahead.ts"));
- function isNumberArray(selectedIndex) {
- return selectedIndex instanceof Array;
- }
- /** List of modifier keys to consider while handling keyboard events. */
- var handledModifierKeys = ['Alt', 'Control', 'Meta', 'Shift'];
- /** Checks if the event has the given modifier keys. */
- function createModifierChecker(event) {
- var eventModifiers = new Set(event ? handledModifierKeys.filter(function (m) {
- return event.getModifierState(m);
- }) : []);
- return function (modifiers) {
- return modifiers.every(function (m) {
- return eventModifiers.has(m);
- }) && modifiers.length === eventModifiers.size;
- };
- }
- /** MDC List Foundation */
- var MDCListFoundation = /** @class */function (_super) {
- __extends(MDCListFoundation, _super);
- function MDCListFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCListFoundation.defaultAdapter), adapter)) || this;
- _this.wrapFocus = false;
- _this.isVertical = true;
- _this.isSingleSelectionList = false;
- _this.areDisabledItemsFocusable = false;
- _this.selectedIndex = constants_1.numbers.UNSET_INDEX;
- _this.focusedItemIndex = constants_1.numbers.UNSET_INDEX;
- _this.useActivatedClass = false;
- _this.useSelectedAttr = false;
- _this.ariaCurrentAttrValue = null;
- _this.isCheckboxList = false;
- _this.isRadioList = false;
- _this.lastSelectedIndex = null;
- _this.hasTypeahead = false;
- // Transiently holds current typeahead prefix from user.
- _this.typeaheadState = typeahead.initState();
- _this.sortedIndexByFirstChar = new Map();
- return _this;
- }
- Object.defineProperty(MDCListFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCListFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCListFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCListFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClassForElementIndex: function addClassForElementIndex() {
- return undefined;
- },
- focusItemAtIndex: function focusItemAtIndex() {
- return undefined;
- },
- getAttributeForElementIndex: function getAttributeForElementIndex() {
- return null;
- },
- getFocusedElementIndex: function getFocusedElementIndex() {
- return 0;
- },
- getListItemCount: function getListItemCount() {
- return 0;
- },
- hasCheckboxAtIndex: function hasCheckboxAtIndex() {
- return false;
- },
- hasRadioAtIndex: function hasRadioAtIndex() {
- return false;
- },
- isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex() {
- return false;
- },
- isFocusInsideList: function isFocusInsideList() {
- return false;
- },
- isRootFocused: function isRootFocused() {
- return false;
- },
- listItemAtIndexHasClass: function listItemAtIndexHasClass() {
- return false;
- },
- notifyAction: function notifyAction() {
- return undefined;
- },
- notifySelectionChange: function notifySelectionChange() {},
- removeClassForElementIndex: function removeClassForElementIndex() {
- return undefined;
- },
- setAttributeForElementIndex: function setAttributeForElementIndex() {
- return undefined;
- },
- setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex() {
- return undefined;
- },
- setTabIndexForListItemChildren: function setTabIndexForListItemChildren() {
- return undefined;
- },
- getPrimaryTextAtIndex: function getPrimaryTextAtIndex() {
- return '';
- }
- };
- },
- enumerable: false,
- configurable: true
- });
- MDCListFoundation.prototype.layout = function () {
- if (this.adapter.getListItemCount() === 0) {
- return;
- }
- // TODO(b/172274142): consider all items when determining the list's type.
- if (this.adapter.hasCheckboxAtIndex(0)) {
- this.isCheckboxList = true;
- this.selectedIndex = [];
- } else if (this.adapter.hasRadioAtIndex(0)) {
- this.isRadioList = true;
- } else {
- this.maybeInitializeSingleSelection();
- }
- if (this.hasTypeahead) {
- this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
- }
- };
- /** Returns the index of the item that was last focused. */
- MDCListFoundation.prototype.getFocusedItemIndex = function () {
- return this.focusedItemIndex;
- };
- /** Toggles focus wrapping with keyboard navigation. */
- MDCListFoundation.prototype.setWrapFocus = function (value) {
- this.wrapFocus = value;
- };
- /**
- * Toggles orientation direction for keyboard navigation (true for vertical,
- * false for horizontal).
- */
- MDCListFoundation.prototype.setVerticalOrientation = function (value) {
- this.isVertical = value;
- };
- /** Toggles single-selection behavior. */
- MDCListFoundation.prototype.setSingleSelection = function (value) {
- this.isSingleSelectionList = value;
- if (value) {
- this.maybeInitializeSingleSelection();
- this.selectedIndex = this.getSelectedIndexFromDOM();
- }
- };
- MDCListFoundation.prototype.setDisabledItemsFocusable = function (value) {
- this.areDisabledItemsFocusable = value;
- };
- /**
- * Automatically determines whether the list is single selection list. If so,
- * initializes the internal state to match the selected item.
- */
- MDCListFoundation.prototype.maybeInitializeSingleSelection = function () {
- var selectedItemIndex = this.getSelectedIndexFromDOM();
- if (selectedItemIndex === constants_1.numbers.UNSET_INDEX) return;
- var hasActivatedClass = this.adapter.listItemAtIndexHasClass(selectedItemIndex, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
- if (hasActivatedClass) {
- this.setUseActivatedClass(true);
- }
- this.isSingleSelectionList = true;
- this.selectedIndex = selectedItemIndex;
- };
- /** @return Index of the first selected item based on the DOM state. */
- MDCListFoundation.prototype.getSelectedIndexFromDOM = function () {
- var selectedIndex = constants_1.numbers.UNSET_INDEX;
- var listItemsCount = this.adapter.getListItemCount();
- for (var i = 0; i < listItemsCount; i++) {
- var hasSelectedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS);
- var hasActivatedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
- if (!(hasSelectedClass || hasActivatedClass)) {
- continue;
- }
- selectedIndex = i;
- break;
- }
- return selectedIndex;
- };
- /**
- * Sets whether typeahead is enabled on the list.
- * @param hasTypeahead Whether typeahead is enabled.
- */
- MDCListFoundation.prototype.setHasTypeahead = function (hasTypeahead) {
- this.hasTypeahead = hasTypeahead;
- if (hasTypeahead) {
- this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
- }
- };
- /**
- * @return Whether typeahead is currently matching a user-specified prefix.
- */
- MDCListFoundation.prototype.isTypeaheadInProgress = function () {
- return this.hasTypeahead && typeahead.isTypingInProgress(this.typeaheadState);
- };
- /** Toggle use of the "activated" CSS class. */
- MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) {
- this.useActivatedClass = useActivated;
- };
- /**
- * Toggles use of the selected attribute (true for aria-selected, false for
- * aria-checked).
- */
- MDCListFoundation.prototype.setUseSelectedAttribute = function (useSelected) {
- this.useSelectedAttr = useSelected;
- };
- MDCListFoundation.prototype.getSelectedIndex = function () {
- return this.selectedIndex;
- };
- MDCListFoundation.prototype.setSelectedIndex = function (index, options) {
- if (options === void 0) {
- options = {};
- }
- if (!this.isIndexValid(index)) {
- return;
- }
- if (this.isCheckboxList) {
- this.setCheckboxAtIndex(index, options);
- } else if (this.isRadioList) {
- this.setRadioAtIndex(index, options);
- } else {
- this.setSingleSelectionAtIndex(index, options);
- }
- };
- /**
- * Focus in handler for the list items.
- */
- MDCListFoundation.prototype.handleFocusIn = function (listItemIndex) {
- if (listItemIndex >= 0) {
- this.focusedItemIndex = listItemIndex;
- this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '0');
- this.adapter.setTabIndexForListItemChildren(listItemIndex, '0');
- }
- };
- /**
- * Focus out handler for the list items.
- */
- MDCListFoundation.prototype.handleFocusOut = function (listItemIndex) {
- var _this = this;
- if (listItemIndex >= 0) {
- this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '-1');
- this.adapter.setTabIndexForListItemChildren(listItemIndex, '-1');
- }
- /**
- * Between Focusout & Focusin some browsers do not have focus on any
- * element. Setting a delay to wait till the focus is moved to next element.
- */
- setTimeout(function () {
- if (!_this.adapter.isFocusInsideList()) {
- _this.setTabindexToFirstSelectedOrFocusedItem();
- }
- }, 0);
- };
- MDCListFoundation.prototype.isIndexDisabled = function (index) {
- return this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
- };
- /**
- * Key handler for the list.
- */
- MDCListFoundation.prototype.handleKeydown = function (event, isRootListItem, listItemIndex) {
- var _this = this;
- var _a;
- var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
- var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
- var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
- var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
- var isHome = keyboard_1.normalizeKey(event) === 'Home';
- var isEnd = keyboard_1.normalizeKey(event) === 'End';
- var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
- var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
- // The keys for forward and back differ based on list orientation.
- var isForward = this.isVertical && isArrowDown || !this.isVertical && isArrowRight;
- var isBack = this.isVertical && isArrowUp || !this.isVertical && isArrowLeft;
- // Have to check both upper and lower case, because having caps lock on
- // affects the value.
- var isLetterA = event.key === 'A' || event.key === 'a';
- var eventHasModifiers = createModifierChecker(event);
- if (this.adapter.isRootFocused()) {
- if ((isBack || isEnd) && eventHasModifiers([])) {
- event.preventDefault();
- this.focusLastElement();
- } else if ((isForward || isHome) && eventHasModifiers([])) {
- event.preventDefault();
- this.focusFirstElement();
- } else if (isBack && eventHasModifiers(['Shift']) && this.isCheckboxList) {
- event.preventDefault();
- var focusedIndex = this.focusLastElement();
- if (focusedIndex !== -1) {
- this.setSelectedIndexOnAction(focusedIndex, false);
- }
- } else if (isForward && eventHasModifiers(['Shift']) && this.isCheckboxList) {
- event.preventDefault();
- var focusedIndex = this.focusFirstElement();
- if (focusedIndex !== -1) {
- this.setSelectedIndexOnAction(focusedIndex, false);
- }
- }
- if (this.hasTypeahead) {
- var handleKeydownOpts = {
- event: event,
- focusItemAtIndex: function focusItemAtIndex(index) {
- _this.focusItemAtIndex(index);
- },
- focusedItemIndex: -1,
- isTargetListItem: isRootListItem,
- sortedIndexByFirstChar: this.sortedIndexByFirstChar,
- isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
- return _this.isIndexDisabled(index);
- }
- };
- typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
- }
- return;
- }
- var currentIndex = this.adapter.getFocusedElementIndex();
- if (currentIndex === -1) {
- currentIndex = listItemIndex;
- if (currentIndex < 0) {
- // If this event doesn't have a mdc-list-item ancestor from the
- // current list (not from a sublist), return early.
- return;
- }
- }
- if (isForward && eventHasModifiers([])) {
- events_1.preventDefaultEvent(event);
- this.focusNextElement(currentIndex);
- } else if (isBack && eventHasModifiers([])) {
- events_1.preventDefaultEvent(event);
- this.focusPrevElement(currentIndex);
- } else if (isForward && eventHasModifiers(['Shift']) && this.isCheckboxList) {
- events_1.preventDefaultEvent(event);
- var focusedIndex = this.focusNextElement(currentIndex);
- if (focusedIndex !== -1) {
- this.setSelectedIndexOnAction(focusedIndex, false);
- }
- } else if (isBack && eventHasModifiers(['Shift']) && this.isCheckboxList) {
- events_1.preventDefaultEvent(event);
- var focusedIndex = this.focusPrevElement(currentIndex);
- if (focusedIndex !== -1) {
- this.setSelectedIndexOnAction(focusedIndex, false);
- }
- } else if (isHome && eventHasModifiers([])) {
- events_1.preventDefaultEvent(event);
- this.focusFirstElement();
- } else if (isEnd && eventHasModifiers([])) {
- events_1.preventDefaultEvent(event);
- this.focusLastElement();
- } else if (isHome && eventHasModifiers(['Control', 'Shift']) && this.isCheckboxList) {
- events_1.preventDefaultEvent(event);
- if (this.isIndexDisabled(currentIndex)) {
- return;
- }
- this.focusFirstElement();
- this.toggleCheckboxRange(0, currentIndex, currentIndex);
- } else if (isEnd && eventHasModifiers(['Control', 'Shift']) && this.isCheckboxList) {
- events_1.preventDefaultEvent(event);
- if (this.isIndexDisabled(currentIndex)) {
- return;
- }
- this.focusLastElement();
- this.toggleCheckboxRange(currentIndex, this.adapter.getListItemCount() - 1, currentIndex);
- } else if (isLetterA && eventHasModifiers(['Control']) && this.isCheckboxList) {
- event.preventDefault();
- this.checkboxListToggleAll(this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex, true);
- } else if ((isEnter || isSpace) && (eventHasModifiers([]) || eventHasModifiers(['Alt']))) {
- if (isRootListItem) {
- // Return early if enter key is pressed on anchor element which triggers
- // synthetic MouseEvent event.
- var target = event.target;
- if (target && target.tagName === 'A' && isEnter) {
- return;
- }
- events_1.preventDefaultEvent(event);
- if (this.isIndexDisabled(currentIndex)) {
- return;
- }
- if (!this.isTypeaheadInProgress()) {
- if (this.isSelectableList()) {
- this.setSelectedIndexOnAction(currentIndex, false);
- }
- this.adapter.notifyAction(currentIndex);
- }
- }
- } else if ((isEnter || isSpace) && eventHasModifiers(['Shift']) && this.isCheckboxList) {
- // Return early if enter key is pressed on anchor element which triggers
- // synthetic MouseEvent event.
- var target = event.target;
- if (target && target.tagName === 'A' && isEnter) {
- return;
- }
- events_1.preventDefaultEvent(event);
- if (this.isIndexDisabled(currentIndex)) {
- return;
- }
- if (!this.isTypeaheadInProgress()) {
- this.toggleCheckboxRange((_a = this.lastSelectedIndex) !== null && _a !== void 0 ? _a : currentIndex, currentIndex, currentIndex);
- this.adapter.notifyAction(currentIndex);
- }
- }
- if (this.hasTypeahead) {
- var handleKeydownOpts = {
- event: event,
- focusItemAtIndex: function focusItemAtIndex(index) {
- _this.focusItemAtIndex(index);
- },
- focusedItemIndex: this.focusedItemIndex,
- isTargetListItem: isRootListItem,
- sortedIndexByFirstChar: this.sortedIndexByFirstChar,
- isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
- return _this.isIndexDisabled(index);
- }
- };
- typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
- }
- };
- /**
- * Click handler for the list.
- *
- * @param index Index for the item that has been clicked.
- * @param isCheckboxAlreadyUpdatedInAdapter Whether the checkbox for
- * the list item has already been updated in the adapter. This attribute
- * should be set to `true` when e.g. the click event directly landed on
- * the underlying native checkbox element which would cause the checked
- * state to be already toggled within `adapter.isCheckboxCheckedAtIndex`.
- */
- MDCListFoundation.prototype.handleClick = function (index, isCheckboxAlreadyUpdatedInAdapter, event) {
- var _a;
- var eventHasModifiers = createModifierChecker(event);
- if (index === constants_1.numbers.UNSET_INDEX) {
- return;
- }
- if (this.isIndexDisabled(index)) {
- return;
- }
- if (eventHasModifiers([])) {
- if (this.isSelectableList()) {
- this.setSelectedIndexOnAction(index, isCheckboxAlreadyUpdatedInAdapter);
- }
- this.adapter.notifyAction(index);
- } else if (this.isCheckboxList && eventHasModifiers(['Shift'])) {
- this.toggleCheckboxRange((_a = this.lastSelectedIndex) !== null && _a !== void 0 ? _a : index, index, index);
- this.adapter.notifyAction(index);
- }
- };
- /**
- * Focuses the next element on the list.
- */
- MDCListFoundation.prototype.focusNextElement = function (index) {
- var count = this.adapter.getListItemCount();
- var nextIndex = index;
- var firstChecked = null;
- do {
- nextIndex++;
- if (nextIndex >= count) {
- if (this.wrapFocus) {
- nextIndex = 0;
- } else {
- // Return early because last item is already focused.
- return index;
- }
- }
- if (nextIndex === firstChecked) {
- return -1;
- }
- firstChecked = firstChecked !== null && firstChecked !== void 0 ? firstChecked : nextIndex;
- } while (!this.areDisabledItemsFocusable && this.isIndexDisabled(nextIndex));
- this.focusItemAtIndex(nextIndex);
- return nextIndex;
- };
- /**
- * Focuses the previous element on the list.
- */
- MDCListFoundation.prototype.focusPrevElement = function (index) {
- var count = this.adapter.getListItemCount();
- var prevIndex = index;
- var firstChecked = null;
- do {
- prevIndex--;
- if (prevIndex < 0) {
- if (this.wrapFocus) {
- prevIndex = count - 1;
- } else {
- // Return early because first item is already focused.
- return index;
- }
- }
- if (prevIndex === firstChecked) {
- return -1;
- }
- firstChecked = firstChecked !== null && firstChecked !== void 0 ? firstChecked : prevIndex;
- } while (!this.areDisabledItemsFocusable && this.isIndexDisabled(prevIndex));
- this.focusItemAtIndex(prevIndex);
- return prevIndex;
- };
- MDCListFoundation.prototype.focusFirstElement = function () {
- // Pass -1 to `focusNextElement`, since it will incremement to 0 and focus
- // the first element.
- return this.focusNextElement(-1);
- };
- MDCListFoundation.prototype.focusLastElement = function () {
- // Pass the length of the list to `focusNextElement` since it will decrement
- // to length - 1 and focus the last element.
- return this.focusPrevElement(this.adapter.getListItemCount());
- };
- MDCListFoundation.prototype.focusInitialElement = function () {
- var initialIndex = this.getFirstSelectedOrFocusedItemIndex();
- if (initialIndex !== constants_1.numbers.UNSET_INDEX) {
- this.focusItemAtIndex(initialIndex);
- }
- return initialIndex;
- };
- /**
- * @param itemIndex Index of the list item
- * @param isEnabled Sets the list item to enabled or disabled.
- */
- MDCListFoundation.prototype.setEnabled = function (itemIndex, isEnabled) {
- if (!this.isIndexValid(itemIndex, false)) {
- return;
- }
- if (isEnabled) {
- this.adapter.removeClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
- this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'false');
- } else {
- this.adapter.addClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
- this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'true');
- }
- };
- MDCListFoundation.prototype.setSingleSelectionAtIndex = function (index, options) {
- if (options === void 0) {
- options = {};
- }
- if (this.selectedIndex === index && !options.forceUpdate) {
- return;
- }
- var selectedClassName = constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS;
- if (this.useActivatedClass) {
- selectedClassName = constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS;
- }
- if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
- this.adapter.removeClassForElementIndex(this.selectedIndex, selectedClassName);
- }
- this.setAriaForSingleSelectionAtIndex(index);
- this.setTabindexAtIndex(index);
- if (index !== constants_1.numbers.UNSET_INDEX) {
- this.adapter.addClassForElementIndex(index, selectedClassName);
- }
- this.selectedIndex = index;
- // If the selected value has changed through user interaction,
- // we want to notify the selection change to the adapter.
- if (options.isUserInteraction && !options.forceUpdate) {
- this.adapter.notifySelectionChange([index]);
- }
- };
- /**
- * Sets aria attribute for single selection at given index.
- */
- MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex = function (index) {
- // Detect the presence of aria-current and get the value only during list
- // initialization when it is in unset state.
- if (this.selectedIndex === constants_1.numbers.UNSET_INDEX && index !== constants_1.numbers.UNSET_INDEX) {
- this.ariaCurrentAttrValue = this.adapter.getAttributeForElementIndex(index, constants_1.strings.ARIA_CURRENT);
- }
- var isAriaCurrent = this.ariaCurrentAttrValue !== null;
- var ariaAttribute = isAriaCurrent ? constants_1.strings.ARIA_CURRENT : constants_1.strings.ARIA_SELECTED;
- if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
- this.adapter.setAttributeForElementIndex(this.selectedIndex, ariaAttribute, 'false');
- }
- if (index !== constants_1.numbers.UNSET_INDEX) {
- var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue : 'true';
- this.adapter.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
- }
- };
- /**
- * Returns the attribute to use for indicating selection status.
- */
- MDCListFoundation.prototype.getSelectionAttribute = function () {
- return this.useSelectedAttr ? constants_1.strings.ARIA_SELECTED : constants_1.strings.ARIA_CHECKED;
- };
- /**
- * Toggles radio at give index. Radio doesn't change the checked state if it
- * is already checked.
- */
- MDCListFoundation.prototype.setRadioAtIndex = function (index, options) {
- if (options === void 0) {
- options = {};
- }
- var selectionAttribute = this.getSelectionAttribute();
- this.adapter.setCheckedCheckboxOrRadioAtIndex(index, true);
- if (this.selectedIndex === index && !options.forceUpdate) {
- return;
- }
- if (this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
- this.adapter.setAttributeForElementIndex(this.selectedIndex, selectionAttribute, 'false');
- }
- this.adapter.setAttributeForElementIndex(index, selectionAttribute, 'true');
- this.selectedIndex = index;
- // If the selected value has changed through user interaction,
- // we want to notify the selection change to the adapter.
- if (options.isUserInteraction && !options.forceUpdate) {
- this.adapter.notifySelectionChange([index]);
- }
- };
- MDCListFoundation.prototype.setCheckboxAtIndex = function (indices, options) {
- if (options === void 0) {
- options = {};
- }
- var currentIndex = this.selectedIndex;
- // If this update is not triggered by a user interaction, we do not
- // need to know about the currently selected indices and can avoid
- // constructing the `Set` for performance reasons.
- var currentlySelected = options.isUserInteraction ? new Set(currentIndex === constants_1.numbers.UNSET_INDEX ? [] : currentIndex) : null;
- var selectionAttribute = this.getSelectionAttribute();
- var changedIndices = [];
- for (var i = 0; i < this.adapter.getListItemCount(); i++) {
- if (options.omitDisabledItems && this.isIndexDisabled(i)) {
- continue;
- }
- var previousIsChecked = currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.has(i);
- var newIsChecked = indices.indexOf(i) >= 0;
- // If the selection has changed for this item, we keep track of it
- // so that we can notify the adapter.
- if (newIsChecked !== previousIsChecked) {
- changedIndices.push(i);
- }
- this.adapter.setCheckedCheckboxOrRadioAtIndex(i, newIsChecked);
- this.adapter.setAttributeForElementIndex(i, selectionAttribute, newIsChecked ? 'true' : 'false');
- }
- this.selectedIndex = options.omitDisabledItems ? this.resolveSelectedIndices(indices) : indices;
- // If the selected value has changed through user interaction,
- // we want to notify the selection change to the adapter.
- if (options.isUserInteraction && changedIndices.length) {
- this.adapter.notifySelectionChange(changedIndices);
- }
- };
- /**
- * Helper method for ensuring that the list of selected indices remains
- * accurate when calling setCheckboxAtIndex with omitDisabledItems set to
- * true.
- */
- MDCListFoundation.prototype.resolveSelectedIndices = function (setCheckedItems) {
- var _this = this;
- var currentlySelectedItems = this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex;
- var currentlySelectedDisabledItems = currentlySelectedItems.filter(function (i) {
- return _this.isIndexDisabled(i);
- });
- var enabledSetCheckedItems = setCheckedItems.filter(function (i) {
- return !_this.isIndexDisabled(i);
- });
- // Updated selectedIndex should be the enabled setCheckedItems + any missing
- // selected disabled items.
- var updatedSelectedItems = __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(enabledSetCheckedItems)), __read(currentlySelectedDisabledItems)))));
- return updatedSelectedItems.sort(function (a, b) {
- return a - b;
- });
- };
- /**
- * Toggles the state of all checkboxes in the given range (inclusive) based
- * on the state of the checkbox at the `toggleIndex`. To determine whether
- * to set the given range to checked or unchecked, read the value of the
- * checkbox at the `toggleIndex` and negate it. Then apply that new checked
- * state to all checkboxes in the range.
- * @param fromIndex The start of the range of checkboxes to toggle
- * @param toIndex The end of the range of checkboxes to toggle
- * @param toggleIndex The index that will be used to determine the new state
- * of the given checkbox range.
- */
- MDCListFoundation.prototype.toggleCheckboxRange = function (fromIndex, toIndex, toggleIndex) {
- this.lastSelectedIndex = toggleIndex;
- var currentlySelected = new Set(this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex);
- var newIsChecked = !(currentlySelected === null || currentlySelected === void 0 ? void 0 : currentlySelected.has(toggleIndex));
- var _a = __read([fromIndex, toIndex].sort(), 2),
- startIndex = _a[0],
- endIndex = _a[1];
- var selectionAttribute = this.getSelectionAttribute();
- var changedIndices = [];
- for (var i = startIndex; i <= endIndex; i++) {
- if (this.isIndexDisabled(i)) {
- continue;
- }
- var previousIsChecked = currentlySelected.has(i);
- // If the selection has changed for this item, we keep track of it
- // so that we can notify the adapter.
- if (newIsChecked !== previousIsChecked) {
- changedIndices.push(i);
- this.adapter.setCheckedCheckboxOrRadioAtIndex(i, newIsChecked);
- this.adapter.setAttributeForElementIndex(i, selectionAttribute, "" + newIsChecked);
- if (newIsChecked) {
- currentlySelected.add(i);
- } else {
- currentlySelected.delete(i);
- }
- }
- }
- // If the selected value has changed, update and notify the selection
- // change to the adapter.
- if (changedIndices.length) {
- this.selectedIndex = __spreadArray([], __read(currentlySelected));
- this.adapter.notifySelectionChange(changedIndices);
- }
- };
- MDCListFoundation.prototype.setTabindexAtIndex = function (index) {
- if (this.focusedItemIndex === constants_1.numbers.UNSET_INDEX && index !== 0 && index !== constants_1.numbers.UNSET_INDEX) {
- // If some list item was selected set first list item's tabindex to -1.
- // Generally, tabindex is set to 0 on first list item of list that has
- // no preselected items.
- this.adapter.setAttributeForElementIndex(0, 'tabindex', '-1');
- } else if (this.focusedItemIndex >= 0 && this.focusedItemIndex !== index) {
- this.adapter.setAttributeForElementIndex(this.focusedItemIndex, 'tabindex', '-1');
- }
- // Set the previous selection's tabindex to -1. We need this because
- // in selection menus that are not visible, programmatically setting an
- // option will not change focus but will change where tabindex should be
- // 0.
- if (!(this.selectedIndex instanceof Array) && this.selectedIndex !== index && this.focusedItemIndex !== constants_1.numbers.UNSET_INDEX) {
- this.adapter.setAttributeForElementIndex(this.selectedIndex, 'tabindex', '-1');
- }
- if (index !== constants_1.numbers.UNSET_INDEX) {
- this.adapter.setAttributeForElementIndex(index, 'tabindex', '0');
- }
- };
- /**
- * @return Return true if it is single selectin list, checkbox list or radio
- * list.
- */
- MDCListFoundation.prototype.isSelectableList = function () {
- return this.isSingleSelectionList || this.isCheckboxList || this.isRadioList;
- };
- MDCListFoundation.prototype.setTabindexToFirstSelectedOrFocusedItem = function () {
- var targetIndex = this.getFirstSelectedOrFocusedItemIndex();
- this.setTabindexAtIndex(targetIndex);
- };
- MDCListFoundation.prototype.getFirstSelectedOrFocusedItemIndex = function () {
- var e_1, _a;
- var firstFocusableListItem = this.getFirstEnabledItem();
- if (this.adapter.getListItemCount() === 0) {
- return constants_1.numbers.UNSET_INDEX;
- }
- // Action lists retain focus on the most recently focused item.
- if (!this.isSelectableList()) {
- return Math.max(this.focusedItemIndex, firstFocusableListItem);
- }
- // Single-selection lists focus the selected item.
- if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
- return this.areDisabledItemsFocusable && this.isIndexDisabled(this.selectedIndex) ? firstFocusableListItem : this.selectedIndex;
- }
- // Multiple-selection lists focus the first enabled selected item.
- if (isNumberArray(this.selectedIndex) && this.selectedIndex.length > 0) {
- var sorted = __spreadArray([], __read(this.selectedIndex)).sort(function (a, b) {
- return a - b;
- });
- try {
- for (var sorted_1 = __values(sorted), sorted_1_1 = sorted_1.next(); !sorted_1_1.done; sorted_1_1 = sorted_1.next()) {
- var index = sorted_1_1.value;
- if (this.isIndexDisabled(index) && !this.areDisabledItemsFocusable) {
- continue;
- } else {
- return index;
- }
- }
- } catch (e_1_1) {
- e_1 = { error: e_1_1 };
- } finally {
- try {
- if (sorted_1_1 && !sorted_1_1.done && (_a = sorted_1.return)) _a.call(sorted_1);
- } finally {
- if (e_1) throw e_1.error;
- }
- }
- }
- // Selection lists without a selection focus the first item.
- return firstFocusableListItem;
- };
- MDCListFoundation.prototype.getFirstEnabledItem = function () {
- var listSize = this.adapter.getListItemCount();
- var i = 0;
- while (i < listSize) {
- if (!this.isIndexDisabled(i)) {
- break;
- }
- i++;
- }
- return i === listSize ? constants_1.numbers.UNSET_INDEX : i;
- };
- MDCListFoundation.prototype.isIndexValid = function (index, validateListType) {
- var _this = this;
- if (validateListType === void 0) {
- validateListType = true;
- }
- if (index instanceof Array) {
- if (!this.isCheckboxList && validateListType) {
- throw new Error('MDCListFoundation: Array of index is only supported for checkbox based list');
- }
- if (index.length === 0) {
- return true;
- } else {
- return index.some(function (i) {
- return _this.isIndexInRange(i);
- });
- }
- } else if (typeof index === 'number') {
- if (this.isCheckboxList && validateListType) {
- throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: " + index);
- }
- return this.isIndexInRange(index) || this.isSingleSelectionList && index === constants_1.numbers.UNSET_INDEX;
- } else {
- return false;
- }
- };
- MDCListFoundation.prototype.isIndexInRange = function (index) {
- var listSize = this.adapter.getListItemCount();
- return index >= 0 && index < listSize;
- };
- /**
- * Sets selected index on user action, toggles checkboxes in checkbox lists
- * by default, unless `isCheckboxAlreadyUpdatedInAdapter` is set to `true`.
- *
- * In cases where `isCheckboxAlreadyUpdatedInAdapter` is set to `true`, the
- * UI is just updated to reflect the value returned by the adapter.
- *
- * When calling this, make sure user interaction does not toggle disabled
- * list items.
- */
- MDCListFoundation.prototype.setSelectedIndexOnAction = function (index, isCheckboxAlreadyUpdatedInAdapter) {
- this.lastSelectedIndex = index;
- if (this.isCheckboxList) {
- this.toggleCheckboxAtIndex(index, isCheckboxAlreadyUpdatedInAdapter);
- this.adapter.notifySelectionChange([index]);
- } else {
- this.setSelectedIndex(index, { isUserInteraction: true });
- }
- };
- MDCListFoundation.prototype.toggleCheckboxAtIndex = function (index, isCheckboxAlreadyUpdatedInAdapter) {
- var selectionAttribute = this.getSelectionAttribute();
- var adapterIsChecked = this.adapter.isCheckboxCheckedAtIndex(index);
- // By default the checked value from the adapter is toggled unless the
- // checked state in the adapter has already been updated beforehand.
- // This can be happen when the underlying native checkbox has already
- // been updated through the native click event.
- var newCheckedValue;
- if (isCheckboxAlreadyUpdatedInAdapter) {
- newCheckedValue = adapterIsChecked;
- } else {
- newCheckedValue = !adapterIsChecked;
- this.adapter.setCheckedCheckboxOrRadioAtIndex(index, newCheckedValue);
- }
- this.adapter.setAttributeForElementIndex(index, selectionAttribute, newCheckedValue ? 'true' : 'false');
- // If none of the checkbox items are selected and selectedIndex is not
- // initialized then provide a default value.
- var selectedIndexes = this.selectedIndex === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex.slice();
- if (newCheckedValue) {
- selectedIndexes.push(index);
- } else {
- selectedIndexes = selectedIndexes.filter(function (i) {
- return i !== index;
- });
- }
- this.selectedIndex = selectedIndexes;
- };
- MDCListFoundation.prototype.focusItemAtIndex = function (index) {
- this.adapter.focusItemAtIndex(index);
- this.focusedItemIndex = index;
- };
- MDCListFoundation.prototype.getEnabledListItemCount = function () {
- var listSize = this.adapter.getListItemCount();
- var adjustedCount = 0;
- for (var i = 0; i < listSize; i++) {
- if (!this.isIndexDisabled(i)) {
- adjustedCount++;
- }
- }
- return adjustedCount;
- };
- MDCListFoundation.prototype.checkboxListToggleAll = function (currentlySelectedIndices, isUserInteraction) {
- var _this = this;
- var enabledListItemCount = this.getEnabledListItemCount();
- var totalListItemCount = this.adapter.getListItemCount();
- var currentlyEnabledSelectedIndices = currentlySelectedIndices.filter(function (i) {
- return !_this.isIndexDisabled(i);
- });
- // If all items are selected, deselect everything.
- // We check >= rather than === to `enabledListItemCount` since a disabled
- // item could be selected, and we don't take that into consideration when
- // toggling the other checkbox values.
- if (currentlyEnabledSelectedIndices.length >= enabledListItemCount) {
- // Use omitDisabledItems option to ensure disabled selected items are not
- // de-selected.
- this.setCheckboxAtIndex([], { isUserInteraction: isUserInteraction, omitDisabledItems: true });
- } else {
- // Otherwise select all enabled options.
- var allIndexes = [];
- for (var i = 0; i < totalListItemCount; i++) {
- if (!this.isIndexDisabled(i) || currentlySelectedIndices.indexOf(i) > -1) {
- allIndexes.push(i);
- }
- }
- // Use omitDisabledItems option to ensure disabled selected items are not
- // de-selected.
- this.setCheckboxAtIndex(allIndexes, { isUserInteraction: isUserInteraction, omitDisabledItems: true });
- }
- };
- /**
- * Given the next desired character from the user, adds it to the typeahead
- * buffer. Then, attempts to find the next option matching the buffer. Wraps
- * around if at the end of options.
- *
- * @param nextChar The next character to add to the prefix buffer.
- * @param startingIndex The index from which to start matching. Only
- * relevant when starting a new match sequence. To start a new match
- * sequence, clear the buffer using `clearTypeaheadBuffer`, or wait for
- * the buffer to clear after a set interval defined in list foundation.
- * Defaults to the currently focused index.
- * @return The index of the matched item, or -1 if no match.
- */
- MDCListFoundation.prototype.typeaheadMatchItem = function (nextChar, startingIndex, skipFocus) {
- var _this = this;
- if (skipFocus === void 0) {
- skipFocus = false;
- }
- var opts = {
- focusItemAtIndex: function focusItemAtIndex(index) {
- _this.focusItemAtIndex(index);
- },
- focusedItemIndex: startingIndex ? startingIndex : this.focusedItemIndex,
- nextChar: nextChar,
- sortedIndexByFirstChar: this.sortedIndexByFirstChar,
- skipFocus: skipFocus,
- isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
- return _this.isIndexDisabled(index);
- }
- };
- return typeahead.matchItem(opts, this.typeaheadState);
- };
- /**
- * Initializes the MDCListTextAndIndex data structure by indexing the
- * current list items by primary text.
- *
- * @return The primary texts of all the list items sorted by first
- * character.
- */
- MDCListFoundation.prototype.typeaheadInitSortedIndex = function () {
- return typeahead.initSortedIndex(this.adapter.getListItemCount(), this.adapter.getPrimaryTextAtIndex);
- };
- /**
- * Clears the typeahead buffer.
- */
- MDCListFoundation.prototype.clearTypeaheadBuffer = function () {
- typeahead.clearBuffer(this.typeaheadState);
- };
- return MDCListFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCListFoundation = MDCListFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCListFoundation;
- /***/ }),
- /***/ "./packages/mdc-list/typeahead.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-list/typeahead.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.handleKeydown = exports.clearBuffer = exports.isTypingInProgress = exports.matchItem = exports.initSortedIndex = exports.initState = void 0;
- var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
- var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
- /**
- * Initializes a state object for typeahead. Use the same reference for calls to
- * typeahead functions.
- *
- * @return The current state of the typeahead process. Each state reference
- * represents a typeahead instance as the reference is typically mutated
- * in-place.
- */
- function initState() {
- var state = {
- bufferClearTimeout: 0,
- currentFirstChar: '',
- sortedIndexCursor: 0,
- typeaheadBuffer: ''
- };
- return state;
- }
- exports.initState = initState;
- /**
- * Initializes typeahead state by indexing the current list items by primary
- * text into the sortedIndexByFirstChar data structure.
- *
- * @param listItemCount numer of items in the list
- * @param getPrimaryTextByItemIndex function that returns the primary text at a
- * given index
- *
- * @return Map that maps the first character of the primary text to the full
- * list text and its index
- */
- function initSortedIndex(listItemCount, getPrimaryTextByItemIndex) {
- var sortedIndexByFirstChar = new Map();
- // Aggregate item text to index mapping
- for (var i = 0; i < listItemCount; i++) {
- var primaryText = getPrimaryTextByItemIndex(i).trim();
- if (!primaryText) {
- continue;
- }
- var firstChar = primaryText[0].toLowerCase();
- if (!sortedIndexByFirstChar.has(firstChar)) {
- sortedIndexByFirstChar.set(firstChar, []);
- }
- sortedIndexByFirstChar.get(firstChar).push({ text: primaryText.toLowerCase(), index: i });
- }
- // Sort the mapping
- // TODO(b/157162694): Investigate replacing forEach with Map.values()
- sortedIndexByFirstChar.forEach(function (values) {
- values.sort(function (first, second) {
- return first.index - second.index;
- });
- });
- return sortedIndexByFirstChar;
- }
- exports.initSortedIndex = initSortedIndex;
- /**
- * Given the next desired character from the user, it attempts to find the next
- * list option matching the buffer. Wraps around if at the end of options.
- *
- * @param opts Options and accessors
- * - nextChar - the next character to match against items
- * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
- * - focusedItemIndex - the index of the currently focused item
- * - focusItemAtIndex - function that focuses a list item at given index
- * - skipFocus - whether or not to focus the matched item
- * - isItemAtIndexDisabled - function that determines whether an item at a
- * given index is disabled
- * @param state The typeahead state instance. See `initState`.
- *
- * @return The index of the matched item, or -1 if no match.
- */
- function matchItem(opts, state) {
- var nextChar = opts.nextChar,
- focusItemAtIndex = opts.focusItemAtIndex,
- sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
- focusedItemIndex = opts.focusedItemIndex,
- skipFocus = opts.skipFocus,
- isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
- clearTimeout(state.bufferClearTimeout);
- state.bufferClearTimeout = setTimeout(function () {
- clearBuffer(state);
- }, constants_1.numbers.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS);
- state.typeaheadBuffer = state.typeaheadBuffer + nextChar;
- var index;
- if (state.typeaheadBuffer.length === 1) {
- index = matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state);
- } else {
- index = matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state);
- }
- if (index !== -1 && !skipFocus) {
- focusItemAtIndex(index);
- }
- return index;
- }
- exports.matchItem = matchItem;
- /**
- * Matches the user's single input character in the buffer to the
- * next option that begins with such character. Wraps around if at
- * end of options. Returns -1 if no match is found.
- */
- function matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state) {
- var firstChar = state.typeaheadBuffer[0];
- var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
- if (!itemsMatchingFirstChar) {
- return -1;
- }
- // Has the same firstChar been recently matched?
- // Also, did starting index remain the same between key presses?
- // If both hold true, simply increment index.
- if (firstChar === state.currentFirstChar && itemsMatchingFirstChar[state.sortedIndexCursor].index === focusedItemIndex) {
- state.sortedIndexCursor = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
- var newIndex = itemsMatchingFirstChar[state.sortedIndexCursor].index;
- if (!isItemAtIndexDisabled(newIndex)) {
- return newIndex;
- }
- }
- // If we're here, it means one of the following happened:
- // - either firstChar or startingIndex has changed, invalidating the
- // cursor.
- // - The next item of typeahead is disabled, so we have to look further.
- state.currentFirstChar = firstChar;
- var newCursorPosition = -1;
- var cursorPosition;
- // Find the first non-disabled item as a fallback.
- for (cursorPosition = 0; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
- if (!isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
- newCursorPosition = cursorPosition;
- break;
- }
- }
- // Advance cursor to first item matching the firstChar that is positioned
- // after starting item. Cursor is unchanged from fallback if there's no
- // such item.
- for (; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
- if (itemsMatchingFirstChar[cursorPosition].index > focusedItemIndex && !isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
- newCursorPosition = cursorPosition;
- break;
- }
- }
- if (newCursorPosition !== -1) {
- state.sortedIndexCursor = newCursorPosition;
- return itemsMatchingFirstChar[state.sortedIndexCursor].index;
- }
- return -1;
- }
- /**
- * Attempts to find the next item that matches all of the typeahead buffer.
- * Wraps around if at end of options. Returns -1 if no match is found.
- */
- function matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state) {
- var firstChar = state.typeaheadBuffer[0];
- var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
- if (!itemsMatchingFirstChar) {
- return -1;
- }
- // Do nothing if text already matches
- var startingItem = itemsMatchingFirstChar[state.sortedIndexCursor];
- if (startingItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0 && !isItemAtIndexDisabled(startingItem.index)) {
- return startingItem.index;
- }
- // Find next item that matches completely; if no match, we'll eventually
- // loop around to same position
- var cursorPosition = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
- var nextCursorPosition = -1;
- while (cursorPosition !== state.sortedIndexCursor) {
- var currentItem = itemsMatchingFirstChar[cursorPosition];
- var matches = currentItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0;
- var isEnabled = !isItemAtIndexDisabled(currentItem.index);
- if (matches && isEnabled) {
- nextCursorPosition = cursorPosition;
- break;
- }
- cursorPosition = (cursorPosition + 1) % itemsMatchingFirstChar.length;
- }
- if (nextCursorPosition !== -1) {
- state.sortedIndexCursor = nextCursorPosition;
- return itemsMatchingFirstChar[state.sortedIndexCursor].index;
- }
- return -1;
- }
- /**
- * Whether or not the given typeahead instaance state is currently typing.
- *
- * @param state The typeahead state instance. See `initState`.
- */
- function isTypingInProgress(state) {
- return state.typeaheadBuffer.length > 0;
- }
- exports.isTypingInProgress = isTypingInProgress;
- /**
- * Clears the typeahaed buffer so that it resets item matching to the first
- * character.
- *
- * @param state The typeahead state instance. See `initState`.
- */
- function clearBuffer(state) {
- state.typeaheadBuffer = '';
- }
- exports.clearBuffer = clearBuffer;
- /**
- * Given a keydown event, it calculates whether or not to automatically focus a
- * list item depending on what was typed mimicking the typeahead functionality
- * of a standard <select> element that is open.
- *
- * @param opts Options and accessors
- * - event - the KeyboardEvent to handle and parse
- * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
- * - focusedItemIndex - the index of the currently focused item
- * - focusItemAtIndex - function that focuses a list item at given index
- * - isItemAtFocusedIndexDisabled - whether or not the currently focused item
- * is disabled
- * - isTargetListItem - whether or not the event target is a list item
- * @param state The typeahead state instance. See `initState`.
- *
- * @return index of the item matched by the keydown. -1 if not matched.
- */
- function handleKeydown(opts, state) {
- var event = opts.event,
- isTargetListItem = opts.isTargetListItem,
- focusedItemIndex = opts.focusedItemIndex,
- focusItemAtIndex = opts.focusItemAtIndex,
- sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
- isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
- var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
- var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
- var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
- var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
- var isHome = keyboard_1.normalizeKey(event) === 'Home';
- var isEnd = keyboard_1.normalizeKey(event) === 'End';
- var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
- var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
- if (event.altKey || event.ctrlKey || event.metaKey || isArrowLeft || isArrowUp || isArrowRight || isArrowDown || isHome || isEnd || isEnter) {
- return -1;
- }
- var isCharacterKey = !isSpace && event.key.length === 1;
- if (isCharacterKey) {
- events_1.preventDefaultEvent(event);
- var matchItemOpts = {
- focusItemAtIndex: focusItemAtIndex,
- focusedItemIndex: focusedItemIndex,
- nextChar: event.key.toLowerCase(),
- sortedIndexByFirstChar: sortedIndexByFirstChar,
- skipFocus: false,
- isItemAtIndexDisabled: isItemAtIndexDisabled
- };
- return matchItem(matchItemOpts, state);
- }
- if (!isSpace) {
- return -1;
- }
- if (isTargetListItem) {
- events_1.preventDefaultEvent(event);
- }
- var typeaheadOnListItem = isTargetListItem && isTypingInProgress(state);
- if (typeaheadOnListItem) {
- var matchItemOpts = {
- focusItemAtIndex: focusItemAtIndex,
- focusedItemIndex: focusedItemIndex,
- nextChar: ' ',
- sortedIndexByFirstChar: sortedIndexByFirstChar,
- skipFocus: false,
- isItemAtIndexDisabled: isItemAtIndexDisabled
- };
- // space participates in typeahead matching if in rapid typing mode
- return matchItem(matchItemOpts, state);
- }
- return -1;
- }
- exports.handleKeydown = handleKeydown;
- /***/ }),
- /***/ "./packages/mdc-menu-surface/component.ts":
- /*!************************************************!*\
- !*** ./packages/mdc-menu-surface/component.ts ***!
- \************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCMenuSurface = void 0;
- var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu-surface/foundation.ts");
- /** MDC Menu Surface */
- var MDCMenuSurface = /** @class */function (_super) {
- __extends(MDCMenuSurface, _super);
- function MDCMenuSurface() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCMenuSurface.attachTo = function (root) {
- return new MDCMenuSurface(root);
- };
- MDCMenuSurface.prototype.initialSyncWithDOM = function () {
- var _this = this;
- var parentEl = this.root.parentElement;
- this.anchorElement = parentEl && parentEl.classList.contains(constants_1.cssClasses.ANCHOR) ? parentEl : null;
- if (this.root.classList.contains(constants_1.cssClasses.FIXED)) {
- this.setFixedPosition(true);
- }
- this.handleKeydown = function (event) {
- _this.foundation.handleKeydown(event);
- };
- this.handleBodyClick = function (event) {
- _this.foundation.handleBodyClick(event);
- };
- // capture so that no race between handleBodyClick and quickOpen when
- // menusurface opened on button click which registers this listener
- this.registerBodyClickListener = function () {
- document.body.addEventListener('click', _this.handleBodyClick, { capture: true });
- };
- this.deregisterBodyClickListener = function () {
- document.body.removeEventListener('click', _this.handleBodyClick, { capture: true });
- };
- this.listen('keydown', this.handleKeydown);
- this.listen(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
- this.listen(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
- };
- MDCMenuSurface.prototype.destroy = function () {
- this.unlisten('keydown', this.handleKeydown);
- this.unlisten(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
- this.unlisten(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
- _super.prototype.destroy.call(this);
- };
- MDCMenuSurface.prototype.isOpen = function () {
- return this.foundation.isOpen();
- };
- MDCMenuSurface.prototype.open = function () {
- this.foundation.open();
- };
- MDCMenuSurface.prototype.close = function (skipRestoreFocus) {
- if (skipRestoreFocus === void 0) {
- skipRestoreFocus = false;
- }
- this.foundation.close(skipRestoreFocus);
- };
- Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", {
- set: function set(quickOpen) {
- this.foundation.setQuickOpen(quickOpen);
- },
- enumerable: false,
- configurable: true
- });
- /**
- * Sets the foundation to use page offsets for a positioning when the menu is
- * hoisted to the body.
- */
- MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) {
- this.foundation.setIsHoisted(isHoisted);
- };
- /** Sets the element that the menu-surface is anchored to. */
- MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) {
- this.anchorElement = element;
- };
- /** Sets the menu-surface to position: fixed. */
- MDCMenuSurface.prototype.setFixedPosition = function (isFixed) {
- if (isFixed) {
- this.root.classList.add(constants_1.cssClasses.FIXED);
- } else {
- this.root.classList.remove(constants_1.cssClasses.FIXED);
- }
- this.foundation.setFixedPosition(isFixed);
- };
- /**
- * Sets the absolute x/y position to position based on. Requires the menu to
- * be hoisted.
- */
- MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) {
- this.foundation.setAbsolutePosition(x, y);
- this.setIsHoisted(true);
- };
- /**
- * @param corner Default anchor corner alignment of top-left surface corner.
- */
- MDCMenuSurface.prototype.setAnchorCorner = function (corner) {
- this.foundation.setAnchorCorner(corner);
- };
- MDCMenuSurface.prototype.setAnchorMargin = function (margin) {
- this.foundation.setAnchorMargin(margin);
- };
- MDCMenuSurface.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- addClass: function addClass(className) {
- _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- hasAnchor: function hasAnchor() {
- return !!_this.anchorElement;
- },
- notifyClose: function notifyClose() {
- _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {});
- },
- notifyClosing: function notifyClosing() {
- _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSING_EVENT, {});
- },
- notifyOpen: function notifyOpen() {
- _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {});
- },
- notifyOpening: function notifyOpening() {
- _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENING_EVENT, {});
- },
- isElementInContainer: function isElementInContainer(el) {
- return _this.root.contains(el);
- },
- isRtl: function isRtl() {
- return getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
- },
- setTransformOrigin: function setTransformOrigin(origin) {
- var propertyName = util_1.getCorrectPropertyName(window, 'transform') + "-origin";
- _this.root.style.setProperty(propertyName, origin);
- },
- isFocused: function isFocused() {
- return document.activeElement === _this.root;
- },
- saveFocus: function saveFocus() {
- _this.previousFocus = document.activeElement;
- },
- restoreFocus: function restoreFocus() {
- if (_this.root.contains(document.activeElement)) {
- if (_this.previousFocus && _this.previousFocus.focus) {
- _this.previousFocus.focus();
- }
- }
- },
- getInnerDimensions: function getInnerDimensions() {
- return { width: _this.root.offsetWidth, height: _this.root.offsetHeight };
- },
- getAnchorDimensions: function getAnchorDimensions() {
- return _this.anchorElement ? _this.anchorElement.getBoundingClientRect() : null;
- },
- getViewportDimensions: function getViewportDimensions() {
- return { width: window.innerWidth, height: window.innerHeight };
- },
- getBodyDimensions: function getBodyDimensions() {
- return {
- width: document.body.clientWidth,
- height: document.body.clientHeight
- };
- },
- getWindowScroll: function getWindowScroll() {
- return { x: window.pageXOffset, y: window.pageYOffset };
- },
- setPosition: function setPosition(position) {
- var rootHTML = _this.root;
- rootHTML.style.left = 'left' in position ? position.left + "px" : '';
- rootHTML.style.right = 'right' in position ? position.right + "px" : '';
- rootHTML.style.top = 'top' in position ? position.top + "px" : '';
- rootHTML.style.bottom = 'bottom' in position ? position.bottom + "px" : '';
- },
- setMaxHeight: function setMaxHeight(height) {
- _this.root.style.maxHeight = height;
- },
- registerWindowEventHandler: function registerWindowEventHandler(evtType, handler) {
- window.addEventListener(evtType, handler);
- },
- deregisterWindowEventHandler: function deregisterWindowEventHandler(evtType, handler) {
- window.removeEventListener(evtType, handler);
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCMenuSurfaceFoundation(adapter);
- };
- return MDCMenuSurface;
- }(component_1.MDCComponent);
- exports.MDCMenuSurface = MDCMenuSurface;
- /***/ }),
- /***/ "./packages/mdc-menu-surface/constants.ts":
- /*!************************************************!*\
- !*** ./packages/mdc-menu-surface/constants.ts ***!
- \************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.Corner = exports.CornerBit = exports.numbers = exports.strings = exports.cssClasses = void 0;
- var cssClasses = {
- ANCHOR: 'mdc-menu-surface--anchor',
- ANIMATING_CLOSED: 'mdc-menu-surface--animating-closed',
- ANIMATING_OPEN: 'mdc-menu-surface--animating-open',
- FIXED: 'mdc-menu-surface--fixed',
- IS_OPEN_BELOW: 'mdc-menu-surface--is-open-below',
- OPEN: 'mdc-menu-surface--open',
- ROOT: 'mdc-menu-surface'
- };
- exports.cssClasses = cssClasses;
- // tslint:disable:object-literal-sort-keys
- var strings = {
- CLOSED_EVENT: 'MDCMenuSurface:closed',
- CLOSING_EVENT: 'MDCMenuSurface:closing',
- OPENED_EVENT: 'MDCMenuSurface:opened',
- OPENING_EVENT: 'MDCMenuSurface:opening',
- 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(', ')
- };
- exports.strings = strings;
- // tslint:enable:object-literal-sort-keys
- var numbers = {
- /** Total duration of menu-surface open animation. */
- TRANSITION_OPEN_DURATION: 120,
- /** Total duration of menu-surface close animation. */
- TRANSITION_CLOSE_DURATION: 75,
- /**
- * Margin left to the edge of the viewport when menu-surface is at maximum
- * possible height. Also used as a viewport margin.
- */
- MARGIN_TO_EDGE: 32,
- /**
- * Ratio of anchor width to menu-surface width for switching from corner
- * positioning to center positioning.
- */
- ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67,
- /**
- * Amount of time to wait before restoring focus when closing the menu
- * surface. This is important because if a touch event triggered the menu
- * close, and the subsequent mouse event occurs after focus is restored, then
- * the restored focus would be lost.
- */
- TOUCH_EVENT_WAIT_MS: 30
- };
- exports.numbers = numbers;
- /**
- * Enum for bits in the {@see Corner) bitmap.
- */
- var CornerBit;
- (function (CornerBit) {
- CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM";
- CornerBit[CornerBit["CENTER"] = 2] = "CENTER";
- CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT";
- CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL";
- })(CornerBit || (CornerBit = {}));
- exports.CornerBit = CornerBit;
- /**
- * Enum for representing an element corner for positioning the menu-surface.
- *
- * The START constants map to LEFT if element directionality is left
- * to right and RIGHT if the directionality is right to left.
- * Likewise END maps to RIGHT or LEFT depending on the directionality.
- */
- var Corner;
- (function (Corner) {
- Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT";
- Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT";
- Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT";
- Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT";
- Corner[Corner["TOP_START"] = 8] = "TOP_START";
- Corner[Corner["TOP_END"] = 12] = "TOP_END";
- Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START";
- Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END";
- })(Corner || (Corner = {}));
- exports.Corner = Corner;
- /***/ }),
- /***/ "./packages/mdc-menu-surface/foundation.ts":
- /*!*************************************************!*\
- !*** ./packages/mdc-menu-surface/foundation.ts ***!
- \*************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var __values = this && this.__values || function (o) {
- var s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCMenuSurfaceFoundation = void 0;
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
- /** MDC Menu Surface Foundation */
- var MDCMenuSurfaceFoundation = /** @class */function (_super) {
- __extends(MDCMenuSurfaceFoundation, _super);
- function MDCMenuSurfaceFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCMenuSurfaceFoundation.defaultAdapter), adapter)) || this;
- _this.isSurfaceOpen = false;
- _this.isQuickOpen = false;
- _this.isHoistedElement = false;
- _this.isFixedPosition = false;
- _this.isHorizontallyCenteredOnViewport = false;
- _this.maxHeight = 0;
- _this.openBottomBias = 0;
- _this.openAnimationEndTimerId = 0;
- _this.closeAnimationEndTimerId = 0;
- _this.animationRequestId = 0;
- _this.anchorCorner = constants_1.Corner.TOP_START;
- /**
- * Corner of the menu surface to which menu surface is attached to anchor.
- *
- * Anchor corner --->+----------+
- * | ANCHOR |
- * +----------+
- * Origin corner --->+--------------+
- * | |
- * | |
- * | MENU SURFACE |
- * | |
- * | |
- * +--------------+
- */
- _this.originCorner = constants_1.Corner.TOP_START;
- _this.anchorMargin = { top: 0, right: 0, bottom: 0, left: 0 };
- _this.position = { x: 0, y: 0 };
- return _this;
- }
- Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenuSurfaceFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", {
- get: function get() {
- return constants_1.Corner;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", {
- /**
- * @see {@link MDCMenuSurfaceAdapter} for typing information on parameters and return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return false;
- },
- hasAnchor: function hasAnchor() {
- return false;
- },
- isElementInContainer: function isElementInContainer() {
- return false;
- },
- isFocused: function isFocused() {
- return false;
- },
- isRtl: function isRtl() {
- return false;
- },
- getInnerDimensions: function getInnerDimensions() {
- return { height: 0, width: 0 };
- },
- getAnchorDimensions: function getAnchorDimensions() {
- return null;
- },
- getViewportDimensions: function getViewportDimensions() {
- return { height: 0, width: 0 };
- },
- getBodyDimensions: function getBodyDimensions() {
- return { height: 0, width: 0 };
- },
- getWindowScroll: function getWindowScroll() {
- return { x: 0, y: 0 };
- },
- setPosition: function setPosition() {
- return undefined;
- },
- setMaxHeight: function setMaxHeight() {
- return undefined;
- },
- setTransformOrigin: function setTransformOrigin() {
- return undefined;
- },
- saveFocus: function saveFocus() {
- return undefined;
- },
- restoreFocus: function restoreFocus() {
- return undefined;
- },
- notifyClose: function notifyClose() {
- return undefined;
- },
- notifyClosing: function notifyClosing() {
- return undefined;
- },
- notifyOpen: function notifyOpen() {
- return undefined;
- },
- notifyOpening: function notifyOpening() {
- return undefined;
- },
- registerWindowEventHandler: function registerWindowEventHandler() {
- return undefined;
- },
- deregisterWindowEventHandler: function deregisterWindowEventHandler() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: false,
- configurable: true
- });
- MDCMenuSurfaceFoundation.prototype.init = function () {
- var _a = MDCMenuSurfaceFoundation.cssClasses,
- ROOT = _a.ROOT,
- OPEN = _a.OPEN;
- if (!this.adapter.hasClass(ROOT)) {
- throw new Error(ROOT + " class required in root element.");
- }
- if (this.adapter.hasClass(OPEN)) {
- this.isSurfaceOpen = true;
- }
- this.resizeListener = this.handleResize.bind(this);
- this.adapter.registerWindowEventHandler('resize', this.resizeListener);
- };
- MDCMenuSurfaceFoundation.prototype.destroy = function () {
- clearTimeout(this.openAnimationEndTimerId);
- clearTimeout(this.closeAnimationEndTimerId);
- // Cancel any currently running animations.
- cancelAnimationFrame(this.animationRequestId);
- this.adapter.deregisterWindowEventHandler('resize', this.resizeListener);
- };
- /**
- * @param corner Default anchor corner alignment of top-left menu surface
- * corner.
- */
- MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) {
- this.anchorCorner = corner;
- };
- /**
- * Flip menu corner horizontally.
- */
- MDCMenuSurfaceFoundation.prototype.flipCornerHorizontally = function () {
- this.originCorner = this.originCorner ^ constants_1.CornerBit.RIGHT;
- };
- /**
- * @param margin Set of margin values from anchor.
- */
- MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) {
- this.anchorMargin.top = margin.top || 0;
- this.anchorMargin.right = margin.right || 0;
- this.anchorMargin.bottom = margin.bottom || 0;
- this.anchorMargin.left = margin.left || 0;
- };
- /** Used to indicate if the menu-surface is hoisted to the body. */
- MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) {
- this.isHoistedElement = isHoisted;
- };
- /**
- * Used to set the menu-surface calculations based on a fixed position menu.
- */
- MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) {
- this.isFixedPosition = isFixedPosition;
- };
- /**
- * @return Returns true if menu is in fixed (`position: fixed`) position.
- */
- MDCMenuSurfaceFoundation.prototype.isFixed = function () {
- return this.isFixedPosition;
- };
- /** Sets the menu-surface position on the page. */
- MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) {
- this.position.x = this.isFinite(x) ? x : 0;
- this.position.y = this.isFinite(y) ? y : 0;
- };
- /** Sets whether menu-surface should be horizontally centered to viewport. */
- MDCMenuSurfaceFoundation.prototype.setIsHorizontallyCenteredOnViewport = function (isCentered) {
- this.isHorizontallyCenteredOnViewport = isCentered;
- };
- MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) {
- this.isQuickOpen = quickOpen;
- };
- /**
- * Sets maximum menu-surface height on open.
- * @param maxHeight The desired max-height. Set to 0 (default) to
- * automatically calculate max height based on available viewport space.
- */
- MDCMenuSurfaceFoundation.prototype.setMaxHeight = function (maxHeight) {
- this.maxHeight = maxHeight;
- };
- /**
- * Set to a positive integer to influence the menu to preferentially open
- * below the anchor instead of above.
- * @param bias A value of `x` simulates an extra `x` pixels of available space
- * below the menu during positioning calculations.
- */
- MDCMenuSurfaceFoundation.prototype.setOpenBottomBias = function (bias) {
- this.openBottomBias = bias;
- };
- MDCMenuSurfaceFoundation.prototype.isOpen = function () {
- return this.isSurfaceOpen;
- };
- /**
- * Open the menu surface.
- */
- MDCMenuSurfaceFoundation.prototype.open = function () {
- var _this = this;
- if (this.isSurfaceOpen) {
- return;
- }
- this.adapter.notifyOpening();
- this.adapter.saveFocus();
- if (this.isQuickOpen) {
- this.isSurfaceOpen = true;
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
- this.dimensions = this.adapter.getInnerDimensions();
- this.autoposition();
- this.adapter.notifyOpen();
- } else {
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
- this.animationRequestId = requestAnimationFrame(function () {
- _this.dimensions = _this.adapter.getInnerDimensions();
- _this.autoposition();
- _this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
- _this.openAnimationEndTimerId = setTimeout(function () {
- _this.openAnimationEndTimerId = 0;
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
- _this.adapter.notifyOpen();
- }, constants_1.numbers.TRANSITION_OPEN_DURATION);
- });
- this.isSurfaceOpen = true;
- }
- this.adapter.registerWindowEventHandler('resize', this.resizeListener);
- };
- /**
- * Closes the menu surface.
- */
- MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) {
- var _this = this;
- if (skipRestoreFocus === void 0) {
- skipRestoreFocus = false;
- }
- if (!this.isSurfaceOpen) {
- return;
- }
- this.adapter.notifyClosing();
- this.adapter.deregisterWindowEventHandler('resize', this.resizeListener);
- if (this.isQuickOpen) {
- this.isSurfaceOpen = false;
- if (!skipRestoreFocus) {
- this.maybeRestoreFocus();
- }
- this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
- this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
- this.adapter.notifyClose();
- return;
- }
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
- requestAnimationFrame(function () {
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
- _this.closeAnimationEndTimerId = setTimeout(function () {
- _this.closeAnimationEndTimerId = 0;
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
- _this.adapter.notifyClose();
- }, constants_1.numbers.TRANSITION_CLOSE_DURATION);
- });
- this.isSurfaceOpen = false;
- if (!skipRestoreFocus) {
- this.maybeRestoreFocus();
- }
- };
- /** Handle clicks and close if not within menu-surface element. */
- MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) {
- var el = evt.target;
- if (this.adapter.isElementInContainer(el)) {
- return;
- }
- this.close();
- };
- /** Handle keys that close the surface. */
- MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) {
- var keyCode = evt.keyCode,
- key = evt.key;
- var isEscape = key === 'Escape' || keyCode === 27;
- if (isEscape) {
- this.close();
- }
- };
- /** Handles resize events on the window. */
- MDCMenuSurfaceFoundation.prototype.handleResize = function () {
- this.dimensions = this.adapter.getInnerDimensions();
- this.autoposition();
- };
- MDCMenuSurfaceFoundation.prototype.autoposition = function () {
- var _a;
- // Compute measurements for autoposition methods reuse.
- this.measurements = this.getAutoLayoutmeasurements();
- var corner = this.getoriginCorner();
- var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight(corner);
- var verticalAlignment = this.hasBit(corner, constants_1.CornerBit.BOTTOM) ? 'bottom' : 'top';
- var horizontalAlignment = this.hasBit(corner, constants_1.CornerBit.RIGHT) ? 'right' : 'left';
- var horizontalOffset = this.getHorizontalOriginOffset(corner);
- var verticalOffset = this.getVerticalOriginOffset(corner);
- var _b = this.measurements,
- anchorSize = _b.anchorSize,
- surfaceSize = _b.surfaceSize;
- var position = (_a = {}, _a[horizontalAlignment] = horizontalOffset, _a[verticalAlignment] = verticalOffset, _a);
- // Center align when anchor width is comparable or greater than menu
- // surface, otherwise keep corner.
- if (anchorSize.width / surfaceSize.width > constants_1.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) {
- horizontalAlignment = 'center';
- }
- // If the menu-surface has been hoisted to the body, it's no longer relative
- // to the anchor element
- if (this.isHoistedElement || this.isFixedPosition) {
- this.adjustPositionForHoistedElement(position);
- }
- this.adapter.setTransformOrigin(horizontalAlignment + " " + verticalAlignment);
- this.adapter.setPosition(position);
- this.adapter.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : '');
- // If it is opened from the top then add is-open-below class
- if (!this.hasBit(corner, constants_1.CornerBit.BOTTOM)) {
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
- }
- };
- /**
- * @return Measurements used to position menu surface popup.
- */
- MDCMenuSurfaceFoundation.prototype.getAutoLayoutmeasurements = function () {
- var anchorRect = this.adapter.getAnchorDimensions();
- var bodySize = this.adapter.getBodyDimensions();
- var viewportSize = this.adapter.getViewportDimensions();
- var windowScroll = this.adapter.getWindowScroll();
- if (!anchorRect) {
- // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
- anchorRect = {
- top: this.position.y,
- right: this.position.x,
- bottom: this.position.y,
- left: this.position.x,
- width: 0,
- height: 0
- };
- // tslint:enable:object-literal-sort-keys
- }
- return {
- anchorSize: anchorRect,
- bodySize: bodySize,
- surfaceSize: this.dimensions,
- viewportDistance: {
- // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together
- top: anchorRect.top,
- right: viewportSize.width - anchorRect.right,
- bottom: viewportSize.height - anchorRect.bottom,
- left: anchorRect.left
- },
- viewportSize: viewportSize,
- windowScroll: windowScroll
- };
- };
- /**
- * Computes the corner of the anchor from which to animate and position the
- * menu surface.
- *
- * Only LEFT or RIGHT bit is used to position the menu surface ignoring RTL
- * context. E.g., menu surface will be positioned from right side on TOP_END.
- */
- MDCMenuSurfaceFoundation.prototype.getoriginCorner = function () {
- var corner = this.originCorner;
- var _a = this.measurements,
- viewportDistance = _a.viewportDistance,
- anchorSize = _a.anchorSize,
- surfaceSize = _a.surfaceSize;
- var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
- var isAnchoredToBottom = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
- var availableTop;
- var availableBottom;
- if (isAnchoredToBottom) {
- availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.bottom;
- availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE - this.anchorMargin.bottom;
- } else {
- availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.top;
- availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE + anchorSize.height - this.anchorMargin.top;
- }
- var isAvailableBottom = availableBottom - surfaceSize.height > 0;
- if (!isAvailableBottom && availableTop > availableBottom + this.openBottomBias) {
- // Attach bottom side of surface to the anchor.
- corner = this.setBit(corner, constants_1.CornerBit.BOTTOM);
- }
- var isRtl = this.adapter.isRtl();
- var isFlipRtl = this.hasBit(this.anchorCorner, constants_1.CornerBit.FLIP_RTL);
- var hasRightBit = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT) || this.hasBit(corner, constants_1.CornerBit.RIGHT);
- // Whether surface attached to right side of anchor element.
- var isAnchoredToRight = false;
- // Anchored to start
- if (isRtl && isFlipRtl) {
- isAnchoredToRight = !hasRightBit;
- } else {
- // Anchored to right
- isAnchoredToRight = hasRightBit;
- }
- var availableLeft;
- var availableRight;
- if (isAnchoredToRight) {
- availableLeft = viewportDistance.left + anchorSize.width + this.anchorMargin.left;
- availableRight = viewportDistance.right - this.anchorMargin.left;
- } else {
- availableLeft = viewportDistance.left + this.anchorMargin.left;
- availableRight = viewportDistance.right + anchorSize.width - this.anchorMargin.left;
- }
- var isAvailableLeft = availableLeft - surfaceSize.width > 0;
- var isAvailableRight = availableRight - surfaceSize.width > 0;
- var isOriginCornerAlignedToEnd = this.hasBit(corner, constants_1.CornerBit.FLIP_RTL) && this.hasBit(corner, constants_1.CornerBit.RIGHT);
- if (isAvailableRight && isOriginCornerAlignedToEnd && isRtl || !isAvailableLeft && isOriginCornerAlignedToEnd) {
- // Attach left side of surface to the anchor.
- corner = this.unsetBit(corner, constants_1.CornerBit.RIGHT);
- } else if (isAvailableLeft && isAnchoredToRight && isRtl || isAvailableLeft && !isAnchoredToRight && hasRightBit || !isAvailableRight && availableLeft >= availableRight) {
- // Attach right side of surface to the anchor.
- corner = this.setBit(corner, constants_1.CornerBit.RIGHT);
- }
- return corner;
- };
- /**
- * @param corner Origin corner of the menu surface.
- * @return Maximum height of the menu surface, based on available space. 0
- * indicates should not be set.
- */
- MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) {
- if (this.maxHeight > 0) {
- return this.maxHeight;
- }
- var viewportDistance = this.measurements.viewportDistance;
- var maxHeight = 0;
- var isBottomAligned = this.hasBit(corner, constants_1.CornerBit.BOTTOM);
- var isBottomAnchored = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
- var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
- // When maximum height is not specified, it is handled from CSS.
- if (isBottomAligned) {
- maxHeight = viewportDistance.top + this.anchorMargin.top - MARGIN_TO_EDGE;
- if (!isBottomAnchored) {
- maxHeight += this.measurements.anchorSize.height;
- }
- } else {
- maxHeight = viewportDistance.bottom - this.anchorMargin.bottom + this.measurements.anchorSize.height - MARGIN_TO_EDGE;
- if (isBottomAnchored) {
- maxHeight -= this.measurements.anchorSize.height;
- }
- }
- return maxHeight;
- };
- /**
- * @param corner Origin corner of the menu surface.
- * @return Horizontal offset of menu surface origin corner from corresponding
- * anchor corner.
- */
- MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset = function (corner) {
- var anchorSize = this.measurements.anchorSize;
- // isRightAligned corresponds to using the 'right' property on the surface.
- var isRightAligned = this.hasBit(corner, constants_1.CornerBit.RIGHT);
- var avoidHorizontalOverlap = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT);
- if (isRightAligned) {
- var rightOffset = avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.left : this.anchorMargin.right;
- // For hoisted or fixed elements, adjust the offset by the difference
- // between viewport width and body width so when we calculate the right
- // value (`adjustPositionForHoistedElement`) based on the element
- // position, the right property is correct.
- if (this.isHoistedElement || this.isFixedPosition) {
- return rightOffset - (this.measurements.viewportSize.width - this.measurements.bodySize.width);
- }
- return rightOffset;
- }
- return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.right : this.anchorMargin.left;
- };
- /**
- * @param corner Origin corner of the menu surface.
- * @return Vertical offset of menu surface origin corner from corresponding
- * anchor corner.
- */
- MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset = function (corner) {
- var anchorSize = this.measurements.anchorSize;
- var isBottomAligned = this.hasBit(corner, constants_1.CornerBit.BOTTOM);
- var avoidVerticalOverlap = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
- var y = 0;
- if (isBottomAligned) {
- y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin.top : -this.anchorMargin.bottom;
- } else {
- y = avoidVerticalOverlap ? anchorSize.height + this.anchorMargin.bottom : this.anchorMargin.top;
- }
- return y;
- };
- /**
- * Calculates the offsets for positioning the menu-surface when the
- * menu-surface has been hoisted to the body.
- */
- MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement = function (position) {
- var e_1, _a;
- var _b = this.measurements,
- windowScroll = _b.windowScroll,
- viewportDistance = _b.viewportDistance,
- surfaceSize = _b.surfaceSize,
- viewportSize = _b.viewportSize;
- var props = Object.keys(position);
- try {
- for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) {
- var prop = props_1_1.value;
- var value = position[prop] || 0;
- if (this.isHorizontallyCenteredOnViewport && (prop === 'left' || prop === 'right')) {
- position[prop] = (viewportSize.width - surfaceSize.width) / 2;
- continue;
- }
- // Hoisted surfaces need to have the anchor elements location on the page
- // added to the position properties for proper alignment on the body.
- value += viewportDistance[prop];
- // Surfaces that are absolutely positioned need to have additional
- // calculations for scroll and bottom positioning.
- if (!this.isFixedPosition) {
- if (prop === 'top') {
- value += windowScroll.y;
- } else if (prop === 'bottom') {
- value -= windowScroll.y;
- } else if (prop === 'left') {
- value += windowScroll.x;
- } else {
- // prop === 'right'
- value -= windowScroll.x;
- }
- }
- position[prop] = value;
- }
- } catch (e_1_1) {
- e_1 = { error: e_1_1 };
- } finally {
- try {
- if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1);
- } finally {
- if (e_1) throw e_1.error;
- }
- }
- };
- /**
- * The last focused element when the menu surface was opened should regain
- * focus, if the user is focused on or within the menu surface when it is
- * closed.
- */
- MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus = function () {
- var _this = this;
- var isRootFocused = this.adapter.isFocused();
- var ownerDocument = this.adapter.getOwnerDocument ? this.adapter.getOwnerDocument() : document;
- var childHasFocus = ownerDocument.activeElement && this.adapter.isElementInContainer(ownerDocument.activeElement);
- if (isRootFocused || childHasFocus) {
- // Wait before restoring focus when closing the menu surface. This is
- // important because if a touch event triggered the menu close, and the
- // subsequent mouse event occurs after focus is restored, then the
- // restored focus would be lost.
- setTimeout(function () {
- _this.adapter.restoreFocus();
- }, constants_1.numbers.TOUCH_EVENT_WAIT_MS);
- }
- };
- MDCMenuSurfaceFoundation.prototype.hasBit = function (corner, bit) {
- return Boolean(corner & bit); // tslint:disable-line:no-bitwise
- };
- MDCMenuSurfaceFoundation.prototype.setBit = function (corner, bit) {
- return corner | bit; // tslint:disable-line:no-bitwise
- };
- MDCMenuSurfaceFoundation.prototype.unsetBit = function (corner, bit) {
- return corner ^ bit;
- };
- /**
- * isFinite that doesn't force conversion to number type.
- * Equivalent to Number.isFinite in ES2015, which is not supported in IE.
- */
- MDCMenuSurfaceFoundation.prototype.isFinite = function (num) {
- return typeof num === 'number' && isFinite(num);
- };
- return MDCMenuSurfaceFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCMenuSurfaceFoundation = MDCMenuSurfaceFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCMenuSurfaceFoundation;
- /***/ }),
- /***/ "./packages/mdc-menu/component.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-menu/component.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCMenu = void 0;
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
- var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
- var foundation_1 = __webpack_require__(/*! @material/list/foundation */ "./packages/mdc-list/foundation.ts");
- var component_3 = __webpack_require__(/*! @material/menu-surface/component */ "./packages/mdc-menu-surface/component.ts");
- var foundation_2 = __webpack_require__(/*! @material/menu-surface/foundation */ "./packages/mdc-menu-surface/foundation.ts");
- var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
- var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts");
- /** MDC Menu */
- var MDCMenu = /** @class */function (_super) {
- __extends(MDCMenu, _super);
- function MDCMenu() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCMenu.attachTo = function (root) {
- return new MDCMenu(root);
- };
- MDCMenu.prototype.initialize = function (menuSurfaceFactory, listFactory) {
- if (menuSurfaceFactory === void 0) {
- menuSurfaceFactory = function menuSurfaceFactory(el) {
- return new component_3.MDCMenuSurface(el);
- };
- }
- if (listFactory === void 0) {
- listFactory = function listFactory(el) {
- return new component_2.MDCList(el);
- };
- }
- this.menuSurfaceFactory = menuSurfaceFactory;
- this.listFactory = listFactory;
- };
- MDCMenu.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.menuSurface = this.menuSurfaceFactory(this.root);
- var list = this.root.querySelector(constants_2.strings.LIST_SELECTOR);
- if (list) {
- this.list = this.listFactory(list);
- this.list.wrapFocus = true;
- } else {
- this.list = null;
- }
- this.handleKeydown = function (evt) {
- _this.foundation.handleKeydown(evt);
- };
- this.handleItemAction = function (evt) {
- _this.foundation.handleItemAction(_this.items[evt.detail.index]);
- };
- this.handleMenuSurfaceOpened = function () {
- _this.foundation.handleMenuSurfaceOpened();
- };
- this.menuSurface.listen(foundation_2.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened);
- this.listen('keydown', this.handleKeydown);
- this.listen(foundation_1.MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction);
- };
- MDCMenu.prototype.destroy = function () {
- if (this.list) {
- this.list.destroy();
- }
- this.menuSurface.destroy();
- this.menuSurface.unlisten(foundation_2.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened);
- this.unlisten('keydown', this.handleKeydown);
- this.unlisten(foundation_1.MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction);
- _super.prototype.destroy.call(this);
- };
- Object.defineProperty(MDCMenu.prototype, "open", {
- get: function get() {
- return this.menuSurface.isOpen();
- },
- set: function set(value) {
- if (value) {
- this.menuSurface.open();
- } else {
- this.menuSurface.close();
- }
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenu.prototype, "wrapFocus", {
- get: function get() {
- return this.list ? this.list.wrapFocus : false;
- },
- set: function set(value) {
- if (this.list) {
- this.list.wrapFocus = value;
- }
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenu.prototype, "hasTypeahead", {
- /**
- * Sets whether the menu has typeahead functionality.
- * @param value Whether typeahead is enabled.
- */
- set: function set(value) {
- if (this.list) {
- this.list.hasTypeahead = value;
- }
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenu.prototype, "typeaheadInProgress", {
- /**
- * @return Whether typeahead logic is currently matching some user prefix.
- */
- get: function get() {
- return this.list ? this.list.typeaheadInProgress : false;
- },
- enumerable: false,
- configurable: true
- });
- /**
- * Given the next desired character from the user, adds it to the typeahead
- * buffer. Then, attempts to find the next option matching the buffer. Wraps
- * around if at the end of options.
- *
- * @param nextChar The next character to add to the prefix buffer.
- * @param startingIndex The index from which to start matching. Only relevant
- * when starting a new match sequence. To start a new match sequence,
- * clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
- * to clear after a set interval defined in list foundation. Defaults to
- * the currently focused index.
- * @return The index of the matched item, or -1 if no match.
- */
- MDCMenu.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
- if (this.list) {
- return this.list.typeaheadMatchItem(nextChar, startingIndex);
- }
- return -1;
- };
- /**
- * Layout the underlying list element in the case of any dynamic updates
- * to its structure.
- */
- MDCMenu.prototype.layout = function () {
- if (this.list) {
- this.list.layout();
- }
- };
- Object.defineProperty(MDCMenu.prototype, "items", {
- /**
- * Return the items within the menu. Note that this only contains the set of
- * elements within the items container that are proper list items, and not
- * supplemental / presentational DOM elements.
- */
- get: function get() {
- return this.list ? this.list.listElements : [];
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenu.prototype, "singleSelection", {
- /**
- * Turns on/off the underlying list's single selection mode. Used mainly
- * by select menu.
- *
- * @param singleSelection Whether to enable single selection mode.
- */
- set: function set(singleSelection) {
- if (this.list) {
- this.list.singleSelection = singleSelection;
- }
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenu.prototype, "selectedIndex", {
- /**
- * Retrieves the selected index. Only applicable to select menus.
- * @return The selected index, which is a number for single selection and
- * radio lists, and an array of numbers for checkbox lists.
- */
- get: function get() {
- return this.list ? this.list.selectedIndex : constants_1.numbers.UNSET_INDEX;
- },
- /**
- * Sets the selected index of the list. Only applicable to select menus.
- * @param index The selected index, which is a number for single selection and
- * radio lists, and an array of numbers for checkbox lists.
- */
- set: function set(index) {
- if (this.list) {
- this.list.selectedIndex = index;
- }
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenu.prototype, "quickOpen", {
- set: function set(quickOpen) {
- this.menuSurface.quickOpen = quickOpen;
- },
- enumerable: false,
- configurable: true
- });
- /**
- * Sets default focus state where the menu should focus every time when menu
- * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
- * default.
- * @param focusState Default focus state.
- */
- MDCMenu.prototype.setDefaultFocusState = function (focusState) {
- this.foundation.setDefaultFocusState(focusState);
- };
- /**
- * @param corner Default anchor corner alignment of top-left menu corner.
- */
- MDCMenu.prototype.setAnchorCorner = function (corner) {
- this.menuSurface.setAnchorCorner(corner);
- };
- MDCMenu.prototype.setAnchorMargin = function (margin) {
- this.menuSurface.setAnchorMargin(margin);
- };
- /**
- * Sets the list item as the selected row at the specified index.
- * @param index Index of list item within menu.
- */
- MDCMenu.prototype.setSelectedIndex = function (index) {
- this.foundation.setSelectedIndex(index);
- };
- /**
- * Sets the enabled state to isEnabled for the menu item at the given index.
- * @param index Index of the menu item
- * @param isEnabled The desired enabled state of the menu item.
- */
- MDCMenu.prototype.setEnabled = function (index, isEnabled) {
- this.foundation.setEnabled(index, isEnabled);
- };
- /**
- * @return The item within the menu at the index specified.
- */
- MDCMenu.prototype.getOptionByIndex = function (index) {
- var items = this.items;
- if (index < items.length) {
- return this.items[index];
- } else {
- return null;
- }
- };
- /**
- * @param index A menu item's index.
- * @return The primary text within the menu at the index specified.
- */
- MDCMenu.prototype.getPrimaryTextAtIndex = function (index) {
- var item = this.getOptionByIndex(index);
- if (item && this.list) {
- return this.list.getPrimaryText(item) || '';
- }
- return '';
- };
- MDCMenu.prototype.setFixedPosition = function (isFixed) {
- this.menuSurface.setFixedPosition(isFixed);
- };
- MDCMenu.prototype.setIsHoisted = function (isHoisted) {
- this.menuSurface.setIsHoisted(isHoisted);
- };
- MDCMenu.prototype.setAbsolutePosition = function (x, y) {
- this.menuSurface.setAbsolutePosition(x, y);
- };
- /**
- * Sets the element that the menu-surface is anchored to.
- */
- MDCMenu.prototype.setAnchorElement = function (element) {
- this.menuSurface.anchorElement = element;
- };
- MDCMenu.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- addClassToElementAtIndex: function addClassToElementAtIndex(index, className) {
- var list = _this.items;
- list[index].classList.add(className);
- },
- removeClassFromElementAtIndex: function removeClassFromElementAtIndex(index, className) {
- var list = _this.items;
- list[index].classList.remove(className);
- },
- addAttributeToElementAtIndex: function addAttributeToElementAtIndex(index, attr, value) {
- var list = _this.items;
- _this.safeSetAttribute(list[index], attr, value);
- },
- removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex(index, attr) {
- var list = _this.items;
- list[index].removeAttribute(attr);
- },
- getAttributeFromElementAtIndex: function getAttributeFromElementAtIndex(index, attr) {
- var list = _this.items;
- return list[index].getAttribute(attr);
- },
- elementContainsClass: function elementContainsClass(element, className) {
- return element.classList.contains(className);
- },
- closeSurface: function closeSurface(skipRestoreFocus) {
- _this.menuSurface.close(skipRestoreFocus);
- },
- getElementIndex: function getElementIndex(element) {
- return _this.items.indexOf(element);
- },
- notifySelected: function notifySelected(evtData) {
- _this.emit(constants_2.strings.SELECTED_EVENT, {
- index: evtData.index,
- item: _this.items[evtData.index]
- });
- },
- getMenuItemCount: function getMenuItemCount() {
- return _this.items.length;
- },
- focusItemAtIndex: function focusItemAtIndex(index) {
- _this.items[index].focus();
- },
- focusListRoot: function focusListRoot() {
- _this.root.querySelector(constants_2.strings.LIST_SELECTOR).focus();
- },
- isSelectableItemAtIndex: function isSelectableItemAtIndex(index) {
- return !!ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
- },
- getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex(index) {
- var selectionGroupEl = ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
- var selectedItemEl = selectionGroupEl.querySelector("." + constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
- return selectedItemEl ? _this.items.indexOf(selectedItemEl) : -1;
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_3.MDCMenuFoundation(adapter);
- };
- return MDCMenu;
- }(component_1.MDCComponent);
- exports.MDCMenu = MDCMenu;
- /***/ }),
- /***/ "./packages/mdc-menu/constants.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-menu/constants.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.DefaultFocusState = exports.numbers = exports.strings = exports.cssClasses = void 0;
- var cssClasses = {
- MENU_SELECTED_LIST_ITEM: 'mdc-menu-item--selected',
- MENU_SELECTION_GROUP: 'mdc-menu__selection-group',
- ROOT: 'mdc-menu'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ARIA_CHECKED_ATTR: 'aria-checked',
- ARIA_DISABLED_ATTR: 'aria-disabled',
- CHECKBOX_SELECTOR: 'input[type="checkbox"]',
- LIST_SELECTOR: '.mdc-list,.mdc-deprecated-list',
- SELECTED_EVENT: 'MDCMenu:selected',
- SKIP_RESTORE_FOCUS: 'data-menu-item-skip-restore-focus'
- };
- exports.strings = strings;
- var numbers = {
- FOCUS_ROOT_INDEX: -1
- };
- exports.numbers = numbers;
- var DefaultFocusState;
- (function (DefaultFocusState) {
- DefaultFocusState[DefaultFocusState["NONE"] = 0] = "NONE";
- DefaultFocusState[DefaultFocusState["LIST_ROOT"] = 1] = "LIST_ROOT";
- DefaultFocusState[DefaultFocusState["FIRST_ITEM"] = 2] = "FIRST_ITEM";
- DefaultFocusState[DefaultFocusState["LAST_ITEM"] = 3] = "LAST_ITEM";
- })(DefaultFocusState || (DefaultFocusState = {}));
- exports.DefaultFocusState = DefaultFocusState;
- /***/ }),
- /***/ "./packages/mdc-menu/foundation.ts":
- /*!*****************************************!*\
- !*** ./packages/mdc-menu/foundation.ts ***!
- \*****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCMenuFoundation = void 0;
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
- var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
- /** MDC Menu Foundation */
- var MDCMenuFoundation = /** @class */function (_super) {
- __extends(MDCMenuFoundation, _super);
- function MDCMenuFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCMenuFoundation.defaultAdapter), adapter)) || this;
- _this.defaultFocusState = constants_2.DefaultFocusState.LIST_ROOT;
- _this.selectedIndex = -1;
- return _this;
- }
- Object.defineProperty(MDCMenuFoundation, "cssClasses", {
- get: function get() {
- return constants_2.cssClasses;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenuFoundation, "strings", {
- get: function get() {
- return constants_2.strings;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenuFoundation, "numbers", {
- get: function get() {
- return constants_2.numbers;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCMenuFoundation, "defaultAdapter", {
- /**
- * @see {@link MDCMenuAdapter} for typing information on parameters and return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClassToElementAtIndex: function addClassToElementAtIndex() {
- return undefined;
- },
- removeClassFromElementAtIndex: function removeClassFromElementAtIndex() {
- return undefined;
- },
- addAttributeToElementAtIndex: function addAttributeToElementAtIndex() {
- return undefined;
- },
- removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex() {
- return undefined;
- },
- getAttributeFromElementAtIndex: function getAttributeFromElementAtIndex() {
- return null;
- },
- elementContainsClass: function elementContainsClass() {
- return false;
- },
- closeSurface: function closeSurface() {
- return undefined;
- },
- getElementIndex: function getElementIndex() {
- return -1;
- },
- notifySelected: function notifySelected() {
- return undefined;
- },
- getMenuItemCount: function getMenuItemCount() {
- return 0;
- },
- focusItemAtIndex: function focusItemAtIndex() {
- return undefined;
- },
- focusListRoot: function focusListRoot() {
- return undefined;
- },
- getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex() {
- return -1;
- },
- isSelectableItemAtIndex: function isSelectableItemAtIndex() {
- return false;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: false,
- configurable: true
- });
- MDCMenuFoundation.prototype.destroy = function () {
- this.adapter.closeSurface();
- };
- MDCMenuFoundation.prototype.handleKeydown = function (evt) {
- var key = evt.key,
- keyCode = evt.keyCode;
- var isTab = key === 'Tab' || keyCode === 9;
- if (isTab) {
- this.adapter.closeSurface( /** skipRestoreFocus */true);
- }
- };
- MDCMenuFoundation.prototype.handleItemAction = function (listItem) {
- var index = this.adapter.getElementIndex(listItem);
- if (index < 0) {
- return;
- }
- this.adapter.notifySelected({ index: index });
- var skipRestoreFocus = this.adapter.getAttributeFromElementAtIndex(index, constants_2.strings.SKIP_RESTORE_FOCUS) === 'true';
- this.adapter.closeSurface(skipRestoreFocus);
- if (this.adapter.isSelectableItemAtIndex(index)) {
- this.setSelectedIndex(index);
- }
- };
- MDCMenuFoundation.prototype.handleMenuSurfaceOpened = function () {
- switch (this.defaultFocusState) {
- case constants_2.DefaultFocusState.FIRST_ITEM:
- this.adapter.focusItemAtIndex(0);
- break;
- case constants_2.DefaultFocusState.LAST_ITEM:
- this.adapter.focusItemAtIndex(this.adapter.getMenuItemCount() - 1);
- break;
- case constants_2.DefaultFocusState.NONE:
- // Do nothing.
- break;
- default:
- this.adapter.focusListRoot();
- break;
- }
- };
- /**
- * Sets default focus state where the menu should focus every time when menu
- * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by
- * default.
- */
- MDCMenuFoundation.prototype.setDefaultFocusState = function (focusState) {
- this.defaultFocusState = focusState;
- };
- /** @return Index of the currently selected list item within the menu. */
- MDCMenuFoundation.prototype.getSelectedIndex = function () {
- return this.selectedIndex;
- };
- /**
- * Selects the list item at `index` within the menu.
- * @param index Index of list item within the menu.
- */
- MDCMenuFoundation.prototype.setSelectedIndex = function (index) {
- this.validatedIndex(index);
- if (!this.adapter.isSelectableItemAtIndex(index)) {
- throw new Error('MDCMenuFoundation: No selection group at specified index.');
- }
- var prevSelectedIndex = this.adapter.getSelectedSiblingOfItemAtIndex(index);
- if (prevSelectedIndex >= 0) {
- this.adapter.removeAttributeFromElementAtIndex(prevSelectedIndex, constants_2.strings.ARIA_CHECKED_ATTR);
- this.adapter.removeClassFromElementAtIndex(prevSelectedIndex, constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
- }
- this.adapter.addClassToElementAtIndex(index, constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
- this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_CHECKED_ATTR, 'true');
- this.selectedIndex = index;
- };
- /**
- * Sets the enabled state to isEnabled for the menu item at the given index.
- * @param index Index of the menu item
- * @param isEnabled The desired enabled state of the menu item.
- */
- MDCMenuFoundation.prototype.setEnabled = function (index, isEnabled) {
- this.validatedIndex(index);
- if (isEnabled) {
- this.adapter.removeClassFromElementAtIndex(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
- this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_DISABLED_ATTR, 'false');
- } else {
- this.adapter.addClassToElementAtIndex(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
- this.adapter.addAttributeToElementAtIndex(index, constants_2.strings.ARIA_DISABLED_ATTR, 'true');
- }
- };
- MDCMenuFoundation.prototype.validatedIndex = function (index) {
- var menuSize = this.adapter.getMenuItemCount();
- var isIndexInRange = index >= 0 && index < menuSize;
- if (!isIndexInRange) {
- throw new Error('MDCMenuFoundation: No list item at specified index.');
- }
- };
- return MDCMenuFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCMenuFoundation = MDCMenuFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCMenuFoundation;
- /***/ }),
- /***/ "./packages/mdc-notched-outline/component.ts":
- /*!***************************************************!*\
- !*** ./packages/mdc-notched-outline/component.ts ***!
- \***************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2017 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCNotchedOutline = void 0;
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/floating-label/foundation */ "./packages/mdc-floating-label/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-notched-outline/foundation.ts");
- /** MDC Notched Outline */
- var MDCNotchedOutline = /** @class */function (_super) {
- __extends(MDCNotchedOutline, _super);
- function MDCNotchedOutline() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCNotchedOutline.attachTo = function (root) {
- return new MDCNotchedOutline(root);
- };
- MDCNotchedOutline.prototype.initialSyncWithDOM = function () {
- this.notchElement = this.root.querySelector(constants_1.strings.NOTCH_ELEMENT_SELECTOR);
- var label = this.root.querySelector('.' + foundation_1.MDCFloatingLabelFoundation.cssClasses.ROOT);
- if (label) {
- label.style.transitionDuration = '0s';
- this.root.classList.add(constants_1.cssClasses.OUTLINE_UPGRADED);
- requestAnimationFrame(function () {
- label.style.transitionDuration = '';
- });
- } else {
- this.root.classList.add(constants_1.cssClasses.NO_LABEL);
- }
- };
- /**
- * Updates classes and styles to open the notch to the specified width.
- * @param notchWidth The notch width in the outline.
- */
- MDCNotchedOutline.prototype.notch = function (notchWidth) {
- this.foundation.notch(notchWidth);
- };
- /**
- * Updates classes and styles to close the notch.
- */
- MDCNotchedOutline.prototype.closeNotch = function () {
- this.foundation.closeNotch();
- };
- MDCNotchedOutline.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- addClass: function addClass(className) {
- _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- setNotchWidthProperty: function setNotchWidthProperty(width) {
- _this.notchElement.style.setProperty('width', width + 'px');
- },
- removeNotchWidthProperty: function removeNotchWidthProperty() {
- _this.notchElement.style.removeProperty('width');
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_2.MDCNotchedOutlineFoundation(adapter);
- };
- return MDCNotchedOutline;
- }(component_1.MDCComponent);
- exports.MDCNotchedOutline = MDCNotchedOutline;
- /***/ }),
- /***/ "./packages/mdc-notched-outline/constants.ts":
- /*!***************************************************!*\
- !*** ./packages/mdc-notched-outline/constants.ts ***!
- \***************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.strings = exports.numbers = exports.cssClasses = void 0;
- var strings = {
- NOTCH_ELEMENT_SELECTOR: '.mdc-notched-outline__notch'
- };
- exports.strings = strings;
- var numbers = {
- // This should stay in sync with $mdc-notched-outline-padding * 2.
- NOTCH_ELEMENT_PADDING: 8
- };
- exports.numbers = numbers;
- var cssClasses = {
- NO_LABEL: 'mdc-notched-outline--no-label',
- OUTLINE_NOTCHED: 'mdc-notched-outline--notched',
- OUTLINE_UPGRADED: 'mdc-notched-outline--upgraded'
- };
- exports.cssClasses = cssClasses;
- /***/ }),
- /***/ "./packages/mdc-notched-outline/foundation.ts":
- /*!****************************************************!*\
- !*** ./packages/mdc-notched-outline/foundation.ts ***!
- \****************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2017 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCNotchedOutlineFoundation = void 0;
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts");
- /** MDC Notched Outline Foundation */
- var MDCNotchedOutlineFoundation = /** @class */function (_super) {
- __extends(MDCNotchedOutlineFoundation, _super);
- function MDCNotchedOutlineFoundation(adapter) {
- return _super.call(this, __assign(__assign({}, MDCNotchedOutlineFoundation.defaultAdapter), adapter)) || this;
- }
- Object.defineProperty(MDCNotchedOutlineFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCNotchedOutlineFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCNotchedOutlineFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCNotchedOutlineFoundation, "defaultAdapter", {
- /**
- * See {@link MDCNotchedOutlineAdapter} for typing information on parameters
- * and return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- setNotchWidthProperty: function setNotchWidthProperty() {
- return undefined;
- },
- removeNotchWidthProperty: function removeNotchWidthProperty() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: false,
- configurable: true
- });
- /**
- * Adds the outline notched selector and updates the notch width calculated
- * based off of notchWidth.
- */
- MDCNotchedOutlineFoundation.prototype.notch = function (notchWidth) {
- var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED;
- if (notchWidth > 0) {
- notchWidth += constants_1.numbers.NOTCH_ELEMENT_PADDING; // Add padding from left/right.
- }
- this.adapter.setNotchWidthProperty(notchWidth);
- this.adapter.addClass(OUTLINE_NOTCHED);
- };
- /**
- * Removes notched outline selector to close the notch in the outline.
- */
- MDCNotchedOutlineFoundation.prototype.closeNotch = function () {
- var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED;
- this.adapter.removeClass(OUTLINE_NOTCHED);
- this.adapter.removeNotchWidthProperty();
- };
- return MDCNotchedOutlineFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCNotchedOutlineFoundation = MDCNotchedOutlineFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCNotchedOutlineFoundation;
- /***/ }),
- /***/ "./packages/mdc-ripple/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-ripple/component.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function get() {
- return m[k];
- } });
- } : function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- } : function (o, v) {
- o["default"] = v;
- });
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- }__setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCRipple = void 0;
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts");
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
- /** MDC Ripple */
- var MDCRipple = /** @class */function (_super) {
- __extends(MDCRipple, _super);
- function MDCRipple() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.disabled = false;
- return _this;
- }
- MDCRipple.attachTo = function (root, opts) {
- if (opts === void 0) {
- opts = {
- isUnbounded: undefined
- };
- }
- var ripple = new MDCRipple(root);
- // Only override unbounded behavior if option is explicitly specified
- if (opts.isUnbounded !== undefined) {
- ripple.unbounded = opts.isUnbounded;
- }
- return ripple;
- };
- MDCRipple.createAdapter = function (instance) {
- return {
- addClass: function addClass(className) {
- instance.root.classList.add(className);
- },
- browserSupportsCssVars: function browserSupportsCssVars() {
- return util.supportsCssVariables(window);
- },
- computeBoundingRect: function computeBoundingRect() {
- return instance.root.getBoundingClientRect();
- },
- containsEventTarget: function containsEventTarget(target) {
- return instance.root.contains(target);
- },
- deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler(evtType, handler) {
- document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- instance.root.removeEventListener(evtType, handler, events_1.applyPassive());
- },
- deregisterResizeHandler: function deregisterResizeHandler(handler) {
- window.removeEventListener('resize', handler);
- },
- getWindowPageOffset: function getWindowPageOffset() {
- return { x: window.pageXOffset, y: window.pageYOffset };
- },
- isSurfaceActive: function isSurfaceActive() {
- return ponyfill_1.matches(instance.root, ':active');
- },
- isSurfaceDisabled: function isSurfaceDisabled() {
- return Boolean(instance.disabled);
- },
- isUnbounded: function isUnbounded() {
- return Boolean(instance.unbounded);
- },
- registerDocumentInteractionHandler: function registerDocumentInteractionHandler(evtType, handler) {
- document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- instance.root.addEventListener(evtType, handler, events_1.applyPassive());
- },
- registerResizeHandler: function registerResizeHandler(handler) {
- window.addEventListener('resize', handler);
- },
- removeClass: function removeClass(className) {
- instance.root.classList.remove(className);
- },
- updateCssVariable: function updateCssVariable(varName, value) {
- instance.root.style.setProperty(varName, value);
- }
- };
- };
- Object.defineProperty(MDCRipple.prototype, "unbounded", {
- get: function get() {
- return Boolean(this.isUnbounded);
- },
- set: function set(unbounded) {
- this.isUnbounded = Boolean(unbounded);
- this.setUnbounded();
- },
- enumerable: false,
- configurable: true
- });
- MDCRipple.prototype.activate = function () {
- this.foundation.activate();
- };
- MDCRipple.prototype.deactivate = function () {
- this.foundation.deactivate();
- };
- MDCRipple.prototype.layout = function () {
- this.foundation.layout();
- };
- MDCRipple.prototype.getDefaultFoundation = function () {
- return new foundation_1.MDCRippleFoundation(MDCRipple.createAdapter(this));
- };
- MDCRipple.prototype.initialSyncWithDOM = function () {
- var root = this.root;
- this.isUnbounded = 'mdcRippleIsUnbounded' in root.dataset;
- };
- /**
- * Closure Compiler throws an access control error when directly accessing a
- * protected or private property inside a getter/setter, like unbounded above.
- * By accessing the protected property inside a method, we solve that problem.
- * That's why this function exists.
- */
- MDCRipple.prototype.setUnbounded = function () {
- this.foundation.setUnbounded(Boolean(this.isUnbounded));
- };
- return MDCRipple;
- }(component_1.MDCComponent);
- exports.MDCRipple = MDCRipple;
- /***/ }),
- /***/ "./packages/mdc-ripple/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-ripple/constants.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.numbers = exports.strings = exports.cssClasses = void 0;
- exports.cssClasses = {
- // Ripple is a special case where the "root" component is really a "mixin" of
- // sorts,
- // given that it's an 'upgrade' to an existing component. That being said it
- // is the root
- // CSS class that all other CSS classes derive from.
- BG_FOCUSED: 'mdc-ripple-upgraded--background-focused',
- FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation',
- FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation',
- ROOT: 'mdc-ripple-upgraded',
- UNBOUNDED: 'mdc-ripple-upgraded--unbounded'
- };
- exports.strings = {
- VAR_FG_SCALE: '--mdc-ripple-fg-scale',
- VAR_FG_SIZE: '--mdc-ripple-fg-size',
- VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end',
- VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start',
- VAR_LEFT: '--mdc-ripple-left',
- VAR_TOP: '--mdc-ripple-top'
- };
- exports.numbers = {
- DEACTIVATION_TIMEOUT_MS: 225,
- // animation duration)
- FG_DEACTIVATION_MS: 150,
- // (i.e. deactivation animation duration)
- INITIAL_ORIGIN_SCALE: 0.6,
- PADDING: 10,
- TAP_DELAY_MS: 300 };
- /***/ }),
- /***/ "./packages/mdc-ripple/foundation.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-ripple/foundation.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var __values = this && this.__values || function (o) {
- var s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCRippleFoundation = void 0;
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts");
- var util_1 = __webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts");
- // Activation events registered on the root element of each instance for
- // activation
- var ACTIVATION_EVENT_TYPES = ['touchstart', 'pointerdown', 'mousedown', 'keydown'];
- // Deactivation events registered on documentElement when a pointer-related down
- // event occurs
- var POINTER_DEACTIVATION_EVENT_TYPES = ['touchend', 'pointerup', 'mouseup', 'contextmenu'];
- // simultaneous nested activations
- var activatedTargets = [];
- /** MDC Ripple Foundation */
- var MDCRippleFoundation = /** @class */function (_super) {
- __extends(MDCRippleFoundation, _super);
- function MDCRippleFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
- _this.activationAnimationHasEnded = false;
- _this.activationTimer = 0;
- _this.fgDeactivationRemovalTimer = 0;
- _this.fgScale = '0';
- _this.frame = { width: 0, height: 0 };
- _this.initialSize = 0;
- _this.layoutFrame = 0;
- _this.maxRadius = 0;
- _this.unboundedCoords = { left: 0, top: 0 };
- _this.activationState = _this.defaultActivationState();
- _this.activationTimerCallback = function () {
- _this.activationAnimationHasEnded = true;
- _this.runDeactivationUXLogicIfReady();
- };
- _this.activateHandler = function (e) {
- _this.activateImpl(e);
- };
- _this.deactivateHandler = function () {
- _this.deactivateImpl();
- };
- _this.focusHandler = function () {
- _this.handleFocus();
- };
- _this.blurHandler = function () {
- _this.handleBlur();
- };
- _this.resizeHandler = function () {
- _this.layout();
- };
- return _this;
- }
- Object.defineProperty(MDCRippleFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- browserSupportsCssVars: function browserSupportsCssVars() {
- return true;
- },
- computeBoundingRect: function computeBoundingRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- containsEventTarget: function containsEventTarget() {
- return true;
- },
- deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
- return undefined;
- },
- deregisterInteractionHandler: function deregisterInteractionHandler() {
- return undefined;
- },
- deregisterResizeHandler: function deregisterResizeHandler() {
- return undefined;
- },
- getWindowPageOffset: function getWindowPageOffset() {
- return { x: 0, y: 0 };
- },
- isSurfaceActive: function isSurfaceActive() {
- return true;
- },
- isSurfaceDisabled: function isSurfaceDisabled() {
- return true;
- },
- isUnbounded: function isUnbounded() {
- return true;
- },
- registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
- return undefined;
- },
- registerInteractionHandler: function registerInteractionHandler() {
- return undefined;
- },
- registerResizeHandler: function registerResizeHandler() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- updateCssVariable: function updateCssVariable() {
- return undefined;
- }
- };
- },
- enumerable: false,
- configurable: true
- });
- MDCRippleFoundation.prototype.init = function () {
- var _this = this;
- var supportsPressRipple = this.supportsPressRipple();
- this.registerRootHandlers(supportsPressRipple);
- if (supportsPressRipple) {
- var _a = MDCRippleFoundation.cssClasses,
- ROOT_1 = _a.ROOT,
- UNBOUNDED_1 = _a.UNBOUNDED;
- requestAnimationFrame(function () {
- _this.adapter.addClass(ROOT_1);
- if (_this.adapter.isUnbounded()) {
- _this.adapter.addClass(UNBOUNDED_1);
- // Unbounded ripples need layout logic applied immediately to set
- // coordinates for both shade and ripple
- _this.layoutInternal();
- }
- });
- }
- };
- MDCRippleFoundation.prototype.destroy = function () {
- var _this = this;
- if (this.supportsPressRipple()) {
- if (this.activationTimer) {
- clearTimeout(this.activationTimer);
- this.activationTimer = 0;
- this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
- }
- if (this.fgDeactivationRemovalTimer) {
- clearTimeout(this.fgDeactivationRemovalTimer);
- this.fgDeactivationRemovalTimer = 0;
- this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
- }
- var _a = MDCRippleFoundation.cssClasses,
- ROOT_2 = _a.ROOT,
- UNBOUNDED_2 = _a.UNBOUNDED;
- requestAnimationFrame(function () {
- _this.adapter.removeClass(ROOT_2);
- _this.adapter.removeClass(UNBOUNDED_2);
- _this.removeCssVars();
- });
- }
- this.deregisterRootHandlers();
- this.deregisterDeactivationHandlers();
- };
- /**
- * @param evt Optional event containing position information.
- */
- MDCRippleFoundation.prototype.activate = function (evt) {
- this.activateImpl(evt);
- };
- MDCRippleFoundation.prototype.deactivate = function () {
- this.deactivateImpl();
- };
- MDCRippleFoundation.prototype.layout = function () {
- var _this = this;
- if (this.layoutFrame) {
- cancelAnimationFrame(this.layoutFrame);
- }
- this.layoutFrame = requestAnimationFrame(function () {
- _this.layoutInternal();
- _this.layoutFrame = 0;
- });
- };
- MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
- var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
- if (unbounded) {
- this.adapter.addClass(UNBOUNDED);
- } else {
- this.adapter.removeClass(UNBOUNDED);
- }
- };
- MDCRippleFoundation.prototype.handleFocus = function () {
- var _this = this;
- requestAnimationFrame(function () {
- _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
- });
- };
- MDCRippleFoundation.prototype.handleBlur = function () {
- var _this = this;
- requestAnimationFrame(function () {
- _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
- });
- };
- /**
- * We compute this property so that we are not querying information about the
- * client until the point in time where the foundation requests it. This
- * prevents scenarios where client-side feature-detection may happen too
- * early, such as when components are rendered on the server and then
- * initialized at mount time on the client.
- */
- MDCRippleFoundation.prototype.supportsPressRipple = function () {
- return this.adapter.browserSupportsCssVars();
- };
- MDCRippleFoundation.prototype.defaultActivationState = function () {
- return {
- activationEvent: undefined,
- hasDeactivationUXRun: false,
- isActivated: false,
- isProgrammatic: false,
- wasActivatedByPointer: false,
- wasElementMadeActive: false
- };
- };
- /**
- * supportsPressRipple Passed from init to save a redundant function call
- */
- MDCRippleFoundation.prototype.registerRootHandlers = function (supportsPressRipple) {
- var e_1, _a;
- if (supportsPressRipple) {
- try {
- 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()) {
- var evtType = ACTIVATION_EVENT_TYPES_1_1.value;
- this.adapter.registerInteractionHandler(evtType, this.activateHandler);
- }
- } catch (e_1_1) {
- e_1 = { error: e_1_1 };
- } finally {
- try {
- if (ACTIVATION_EVENT_TYPES_1_1 && !ACTIVATION_EVENT_TYPES_1_1.done && (_a = ACTIVATION_EVENT_TYPES_1.return)) _a.call(ACTIVATION_EVENT_TYPES_1);
- } finally {
- if (e_1) throw e_1.error;
- }
- }
- if (this.adapter.isUnbounded()) {
- this.adapter.registerResizeHandler(this.resizeHandler);
- }
- }
- this.adapter.registerInteractionHandler('focus', this.focusHandler);
- this.adapter.registerInteractionHandler('blur', this.blurHandler);
- };
- MDCRippleFoundation.prototype.registerDeactivationHandlers = function (evt) {
- var e_2, _a;
- if (evt.type === 'keydown') {
- this.adapter.registerInteractionHandler('keyup', this.deactivateHandler);
- } else {
- try {
- 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()) {
- var evtType = POINTER_DEACTIVATION_EVENT_TYPES_1_1.value;
- this.adapter.registerDocumentInteractionHandler(evtType, this.deactivateHandler);
- }
- } catch (e_2_1) {
- e_2 = { error: e_2_1 };
- } finally {
- try {
- 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);
- } finally {
- if (e_2) throw e_2.error;
- }
- }
- }
- };
- MDCRippleFoundation.prototype.deregisterRootHandlers = function () {
- var e_3, _a;
- try {
- 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()) {
- var evtType = ACTIVATION_EVENT_TYPES_2_1.value;
- this.adapter.deregisterInteractionHandler(evtType, this.activateHandler);
- }
- } catch (e_3_1) {
- e_3 = { error: e_3_1 };
- } finally {
- try {
- if (ACTIVATION_EVENT_TYPES_2_1 && !ACTIVATION_EVENT_TYPES_2_1.done && (_a = ACTIVATION_EVENT_TYPES_2.return)) _a.call(ACTIVATION_EVENT_TYPES_2);
- } finally {
- if (e_3) throw e_3.error;
- }
- }
- this.adapter.deregisterInteractionHandler('focus', this.focusHandler);
- this.adapter.deregisterInteractionHandler('blur', this.blurHandler);
- if (this.adapter.isUnbounded()) {
- this.adapter.deregisterResizeHandler(this.resizeHandler);
- }
- };
- MDCRippleFoundation.prototype.deregisterDeactivationHandlers = function () {
- var e_4, _a;
- this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler);
- try {
- 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()) {
- var evtType = POINTER_DEACTIVATION_EVENT_TYPES_2_1.value;
- this.adapter.deregisterDocumentInteractionHandler(evtType, this.deactivateHandler);
- }
- } catch (e_4_1) {
- e_4 = { error: e_4_1 };
- } finally {
- try {
- 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);
- } finally {
- if (e_4) throw e_4.error;
- }
- }
- };
- MDCRippleFoundation.prototype.removeCssVars = function () {
- var _this = this;
- var rippleStrings = MDCRippleFoundation.strings;
- var keys = Object.keys(rippleStrings);
- keys.forEach(function (key) {
- if (key.indexOf('VAR_') === 0) {
- _this.adapter.updateCssVariable(rippleStrings[key], null);
- }
- });
- };
- MDCRippleFoundation.prototype.activateImpl = function (evt) {
- var _this = this;
- if (this.adapter.isSurfaceDisabled()) {
- return;
- }
- var activationState = this.activationState;
- if (activationState.isActivated) {
- return;
- }
- // Avoid reacting to follow-on events fired by touch device after an
- // already-processed user interaction
- var previousActivationEvent = this.previousActivationEvent;
- var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
- if (isSameInteraction) {
- return;
- }
- activationState.isActivated = true;
- activationState.isProgrammatic = evt === undefined;
- activationState.activationEvent = evt;
- activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
- var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
- return _this.adapter.containsEventTarget(target);
- });
- if (hasActivatedChild) {
- // Immediately reset activation state, while preserving logic that
- // prevents touch follow-on events
- this.resetActivationState();
- return;
- }
- if (evt !== undefined) {
- activatedTargets.push(evt.target);
- this.registerDeactivationHandlers(evt);
- }
- activationState.wasElementMadeActive = this.checkElementMadeActive(evt);
- if (activationState.wasElementMadeActive) {
- this.animateActivation();
- }
- requestAnimationFrame(function () {
- // Reset array on next frame after the current event has had a chance to
- // bubble to prevent ancestor ripples
- activatedTargets = [];
- if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
- // If space was pressed, try again within an rAF call to detect :active,
- // because different UAs report active states inconsistently when
- // they're called within event handling code:
- // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
- // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
- // We try first outside rAF to support Edge, which does not exhibit this
- // problem, but will crash if a CSS variable is set within a rAF
- // callback for a submit button interaction (#2241).
- activationState.wasElementMadeActive = _this.checkElementMadeActive(evt);
- if (activationState.wasElementMadeActive) {
- _this.animateActivation();
- }
- }
- if (!activationState.wasElementMadeActive) {
- // Reset activation state immediately if element was not made active.
- _this.activationState = _this.defaultActivationState();
- }
- });
- };
- MDCRippleFoundation.prototype.checkElementMadeActive = function (evt) {
- return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
- };
- MDCRippleFoundation.prototype.animateActivation = function () {
- var _this = this;
- var _a = MDCRippleFoundation.strings,
- VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
- VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
- var _b = MDCRippleFoundation.cssClasses,
- FG_DEACTIVATION = _b.FG_DEACTIVATION,
- FG_ACTIVATION = _b.FG_ACTIVATION;
- var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
- this.layoutInternal();
- var translateStart = '';
- var translateEnd = '';
- if (!this.adapter.isUnbounded()) {
- var _c = this.getFgTranslationCoordinates(),
- startPoint = _c.startPoint,
- endPoint = _c.endPoint;
- translateStart = startPoint.x + "px, " + startPoint.y + "px";
- translateEnd = endPoint.x + "px, " + endPoint.y + "px";
- }
- this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
- this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
- // Cancel any ongoing activation/deactivation animations
- clearTimeout(this.activationTimer);
- clearTimeout(this.fgDeactivationRemovalTimer);
- this.rmBoundedActivationClasses();
- this.adapter.removeClass(FG_DEACTIVATION);
- // Force layout in order to re-trigger the animation.
- this.adapter.computeBoundingRect();
- this.adapter.addClass(FG_ACTIVATION);
- this.activationTimer = setTimeout(function () {
- _this.activationTimerCallback();
- }, DEACTIVATION_TIMEOUT_MS);
- };
- MDCRippleFoundation.prototype.getFgTranslationCoordinates = function () {
- var _a = this.activationState,
- activationEvent = _a.activationEvent,
- wasActivatedByPointer = _a.wasActivatedByPointer;
- var startPoint;
- if (wasActivatedByPointer) {
- startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
- } else {
- startPoint = {
- x: this.frame.width / 2,
- y: this.frame.height / 2
- };
- }
- // Center the element around the start point.
- startPoint = {
- x: startPoint.x - this.initialSize / 2,
- y: startPoint.y - this.initialSize / 2
- };
- var endPoint = {
- x: this.frame.width / 2 - this.initialSize / 2,
- y: this.frame.height / 2 - this.initialSize / 2
- };
- return { startPoint: startPoint, endPoint: endPoint };
- };
- MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady = function () {
- var _this = this;
- // This method is called both when a pointing device is released, and when
- // the activation animation ends. The deactivation animation should only run
- // after both of those occur.
- var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
- var _a = this.activationState,
- hasDeactivationUXRun = _a.hasDeactivationUXRun,
- isActivated = _a.isActivated;
- var activationHasEnded = hasDeactivationUXRun || !isActivated;
- if (activationHasEnded && this.activationAnimationHasEnded) {
- this.rmBoundedActivationClasses();
- this.adapter.addClass(FG_DEACTIVATION);
- this.fgDeactivationRemovalTimer = setTimeout(function () {
- _this.adapter.removeClass(FG_DEACTIVATION);
- }, constants_1.numbers.FG_DEACTIVATION_MS);
- }
- };
- MDCRippleFoundation.prototype.rmBoundedActivationClasses = function () {
- var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
- this.adapter.removeClass(FG_ACTIVATION);
- this.activationAnimationHasEnded = false;
- this.adapter.computeBoundingRect();
- };
- MDCRippleFoundation.prototype.resetActivationState = function () {
- var _this = this;
- this.previousActivationEvent = this.activationState.activationEvent;
- this.activationState = this.defaultActivationState();
- // Touch devices may fire additional events for the same interaction within
- // a short time. Store the previous event until it's safe to assume that
- // subsequent events are for new interactions.
- setTimeout(function () {
- return _this.previousActivationEvent = undefined;
- }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
- };
- MDCRippleFoundation.prototype.deactivateImpl = function () {
- var _this = this;
- var activationState = this.activationState;
- // This can happen in scenarios such as when you have a keyup event that
- // blurs the element.
- if (!activationState.isActivated) {
- return;
- }
- var state = __assign({}, activationState);
- if (activationState.isProgrammatic) {
- requestAnimationFrame(function () {
- _this.animateDeactivation(state);
- });
- this.resetActivationState();
- } else {
- this.deregisterDeactivationHandlers();
- requestAnimationFrame(function () {
- _this.activationState.hasDeactivationUXRun = true;
- _this.animateDeactivation(state);
- _this.resetActivationState();
- });
- }
- };
- MDCRippleFoundation.prototype.animateDeactivation = function (_a) {
- var wasActivatedByPointer = _a.wasActivatedByPointer,
- wasElementMadeActive = _a.wasElementMadeActive;
- if (wasActivatedByPointer || wasElementMadeActive) {
- this.runDeactivationUXLogicIfReady();
- }
- };
- MDCRippleFoundation.prototype.layoutInternal = function () {
- var _this = this;
- this.frame = this.adapter.computeBoundingRect();
- var maxDim = Math.max(this.frame.height, this.frame.width);
- // Surface diameter is treated differently for unbounded vs. bounded
- // ripples. Unbounded ripple diameter is calculated smaller since the
- // surface is expected to already be padded appropriately to extend the
- // hitbox, and the ripple is expected to meet the edges of the padded hitbox
- // (which is typically square). Bounded ripples, on the other hand, are
- // fully expected to expand beyond the surface's longest diameter
- // (calculated based on the diagonal plus a constant padding), and are
- // clipped at the surface's border via `overflow: hidden`.
- var getBoundedRadius = function getBoundedRadius() {
- var hypotenuse = Math.sqrt(Math.pow(_this.frame.width, 2) + Math.pow(_this.frame.height, 2));
- return hypotenuse + MDCRippleFoundation.numbers.PADDING;
- };
- this.maxRadius = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
- // Ripple is sized as a fraction of the largest dimension of the surface,
- // then scales up using a CSS scale transform
- var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
- // Unbounded ripple size should always be even number to equally center
- // align.
- if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
- this.initialSize = initialSize - 1;
- } else {
- this.initialSize = initialSize;
- }
- this.fgScale = "" + this.maxRadius / this.initialSize;
- this.updateLayoutCssVars();
- };
- MDCRippleFoundation.prototype.updateLayoutCssVars = function () {
- var _a = MDCRippleFoundation.strings,
- VAR_FG_SIZE = _a.VAR_FG_SIZE,
- VAR_LEFT = _a.VAR_LEFT,
- VAR_TOP = _a.VAR_TOP,
- VAR_FG_SCALE = _a.VAR_FG_SCALE;
- this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize + "px");
- this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale);
- if (this.adapter.isUnbounded()) {
- this.unboundedCoords = {
- left: Math.round(this.frame.width / 2 - this.initialSize / 2),
- top: Math.round(this.frame.height / 2 - this.initialSize / 2)
- };
- this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords.left + "px");
- this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords.top + "px");
- }
- };
- return MDCRippleFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCRippleFoundation = MDCRippleFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCRippleFoundation;
- /***/ }),
- /***/ "./packages/mdc-ripple/util.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-ripple/util.ts ***!
- \*************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.getNormalizedEventCoords = exports.supportsCssVariables = void 0;
- /**
- * Stores result from supportsCssVariables to avoid redundant processing to
- * detect CSS custom variable support.
- */
- var supportsCssVariables_;
- function supportsCssVariables(windowObj, forceRefresh) {
- if (forceRefresh === void 0) {
- forceRefresh = false;
- }
- var CSS = windowObj.CSS;
- var supportsCssVars = supportsCssVariables_;
- if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
- return supportsCssVariables_;
- }
- var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
- if (!supportsFunctionPresent) {
- return false;
- }
- var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
- // See: https://bugs.webkit.org/show_bug.cgi?id=154669
- // See: README section on Safari
- var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
- supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
- if (!forceRefresh) {
- supportsCssVariables_ = supportsCssVars;
- }
- return supportsCssVars;
- }
- exports.supportsCssVariables = supportsCssVariables;
- function getNormalizedEventCoords(evt, pageOffset, clientRect) {
- if (!evt) {
- return { x: 0, y: 0 };
- }
- var x = pageOffset.x,
- y = pageOffset.y;
- var documentX = x + clientRect.left;
- var documentY = y + clientRect.top;
- var normalizedX;
- var normalizedY;
- // Determine touch point relative to the ripple container.
- if (evt.type === 'touchstart') {
- var touchEvent = evt;
- normalizedX = touchEvent.changedTouches[0].pageX - documentX;
- normalizedY = touchEvent.changedTouches[0].pageY - documentY;
- } else {
- var mouseEvent = evt;
- normalizedX = mouseEvent.pageX - documentX;
- normalizedY = mouseEvent.pageY - documentY;
- }
- return { x: normalizedX, y: normalizedY };
- }
- exports.getNormalizedEventCoords = getNormalizedEventCoords;
- /***/ }),
- /***/ "./packages/mdc-select/adapter.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-select/adapter.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /***/ }),
- /***/ "./packages/mdc-select/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-select/component.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function get() {
- return m[k];
- } });
- } : function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) {
- Object.defineProperty(o, "default", { enumerable: true, value: v });
- } : function (o, v) {
- o["default"] = v;
- });
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
- }__setModuleDefault(result, mod);
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCSelect = void 0;
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/floating-label/component */ "./packages/mdc-floating-label/component.ts");
- var component_3 = __webpack_require__(/*! @material/line-ripple/component */ "./packages/mdc-line-ripple/component.ts");
- var menuSurfaceConstants = __importStar(__webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts"));
- var component_4 = __webpack_require__(/*! @material/menu/component */ "./packages/mdc-menu/component.ts");
- var menuConstants = __importStar(__webpack_require__(/*! @material/menu/constants */ "./packages/mdc-menu/constants.ts"));
- var component_5 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
- var component_6 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts");
- var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-select/helper-text/component.ts");
- var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-select/icon/component.ts");
- /** MDC Select */
- var MDCSelect = /** @class */function (_super) {
- __extends(MDCSelect, _super);
- function MDCSelect() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCSelect.attachTo = function (root) {
- return new MDCSelect(root);
- };
- MDCSelect.prototype.initialize = function (labelFactory, lineRippleFactory, outlineFactory, menuFactory, iconFactory, helperTextFactory) {
- if (labelFactory === void 0) {
- labelFactory = function labelFactory(el) {
- return new component_2.MDCFloatingLabel(el);
- };
- }
- if (lineRippleFactory === void 0) {
- lineRippleFactory = function lineRippleFactory(el) {
- return new component_3.MDCLineRipple(el);
- };
- }
- if (outlineFactory === void 0) {
- outlineFactory = function outlineFactory(el) {
- return new component_5.MDCNotchedOutline(el);
- };
- }
- if (menuFactory === void 0) {
- menuFactory = function menuFactory(el) {
- return new component_4.MDCMenu(el);
- };
- }
- if (iconFactory === void 0) {
- iconFactory = function iconFactory(el) {
- return new component_8.MDCSelectIcon(el);
- };
- }
- if (helperTextFactory === void 0) {
- helperTextFactory = function helperTextFactory(el) {
- return new component_7.MDCSelectHelperText(el);
- };
- }
- this.selectAnchor = this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
- this.selectedText = this.root.querySelector(constants_1.strings.SELECTED_TEXT_SELECTOR);
- this.hiddenInput = this.root.querySelector(constants_1.strings.HIDDEN_INPUT_SELECTOR);
- if (!this.selectedText) {
- throw new Error('MDCSelect: Missing required element: The following selector must be present: ' + ("'" + constants_1.strings.SELECTED_TEXT_SELECTOR + "'"));
- }
- if (this.selectAnchor.hasAttribute(constants_1.strings.ARIA_CONTROLS)) {
- var helperTextElement = document.getElementById(this.selectAnchor.getAttribute(constants_1.strings.ARIA_CONTROLS));
- if (helperTextElement) {
- this.helperText = helperTextFactory(helperTextElement);
- }
- }
- this.menuSetup(menuFactory);
- var labelElement = this.root.querySelector(constants_1.strings.LABEL_SELECTOR);
- this.label = labelElement ? labelFactory(labelElement) : null;
- var lineRippleElement = this.root.querySelector(constants_1.strings.LINE_RIPPLE_SELECTOR);
- this.lineRipple = lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
- var outlineElement = this.root.querySelector(constants_1.strings.OUTLINE_SELECTOR);
- this.outline = outlineElement ? outlineFactory(outlineElement) : null;
- var leadingIcon = this.root.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
- if (leadingIcon) {
- this.leadingIcon = iconFactory(leadingIcon);
- }
- if (!this.root.classList.contains(constants_1.cssClasses.OUTLINED)) {
- this.ripple = this.createRipple();
- }
- };
- /**
- * Initializes the select's event listeners and internal state based
- * on the environment's state.
- */
- MDCSelect.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleFocus = function () {
- _this.foundation.handleFocus();
- };
- this.handleBlur = function () {
- _this.foundation.handleBlur();
- };
- this.handleClick = function (evt) {
- _this.selectAnchor.focus();
- _this.foundation.handleClick(_this.getNormalizedXCoordinate(evt));
- };
- this.handleKeydown = function (evt) {
- _this.foundation.handleKeydown(evt);
- };
- this.handleMenuItemAction = function (evt) {
- _this.foundation.handleMenuItemAction(evt.detail.index);
- };
- this.handleMenuOpened = function () {
- _this.foundation.handleMenuOpened();
- };
- this.handleMenuClosed = function () {
- _this.foundation.handleMenuClosed();
- };
- this.handleMenuClosing = function () {
- _this.foundation.handleMenuClosing();
- };
- this.selectAnchor.addEventListener('focus', this.handleFocus);
- this.selectAnchor.addEventListener('blur', this.handleBlur);
- this.selectAnchor.addEventListener('click', this.handleClick);
- this.selectAnchor.addEventListener('keydown', this.handleKeydown);
- this.menu.listen(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
- this.menu.listen(menuSurfaceConstants.strings.CLOSING_EVENT, this.handleMenuClosing);
- this.menu.listen(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
- this.menu.listen(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
- if (this.hiddenInput) {
- if (this.hiddenInput.value) {
- // If the hidden input already has a value, use it to restore the
- // select's value. This can happen e.g. if the user goes back or (in
- // some browsers) refreshes the page.
- this.foundation.setValue(this.hiddenInput.value, /** skipNotify */true);
- this.foundation.layout();
- return;
- }
- this.hiddenInput.value = this.value;
- }
- };
- MDCSelect.prototype.destroy = function () {
- this.selectAnchor.removeEventListener('focus', this.handleFocus);
- this.selectAnchor.removeEventListener('blur', this.handleBlur);
- this.selectAnchor.removeEventListener('keydown', this.handleKeydown);
- this.selectAnchor.removeEventListener('click', this.handleClick);
- this.menu.unlisten(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
- this.menu.unlisten(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
- this.menu.unlisten(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
- this.menu.destroy();
- if (this.ripple) {
- this.ripple.destroy();
- }
- if (this.outline) {
- this.outline.destroy();
- }
- if (this.leadingIcon) {
- this.leadingIcon.destroy();
- }
- if (this.helperText) {
- this.helperText.destroy();
- }
- _super.prototype.destroy.call(this);
- };
- Object.defineProperty(MDCSelect.prototype, "value", {
- get: function get() {
- return this.foundation.getValue();
- },
- set: function set(value) {
- this.foundation.setValue(value);
- },
- enumerable: false,
- configurable: true
- });
- MDCSelect.prototype.setValue = function (value, skipNotify) {
- if (skipNotify === void 0) {
- skipNotify = false;
- }
- this.foundation.setValue(value, skipNotify);
- };
- Object.defineProperty(MDCSelect.prototype, "selectedIndex", {
- get: function get() {
- return this.foundation.getSelectedIndex();
- },
- set: function set(selectedIndex) {
- this.foundation.setSelectedIndex(selectedIndex, /* closeMenu */true);
- },
- enumerable: false,
- configurable: true
- });
- MDCSelect.prototype.setSelectedIndex = function (selectedIndex, skipNotify) {
- if (skipNotify === void 0) {
- skipNotify = false;
- }
- this.foundation.setSelectedIndex(selectedIndex, /* closeMenu */true, skipNotify);
- };
- Object.defineProperty(MDCSelect.prototype, "disabled", {
- get: function get() {
- return this.foundation.getDisabled();
- },
- set: function set(disabled) {
- this.foundation.setDisabled(disabled);
- if (this.hiddenInput) {
- this.hiddenInput.disabled = disabled;
- }
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "leadingIconAriaLabel", {
- set: function set(label) {
- this.foundation.setLeadingIconAriaLabel(label);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "leadingIconContent", {
- /**
- * Sets the text content of the leading icon.
- */
- set: function set(content) {
- this.foundation.setLeadingIconContent(content);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "helperTextContent", {
- /**
- * Sets the text content of the helper text.
- */
- set: function set(content) {
- this.foundation.setHelperTextContent(content);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "useDefaultValidation", {
- /**
- * Enables or disables the default validation scheme where a required select
- * must be non-empty. Set to false for custom validation.
- * @param useDefaultValidation Set this to false to ignore default
- * validation scheme.
- */
- set: function set(useDefaultValidation) {
- this.foundation.setUseDefaultValidation(useDefaultValidation);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "valid", {
- /**
- * Checks if the select is in a valid state.
- */
- get: function get() {
- return this.foundation.isValid();
- },
- /**
- * Sets the current invalid state of the select.
- */
- set: function set(isValid) {
- this.foundation.setValid(isValid);
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "required", {
- /**
- * Returns whether the select is required.
- */
- get: function get() {
- return this.foundation.getRequired();
- },
- /**
- * Sets the control to the required state.
- */
- set: function set(isRequired) {
- this.foundation.setRequired(isRequired);
- },
- enumerable: false,
- configurable: true
- });
- /**
- * Re-calculates if the notched outline should be notched and if the label
- * should float.
- */
- MDCSelect.prototype.layout = function () {
- this.foundation.layout();
- };
- /**
- * Synchronizes the list of options with the state of the foundation. Call
- * this whenever menu options are dynamically updated.
- */
- MDCSelect.prototype.layoutOptions = function () {
- this.foundation.layoutOptions();
- this.menu.layout();
- // Update cached menuItemValues for adapter.
- this.menuItemValues = this.menu.items.map(function (el) {
- return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
- });
- if (this.hiddenInput) {
- this.hiddenInput.value = this.value;
- }
- };
- MDCSelect.prototype.getDefaultFoundation = function () {
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- var adapter = __assign(__assign(__assign(__assign({}, this.getSelectAdapterMethods()), this.getCommonAdapterMethods()), this.getOutlineAdapterMethods()), this.getLabelAdapterMethods());
- return new foundation_2.MDCSelectFoundation(adapter, this.getFoundationMap());
- };
- /**
- * Handles setup for the menu.
- */
- MDCSelect.prototype.menuSetup = function (menuFactory) {
- this.menuElement = this.root.querySelector(constants_1.strings.MENU_SELECTOR);
- this.menu = menuFactory(this.menuElement);
- this.menu.hasTypeahead = true;
- this.menu.singleSelection = true;
- this.menuItemValues = this.menu.items.map(function (el) {
- return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
- });
- };
- MDCSelect.prototype.createRipple = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = __assign(__assign({}, component_6.MDCRipple.createAdapter({ root: this.selectAnchor })), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- _this.selectAnchor.addEventListener(evtType, handler);
- }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- _this.selectAnchor.removeEventListener(evtType, handler);
- } });
- // tslint:enable:object-literal-sort-keys
- return new component_6.MDCRipple(this.selectAnchor, new foundation_1.MDCRippleFoundation(adapter));
- };
- MDCSelect.prototype.getSelectAdapterMethods = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- getMenuItemAttr: function getMenuItemAttr(menuItem, attr) {
- return menuItem.getAttribute(attr);
- },
- setSelectedText: function setSelectedText(text) {
- _this.selectedText.textContent = text;
- var index = _this.menu.selectedIndex;
- if (index === -1) return;
- index = index instanceof Array ? index[0] : index;
- var selectedItem = _this.menu.items[index];
- if (!selectedItem) return;
- _this.selectedText.setAttribute('aria-label', selectedItem.getAttribute('aria-label') || '');
- },
- isSelectAnchorFocused: function isSelectAnchorFocused() {
- return document.activeElement === _this.selectAnchor;
- },
- getSelectAnchorAttr: function getSelectAnchorAttr(attr) {
- return _this.selectAnchor.getAttribute(attr);
- },
- setSelectAnchorAttr: function setSelectAnchorAttr(attr, value) {
- _this.safeSetAttribute(_this.selectAnchor, attr, value);
- },
- removeSelectAnchorAttr: function removeSelectAnchorAttr(attr) {
- _this.selectAnchor.removeAttribute(attr);
- },
- addMenuClass: function addMenuClass(className) {
- _this.menuElement.classList.add(className);
- },
- removeMenuClass: function removeMenuClass(className) {
- _this.menuElement.classList.remove(className);
- },
- openMenu: function openMenu() {
- _this.menu.open = true;
- },
- closeMenu: function closeMenu() {
- _this.menu.open = false;
- },
- getAnchorElement: function getAnchorElement() {
- return _this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
- },
- setMenuAnchorElement: function setMenuAnchorElement(anchorEl) {
- _this.menu.setAnchorElement(anchorEl);
- },
- setMenuAnchorCorner: function setMenuAnchorCorner(anchorCorner) {
- _this.menu.setAnchorCorner(anchorCorner);
- },
- setMenuWrapFocus: function setMenuWrapFocus(wrapFocus) {
- _this.menu.wrapFocus = wrapFocus;
- },
- getSelectedIndex: function getSelectedIndex() {
- var index = _this.menu.selectedIndex;
- return index instanceof Array ? index[0] : index;
- },
- setSelectedIndex: function setSelectedIndex(index) {
- _this.menu.selectedIndex = index;
- },
- focusMenuItemAtIndex: function focusMenuItemAtIndex(index) {
- var _a;
- (_a = _this.menu.items[index]) === null || _a === void 0 ? void 0 : _a.focus();
- },
- getMenuItemCount: function getMenuItemCount() {
- return _this.menu.items.length;
- },
- // Cache menu item values. layoutOptions() updates this cache.
- getMenuItemValues: function getMenuItemValues() {
- return _this.menuItemValues;
- },
- getMenuItemTextAtIndex: function getMenuItemTextAtIndex(index) {
- return _this.menu.getPrimaryTextAtIndex(index);
- },
- isTypeaheadInProgress: function isTypeaheadInProgress() {
- return _this.menu.typeaheadInProgress;
- },
- typeaheadMatchItem: function typeaheadMatchItem(nextChar, startingIndex) {
- return _this.menu.typeaheadMatchItem(nextChar, startingIndex);
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- MDCSelect.prototype.getCommonAdapterMethods = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass(className) {
- _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- setRippleCenter: function setRippleCenter(normalizedX) {
- _this.lineRipple && _this.lineRipple.setRippleCenter(normalizedX);
- },
- activateBottomLine: function activateBottomLine() {
- _this.lineRipple && _this.lineRipple.activate();
- },
- deactivateBottomLine: function deactivateBottomLine() {
- _this.lineRipple && _this.lineRipple.deactivate();
- },
- notifyChange: function notifyChange(value) {
- if (_this.hiddenInput) {
- _this.hiddenInput.value = value;
- }
- var index = _this.selectedIndex;
- _this.emit(constants_1.strings.CHANGE_EVENT, { value: value, index: index }, true /* shouldBubble */);
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- MDCSelect.prototype.getOutlineAdapterMethods = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- hasOutline: function hasOutline() {
- return Boolean(_this.outline);
- },
- notchOutline: function notchOutline(labelWidth) {
- _this.outline && _this.outline.notch(labelWidth);
- },
- closeOutline: function closeOutline() {
- _this.outline && _this.outline.closeNotch();
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- MDCSelect.prototype.getLabelAdapterMethods = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- hasLabel: function hasLabel() {
- return !!_this.label;
- },
- floatLabel: function floatLabel(shouldFloat) {
- _this.label && _this.label.float(shouldFloat);
- },
- getLabelWidth: function getLabelWidth() {
- return _this.label ? _this.label.getWidth() : 0;
- },
- setLabelRequired: function setLabelRequired(isRequired) {
- _this.label && _this.label.setRequired(isRequired);
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- /**
- * Calculates where the line ripple should start based on the x coordinate
- * within the component.
- */
- MDCSelect.prototype.getNormalizedXCoordinate = function (evt) {
- var targetClientRect = evt.target.getBoundingClientRect();
- var xCoordinate = this.isTouchEvent(evt) ? evt.touches[0].clientX : evt.clientX;
- return xCoordinate - targetClientRect.left;
- };
- MDCSelect.prototype.isTouchEvent = function (evt) {
- return Boolean(evt.touches);
- };
- /**
- * Returns a map of all subcomponents to subfoundations.
- */
- MDCSelect.prototype.getFoundationMap = function () {
- return {
- helperText: this.helperText ? this.helperText.foundationForSelect : undefined,
- leadingIcon: this.leadingIcon ? this.leadingIcon.foundationForSelect : undefined
- };
- };
- return MDCSelect;
- }(component_1.MDCComponent);
- exports.MDCSelect = MDCSelect;
- /***/ }),
- /***/ "./packages/mdc-select/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-select/constants.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.numbers = exports.strings = exports.cssClasses = void 0;
- var cssClasses = {
- ACTIVATED: 'mdc-select--activated',
- DISABLED: 'mdc-select--disabled',
- FOCUSED: 'mdc-select--focused',
- INVALID: 'mdc-select--invalid',
- MENU_INVALID: 'mdc-select__menu--invalid',
- OUTLINED: 'mdc-select--outlined',
- REQUIRED: 'mdc-select--required',
- ROOT: 'mdc-select',
- WITH_LEADING_ICON: 'mdc-select--with-leading-icon'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ARIA_CONTROLS: 'aria-controls',
- ARIA_DESCRIBEDBY: 'aria-describedby',
- ARIA_SELECTED_ATTR: 'aria-selected',
- CHANGE_EVENT: 'MDCSelect:change',
- HIDDEN_INPUT_SELECTOR: 'input[type="hidden"]',
- LABEL_SELECTOR: '.mdc-floating-label',
- LEADING_ICON_SELECTOR: '.mdc-select__icon',
- LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
- MENU_SELECTOR: '.mdc-select__menu',
- OUTLINE_SELECTOR: '.mdc-notched-outline',
- SELECTED_TEXT_SELECTOR: '.mdc-select__selected-text',
- SELECT_ANCHOR_SELECTOR: '.mdc-select__anchor',
- VALUE_ATTR: 'data-value'
- };
- exports.strings = strings;
- var numbers = {
- LABEL_SCALE: 0.75,
- UNSET_INDEX: -1,
- CLICK_DEBOUNCE_TIMEOUT_MS: 330
- };
- exports.numbers = numbers;
- /***/ }),
- /***/ "./packages/mdc-select/foundation.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-select/foundation.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var __read = this && this.__read || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o),
- r,
- ar = [],
- e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
- ar.push(r.value);
- }
- } catch (error) {
- e = { error: error };
- } finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- } finally {
- if (e) throw e.error;
- }
- }
- return ar;
- };
- var __spreadArray = this && this.__spreadArray || function (to, from) {
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
- to[j] = from[i];
- }return to;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCSelectFoundation = void 0;
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
- var constants_1 = __webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts");
- var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
- /** MDC Select Foundation */
- var MDCSelectFoundation = /** @class */function (_super) {
- __extends(MDCSelectFoundation, _super);
- /* istanbul ignore next: optional argument is not a branch statement */
- /**
- * @param adapter
- * @param foundationMap Map from subcomponent names to their subfoundations.
- */
- function MDCSelectFoundation(adapter, foundationMap) {
- if (foundationMap === void 0) {
- foundationMap = {};
- }
- var _a, _b;
- var _this = _super.call(this, __assign(__assign({}, MDCSelectFoundation.defaultAdapter), adapter)) || this;
- // Disabled state
- _this.disabled = false;
- // isMenuOpen is used to track the state of the menu by listening to the
- // MDCMenuSurface:closed event For reference, menu.open will return false if
- // the menu is still closing, but isMenuOpen returns false only after the menu
- // has closed
- _this.isMenuOpen = false;
- // By default, select is invalid if it is required but no value is selected.
- _this.useDefaultValidation = true;
- _this.customValidity = true;
- _this.lastSelectedIndex = constants_2.numbers.UNSET_INDEX;
- _this.clickDebounceTimeout = 0;
- _this.recentlyClicked = false;
- _this.leadingIcon = foundationMap.leadingIcon;
- _this.helperText = foundationMap.helperText;
- _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) {
- var _a;return id !== ((_a = _this.helperText) === null || _a === void 0 ? void 0 : _a.getId()) && id !== '';
- })) || [];
- return _this;
- }
- Object.defineProperty(MDCSelectFoundation, "cssClasses", {
- get: function get() {
- return constants_2.cssClasses;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelectFoundation, "numbers", {
- get: function get() {
- return constants_2.numbers;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelectFoundation, "strings", {
- get: function get() {
- return constants_2.strings;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelectFoundation, "defaultAdapter", {
- /**
- * See {@link MDCSelectAdapter} for typing information on parameters and
- * return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return false;
- },
- activateBottomLine: function activateBottomLine() {
- return undefined;
- },
- deactivateBottomLine: function deactivateBottomLine() {
- return undefined;
- },
- getSelectedIndex: function getSelectedIndex() {
- return -1;
- },
- setSelectedIndex: function setSelectedIndex() {
- return undefined;
- },
- hasLabel: function hasLabel() {
- return false;
- },
- floatLabel: function floatLabel() {
- return undefined;
- },
- getLabelWidth: function getLabelWidth() {
- return 0;
- },
- setLabelRequired: function setLabelRequired() {
- return undefined;
- },
- hasOutline: function hasOutline() {
- return false;
- },
- notchOutline: function notchOutline() {
- return undefined;
- },
- closeOutline: function closeOutline() {
- return undefined;
- },
- setRippleCenter: function setRippleCenter() {
- return undefined;
- },
- notifyChange: function notifyChange() {
- return undefined;
- },
- setSelectedText: function setSelectedText() {
- return undefined;
- },
- isSelectAnchorFocused: function isSelectAnchorFocused() {
- return false;
- },
- getSelectAnchorAttr: function getSelectAnchorAttr() {
- return '';
- },
- setSelectAnchorAttr: function setSelectAnchorAttr() {
- return undefined;
- },
- removeSelectAnchorAttr: function removeSelectAnchorAttr() {
- return undefined;
- },
- addMenuClass: function addMenuClass() {
- return undefined;
- },
- removeMenuClass: function removeMenuClass() {
- return undefined;
- },
- openMenu: function openMenu() {
- return undefined;
- },
- closeMenu: function closeMenu() {
- return undefined;
- },
- getAnchorElement: function getAnchorElement() {
- return null;
- },
- setMenuAnchorElement: function setMenuAnchorElement() {
- return undefined;
- },
- setMenuAnchorCorner: function setMenuAnchorCorner() {
- return undefined;
- },
- setMenuWrapFocus: function setMenuWrapFocus() {
- return undefined;
- },
- focusMenuItemAtIndex: function focusMenuItemAtIndex() {
- return undefined;
- },
- getMenuItemCount: function getMenuItemCount() {
- return 0;
- },
- getMenuItemValues: function getMenuItemValues() {
- return [];
- },
- getMenuItemTextAtIndex: function getMenuItemTextAtIndex() {
- return '';
- },
- isTypeaheadInProgress: function isTypeaheadInProgress() {
- return false;
- },
- typeaheadMatchItem: function typeaheadMatchItem() {
- return -1;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: false,
- configurable: true
- });
- /** Returns the index of the currently selected menu item, or -1 if none. */
- MDCSelectFoundation.prototype.getSelectedIndex = function () {
- return this.adapter.getSelectedIndex();
- };
- MDCSelectFoundation.prototype.setSelectedIndex = function (index, closeMenu, skipNotify) {
- if (closeMenu === void 0) {
- closeMenu = false;
- }
- if (skipNotify === void 0) {
- skipNotify = false;
- }
- if (index >= this.adapter.getMenuItemCount()) {
- return;
- }
- this.adapter.setSelectedIndex(index);
- if (index === constants_2.numbers.UNSET_INDEX) {
- this.adapter.setSelectedText('');
- } else {
- this.adapter.setSelectedText(this.adapter.getMenuItemTextAtIndex(index).trim());
- }
- if (closeMenu) {
- this.adapter.closeMenu();
- }
- if (!skipNotify && this.lastSelectedIndex !== index) {
- this.handleChange();
- }
- this.lastSelectedIndex = index;
- };
- MDCSelectFoundation.prototype.setValue = function (value, skipNotify) {
- if (skipNotify === void 0) {
- skipNotify = false;
- }
- var index = this.adapter.getMenuItemValues().indexOf(value);
- this.setSelectedIndex(index, /** closeMenu */false, skipNotify);
- };
- MDCSelectFoundation.prototype.getValue = function () {
- var index = this.adapter.getSelectedIndex();
- var menuItemValues = this.adapter.getMenuItemValues();
- return index !== constants_2.numbers.UNSET_INDEX ? menuItemValues[index] : '';
- };
- MDCSelectFoundation.prototype.getDisabled = function () {
- return this.disabled;
- };
- MDCSelectFoundation.prototype.setDisabled = function (isDisabled) {
- this.disabled = isDisabled;
- if (this.disabled) {
- this.adapter.addClass(constants_2.cssClasses.DISABLED);
- this.adapter.closeMenu();
- } else {
- this.adapter.removeClass(constants_2.cssClasses.DISABLED);
- }
- if (this.leadingIcon) {
- this.leadingIcon.setDisabled(this.disabled);
- }
- if (this.disabled) {
- // Prevent click events from focusing select. Simply pointer-events: none
- // is not enough since screenreader clicks may bypass this.
- this.adapter.removeSelectAnchorAttr('tabindex');
- } else {
- this.adapter.setSelectAnchorAttr('tabindex', '0');
- }
- this.adapter.setSelectAnchorAttr('aria-disabled', this.disabled.toString());
- };
- /** Opens the menu. */
- MDCSelectFoundation.prototype.openMenu = function () {
- this.adapter.addClass(constants_2.cssClasses.ACTIVATED);
- this.adapter.openMenu();
- this.isMenuOpen = true;
- this.adapter.setSelectAnchorAttr('aria-expanded', 'true');
- };
- /**
- * @param content Sets the content of the helper text.
- */
- MDCSelectFoundation.prototype.setHelperTextContent = function (content) {
- if (this.helperText) {
- this.helperText.setContent(content);
- }
- };
- /**
- * Re-calculates if the notched outline should be notched and if the label
- * should float.
- */
- MDCSelectFoundation.prototype.layout = function () {
- if (this.adapter.hasLabel()) {
- var optionHasValue = this.getValue().length > 0;
- var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
- var shouldFloatAndNotch = optionHasValue || isFocused;
- var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
- this.notchOutline(shouldFloatAndNotch);
- this.adapter.floatLabel(shouldFloatAndNotch);
- this.adapter.setLabelRequired(isRequired);
- }
- };
- /**
- * Synchronizes the list of options with the state of the foundation. Call
- * this whenever menu options are dynamically updated.
- */
- MDCSelectFoundation.prototype.layoutOptions = function () {
- var menuItemValues = this.adapter.getMenuItemValues();
- var selectedIndex = menuItemValues.indexOf(this.getValue());
- this.setSelectedIndex(selectedIndex, /** closeMenu */false, /** skipNotify */true);
- };
- MDCSelectFoundation.prototype.handleMenuOpened = function () {
- if (this.adapter.getMenuItemValues().length === 0) {
- return;
- }
- // Menu should open to the last selected element, should open to first menu
- // item otherwise.
- var selectedIndex = this.getSelectedIndex();
- var focusItemIndex = selectedIndex >= 0 ? selectedIndex : 0;
- this.adapter.focusMenuItemAtIndex(focusItemIndex);
- };
- MDCSelectFoundation.prototype.handleMenuClosing = function () {
- this.adapter.setSelectAnchorAttr('aria-expanded', 'false');
- };
- MDCSelectFoundation.prototype.handleMenuClosed = function () {
- this.adapter.removeClass(constants_2.cssClasses.ACTIVATED);
- this.isMenuOpen = false;
- // Unfocus the select if menu is closed without a selection
- if (!this.adapter.isSelectAnchorFocused()) {
- this.blur();
- }
- };
- /**
- * Handles value changes, via change event or programmatic updates.
- */
- MDCSelectFoundation.prototype.handleChange = function () {
- this.layout();
- this.adapter.notifyChange(this.getValue());
- var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
- if (isRequired && this.useDefaultValidation) {
- this.setValid(this.isValid());
- }
- };
- MDCSelectFoundation.prototype.handleMenuItemAction = function (index) {
- this.setSelectedIndex(index, /** closeMenu */true);
- };
- /**
- * Handles focus events from select element.
- */
- MDCSelectFoundation.prototype.handleFocus = function () {
- this.adapter.addClass(constants_2.cssClasses.FOCUSED);
- this.layout();
- this.adapter.activateBottomLine();
- };
- /**
- * Handles blur events from select element.
- */
- MDCSelectFoundation.prototype.handleBlur = function () {
- if (this.isMenuOpen) {
- return;
- }
- this.blur();
- };
- MDCSelectFoundation.prototype.handleClick = function (normalizedX) {
- if (this.disabled || this.recentlyClicked) {
- return;
- }
- this.setClickDebounceTimeout();
- if (this.isMenuOpen) {
- this.adapter.closeMenu();
- return;
- }
- this.adapter.setRippleCenter(normalizedX);
- this.openMenu();
- };
- /**
- * Handles keydown events on select element. Depending on the type of
- * character typed, does typeahead matching or opens menu.
- */
- MDCSelectFoundation.prototype.handleKeydown = function (event) {
- if (this.isMenuOpen || !this.adapter.hasClass(constants_2.cssClasses.FOCUSED)) {
- return;
- }
- var isEnter = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ENTER;
- var isSpace = keyboard_1.normalizeKey(event) === keyboard_1.KEY.SPACEBAR;
- var arrowUp = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_UP;
- var arrowDown = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_DOWN;
- var isModifier = event.ctrlKey || event.metaKey;
- // Typeahead
- if (!isModifier && (!isSpace && event.key && event.key.length === 1 || isSpace && this.adapter.isTypeaheadInProgress())) {
- var key = isSpace ? ' ' : event.key;
- var typeaheadNextIndex = this.adapter.typeaheadMatchItem(key, this.getSelectedIndex());
- if (typeaheadNextIndex >= 0) {
- this.setSelectedIndex(typeaheadNextIndex);
- }
- event.preventDefault();
- return;
- }
- if (!isEnter && !isSpace && !arrowUp && !arrowDown) {
- return;
- }
- this.openMenu();
- event.preventDefault();
- };
- /**
- * Opens/closes the notched outline.
- */
- MDCSelectFoundation.prototype.notchOutline = function (openNotch) {
- if (!this.adapter.hasOutline()) {
- return;
- }
- var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
- if (openNotch) {
- var labelScale = constants_2.numbers.LABEL_SCALE;
- var labelWidth = this.adapter.getLabelWidth() * labelScale;
- this.adapter.notchOutline(labelWidth);
- } else if (!isFocused) {
- this.adapter.closeOutline();
- }
- };
- /**
- * Sets the aria label of the leading icon.
- */
- MDCSelectFoundation.prototype.setLeadingIconAriaLabel = function (label) {
- if (this.leadingIcon) {
- this.leadingIcon.setAriaLabel(label);
- }
- };
- /**
- * Sets the text content of the leading icon.
- */
- MDCSelectFoundation.prototype.setLeadingIconContent = function (content) {
- if (this.leadingIcon) {
- this.leadingIcon.setContent(content);
- }
- };
- MDCSelectFoundation.prototype.getUseDefaultValidation = function () {
- return this.useDefaultValidation;
- };
- MDCSelectFoundation.prototype.setUseDefaultValidation = function (useDefaultValidation) {
- this.useDefaultValidation = useDefaultValidation;
- };
- MDCSelectFoundation.prototype.setValid = function (isValid) {
- if (!this.useDefaultValidation) {
- this.customValidity = isValid;
- }
- this.adapter.setSelectAnchorAttr('aria-invalid', (!isValid).toString());
- if (isValid) {
- this.adapter.removeClass(constants_2.cssClasses.INVALID);
- this.adapter.removeMenuClass(constants_2.cssClasses.MENU_INVALID);
- } else {
- this.adapter.addClass(constants_2.cssClasses.INVALID);
- this.adapter.addMenuClass(constants_2.cssClasses.MENU_INVALID);
- }
- this.syncHelperTextValidity(isValid);
- };
- MDCSelectFoundation.prototype.isValid = function () {
- if (this.useDefaultValidation && this.adapter.hasClass(constants_2.cssClasses.REQUIRED) && !this.adapter.hasClass(constants_2.cssClasses.DISABLED)) {
- // See notes for required attribute under
- // https://www.w3.org/TR/html52/sec-forms.html#the-select-element TL;DR:
- // Invalid if no index is selected, or if the first index is selected and
- // has an empty value.
- return this.getSelectedIndex() !== constants_2.numbers.UNSET_INDEX && (this.getSelectedIndex() !== 0 || Boolean(this.getValue()));
- }
- return this.customValidity;
- };
- MDCSelectFoundation.prototype.setRequired = function (isRequired) {
- if (isRequired) {
- this.adapter.addClass(constants_2.cssClasses.REQUIRED);
- } else {
- this.adapter.removeClass(constants_2.cssClasses.REQUIRED);
- }
- this.adapter.setSelectAnchorAttr('aria-required', isRequired.toString());
- this.adapter.setLabelRequired(isRequired);
- };
- MDCSelectFoundation.prototype.getRequired = function () {
- return this.adapter.getSelectAnchorAttr('aria-required') === 'true';
- };
- MDCSelectFoundation.prototype.init = function () {
- var anchorEl = this.adapter.getAnchorElement();
- if (anchorEl) {
- this.adapter.setMenuAnchorElement(anchorEl);
- this.adapter.setMenuAnchorCorner(constants_1.Corner.BOTTOM_START);
- }
- this.adapter.setMenuWrapFocus(false);
- this.setDisabled(this.adapter.hasClass(constants_2.cssClasses.DISABLED));
- this.syncHelperTextValidity(!this.adapter.hasClass(constants_2.cssClasses.INVALID));
- this.layout();
- this.layoutOptions();
- };
- /**
- * Unfocuses the select component.
- */
- MDCSelectFoundation.prototype.blur = function () {
- this.adapter.removeClass(constants_2.cssClasses.FOCUSED);
- this.layout();
- this.adapter.deactivateBottomLine();
- var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
- if (isRequired && this.useDefaultValidation) {
- this.setValid(this.isValid());
- }
- };
- MDCSelectFoundation.prototype.syncHelperTextValidity = function (isValid) {
- if (!this.helperText) {
- return;
- }
- this.helperText.setValidity(isValid);
- var helperTextVisible = this.helperText.isVisible();
- var helperTextId = this.helperText.getId();
- if (helperTextVisible && helperTextId) {
- this.adapter.setSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY, __spreadArray(__spreadArray([], __read(this.ariaDescribedbyIds)), [helperTextId]).join(' '));
- } else {
- // Remove helptext from list of describedby ids. Needed because
- // screenreaders will read labels pointed to by `aria-describedby` even if
- // they are `aria-hidden`.
- if (this.ariaDescribedbyIds.length > 0) {
- this.adapter.setSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY, this.ariaDescribedbyIds.join(' '));
- } else {
- // helper text is the only describedby element
- this.adapter.removeSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY);
- }
- }
- };
- MDCSelectFoundation.prototype.setClickDebounceTimeout = function () {
- var _this = this;
- clearTimeout(this.clickDebounceTimeout);
- this.clickDebounceTimeout = setTimeout(function () {
- _this.recentlyClicked = false;
- }, constants_2.numbers.CLICK_DEBOUNCE_TIMEOUT_MS);
- this.recentlyClicked = true;
- };
- return MDCSelectFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSelectFoundation = MDCSelectFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCSelectFoundation;
- /***/ }),
- /***/ "./packages/mdc-select/helper-text/adapter.ts":
- /*!****************************************************!*\
- !*** ./packages/mdc-select/helper-text/adapter.ts ***!
- \****************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /***/ }),
- /***/ "./packages/mdc-select/helper-text/component.ts":
- /*!******************************************************!*\
- !*** ./packages/mdc-select/helper-text/component.ts ***!
- \******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCSelectHelperText = void 0;
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts");
- /** MDC Select Helper Text */
- var MDCSelectHelperText = /** @class */function (_super) {
- __extends(MDCSelectHelperText, _super);
- function MDCSelectHelperText() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCSelectHelperText.attachTo = function (root) {
- return new MDCSelectHelperText(root);
- };
- Object.defineProperty(MDCSelectHelperText.prototype, "foundationForSelect", {
- // Provided for access by MDCSelect component
- get: function get() {
- return this.foundation;
- },
- enumerable: false,
- configurable: true
- });
- MDCSelectHelperText.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- addClass: function addClass(className) {
- _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- getAttr: function getAttr(attr) {
- return _this.root.getAttribute(attr);
- },
- setAttr: function setAttr(attr, value) {
- _this.safeSetAttribute(_this.root, attr, value);
- },
- removeAttr: function removeAttr(attr) {
- _this.root.removeAttribute(attr);
- },
- setContent: function setContent(content) {
- _this.root.textContent = content;
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCSelectHelperTextFoundation(adapter);
- };
- return MDCSelectHelperText;
- }(component_1.MDCComponent);
- exports.MDCSelectHelperText = MDCSelectHelperText;
- /***/ }),
- /***/ "./packages/mdc-select/helper-text/constants.ts":
- /*!******************************************************!*\
- !*** ./packages/mdc-select/helper-text/constants.ts ***!
- \******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.cssClasses = exports.strings = void 0;
- var strings = {
- ARIA_HIDDEN: 'aria-hidden',
- ROLE: 'role'
- };
- exports.strings = strings;
- var cssClasses = {
- HELPER_TEXT_VALIDATION_MSG: 'mdc-select-helper-text--validation-msg',
- HELPER_TEXT_VALIDATION_MSG_PERSISTENT: 'mdc-select-helper-text--validation-msg-persistent'
- };
- exports.cssClasses = cssClasses;
- /***/ }),
- /***/ "./packages/mdc-select/helper-text/foundation.ts":
- /*!*******************************************************!*\
- !*** ./packages/mdc-select/helper-text/foundation.ts ***!
- \*******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCSelectHelperTextFoundation = void 0;
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
- /** MDC Select Helper Text Foundation */
- var MDCSelectHelperTextFoundation = /** @class */function (_super) {
- __extends(MDCSelectHelperTextFoundation, _super);
- function MDCSelectHelperTextFoundation(adapter) {
- return _super.call(this, __assign(__assign({}, MDCSelectHelperTextFoundation.defaultAdapter), adapter)) || this;
- }
- Object.defineProperty(MDCSelectHelperTextFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelectHelperTextFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelectHelperTextFoundation, "defaultAdapter", {
- /**
- * See {@link MDCSelectHelperTextAdapter} for typing information on parameters
- * and return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return false;
- },
- setAttr: function setAttr() {
- return undefined;
- },
- getAttr: function getAttr() {
- return null;
- },
- removeAttr: function removeAttr() {
- return undefined;
- },
- setContent: function setContent() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: false,
- configurable: true
- });
- /**
- * @return The ID of the helper text, or null if none is set.
- */
- MDCSelectHelperTextFoundation.prototype.getId = function () {
- return this.adapter.getAttr('id');
- };
- /**
- * @return Whether the helper text is currently visible.
- */
- MDCSelectHelperTextFoundation.prototype.isVisible = function () {
- return this.adapter.getAttr(constants_1.strings.ARIA_HIDDEN) !== 'true';
- };
- /**
- * Sets the content of the helper text field.
- */
- MDCSelectHelperTextFoundation.prototype.setContent = function (content) {
- this.adapter.setContent(content);
- };
- /**
- * Sets the helper text to act as a validation message.
- * By default, validation messages are hidden when the select is valid and
- * visible when the select is invalid.
- *
- * @param isValidation True to make the helper text act as an error validation
- * message.
- */
- MDCSelectHelperTextFoundation.prototype.setValidation = function (isValidation) {
- if (isValidation) {
- this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
- } else {
- this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
- }
- };
- /**
- * Sets the persistency of the validation helper text.
- * This keeps the validation message visible even if the select is valid,
- * though it will be displayed in the normal (grey) color.
- */
- MDCSelectHelperTextFoundation.prototype.setValidationMsgPersistent = function (isPersistent) {
- if (isPersistent) {
- this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
- } else {
- this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
- }
- };
- /**
- * @return Whether the helper text acts as a validation message.
- * By default, validation messages are hidden when the select is valid and
- * visible when the select is invalid.
- */
- MDCSelectHelperTextFoundation.prototype.getIsValidation = function () {
- return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
- };
- /**
- * @return Whether the validation helper text persists even if the input is
- * valid. If it is, it will be displayed in the normal (grey) color.
- */
- MDCSelectHelperTextFoundation.prototype.getIsValidationMsgPersistent = function () {
- return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
- };
- /**
- * When acting as a validation message, shows/hides the helper text and
- * triggers alerts as necessary based on the select's validity.
- */
- MDCSelectHelperTextFoundation.prototype.setValidity = function (selectIsValid) {
- var isValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
- if (!isValidationMsg) {
- // Non-validating helper-text is always displayed and does not participate
- // in validation logic.
- return;
- }
- var isPersistentValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
- // Validating helper text is displayed if select is invalid, unless it is
- // set as persistent, in which case it always displays.
- var msgShouldDisplay = !selectIsValid || isPersistentValidationMsg;
- if (msgShouldDisplay) {
- this.showToScreenReader();
- // In addition to displaying, also trigger an alert if the select
- // has become invalid.
- if (!selectIsValid) {
- this.adapter.setAttr(constants_1.strings.ROLE, 'alert');
- } else {
- this.adapter.removeAttr(constants_1.strings.ROLE);
- }
- return;
- }
- // Hide everything.
- this.adapter.removeAttr(constants_1.strings.ROLE);
- this.hide();
- };
- /**
- * Makes the helper text visible to screen readers.
- */
- MDCSelectHelperTextFoundation.prototype.showToScreenReader = function () {
- this.adapter.removeAttr(constants_1.strings.ARIA_HIDDEN);
- };
- /**
- * Hides the help text from screen readers.
- */
- MDCSelectHelperTextFoundation.prototype.hide = function () {
- this.adapter.setAttr(constants_1.strings.ARIA_HIDDEN, 'true');
- };
- return MDCSelectHelperTextFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSelectHelperTextFoundation = MDCSelectHelperTextFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCSelectHelperTextFoundation;
- /***/ }),
- /***/ "./packages/mdc-select/helper-text/index.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-select/helper-text/index.ts ***!
- \**************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function get() {
- return m[k];
- } });
- } : function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- var __exportStar = this && this.__exportStar || function (m, exports) {
- for (var p in m) {
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.helperTextStrings = exports.helperTextCssClasses = void 0;
- __exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-select/helper-text/adapter.ts"), exports);
- __exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-select/helper-text/component.ts"), exports);
- __exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts"), exports);
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
- Object.defineProperty(exports, "helperTextCssClasses", { enumerable: true, get: function get() {
- return constants_1.cssClasses;
- } });
- Object.defineProperty(exports, "helperTextStrings", { enumerable: true, get: function get() {
- return constants_1.strings;
- } });
- /***/ }),
- /***/ "./packages/mdc-select/icon/adapter.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-select/icon/adapter.ts ***!
- \*********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /***/ }),
- /***/ "./packages/mdc-select/icon/component.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-select/icon/component.ts ***!
- \***********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCSelectIcon = void 0;
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts");
- /** MDC Select Icon */
- var MDCSelectIcon = /** @class */function (_super) {
- __extends(MDCSelectIcon, _super);
- function MDCSelectIcon() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCSelectIcon.attachTo = function (root) {
- return new MDCSelectIcon(root);
- };
- Object.defineProperty(MDCSelectIcon.prototype, "foundationForSelect", {
- // Provided for access by MDCSelect component
- get: function get() {
- return this.foundation;
- },
- enumerable: false,
- configurable: true
- });
- MDCSelectIcon.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- getAttr: function getAttr(attr) {
- return _this.root.getAttribute(attr);
- },
- setAttr: function setAttr(attr, value) {
- _this.safeSetAttribute(_this.root, attr, value);
- },
- removeAttr: function removeAttr(attr) {
- _this.root.removeAttribute(attr);
- },
- setContent: function setContent(content) {
- _this.root.textContent = content;
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- _this.listen(evtType, handler);
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- _this.unlisten(evtType, handler);
- },
- notifyIconAction: function notifyIconAction() {
- _this.emit(foundation_1.MDCSelectIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */);
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCSelectIconFoundation(adapter);
- };
- return MDCSelectIcon;
- }(component_1.MDCComponent);
- exports.MDCSelectIcon = MDCSelectIcon;
- /***/ }),
- /***/ "./packages/mdc-select/icon/constants.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-select/icon/constants.ts ***!
- \***********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.strings = void 0;
- var strings = {
- ICON_EVENT: 'MDCSelect:icon',
- ICON_ROLE: 'button'
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-select/icon/foundation.ts":
- /*!************************************************!*\
- !*** ./packages/mdc-select/icon/foundation.ts ***!
- \************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var __values = this && this.__values || function (o) {
- var s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.MDCSelectIconFoundation = void 0;
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
- var INTERACTION_EVENTS = ['click', 'keydown'];
- /** MDC Select Icon Foundation */
- var MDCSelectIconFoundation = /** @class */function (_super) {
- __extends(MDCSelectIconFoundation, _super);
- function MDCSelectIconFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCSelectIconFoundation.defaultAdapter), adapter)) || this;
- _this.savedTabIndex = null;
- _this.interactionHandler = function (evt) {
- _this.handleInteraction(evt);
- };
- return _this;
- }
- Object.defineProperty(MDCSelectIconFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: false,
- configurable: true
- });
- Object.defineProperty(MDCSelectIconFoundation, "defaultAdapter", {
- /**
- * See {@link MDCSelectIconAdapter} for typing information on parameters and
- * return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- getAttr: function getAttr() {
- return null;
- },
- setAttr: function setAttr() {
- return undefined;
- },
- removeAttr: function removeAttr() {
- return undefined;
- },
- setContent: function setContent() {
- return undefined;
- },
- registerInteractionHandler: function registerInteractionHandler() {
- return undefined;
- },
- deregisterInteractionHandler: function deregisterInteractionHandler() {
- return undefined;
- },
- notifyIconAction: function notifyIconAction() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: false,
- configurable: true
- });
- MDCSelectIconFoundation.prototype.init = function () {
- var e_1, _a;
- this.savedTabIndex = this.adapter.getAttr('tabindex');
- try {
- 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()) {
- var evtType = INTERACTION_EVENTS_1_1.value;
- this.adapter.registerInteractionHandler(evtType, this.interactionHandler);
- }
- } catch (e_1_1) {
- e_1 = { error: e_1_1 };
- } finally {
- try {
- if (INTERACTION_EVENTS_1_1 && !INTERACTION_EVENTS_1_1.done && (_a = INTERACTION_EVENTS_1.return)) _a.call(INTERACTION_EVENTS_1);
- } finally {
- if (e_1) throw e_1.error;
- }
- }
- };
- MDCSelectIconFoundation.prototype.destroy = function () {
- var e_2, _a;
- try {
- 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()) {
- var evtType = INTERACTION_EVENTS_2_1.value;
- this.adapter.deregisterInteractionHandler(evtType, this.interactionHandler);
- }
- } catch (e_2_1) {
- e_2 = { error: e_2_1 };
- } finally {
- try {
- if (INTERACTION_EVENTS_2_1 && !INTERACTION_EVENTS_2_1.done && (_a = INTERACTION_EVENTS_2.return)) _a.call(INTERACTION_EVENTS_2);
- } finally {
- if (e_2) throw e_2.error;
- }
- }
- };
- MDCSelectIconFoundation.prototype.setDisabled = function (disabled) {
- if (!this.savedTabIndex) {
- return;
- }
- if (disabled) {
- this.adapter.setAttr('tabindex', '-1');
- this.adapter.removeAttr('role');
- } else {
- this.adapter.setAttr('tabindex', this.savedTabIndex);
- this.adapter.setAttr('role', constants_1.strings.ICON_ROLE);
- }
- };
- MDCSelectIconFoundation.prototype.setAriaLabel = function (label) {
- this.adapter.setAttr('aria-label', label);
- };
- MDCSelectIconFoundation.prototype.setContent = function (content) {
- this.adapter.setContent(content);
- };
- MDCSelectIconFoundation.prototype.handleInteraction = function (evt) {
- var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
- if (evt.type === 'click' || isEnterKey) {
- this.adapter.notifyIconAction();
- }
- };
- return MDCSelectIconFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSelectIconFoundation = MDCSelectIconFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCSelectIconFoundation;
- /***/ }),
- /***/ "./packages/mdc-select/icon/index.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-select/icon/index.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function get() {
- return m[k];
- } });
- } : function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- var __exportStar = this && this.__exportStar || function (m, exports) {
- for (var p in m) {
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.iconStrings = void 0;
- __exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-select/icon/adapter.ts"), exports);
- __exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-select/icon/component.ts"), exports);
- __exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts"), exports);
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
- Object.defineProperty(exports, "iconStrings", { enumerable: true, get: function get() {
- return constants_1.strings;
- } });
- /***/ }),
- /***/ "./packages/mdc-select/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-select/index.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- Object.defineProperty(o, k2, { enumerable: true, get: function get() {
- return m[k];
- } });
- } : function (o, m, k, k2) {
- if (k2 === undefined) k2 = k;
- o[k2] = m[k];
- });
- var __exportStar = this && this.__exportStar || function (m, exports) {
- for (var p in m) {
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- __exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-select/adapter.ts"), exports);
- __exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-select/component.ts"), exports);
- __exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts"), exports);
- __exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts"), exports);
- __exportStar(__webpack_require__(/*! ./types */ "./packages/mdc-select/types.ts"), exports);
- __exportStar(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-select/helper-text/index.ts"), exports);
- __exportStar(__webpack_require__(/*! ./icon/index */ "./packages/mdc-select/icon/index.ts"), exports);
- /***/ }),
- /***/ "./packages/mdc-select/types.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-select/types.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /***/ })
- /******/ });
- });
- //# sourceMappingURL=mdc.select.js.map
|