123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567 |
- /**
- * @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([], factory);
- else if(typeof exports === 'object')
- exports["mdc"] = factory();
- else
- root["mdc"] = 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/material-components-web/index.ts");
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ "./packages/material-components-web/index.ts":
- /*!***************************************************!*\
- !*** ./packages/material-components-web/index.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 __importDefault = this && this.__importDefault || function (mod) {
- return mod && mod.__esModule ? mod : { "default": mod };
- };
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var index_1 = __importDefault(__webpack_require__(/*! @material/auto-init/index */ "./packages/mdc-auto-init/index.ts"));
- exports.autoInit = index_1.default;
- var base = __importStar(__webpack_require__(/*! @material/base/index */ "./packages/mdc-base/index.ts"));
- exports.base = base;
- var checkbox = __importStar(__webpack_require__(/*! @material/checkbox/index */ "./packages/mdc-checkbox/index.ts"));
- exports.checkbox = checkbox;
- var chips = __importStar(__webpack_require__(/*! @material/chips/index */ "./packages/mdc-chips/index.ts"));
- exports.chips = chips;
- var dataTable = __importStar(__webpack_require__(/*! @material/data-table/index */ "./packages/mdc-data-table/index.ts"));
- exports.dataTable = dataTable;
- var dialog = __importStar(__webpack_require__(/*! @material/dialog/index */ "./packages/mdc-dialog/index.ts"));
- exports.dialog = dialog;
- var dom = __importStar(__webpack_require__(/*! @material/dom/index */ "./packages/mdc-dom/index.ts"));
- exports.dom = dom;
- var drawer = __importStar(__webpack_require__(/*! @material/drawer/index */ "./packages/mdc-drawer/index.ts"));
- exports.drawer = drawer;
- var floatingLabel = __importStar(__webpack_require__(/*! @material/floating-label/index */ "./packages/mdc-floating-label/index.ts"));
- exports.floatingLabel = floatingLabel;
- var formField = __importStar(__webpack_require__(/*! @material/form-field/index */ "./packages/mdc-form-field/index.ts"));
- exports.formField = formField;
- var iconButton = __importStar(__webpack_require__(/*! @material/icon-button/index */ "./packages/mdc-icon-button/index.ts"));
- exports.iconButton = iconButton;
- var lineRipple = __importStar(__webpack_require__(/*! @material/line-ripple/index */ "./packages/mdc-line-ripple/index.ts"));
- exports.lineRipple = lineRipple;
- var linearProgress = __importStar(__webpack_require__(/*! @material/linear-progress/index */ "./packages/mdc-linear-progress/index.ts"));
- exports.linearProgress = linearProgress;
- var list = __importStar(__webpack_require__(/*! @material/list/index */ "./packages/mdc-list/index.ts"));
- exports.list = list;
- var menuSurface = __importStar(__webpack_require__(/*! @material/menu-surface/index */ "./packages/mdc-menu-surface/index.ts"));
- exports.menuSurface = menuSurface;
- var menu = __importStar(__webpack_require__(/*! @material/menu/index */ "./packages/mdc-menu/index.ts"));
- exports.menu = menu;
- var notchedOutline = __importStar(__webpack_require__(/*! @material/notched-outline/index */ "./packages/mdc-notched-outline/index.ts"));
- exports.notchedOutline = notchedOutline;
- var radio = __importStar(__webpack_require__(/*! @material/radio/index */ "./packages/mdc-radio/index.ts"));
- exports.radio = radio;
- var ripple = __importStar(__webpack_require__(/*! @material/ripple/index */ "./packages/mdc-ripple/index.ts"));
- exports.ripple = ripple;
- var select = __importStar(__webpack_require__(/*! @material/select/index */ "./packages/mdc-select/index.ts"));
- exports.select = select;
- var slider = __importStar(__webpack_require__(/*! @material/slider/index */ "./packages/mdc-slider/index.ts"));
- exports.slider = slider;
- var snackbar = __importStar(__webpack_require__(/*! @material/snackbar/index */ "./packages/mdc-snackbar/index.ts"));
- exports.snackbar = snackbar;
- var switchControl = __importStar(__webpack_require__(/*! @material/switch/index */ "./packages/mdc-switch/index.ts"));
- exports.switchControl = switchControl;
- var tabBar = __importStar(__webpack_require__(/*! @material/tab-bar/index */ "./packages/mdc-tab-bar/index.ts"));
- exports.tabBar = tabBar;
- var tabIndicator = __importStar(__webpack_require__(/*! @material/tab-indicator/index */ "./packages/mdc-tab-indicator/index.ts"));
- exports.tabIndicator = tabIndicator;
- var tabScroller = __importStar(__webpack_require__(/*! @material/tab-scroller/index */ "./packages/mdc-tab-scroller/index.ts"));
- exports.tabScroller = tabScroller;
- var tab = __importStar(__webpack_require__(/*! @material/tab/index */ "./packages/mdc-tab/index.ts"));
- exports.tab = tab;
- var textField = __importStar(__webpack_require__(/*! @material/textfield/index */ "./packages/mdc-textfield/index.ts"));
- exports.textField = textField;
- var topAppBar = __importStar(__webpack_require__(/*! @material/top-app-bar/index */ "./packages/mdc-top-app-bar/index.ts"));
- exports.topAppBar = topAppBar;
- // Register all components
- index_1.default.register('MDCCheckbox', checkbox.MDCCheckbox);
- index_1.default.register('MDCChip', chips.MDCChip);
- index_1.default.register('MDCChipSet', chips.MDCChipSet);
- index_1.default.register('MDCDataTable', dataTable.MDCDataTable);
- index_1.default.register('MDCDialog', dialog.MDCDialog);
- index_1.default.register('MDCDrawer', drawer.MDCDrawer);
- index_1.default.register('MDCFloatingLabel', floatingLabel.MDCFloatingLabel);
- index_1.default.register('MDCFormField', formField.MDCFormField);
- index_1.default.register('MDCIconButtonToggle', iconButton.MDCIconButtonToggle);
- index_1.default.register('MDCLineRipple', lineRipple.MDCLineRipple);
- index_1.default.register('MDCLinearProgress', linearProgress.MDCLinearProgress);
- index_1.default.register('MDCList', list.MDCList);
- index_1.default.register('MDCMenu', menu.MDCMenu);
- index_1.default.register('MDCMenuSurface', menuSurface.MDCMenuSurface);
- index_1.default.register('MDCNotchedOutline', notchedOutline.MDCNotchedOutline);
- index_1.default.register('MDCRadio', radio.MDCRadio);
- index_1.default.register('MDCRipple', ripple.MDCRipple);
- index_1.default.register('MDCSelect', select.MDCSelect);
- index_1.default.register('MDCSlider', slider.MDCSlider);
- index_1.default.register('MDCSnackbar', snackbar.MDCSnackbar);
- index_1.default.register('MDCSwitch', switchControl.MDCSwitch);
- index_1.default.register('MDCTabBar', tabBar.MDCTabBar);
- index_1.default.register('MDCTextField', textField.MDCTextField);
- index_1.default.register('MDCTopAppBar', topAppBar.MDCTopAppBar);
- /***/ }),
- /***/ "./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 });
- 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-auto-init/constants.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-auto-init/constants.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.strings = {
- AUTO_INIT_ATTR: 'data-mdc-auto-init',
- AUTO_INIT_STATE_ATTR: 'data-mdc-auto-init-state',
- INITIALIZED_STATE: 'initialized'
- };
- /***/ }),
- /***/ "./packages/mdc-auto-init/index.ts":
- /*!*****************************************!*\
- !*** ./packages/mdc-auto-init/index.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 __values = this && this.__values || function (o) {
- var m = typeof Symbol === "function" && o[Symbol.iterator],
- i = 0;
- if (m) return m.call(o);
- return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-auto-init/constants.ts");
- var AUTO_INIT_ATTR = constants_1.strings.AUTO_INIT_ATTR,
- AUTO_INIT_STATE_ATTR = constants_1.strings.AUTO_INIT_STATE_ATTR,
- INITIALIZED_STATE = constants_1.strings.INITIALIZED_STATE;
- var registry = {};
- var CONSOLE_WARN = console.warn.bind(console); // tslint:disable-line:no-console
- function emit(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);
- }
- document.dispatchEvent(evt);
- }
- /* istanbul ignore next: optional argument is not a branch statement */
- /**
- * Auto-initializes all MDC components on a page.
- */
- function mdcAutoInit(root) {
- var e_1, _a;
- if (root === void 0) {
- root = document;
- }
- var components = [];
- var nodes = [].slice.call(root.querySelectorAll("[" + AUTO_INIT_ATTR + "]"));
- nodes = nodes.filter(function (node) {
- return node.getAttribute(AUTO_INIT_STATE_ATTR) !== INITIALIZED_STATE;
- });
- try {
- for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
- var node = nodes_1_1.value;
- var ctorName = node.getAttribute(AUTO_INIT_ATTR);
- if (!ctorName) {
- throw new Error('(mdc-auto-init) Constructor name must be given.');
- }
- var Constructor = registry[ctorName]; // tslint:disable-line:variable-name
- if (typeof Constructor !== 'function') {
- throw new Error("(mdc-auto-init) Could not find constructor in registry for " + ctorName);
- }
- // TODO: Should we make an eslint rule for an attachTo() static method?
- // See https://github.com/Microsoft/TypeScript/issues/14600 for discussion of static interface support in TS
- var component = Constructor.attachTo(node);
- Object.defineProperty(node, ctorName, {
- configurable: true,
- enumerable: false,
- value: component,
- writable: false
- });
- components.push(component);
- node.setAttribute(AUTO_INIT_STATE_ATTR, INITIALIZED_STATE);
- }
- } catch (e_1_1) {
- e_1 = { error: e_1_1 };
- } finally {
- try {
- if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
- } finally {
- if (e_1) throw e_1.error;
- }
- }
- emit('MDCAutoInit:End', {});
- return components;
- }
- exports.mdcAutoInit = mdcAutoInit;
- // Constructor is PascalCased because it is a direct reference to a class, rather than an instance of a class.
- // tslint:disable-next-line:variable-name
- mdcAutoInit.register = function (componentName, Constructor, warn) {
- if (warn === void 0) {
- warn = CONSOLE_WARN;
- }
- if (typeof Constructor !== 'function') {
- throw new Error("(mdc-auto-init) Invalid Constructor value: " + Constructor + ". Expected function.");
- }
- var registryValue = registry[componentName];
- if (registryValue) {
- warn("(mdc-auto-init) Overriding registration for " + componentName + " with " + Constructor + ". Was: " + registryValue);
- }
- registry[componentName] = Constructor;
- };
- mdcAutoInit.deregister = function (componentName) {
- delete registry[componentName];
- };
- mdcAutoInit.deregisterAll = function () {
- var keys = Object.keys(registry);
- keys.forEach(this.deregister, this);
- };
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = mdcAutoInit;
- /***/ }),
- /***/ "./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 __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 __spread = this && this.__spread || function () {
- for (var ar = [], i = 0; i < arguments.length; i++) {
- ar = ar.concat(__read(arguments[i]));
- }return ar;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
- 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, __spread(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 */
- 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);
- };
- 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;
- /***/ }),
- /***/ "./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 });
- 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: true,
- 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: true,
- 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: true,
- 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: true,
- 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-base/index.ts":
- /*!************************************!*\
- !*** ./packages/mdc-base/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-base/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-checkbox/component.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-checkbox/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- 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 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 component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-checkbox/foundation.ts");
- var CB_PROTO_PROPS = ['checked', 'indeterminate'];
- var MDCCheckbox = /** @class */function (_super) {
- __extends(MDCCheckbox, _super);
- function MDCCheckbox() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.ripple_ = _this.createRipple_();
- return _this;
- }
- MDCCheckbox.attachTo = function (root) {
- return new MDCCheckbox(root);
- };
- Object.defineProperty(MDCCheckbox.prototype, "ripple", {
- get: function get() {
- return this.ripple_;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCheckbox.prototype, "checked", {
- get: function get() {
- return this.nativeControl_.checked;
- },
- set: function set(checked) {
- this.nativeControl_.checked = checked;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCheckbox.prototype, "indeterminate", {
- get: function get() {
- return this.nativeControl_.indeterminate;
- },
- set: function set(indeterminate) {
- this.nativeControl_.indeterminate = indeterminate;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCheckbox.prototype, "disabled", {
- get: function get() {
- return this.nativeControl_.disabled;
- },
- set: function set(disabled) {
- this.foundation_.setDisabled(disabled);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCheckbox.prototype, "value", {
- get: function get() {
- return this.nativeControl_.value;
- },
- set: function set(value) {
- this.nativeControl_.value = value;
- },
- enumerable: true,
- configurable: true
- });
- MDCCheckbox.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleChange_ = function () {
- return _this.foundation_.handleChange();
- };
- this.handleAnimationEnd_ = function () {
- return _this.foundation_.handleAnimationEnd();
- };
- this.nativeControl_.addEventListener('change', this.handleChange_);
- this.listen(util_1.getCorrectEventName(window, 'animationend'), this.handleAnimationEnd_);
- this.installPropertyChangeHooks_();
- };
- MDCCheckbox.prototype.destroy = function () {
- this.ripple_.destroy();
- this.nativeControl_.removeEventListener('change', this.handleChange_);
- this.unlisten(util_1.getCorrectEventName(window, 'animationend'), this.handleAnimationEnd_);
- this.uninstallPropertyChangeHooks_();
- _super.prototype.destroy.call(this);
- };
- MDCCheckbox.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 = {
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- forceLayout: function forceLayout() {
- return _this.root_.offsetWidth;
- },
- hasNativeControl: function hasNativeControl() {
- return !!_this.nativeControl_;
- },
- isAttachedToDOM: function isAttachedToDOM() {
- return Boolean(_this.root_.parentNode);
- },
- isChecked: function isChecked() {
- return _this.checked;
- },
- isIndeterminate: function isIndeterminate() {
- return _this.indeterminate;
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- removeNativeControlAttr: function removeNativeControlAttr(attr) {
- return _this.nativeControl_.removeAttribute(attr);
- },
- setNativeControlAttr: function setNativeControlAttr(attr, value) {
- return _this.nativeControl_.setAttribute(attr, value);
- },
- setNativeControlDisabled: function setNativeControlDisabled(disabled) {
- return _this.nativeControl_.disabled = disabled;
- }
- };
- return new foundation_2.MDCCheckboxFoundation(adapter);
- };
- MDCCheckbox.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.
- var adapter = __assign({}, component_2.MDCRipple.createAdapter(this), { deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return _this.nativeControl_.removeEventListener(evtType, handler, events_1.applyPassive());
- }, isSurfaceActive: function isSurfaceActive() {
- return ponyfill_1.matches(_this.nativeControl_, ':active');
- }, isUnbounded: function isUnbounded() {
- return true;
- }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
- } });
- return new component_2.MDCRipple(this.root_, new foundation_1.MDCRippleFoundation(adapter));
- };
- MDCCheckbox.prototype.installPropertyChangeHooks_ = function () {
- var _this = this;
- var nativeCb = this.nativeControl_;
- var cbProto = Object.getPrototypeOf(nativeCb);
- CB_PROTO_PROPS.forEach(function (controlState) {
- var desc = Object.getOwnPropertyDescriptor(cbProto, controlState);
- // We have to check for this descriptor, since some browsers (Safari) don't support its return.
- // See: https://bugs.webkit.org/show_bug.cgi?id=49739
- if (!validDescriptor(desc)) {
- return;
- }
- // Type cast is needed for compatibility with Closure Compiler.
- var nativeGetter = desc.get;
- var nativeCbDesc = {
- configurable: desc.configurable,
- enumerable: desc.enumerable,
- get: nativeGetter,
- set: function set(state) {
- desc.set.call(nativeCb, state);
- _this.foundation_.handleChange();
- }
- };
- Object.defineProperty(nativeCb, controlState, nativeCbDesc);
- });
- };
- MDCCheckbox.prototype.uninstallPropertyChangeHooks_ = function () {
- var nativeCb = this.nativeControl_;
- var cbProto = Object.getPrototypeOf(nativeCb);
- CB_PROTO_PROPS.forEach(function (controlState) {
- var desc = Object.getOwnPropertyDescriptor(cbProto, controlState);
- if (!validDescriptor(desc)) {
- return;
- }
- Object.defineProperty(nativeCb, controlState, desc);
- });
- };
- Object.defineProperty(MDCCheckbox.prototype, "nativeControl_", {
- get: function get() {
- var NATIVE_CONTROL_SELECTOR = foundation_2.MDCCheckboxFoundation.strings.NATIVE_CONTROL_SELECTOR;
- var el = this.root_.querySelector(NATIVE_CONTROL_SELECTOR);
- if (!el) {
- throw new Error("Checkbox component requires a " + NATIVE_CONTROL_SELECTOR + " element");
- }
- return el;
- },
- enumerable: true,
- configurable: true
- });
- return MDCCheckbox;
- }(component_1.MDCComponent);
- exports.MDCCheckbox = MDCCheckbox;
- function validDescriptor(inputPropDesc) {
- return !!inputPropDesc && typeof inputPropDesc.set === 'function';
- }
- /***/ }),
- /***/ "./packages/mdc-checkbox/constants.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-checkbox/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 = {
- ANIM_CHECKED_INDETERMINATE: 'mdc-checkbox--anim-checked-indeterminate',
- ANIM_CHECKED_UNCHECKED: 'mdc-checkbox--anim-checked-unchecked',
- ANIM_INDETERMINATE_CHECKED: 'mdc-checkbox--anim-indeterminate-checked',
- ANIM_INDETERMINATE_UNCHECKED: 'mdc-checkbox--anim-indeterminate-unchecked',
- ANIM_UNCHECKED_CHECKED: 'mdc-checkbox--anim-unchecked-checked',
- ANIM_UNCHECKED_INDETERMINATE: 'mdc-checkbox--anim-unchecked-indeterminate',
- BACKGROUND: 'mdc-checkbox__background',
- CHECKED: 'mdc-checkbox--checked',
- CHECKMARK: 'mdc-checkbox__checkmark',
- CHECKMARK_PATH: 'mdc-checkbox__checkmark-path',
- DISABLED: 'mdc-checkbox--disabled',
- INDETERMINATE: 'mdc-checkbox--indeterminate',
- MIXEDMARK: 'mdc-checkbox__mixedmark',
- NATIVE_CONTROL: 'mdc-checkbox__native-control',
- ROOT: 'mdc-checkbox',
- SELECTED: 'mdc-checkbox--selected',
- UPGRADED: 'mdc-checkbox--upgraded'
- };
- exports.strings = {
- ARIA_CHECKED_ATTR: 'aria-checked',
- ARIA_CHECKED_INDETERMINATE_VALUE: 'mixed',
- NATIVE_CONTROL_SELECTOR: '.mdc-checkbox__native-control',
- TRANSITION_STATE_CHECKED: 'checked',
- TRANSITION_STATE_INDETERMINATE: 'indeterminate',
- TRANSITION_STATE_INIT: 'init',
- TRANSITION_STATE_UNCHECKED: 'unchecked'
- };
- exports.numbers = {
- ANIM_END_LATCH_MS: 250
- };
- /***/ }),
- /***/ "./packages/mdc-checkbox/foundation.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-checkbox/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts");
- var MDCCheckboxFoundation = /** @class */function (_super) {
- __extends(MDCCheckboxFoundation, _super);
- function MDCCheckboxFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCCheckboxFoundation.defaultAdapter, adapter)) || this;
- _this.currentCheckState_ = constants_1.strings.TRANSITION_STATE_INIT;
- _this.currentAnimationClass_ = '';
- _this.animEndLatchTimer_ = 0;
- _this.enableAnimationEndHandler_ = false;
- return _this;
- }
- Object.defineProperty(MDCCheckboxFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCheckboxFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCheckboxFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCheckboxFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- forceLayout: function forceLayout() {
- return undefined;
- },
- hasNativeControl: function hasNativeControl() {
- return false;
- },
- isAttachedToDOM: function isAttachedToDOM() {
- return false;
- },
- isChecked: function isChecked() {
- return false;
- },
- isIndeterminate: function isIndeterminate() {
- return false;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- removeNativeControlAttr: function removeNativeControlAttr() {
- return undefined;
- },
- setNativeControlAttr: function setNativeControlAttr() {
- return undefined;
- },
- setNativeControlDisabled: function setNativeControlDisabled() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCCheckboxFoundation.prototype.init = function () {
- this.currentCheckState_ = this.determineCheckState_();
- this.updateAriaChecked_();
- this.adapter_.addClass(constants_1.cssClasses.UPGRADED);
- };
- MDCCheckboxFoundation.prototype.destroy = function () {
- clearTimeout(this.animEndLatchTimer_);
- };
- MDCCheckboxFoundation.prototype.setDisabled = function (disabled) {
- this.adapter_.setNativeControlDisabled(disabled);
- if (disabled) {
- this.adapter_.addClass(constants_1.cssClasses.DISABLED);
- } else {
- this.adapter_.removeClass(constants_1.cssClasses.DISABLED);
- }
- };
- /**
- * Handles the animationend event for the checkbox
- */
- MDCCheckboxFoundation.prototype.handleAnimationEnd = function () {
- var _this = this;
- if (!this.enableAnimationEndHandler_) {
- return;
- }
- clearTimeout(this.animEndLatchTimer_);
- this.animEndLatchTimer_ = setTimeout(function () {
- _this.adapter_.removeClass(_this.currentAnimationClass_);
- _this.enableAnimationEndHandler_ = false;
- }, constants_1.numbers.ANIM_END_LATCH_MS);
- };
- /**
- * Handles the change event for the checkbox
- */
- MDCCheckboxFoundation.prototype.handleChange = function () {
- this.transitionCheckState_();
- };
- MDCCheckboxFoundation.prototype.transitionCheckState_ = function () {
- if (!this.adapter_.hasNativeControl()) {
- return;
- }
- var oldState = this.currentCheckState_;
- var newState = this.determineCheckState_();
- if (oldState === newState) {
- return;
- }
- this.updateAriaChecked_();
- var TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
- var SELECTED = constants_1.cssClasses.SELECTED;
- if (newState === TRANSITION_STATE_UNCHECKED) {
- this.adapter_.removeClass(SELECTED);
- } else {
- this.adapter_.addClass(SELECTED);
- }
- // Check to ensure that there isn't a previously existing animation class, in case for example
- // the user interacted with the checkbox before the animation was finished.
- if (this.currentAnimationClass_.length > 0) {
- clearTimeout(this.animEndLatchTimer_);
- this.adapter_.forceLayout();
- this.adapter_.removeClass(this.currentAnimationClass_);
- }
- this.currentAnimationClass_ = this.getTransitionAnimationClass_(oldState, newState);
- this.currentCheckState_ = newState;
- // Check for parentNode so that animations are only run when the element is attached
- // to the DOM.
- if (this.adapter_.isAttachedToDOM() && this.currentAnimationClass_.length > 0) {
- this.adapter_.addClass(this.currentAnimationClass_);
- this.enableAnimationEndHandler_ = true;
- }
- };
- MDCCheckboxFoundation.prototype.determineCheckState_ = function () {
- var TRANSITION_STATE_INDETERMINATE = constants_1.strings.TRANSITION_STATE_INDETERMINATE,
- TRANSITION_STATE_CHECKED = constants_1.strings.TRANSITION_STATE_CHECKED,
- TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
- if (this.adapter_.isIndeterminate()) {
- return TRANSITION_STATE_INDETERMINATE;
- }
- return this.adapter_.isChecked() ? TRANSITION_STATE_CHECKED : TRANSITION_STATE_UNCHECKED;
- };
- MDCCheckboxFoundation.prototype.getTransitionAnimationClass_ = function (oldState, newState) {
- var TRANSITION_STATE_INIT = constants_1.strings.TRANSITION_STATE_INIT,
- TRANSITION_STATE_CHECKED = constants_1.strings.TRANSITION_STATE_CHECKED,
- TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
- var _a = MDCCheckboxFoundation.cssClasses,
- ANIM_UNCHECKED_CHECKED = _a.ANIM_UNCHECKED_CHECKED,
- ANIM_UNCHECKED_INDETERMINATE = _a.ANIM_UNCHECKED_INDETERMINATE,
- ANIM_CHECKED_UNCHECKED = _a.ANIM_CHECKED_UNCHECKED,
- ANIM_CHECKED_INDETERMINATE = _a.ANIM_CHECKED_INDETERMINATE,
- ANIM_INDETERMINATE_CHECKED = _a.ANIM_INDETERMINATE_CHECKED,
- ANIM_INDETERMINATE_UNCHECKED = _a.ANIM_INDETERMINATE_UNCHECKED;
- switch (oldState) {
- case TRANSITION_STATE_INIT:
- if (newState === TRANSITION_STATE_UNCHECKED) {
- return '';
- }
- return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED;
- case TRANSITION_STATE_UNCHECKED:
- return newState === TRANSITION_STATE_CHECKED ? ANIM_UNCHECKED_CHECKED : ANIM_UNCHECKED_INDETERMINATE;
- case TRANSITION_STATE_CHECKED:
- return newState === TRANSITION_STATE_UNCHECKED ? ANIM_CHECKED_UNCHECKED : ANIM_CHECKED_INDETERMINATE;
- default:
- // TRANSITION_STATE_INDETERMINATE
- return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED;
- }
- };
- MDCCheckboxFoundation.prototype.updateAriaChecked_ = function () {
- // Ensure aria-checked is set to mixed if checkbox is in indeterminate state.
- if (this.adapter_.isIndeterminate()) {
- this.adapter_.setNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR, constants_1.strings.ARIA_CHECKED_INDETERMINATE_VALUE);
- } else {
- // The on/off state does not need to keep track of aria-checked, since
- // the screenreader uses the checked property on the checkbox element.
- this.adapter_.removeNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR);
- }
- };
- return MDCCheckboxFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCCheckboxFoundation = MDCCheckboxFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCCheckboxFoundation;
- /***/ }),
- /***/ "./packages/mdc-checkbox/index.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-checkbox/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-checkbox/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-checkbox/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-chips/chip-set/component.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-chips/chip-set/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var announce_1 = __webpack_require__(/*! @material/dom/announce */ "./packages/mdc-dom/announce.ts");
- var component_2 = __webpack_require__(/*! ../chip/component */ "./packages/mdc-chips/chip/component.ts");
- var foundation_1 = __webpack_require__(/*! ../chip/foundation */ "./packages/mdc-chips/chip/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip-set/foundation.ts");
- var _a = foundation_1.MDCChipFoundation.strings,
- INTERACTION_EVENT = _a.INTERACTION_EVENT,
- SELECTION_EVENT = _a.SELECTION_EVENT,
- REMOVAL_EVENT = _a.REMOVAL_EVENT,
- NAVIGATION_EVENT = _a.NAVIGATION_EVENT;
- var CHIP_SELECTOR = foundation_2.MDCChipSetFoundation.strings.CHIP_SELECTOR;
- var idCounter = 0;
- var MDCChipSet = /** @class */function (_super) {
- __extends(MDCChipSet, _super);
- function MDCChipSet() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCChipSet.attachTo = function (root) {
- return new MDCChipSet(root);
- };
- Object.defineProperty(MDCChipSet.prototype, "chips", {
- get: function get() {
- return this.chips_.slice();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipSet.prototype, "selectedChipIds", {
- /**
- * @return An array of the IDs of all selected chips.
- */
- get: function get() {
- return this.foundation_.getSelectedChipIds();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param chipFactory A function which creates a new MDCChip.
- */
- MDCChipSet.prototype.initialize = function (chipFactory) {
- if (chipFactory === void 0) {
- chipFactory = function chipFactory(el) {
- return new component_2.MDCChip(el);
- };
- }
- this.chipFactory_ = chipFactory;
- this.chips_ = this.instantiateChips_(this.chipFactory_);
- };
- MDCChipSet.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.chips_.forEach(function (chip) {
- if (chip.id && chip.selected) {
- _this.foundation_.select(chip.id);
- }
- });
- this.handleChipInteraction_ = function (evt) {
- return _this.foundation_.handleChipInteraction(evt.detail);
- };
- this.handleChipSelection_ = function (evt) {
- return _this.foundation_.handleChipSelection(evt.detail);
- };
- this.handleChipRemoval_ = function (evt) {
- return _this.foundation_.handleChipRemoval(evt.detail);
- };
- this.handleChipNavigation_ = function (evt) {
- return _this.foundation_.handleChipNavigation(evt.detail);
- };
- this.listen(INTERACTION_EVENT, this.handleChipInteraction_);
- this.listen(SELECTION_EVENT, this.handleChipSelection_);
- this.listen(REMOVAL_EVENT, this.handleChipRemoval_);
- this.listen(NAVIGATION_EVENT, this.handleChipNavigation_);
- };
- MDCChipSet.prototype.destroy = function () {
- this.chips_.forEach(function (chip) {
- chip.destroy();
- });
- this.unlisten(INTERACTION_EVENT, this.handleChipInteraction_);
- this.unlisten(SELECTION_EVENT, this.handleChipSelection_);
- this.unlisten(REMOVAL_EVENT, this.handleChipRemoval_);
- this.unlisten(NAVIGATION_EVENT, this.handleChipNavigation_);
- _super.prototype.destroy.call(this);
- };
- /**
- * Adds a new chip object to the chip set from the given chip element.
- */
- MDCChipSet.prototype.addChip = function (chipEl) {
- chipEl.id = chipEl.id || "mdc-chip-" + ++idCounter;
- this.chips_.push(this.chipFactory_(chipEl));
- };
- MDCChipSet.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 = {
- announceMessage: function announceMessage(message) {
- announce_1.announce(message);
- },
- focusChipPrimaryActionAtIndex: function focusChipPrimaryActionAtIndex(index) {
- _this.chips_[index].focusPrimaryAction();
- },
- focusChipTrailingActionAtIndex: function focusChipTrailingActionAtIndex(index) {
- _this.chips_[index].focusTrailingAction();
- },
- getChipListCount: function getChipListCount() {
- return _this.chips_.length;
- },
- getIndexOfChipById: function getIndexOfChipById(chipId) {
- return _this.findChipIndex_(chipId);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- isRTL: function isRTL() {
- return window.getComputedStyle(_this.root_).getPropertyValue('direction') === 'rtl';
- },
- removeChipAtIndex: function removeChipAtIndex(index) {
- if (index >= 0 && index < _this.chips_.length) {
- _this.chips_[index].destroy();
- _this.chips_[index].remove();
- _this.chips_.splice(index, 1);
- }
- },
- removeFocusFromChipAtIndex: function removeFocusFromChipAtIndex(index) {
- _this.chips_[index].removeFocus();
- },
- selectChipAtIndex: function selectChipAtIndex(index, selected, shouldNotifyClients) {
- if (index >= 0 && index < _this.chips_.length) {
- _this.chips_[index].setSelectedFromChipSet(selected, shouldNotifyClients);
- }
- }
- };
- return new foundation_2.MDCChipSetFoundation(adapter);
- };
- /**
- * Instantiates chip components on all of the chip set's child chip elements.
- */
- MDCChipSet.prototype.instantiateChips_ = function (chipFactory) {
- var chipElements = [].slice.call(this.root_.querySelectorAll(CHIP_SELECTOR));
- return chipElements.map(function (el) {
- el.id = el.id || "mdc-chip-" + ++idCounter;
- return chipFactory(el);
- });
- };
- /**
- * Returns the index of the chip with the given id, or -1 if the chip does not exist.
- */
- MDCChipSet.prototype.findChipIndex_ = function (chipId) {
- for (var i = 0; i < this.chips_.length; i++) {
- if (this.chips_[i].id === chipId) {
- return i;
- }
- }
- return -1;
- };
- return MDCChipSet;
- }(component_1.MDCComponent);
- exports.MDCChipSet = MDCChipSet;
- /***/ }),
- /***/ "./packages/mdc-chips/chip-set/constants.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-chips/chip-set/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.strings = {
- CHIP_SELECTOR: '.mdc-chip'
- };
- exports.cssClasses = {
- CHOICE: 'mdc-chip-set--choice',
- FILTER: 'mdc-chip-set--filter'
- };
- /***/ }),
- /***/ "./packages/mdc-chips/chip-set/foundation.ts":
- /*!***************************************************!*\
- !*** ./packages/mdc-chips/chip-set/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ../chip/constants */ "./packages/mdc-chips/chip/constants.ts");
- var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip-set/constants.ts");
- var MDCChipSetFoundation = /** @class */function (_super) {
- __extends(MDCChipSetFoundation, _super);
- function MDCChipSetFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCChipSetFoundation.defaultAdapter, adapter)) || this;
- /**
- * The ids of the selected chips in the set. Only used for choice chip set or filter chip set.
- */
- _this.selectedChipIds_ = [];
- return _this;
- }
- Object.defineProperty(MDCChipSetFoundation, "strings", {
- get: function get() {
- return constants_2.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipSetFoundation, "cssClasses", {
- get: function get() {
- return constants_2.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipSetFoundation, "defaultAdapter", {
- get: function get() {
- return {
- announceMessage: function announceMessage() {
- return undefined;
- },
- focusChipPrimaryActionAtIndex: function focusChipPrimaryActionAtIndex() {
- return undefined;
- },
- focusChipTrailingActionAtIndex: function focusChipTrailingActionAtIndex() {
- return undefined;
- },
- getChipListCount: function getChipListCount() {
- return -1;
- },
- getIndexOfChipById: function getIndexOfChipById() {
- return -1;
- },
- hasClass: function hasClass() {
- return false;
- },
- isRTL: function isRTL() {
- return false;
- },
- removeChipAtIndex: function removeChipAtIndex() {
- return undefined;
- },
- removeFocusFromChipAtIndex: function removeFocusFromChipAtIndex() {
- return undefined;
- },
- selectChipAtIndex: function selectChipAtIndex() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Returns an array of the IDs of all selected chips.
- */
- MDCChipSetFoundation.prototype.getSelectedChipIds = function () {
- return this.selectedChipIds_.slice();
- };
- /**
- * Selects the chip with the given id. Deselects all other chips if the chip set is of the choice variant.
- * Does not notify clients of the updated selection state.
- */
- MDCChipSetFoundation.prototype.select = function (chipId) {
- this.select_(chipId, false);
- };
- /**
- * Handles a chip interaction event
- */
- MDCChipSetFoundation.prototype.handleChipInteraction = function (_a) {
- var chipId = _a.chipId;
- var index = this.adapter_.getIndexOfChipById(chipId);
- this.removeFocusFromChipsExcept_(index);
- if (this.adapter_.hasClass(constants_2.cssClasses.CHOICE) || this.adapter_.hasClass(constants_2.cssClasses.FILTER)) {
- this.toggleSelect_(chipId);
- }
- };
- /**
- * Handles a chip selection event, used to handle discrepancy when selection state is set directly on the Chip.
- */
- MDCChipSetFoundation.prototype.handleChipSelection = function (_a) {
- var chipId = _a.chipId,
- selected = _a.selected,
- shouldIgnore = _a.shouldIgnore;
- // Early exit if we should ignore the event
- if (shouldIgnore) {
- return;
- }
- var chipIsSelected = this.selectedChipIds_.indexOf(chipId) >= 0;
- if (selected && !chipIsSelected) {
- this.select(chipId);
- } else if (!selected && chipIsSelected) {
- this.deselect_(chipId);
- }
- };
- /**
- * Handles the event when a chip is removed.
- */
- MDCChipSetFoundation.prototype.handleChipRemoval = function (_a) {
- var chipId = _a.chipId,
- removedAnnouncement = _a.removedAnnouncement;
- if (removedAnnouncement) {
- this.adapter_.announceMessage(removedAnnouncement);
- }
- var index = this.adapter_.getIndexOfChipById(chipId);
- this.deselectAndNotifyClients_(chipId);
- this.adapter_.removeChipAtIndex(index);
- var maxIndex = this.adapter_.getChipListCount() - 1;
- var nextIndex = Math.min(index, maxIndex);
- this.removeFocusFromChipsExcept_(nextIndex);
- // After removing a chip, we should focus the trailing action for the next chip.
- this.adapter_.focusChipTrailingActionAtIndex(nextIndex);
- };
- /**
- * Handles a chip navigation event.
- */
- MDCChipSetFoundation.prototype.handleChipNavigation = function (_a) {
- var chipId = _a.chipId,
- key = _a.key,
- source = _a.source;
- var maxIndex = this.adapter_.getChipListCount() - 1;
- var index = this.adapter_.getIndexOfChipById(chipId);
- // Early exit if the index is out of range or the key is unusable
- if (index === -1 || !constants_1.navigationKeys.has(key)) {
- return;
- }
- var isRTL = this.adapter_.isRTL();
- var shouldIncrement = key === constants_1.strings.ARROW_RIGHT_KEY && !isRTL || key === constants_1.strings.ARROW_LEFT_KEY && isRTL || key === constants_1.strings.ARROW_DOWN_KEY;
- var isHome = key === constants_1.strings.HOME_KEY;
- var isEnd = key === constants_1.strings.END_KEY;
- if (shouldIncrement) {
- index++;
- } else if (isHome) {
- index = 0;
- } else if (isEnd) {
- index = maxIndex;
- } else {
- index--;
- }
- // Early exit if the index is out of bounds
- if (index < 0 || index > maxIndex) {
- return;
- }
- this.removeFocusFromChipsExcept_(index);
- this.focusChipAction_(index, key, source);
- };
- MDCChipSetFoundation.prototype.focusChipAction_ = function (index, key, source) {
- var shouldJumpChips = constants_1.jumpChipKeys.has(key);
- if (shouldJumpChips && source === constants_1.EventSource.PRIMARY) {
- return this.adapter_.focusChipPrimaryActionAtIndex(index);
- }
- if (shouldJumpChips && source === constants_1.EventSource.TRAILING) {
- return this.adapter_.focusChipTrailingActionAtIndex(index);
- }
- var dir = this.getDirection_(key);
- if (dir === constants_1.Direction.LEFT) {
- return this.adapter_.focusChipTrailingActionAtIndex(index);
- }
- if (dir === constants_1.Direction.RIGHT) {
- return this.adapter_.focusChipPrimaryActionAtIndex(index);
- }
- };
- MDCChipSetFoundation.prototype.getDirection_ = function (key) {
- var isRTL = this.adapter_.isRTL();
- if (key === constants_1.strings.ARROW_LEFT_KEY && !isRTL || key === constants_1.strings.ARROW_RIGHT_KEY && isRTL) {
- return constants_1.Direction.LEFT;
- }
- return constants_1.Direction.RIGHT;
- };
- /**
- * Deselects the chip with the given id and optionally notifies clients.
- */
- MDCChipSetFoundation.prototype.deselect_ = function (chipId, shouldNotifyClients) {
- if (shouldNotifyClients === void 0) {
- shouldNotifyClients = false;
- }
- var index = this.selectedChipIds_.indexOf(chipId);
- if (index >= 0) {
- this.selectedChipIds_.splice(index, 1);
- var chipIndex = this.adapter_.getIndexOfChipById(chipId);
- this.adapter_.selectChipAtIndex(chipIndex, /** isSelected */false, shouldNotifyClients);
- }
- };
- /**
- * Deselects the chip with the given id and notifies clients.
- */
- MDCChipSetFoundation.prototype.deselectAndNotifyClients_ = function (chipId) {
- this.deselect_(chipId, true);
- };
- /**
- * Toggles selection of the chip with the given id.
- */
- MDCChipSetFoundation.prototype.toggleSelect_ = function (chipId) {
- if (this.selectedChipIds_.indexOf(chipId) >= 0) {
- this.deselectAndNotifyClients_(chipId);
- } else {
- this.selectAndNotifyClients_(chipId);
- }
- };
- MDCChipSetFoundation.prototype.removeFocusFromChipsExcept_ = function (index) {
- var chipCount = this.adapter_.getChipListCount();
- for (var i = 0; i < chipCount; i++) {
- if (i !== index) {
- this.adapter_.removeFocusFromChipAtIndex(i);
- }
- }
- };
- MDCChipSetFoundation.prototype.selectAndNotifyClients_ = function (chipId) {
- this.select_(chipId, true);
- };
- MDCChipSetFoundation.prototype.select_ = function (chipId, shouldNotifyClients) {
- if (this.selectedChipIds_.indexOf(chipId) >= 0) {
- return;
- }
- if (this.adapter_.hasClass(constants_2.cssClasses.CHOICE) && this.selectedChipIds_.length > 0) {
- var previouslySelectedChip = this.selectedChipIds_[0];
- var previouslySelectedIndex = this.adapter_.getIndexOfChipById(previouslySelectedChip);
- this.selectedChipIds_ = [];
- this.adapter_.selectChipAtIndex(previouslySelectedIndex, /** isSelected */false, shouldNotifyClients);
- }
- this.selectedChipIds_.push(chipId);
- var index = this.adapter_.getIndexOfChipById(chipId);
- this.adapter_.selectChipAtIndex(index, /** isSelected */true, shouldNotifyClients);
- };
- return MDCChipSetFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCChipSetFoundation = MDCChipSetFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCChipSetFoundation;
- /***/ }),
- /***/ "./packages/mdc-chips/chip-set/index.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-chips/chip-set/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-chips/chip-set/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip-set/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip-set/constants.ts");
- exports.chipSetCssClasses = constants_1.cssClasses;
- exports.chipSetStrings = constants_1.strings;
- /***/ }),
- /***/ "./packages/mdc-chips/chip/component.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-chips/chip/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __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-chips/chip/constants.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip/foundation.ts");
- var INTERACTION_EVENTS = ['click', 'keydown'];
- var MDCChip = /** @class */function (_super) {
- __extends(MDCChip, _super);
- function MDCChip() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- Object.defineProperty(MDCChip.prototype, "selected", {
- /**
- * @return Whether the chip is selected.
- */
- get: function get() {
- return this.foundation_.isSelected();
- },
- /**
- * Sets selected state on the chip.
- */
- set: function set(selected) {
- this.foundation_.setSelected(selected);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChip.prototype, "shouldRemoveOnTrailingIconClick", {
- /**
- * @return Whether a trailing icon click should trigger exit/removal of the chip.
- */
- get: function get() {
- return this.foundation_.getShouldRemoveOnTrailingIconClick();
- },
- /**
- * Sets whether a trailing icon click should trigger exit/removal of the chip.
- */
- set: function set(shouldRemove) {
- this.foundation_.setShouldRemoveOnTrailingIconClick(shouldRemove);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChip.prototype, "ripple", {
- get: function get() {
- return this.ripple_;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChip.prototype, "id", {
- get: function get() {
- return this.root_.id;
- },
- enumerable: true,
- configurable: true
- });
- MDCChip.attachTo = function (root) {
- return new MDCChip(root);
- };
- MDCChip.prototype.initialize = function (rippleFactory) {
- var _this = this;
- if (rippleFactory === void 0) {
- rippleFactory = function rippleFactory(el, foundation) {
- return new component_2.MDCRipple(el, foundation);
- };
- }
- this.leadingIcon_ = this.root_.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
- this.trailingIcon_ = this.root_.querySelector(constants_1.strings.TRAILING_ICON_SELECTOR);
- this.checkmark_ = this.root_.querySelector(constants_1.strings.CHECKMARK_SELECTOR);
- this.primaryAction_ = this.root_.querySelector(constants_1.strings.PRIMARY_ACTION_SELECTOR);
- this.trailingAction_ = this.root_.querySelector(constants_1.strings.TRAILING_ACTION_SELECTOR);
- // 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 rippleAdapter = __assign({}, component_2.MDCRipple.createAdapter(this), { computeBoundingRect: function computeBoundingRect() {
- return _this.foundation_.getDimensions();
- } });
- this.ripple_ = rippleFactory(this.root_, new foundation_1.MDCRippleFoundation(rippleAdapter));
- };
- MDCChip.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleInteraction_ = function (evt) {
- return _this.foundation_.handleInteraction(evt);
- };
- this.handleTransitionEnd_ = function (evt) {
- return _this.foundation_.handleTransitionEnd(evt);
- };
- this.handleTrailingIconInteraction_ = function (evt) {
- return _this.foundation_.handleTrailingIconInteraction(evt);
- };
- this.handleKeydown_ = function (evt) {
- return _this.foundation_.handleKeydown(evt);
- };
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.listen(evtType, _this.handleInteraction_);
- });
- this.listen('transitionend', this.handleTransitionEnd_);
- this.listen('keydown', this.handleKeydown_);
- if (this.trailingIcon_) {
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.trailingIcon_.addEventListener(evtType, _this.handleTrailingIconInteraction_);
- });
- }
- };
- MDCChip.prototype.destroy = function () {
- var _this = this;
- this.ripple_.destroy();
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.unlisten(evtType, _this.handleInteraction_);
- });
- this.unlisten('transitionend', this.handleTransitionEnd_);
- this.unlisten('keydown', this.handleKeydown_);
- if (this.trailingIcon_) {
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.trailingIcon_.removeEventListener(evtType, _this.handleTrailingIconInteraction_);
- });
- }
- _super.prototype.destroy.call(this);
- };
- /**
- * Begins the exit animation which leads to removal of the chip.
- */
- MDCChip.prototype.beginExit = function () {
- this.foundation_.beginExit();
- };
- MDCChip.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 = {
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- addClassToLeadingIcon: function addClassToLeadingIcon(className) {
- if (_this.leadingIcon_) {
- _this.leadingIcon_.classList.add(className);
- }
- },
- eventTargetHasClass: function eventTargetHasClass(target, className) {
- return target ? target.classList.contains(className) : false;
- },
- focusPrimaryAction: function focusPrimaryAction() {
- if (_this.primaryAction_) {
- _this.primaryAction_.focus();
- }
- },
- focusTrailingAction: function focusTrailingAction() {
- if (_this.trailingAction_) {
- _this.trailingAction_.focus();
- }
- },
- getAttribute: function getAttribute(attr) {
- return _this.root_.getAttribute(attr);
- },
- getCheckmarkBoundingClientRect: function getCheckmarkBoundingClientRect() {
- return _this.checkmark_ ? _this.checkmark_.getBoundingClientRect() : null;
- },
- getComputedStyleValue: function getComputedStyleValue(propertyName) {
- return window.getComputedStyle(_this.root_).getPropertyValue(propertyName);
- },
- getRootBoundingClientRect: function getRootBoundingClientRect() {
- return _this.root_.getBoundingClientRect();
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- hasLeadingIcon: function hasLeadingIcon() {
- return !!_this.leadingIcon_;
- },
- hasTrailingAction: function hasTrailingAction() {
- return !!_this.trailingAction_;
- },
- isRTL: function isRTL() {
- return window.getComputedStyle(_this.root_).getPropertyValue('direction') === 'rtl';
- },
- notifyInteraction: function notifyInteraction() {
- return _this.emit(constants_1.strings.INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */);
- },
- notifyNavigation: function notifyNavigation(key, source) {
- return _this.emit(constants_1.strings.NAVIGATION_EVENT, { chipId: _this.id, key: key, source: source }, true /* shouldBubble */);
- },
- notifyRemoval: function notifyRemoval(removedAnnouncement) {
- _this.emit(constants_1.strings.REMOVAL_EVENT, { chipId: _this.id, removedAnnouncement: removedAnnouncement }, true /* shouldBubble */);
- },
- notifySelection: function notifySelection(selected, shouldIgnore) {
- return _this.emit(constants_1.strings.SELECTION_EVENT, { chipId: _this.id, selected: selected, shouldIgnore: shouldIgnore }, true /* shouldBubble */);
- },
- notifyTrailingIconInteraction: function notifyTrailingIconInteraction() {
- return _this.emit(constants_1.strings.TRAILING_ICON_INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- removeClassFromLeadingIcon: function removeClassFromLeadingIcon(className) {
- if (_this.leadingIcon_) {
- _this.leadingIcon_.classList.remove(className);
- }
- },
- setPrimaryActionAttr: function setPrimaryActionAttr(attr, value) {
- if (_this.primaryAction_) {
- _this.primaryAction_.setAttribute(attr, value);
- }
- },
- setStyleProperty: function setStyleProperty(propertyName, value) {
- return _this.root_.style.setProperty(propertyName, value);
- },
- setTrailingActionAttr: function setTrailingActionAttr(attr, value) {
- if (_this.trailingAction_) {
- _this.trailingAction_.setAttribute(attr, value);
- }
- }
- };
- return new foundation_2.MDCChipFoundation(adapter);
- };
- MDCChip.prototype.setSelectedFromChipSet = function (selected, shouldNotifyClients) {
- this.foundation_.setSelectedFromChipSet(selected, shouldNotifyClients);
- };
- MDCChip.prototype.focusPrimaryAction = function () {
- this.foundation_.focusPrimaryAction();
- };
- MDCChip.prototype.focusTrailingAction = function () {
- this.foundation_.focusTrailingAction();
- };
- MDCChip.prototype.removeFocus = function () {
- this.foundation_.removeFocus();
- };
- MDCChip.prototype.remove = function () {
- var parent = this.root_.parentNode;
- if (parent !== null) {
- parent.removeChild(this.root_);
- }
- };
- return MDCChip;
- }(component_1.MDCComponent);
- exports.MDCChip = MDCChip;
- /***/ }),
- /***/ "./packages/mdc-chips/chip/constants.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-chips/chip/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 });
- var Direction;
- (function (Direction) {
- Direction[Direction["RIGHT"] = 0] = "RIGHT";
- Direction[Direction["LEFT"] = 1] = "LEFT";
- })(Direction = exports.Direction || (exports.Direction = {}));
- var EventSource;
- (function (EventSource) {
- EventSource[EventSource["PRIMARY"] = 0] = "PRIMARY";
- EventSource[EventSource["TRAILING"] = 1] = "TRAILING";
- EventSource[EventSource["NONE"] = 2] = "NONE";
- })(EventSource = exports.EventSource || (exports.EventSource = {}));
- exports.strings = {
- ADDED_ANNOUNCEMENT_ATTRIBUTE: 'data-mdc-chip-added-announcement',
- ARIA_CHECKED: 'aria-checked',
- ARROW_DOWN_KEY: 'ArrowDown',
- ARROW_LEFT_KEY: 'ArrowLeft',
- ARROW_RIGHT_KEY: 'ArrowRight',
- ARROW_UP_KEY: 'ArrowUp',
- BACKSPACE_KEY: 'Backspace',
- CHECKMARK_SELECTOR: '.mdc-chip__checkmark',
- DELETE_KEY: 'Delete',
- END_KEY: 'End',
- ENTER_KEY: 'Enter',
- ENTRY_ANIMATION_NAME: 'mdc-chip-entry',
- HOME_KEY: 'Home',
- INTERACTION_EVENT: 'MDCChip:interaction',
- LEADING_ICON_SELECTOR: '.mdc-chip__icon--leading',
- NAVIGATION_EVENT: 'MDCChip:navigation',
- PRIMARY_ACTION_SELECTOR: '.mdc-chip__primary-action',
- REMOVED_ANNOUNCEMENT_ATTRIBUTE: 'data-mdc-chip-removed-announcement',
- REMOVAL_EVENT: 'MDCChip:removal',
- SELECTION_EVENT: 'MDCChip:selection',
- SPACEBAR_KEY: ' ',
- TAB_INDEX: 'tabindex',
- TRAILING_ACTION_SELECTOR: '.mdc-chip__trailing-action',
- TRAILING_ICON_INTERACTION_EVENT: 'MDCChip:trailingIconInteraction',
- TRAILING_ICON_SELECTOR: '.mdc-chip__icon--trailing'
- };
- exports.cssClasses = {
- CHECKMARK: 'mdc-chip__checkmark',
- CHIP_EXIT: 'mdc-chip--exit',
- DELETABLE: 'mdc-chip--deletable',
- HIDDEN_LEADING_ICON: 'mdc-chip__icon--leading-hidden',
- LEADING_ICON: 'mdc-chip__icon--leading',
- PRIMARY_ACTION: 'mdc-chip__primary-action',
- SELECTED: 'mdc-chip--selected',
- TEXT: 'mdc-chip__text',
- TRAILING_ACTION: 'mdc-chip__trailing-action',
- TRAILING_ICON: 'mdc-chip__icon--trailing'
- };
- exports.navigationKeys = new Set();
- // IE11 has no support for new Set with iterable so we need to initialize this by hand
- exports.navigationKeys.add(exports.strings.ARROW_LEFT_KEY);
- exports.navigationKeys.add(exports.strings.ARROW_RIGHT_KEY);
- exports.navigationKeys.add(exports.strings.ARROW_DOWN_KEY);
- exports.navigationKeys.add(exports.strings.ARROW_UP_KEY);
- exports.navigationKeys.add(exports.strings.END_KEY);
- exports.navigationKeys.add(exports.strings.HOME_KEY);
- exports.jumpChipKeys = new Set();
- // IE11 has no support for new Set with iterable so we need to initialize this by hand
- exports.jumpChipKeys.add(exports.strings.ARROW_UP_KEY);
- exports.jumpChipKeys.add(exports.strings.ARROW_DOWN_KEY);
- exports.jumpChipKeys.add(exports.strings.HOME_KEY);
- exports.jumpChipKeys.add(exports.strings.END_KEY);
- /***/ }),
- /***/ "./packages/mdc-chips/chip/foundation.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-chips/chip/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip/constants.ts");
- var emptyClientRect = {
- bottom: 0,
- height: 0,
- left: 0,
- right: 0,
- top: 0,
- width: 0
- };
- var MDCChipFoundation = /** @class */function (_super) {
- __extends(MDCChipFoundation, _super);
- function MDCChipFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCChipFoundation.defaultAdapter, adapter)) || this;
- /** Whether a trailing icon click should immediately trigger exit/removal of the chip. */
- _this.shouldRemoveOnTrailingIconClick_ = true;
- return _this;
- }
- Object.defineProperty(MDCChipFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- addClassToLeadingIcon: function addClassToLeadingIcon() {
- return undefined;
- },
- eventTargetHasClass: function eventTargetHasClass() {
- return false;
- },
- focusPrimaryAction: function focusPrimaryAction() {
- return undefined;
- },
- focusTrailingAction: function focusTrailingAction() {
- return undefined;
- },
- getAttribute: function getAttribute() {
- return null;
- },
- getCheckmarkBoundingClientRect: function getCheckmarkBoundingClientRect() {
- return emptyClientRect;
- },
- getComputedStyleValue: function getComputedStyleValue() {
- return '';
- },
- getRootBoundingClientRect: function getRootBoundingClientRect() {
- return emptyClientRect;
- },
- hasClass: function hasClass() {
- return false;
- },
- hasLeadingIcon: function hasLeadingIcon() {
- return false;
- },
- hasTrailingAction: function hasTrailingAction() {
- return false;
- },
- isRTL: function isRTL() {
- return false;
- },
- notifyInteraction: function notifyInteraction() {
- return undefined;
- },
- notifyNavigation: function notifyNavigation() {
- return undefined;
- },
- notifyRemoval: function notifyRemoval() {
- return undefined;
- },
- notifySelection: function notifySelection() {
- return undefined;
- },
- notifyTrailingIconInteraction: function notifyTrailingIconInteraction() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- removeClassFromLeadingIcon: function removeClassFromLeadingIcon() {
- return undefined;
- },
- setPrimaryActionAttr: function setPrimaryActionAttr() {
- return undefined;
- },
- setStyleProperty: function setStyleProperty() {
- return undefined;
- },
- setTrailingActionAttr: function setTrailingActionAttr() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCChipFoundation.prototype.isSelected = function () {
- return this.adapter_.hasClass(constants_1.cssClasses.SELECTED);
- };
- MDCChipFoundation.prototype.setSelected = function (selected) {
- this.setSelected_(selected);
- this.notifySelection_(selected);
- };
- MDCChipFoundation.prototype.setSelectedFromChipSet = function (selected, shouldNotifyClients) {
- this.setSelected_(selected);
- if (shouldNotifyClients) {
- this.notifyIgnoredSelection_(selected);
- }
- };
- MDCChipFoundation.prototype.getShouldRemoveOnTrailingIconClick = function () {
- return this.shouldRemoveOnTrailingIconClick_;
- };
- MDCChipFoundation.prototype.setShouldRemoveOnTrailingIconClick = function (shouldRemove) {
- this.shouldRemoveOnTrailingIconClick_ = shouldRemove;
- };
- MDCChipFoundation.prototype.getDimensions = function () {
- var _this = this;
- var getRootRect = function getRootRect() {
- return _this.adapter_.getRootBoundingClientRect();
- };
- var getCheckmarkRect = function getCheckmarkRect() {
- return _this.adapter_.getCheckmarkBoundingClientRect();
- };
- // When a chip has a checkmark and not a leading icon, the bounding rect changes in size depending on the current
- // size of the checkmark.
- if (!this.adapter_.hasLeadingIcon()) {
- var checkmarkRect = getCheckmarkRect();
- if (checkmarkRect) {
- var rootRect = getRootRect();
- // Checkmark is a square, meaning the client rect's width and height are identical once the animation completes.
- // However, the checkbox is initially hidden by setting the width to 0.
- // To account for an initial width of 0, we use the checkbox's height instead (which equals the end-state width)
- // when adding it to the root client rect's width.
- return {
- bottom: rootRect.bottom,
- height: rootRect.height,
- left: rootRect.left,
- right: rootRect.right,
- top: rootRect.top,
- width: rootRect.width + checkmarkRect.height
- };
- }
- }
- return getRootRect();
- };
- /**
- * Begins the exit animation which leads to removal of the chip.
- */
- MDCChipFoundation.prototype.beginExit = function () {
- this.adapter_.addClass(constants_1.cssClasses.CHIP_EXIT);
- };
- /**
- * Handles an interaction event on the root element.
- */
- MDCChipFoundation.prototype.handleInteraction = function (evt) {
- if (this.shouldHandleInteraction_(evt)) {
- this.adapter_.notifyInteraction();
- this.focusPrimaryAction_();
- }
- };
- /**
- * Handles a transition end event on the root element.
- */
- MDCChipFoundation.prototype.handleTransitionEnd = function (evt) {
- var _this = this;
- // Handle transition end event on the chip when it is about to be removed.
- var shouldHandle = this.adapter_.eventTargetHasClass(evt.target, constants_1.cssClasses.CHIP_EXIT);
- var widthIsAnimating = evt.propertyName === 'width';
- var opacityIsAnimating = evt.propertyName === 'opacity';
- if (shouldHandle && opacityIsAnimating) {
- // See: https://css-tricks.com/using-css-transitions-auto-dimensions/#article-header-id-5
- var chipWidth_1 = this.adapter_.getComputedStyleValue('width');
- // On the next frame (once we get the computed width), explicitly set the chip's width
- // to its current pixel width, so we aren't transitioning out of 'auto'.
- requestAnimationFrame(function () {
- _this.adapter_.setStyleProperty('width', chipWidth_1);
- // To mitigate jitter, start transitioning padding and margin before width.
- _this.adapter_.setStyleProperty('padding', '0');
- _this.adapter_.setStyleProperty('margin', '0');
- // On the next frame (once width is explicitly set), transition width to 0.
- requestAnimationFrame(function () {
- _this.adapter_.setStyleProperty('width', '0');
- });
- });
- return;
- }
- if (shouldHandle && widthIsAnimating) {
- this.removeFocus_();
- var removedAnnouncement = this.adapter_.getAttribute(constants_1.strings.REMOVED_ANNOUNCEMENT_ATTRIBUTE);
- this.adapter_.notifyRemoval(removedAnnouncement);
- }
- // Handle a transition end event on the leading icon or checkmark, since the transition end event bubbles.
- if (!opacityIsAnimating) {
- return;
- }
- var shouldHideLeadingIcon = this.adapter_.eventTargetHasClass(evt.target, constants_1.cssClasses.LEADING_ICON) && this.adapter_.hasClass(constants_1.cssClasses.SELECTED);
- var shouldShowLeadingIcon = this.adapter_.eventTargetHasClass(evt.target, constants_1.cssClasses.CHECKMARK) && !this.adapter_.hasClass(constants_1.cssClasses.SELECTED);
- if (shouldHideLeadingIcon) {
- return this.adapter_.addClassToLeadingIcon(constants_1.cssClasses.HIDDEN_LEADING_ICON);
- }
- if (shouldShowLeadingIcon) {
- return this.adapter_.removeClassFromLeadingIcon(constants_1.cssClasses.HIDDEN_LEADING_ICON);
- }
- };
- /**
- * Handles an interaction event on the trailing icon element. This is used to
- * prevent the ripple from activating on interaction with the trailing icon.
- */
- MDCChipFoundation.prototype.handleTrailingIconInteraction = function (evt) {
- if (this.shouldHandleInteraction_(evt)) {
- this.adapter_.notifyTrailingIconInteraction();
- this.removeChip_(evt);
- }
- };
- /**
- * Handles a keydown event from the root element.
- */
- MDCChipFoundation.prototype.handleKeydown = function (evt) {
- if (this.shouldRemoveChip_(evt)) {
- return this.removeChip_(evt);
- }
- var key = evt.key;
- // Early exit if the key is not usable
- if (!constants_1.navigationKeys.has(key)) {
- return;
- }
- // Prevent default behavior for movement keys which could include scrolling
- evt.preventDefault();
- this.focusNextAction_(evt);
- };
- MDCChipFoundation.prototype.removeFocus = function () {
- this.adapter_.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '-1');
- this.adapter_.setTrailingActionAttr(constants_1.strings.TAB_INDEX, '-1');
- };
- MDCChipFoundation.prototype.focusPrimaryAction = function () {
- this.focusPrimaryAction_();
- };
- MDCChipFoundation.prototype.focusTrailingAction = function () {
- if (!this.adapter_.hasTrailingAction()) {
- return this.focusPrimaryAction_();
- }
- this.focusTrailingAction_();
- };
- MDCChipFoundation.prototype.focusNextAction_ = function (evt) {
- var key = evt.key;
- var hasTrailingAction = this.adapter_.hasTrailingAction();
- var dir = this.getDirection_(key);
- var source = this.getEvtSource_(evt);
- // Early exit if the key should jump keys or the chip only has one action (i.e. no trailing action)
- if (constants_1.jumpChipKeys.has(key) || !hasTrailingAction) {
- this.adapter_.notifyNavigation(key, source);
- return;
- }
- if (source === constants_1.EventSource.PRIMARY && dir === constants_1.Direction.RIGHT) {
- return this.focusTrailingAction_();
- }
- if (source === constants_1.EventSource.TRAILING && dir === constants_1.Direction.LEFT) {
- return this.focusPrimaryAction_();
- }
- this.adapter_.notifyNavigation(key, constants_1.EventSource.NONE);
- };
- MDCChipFoundation.prototype.getEvtSource_ = function (evt) {
- if (this.adapter_.eventTargetHasClass(evt.target, constants_1.cssClasses.PRIMARY_ACTION)) {
- return constants_1.EventSource.PRIMARY;
- }
- if (this.adapter_.eventTargetHasClass(evt.target, constants_1.cssClasses.TRAILING_ACTION)) {
- return constants_1.EventSource.TRAILING;
- }
- return constants_1.EventSource.NONE;
- };
- MDCChipFoundation.prototype.getDirection_ = function (key) {
- var isRTL = this.adapter_.isRTL();
- if (key === constants_1.strings.ARROW_LEFT_KEY && !isRTL || key === constants_1.strings.ARROW_RIGHT_KEY && isRTL) {
- return constants_1.Direction.LEFT;
- }
- return constants_1.Direction.RIGHT;
- };
- MDCChipFoundation.prototype.focusPrimaryAction_ = function () {
- this.adapter_.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '0');
- this.adapter_.focusPrimaryAction();
- this.adapter_.setTrailingActionAttr(constants_1.strings.TAB_INDEX, '-1');
- };
- MDCChipFoundation.prototype.focusTrailingAction_ = function () {
- this.adapter_.setTrailingActionAttr(constants_1.strings.TAB_INDEX, '0');
- this.adapter_.focusTrailingAction();
- this.adapter_.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '-1');
- };
- MDCChipFoundation.prototype.removeFocus_ = function () {
- this.adapter_.setTrailingActionAttr(constants_1.strings.TAB_INDEX, '-1');
- this.adapter_.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '-1');
- };
- MDCChipFoundation.prototype.removeChip_ = function (evt) {
- evt.stopPropagation();
- // Prevent default behavior for backspace on Firefox which causes a page
- // navigation.
- evt.preventDefault();
- if (this.shouldRemoveOnTrailingIconClick_) {
- this.beginExit();
- }
- };
- MDCChipFoundation.prototype.shouldHandleInteraction_ = function (evt) {
- if (evt.type === 'click') {
- return true;
- }
- var keyEvt = evt;
- return keyEvt.key === constants_1.strings.ENTER_KEY || keyEvt.key === constants_1.strings.SPACEBAR_KEY;
- };
- MDCChipFoundation.prototype.shouldRemoveChip_ = function (evt) {
- var isDeletable = this.adapter_.hasClass(constants_1.cssClasses.DELETABLE);
- return isDeletable && (evt.key === constants_1.strings.BACKSPACE_KEY || evt.key === constants_1.strings.DELETE_KEY);
- };
- MDCChipFoundation.prototype.setSelected_ = function (selected) {
- if (selected) {
- this.adapter_.addClass(constants_1.cssClasses.SELECTED);
- this.adapter_.setPrimaryActionAttr(constants_1.strings.ARIA_CHECKED, 'true');
- } else {
- this.adapter_.removeClass(constants_1.cssClasses.SELECTED);
- this.adapter_.setPrimaryActionAttr(constants_1.strings.ARIA_CHECKED, 'false');
- }
- };
- MDCChipFoundation.prototype.notifySelection_ = function (selected) {
- this.adapter_.notifySelection(selected, false);
- };
- MDCChipFoundation.prototype.notifyIgnoredSelection_ = function (selected) {
- this.adapter_.notifySelection(selected, true);
- };
- return MDCChipFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCChipFoundation = MDCChipFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCChipFoundation;
- /***/ }),
- /***/ "./packages/mdc-chips/chip/index.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-chips/chip/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-chips/chip/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip/constants.ts");
- exports.chipCssClasses = constants_1.cssClasses;
- exports.chipStrings = constants_1.strings;
- /***/ }),
- /***/ "./packages/mdc-chips/index.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-chips/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./chip/index */ "./packages/mdc-chips/chip/index.ts"));
- __export(__webpack_require__(/*! ./chip-set/index */ "./packages/mdc-chips/chip-set/index.ts"));
- /***/ }),
- /***/ "./packages/mdc-data-table/component.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-data-table/component.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 __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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/checkbox/component */ "./packages/mdc-checkbox/component.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-data-table/constants.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-data-table/foundation.ts");
- var MDCDataTable = /** @class */function (_super) {
- __extends(MDCDataTable, _super);
- function MDCDataTable() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCDataTable.attachTo = function (root) {
- return new MDCDataTable(root);
- };
- MDCDataTable.prototype.initialize = function (checkboxFactory) {
- if (checkboxFactory === void 0) {
- checkboxFactory = function checkboxFactory(el) {
- return new component_2.MDCCheckbox(el);
- };
- }
- this.checkboxFactory_ = checkboxFactory;
- };
- MDCDataTable.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.headerRow_ = this.root_.querySelector("." + constants_1.cssClasses.HEADER_ROW);
- this.handleHeaderRowCheckboxChange_ = function () {
- return _this.foundation_.handleHeaderRowCheckboxChange();
- };
- this.headerRow_.addEventListener('change', this.handleHeaderRowCheckboxChange_);
- this.content_ = this.root_.querySelector("." + constants_1.cssClasses.CONTENT);
- this.handleRowCheckboxChange_ = function (event) {
- return _this.foundation_.handleRowCheckboxChange(event);
- };
- this.content_.addEventListener('change', this.handleRowCheckboxChange_);
- this.layout();
- };
- /**
- * Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
- */
- MDCDataTable.prototype.layout = function () {
- this.foundation_.layout();
- };
- /**
- * @return Returns array of row elements.
- */
- MDCDataTable.prototype.getRows = function () {
- return this.foundation_.getRows();
- };
- /**
- * @return Returns array of selected row ids.
- */
- MDCDataTable.prototype.getSelectedRowIds = function () {
- return this.foundation_.getSelectedRowIds();
- };
- /**
- * Sets selected row ids. Overwrites previously selected rows.
- * @param rowIds Array of row ids that needs to be selected.
- */
- MDCDataTable.prototype.setSelectedRowIds = function (rowIds) {
- this.foundation_.setSelectedRowIds(rowIds);
- };
- MDCDataTable.prototype.destroy = function () {
- this.headerRow_.removeEventListener('change', this.handleHeaderRowCheckboxChange_);
- this.content_.removeEventListener('change', this.handleRowCheckboxChange_);
- this.headerRowCheckbox_.destroy();
- this.rowCheckboxList_.forEach(function (checkbox) {
- return checkbox.destroy();
- });
- };
- MDCDataTable.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 = {
- addClassAtRowIndex: function addClassAtRowIndex(rowIndex, className) {
- return _this.getRows()[rowIndex].classList.add(className);
- },
- getRowCount: function getRowCount() {
- return _this.getRows().length;
- },
- getRowElements: function getRowElements() {
- return [].slice.call(_this.root_.querySelectorAll(constants_1.strings.ROW_SELECTOR));
- },
- getRowIdAtIndex: function getRowIdAtIndex(rowIndex) {
- return _this.getRows()[rowIndex].getAttribute(constants_1.strings.DATA_ROW_ID_ATTR);
- },
- getRowIndexByChildElement: function getRowIndexByChildElement(el) {
- return _this.getRows().indexOf(ponyfill_1.closest(el, constants_1.strings.ROW_SELECTOR));
- },
- getSelectedRowCount: function getSelectedRowCount() {
- return _this.root_.querySelectorAll(constants_1.strings.ROW_SELECTED_SELECTOR).length;
- },
- isCheckboxAtRowIndexChecked: function isCheckboxAtRowIndexChecked(rowIndex) {
- return _this.rowCheckboxList_[rowIndex].checked;
- },
- isHeaderRowCheckboxChecked: function isHeaderRowCheckboxChecked() {
- return _this.headerRowCheckbox_.checked;
- },
- isRowsSelectable: function isRowsSelectable() {
- return !!_this.root_.querySelector(constants_1.strings.ROW_CHECKBOX_SELECTOR);
- },
- notifyRowSelectionChanged: function notifyRowSelectionChanged(data) {
- _this.emit(constants_1.events.ROW_SELECTION_CHANGED, {
- row: _this.getRowByIndex_(data.rowIndex),
- rowId: _this.getRowIdByIndex_(data.rowIndex),
- rowIndex: data.rowIndex,
- selected: data.selected
- },
- /** shouldBubble */true);
- },
- notifySelectedAll: function notifySelectedAll() {
- return _this.emit(constants_1.events.SELECTED_ALL, {}, /** shouldBubble */true);
- },
- notifyUnselectedAll: function notifyUnselectedAll() {
- return _this.emit(constants_1.events.UNSELECTED_ALL, {}, /** shouldBubble */true);
- },
- registerHeaderRowCheckbox: function registerHeaderRowCheckbox() {
- if (_this.headerRowCheckbox_) {
- _this.headerRowCheckbox_.destroy();
- }
- var checkboxEl = _this.root_.querySelector(constants_1.strings.HEADER_ROW_CHECKBOX_SELECTOR);
- _this.headerRowCheckbox_ = _this.checkboxFactory_(checkboxEl);
- },
- registerRowCheckboxes: function registerRowCheckboxes() {
- if (_this.rowCheckboxList_) {
- _this.rowCheckboxList_.forEach(function (checkbox) {
- return checkbox.destroy();
- });
- }
- _this.rowCheckboxList_ = [];
- _this.getRows().forEach(function (rowEl) {
- var checkbox = _this.checkboxFactory_(rowEl.querySelector(constants_1.strings.ROW_CHECKBOX_SELECTOR));
- _this.rowCheckboxList_.push(checkbox);
- });
- },
- removeClassAtRowIndex: function removeClassAtRowIndex(rowIndex, className) {
- _this.getRows()[rowIndex].classList.remove(className);
- },
- setAttributeAtRowIndex: function setAttributeAtRowIndex(rowIndex, attr, value) {
- _this.getRows()[rowIndex].setAttribute(attr, value);
- },
- setHeaderRowCheckboxChecked: function setHeaderRowCheckboxChecked(checked) {
- _this.headerRowCheckbox_.checked = checked;
- },
- setHeaderRowCheckboxIndeterminate: function setHeaderRowCheckboxIndeterminate(indeterminate) {
- _this.headerRowCheckbox_.indeterminate = indeterminate;
- },
- setRowCheckboxCheckedAtIndex: function setRowCheckboxCheckedAtIndex(rowIndex, checked) {
- _this.rowCheckboxList_[rowIndex].checked = checked;
- }
- };
- return new foundation_1.MDCDataTableFoundation(adapter);
- };
- MDCDataTable.prototype.getRowByIndex_ = function (index) {
- return this.getRows()[index];
- };
- MDCDataTable.prototype.getRowIdByIndex_ = function (index) {
- return this.getRowByIndex_(index).getAttribute(constants_1.strings.DATA_ROW_ID_ATTR);
- };
- return MDCDataTable;
- }(component_1.MDCComponent);
- exports.MDCDataTable = MDCDataTable;
- /***/ }),
- /***/ "./packages/mdc-data-table/constants.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-data-table/constants.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.cssClasses = {
- CELL: 'mdc-data-table__cell',
- CELL_NUMERIC: 'mdc-data-table__cell--numeric',
- CONTENT: 'mdc-data-table__content',
- HEADER_ROW: 'mdc-data-table__header-row',
- HEADER_ROW_CHECKBOX: 'mdc-data-table__header-row-checkbox',
- ROOT: 'mdc-data-table',
- ROW: 'mdc-data-table__row',
- ROW_CHECKBOX: 'mdc-data-table__row-checkbox',
- ROW_SELECTED: 'mdc-data-table__row--selected'
- };
- exports.strings = {
- ARIA_SELECTED: 'aria-selected',
- DATA_ROW_ID_ATTR: 'data-row-id',
- HEADER_ROW_CHECKBOX_SELECTOR: "." + exports.cssClasses.HEADER_ROW_CHECKBOX,
- ROW_CHECKBOX_SELECTOR: "." + exports.cssClasses.ROW_CHECKBOX,
- ROW_SELECTED_SELECTOR: "." + exports.cssClasses.ROW_SELECTED,
- ROW_SELECTOR: "." + exports.cssClasses.ROW
- };
- exports.events = {
- ROW_SELECTION_CHANGED: 'MDCDataTable:rowSelectionChanged',
- SELECTED_ALL: 'MDCDataTable:selectedAll',
- UNSELECTED_ALL: 'MDCDataTable:unselectedAll'
- };
- /***/ }),
- /***/ "./packages/mdc-data-table/foundation.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-data-table/foundation.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 __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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) {
- try {
- step(generator.next(value));
- } catch (e) {
- reject(e);
- }
- }
- function rejected(value) {
- try {
- step(generator["throw"](value));
- } catch (e) {
- reject(e);
- }
- }
- function step(result) {
- result.done ? resolve(result.value) : new P(function (resolve) {
- resolve(result.value);
- }).then(fulfilled, rejected);
- }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = this && this.__generator || function (thisArg, body) {
- var _ = { label: 0, sent: function sent() {
- if (t[0] & 1) throw t[1];return t[1];
- }, trys: [], ops: [] },
- f,
- y,
- t,
- g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
- return this;
- }), g;
- function verb(n) {
- return function (v) {
- return step([n, v]);
- };
- }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) {
- try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0:case 1:
- t = op;break;
- case 4:
- _.label++;return { value: op[1], done: false };
- case 5:
- _.label++;y = op[1];op = [0];continue;
- case 7:
- op = _.ops.pop();_.trys.pop();continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
- _ = 0;continue;
- }
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
- _.label = op[1];break;
- }
- if (op[0] === 6 && _.label < t[1]) {
- _.label = t[1];t = op;break;
- }
- if (t && _.label < t[2]) {
- _.label = t[2];_.ops.push(op);break;
- }
- if (t[2]) _.ops.pop();
- _.trys.pop();continue;
- }
- op = body.call(thisArg, _);
- } catch (e) {
- op = [6, e];y = 0;
- } finally {
- f = t = 0;
- }
- }if (op[0] & 5) throw op[1];return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-data-table/constants.ts");
- var MDCDataTableFoundation = /** @class */function (_super) {
- __extends(MDCDataTableFoundation, _super);
- function MDCDataTableFoundation(adapter) {
- return _super.call(this, __assign({}, MDCDataTableFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCDataTableFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClassAtRowIndex: function addClassAtRowIndex() {
- return undefined;
- },
- getRowCount: function getRowCount() {
- return 0;
- },
- getRowElements: function getRowElements() {
- return [];
- },
- getRowIdAtIndex: function getRowIdAtIndex() {
- return '';
- },
- getRowIndexByChildElement: function getRowIndexByChildElement() {
- return 0;
- },
- getSelectedRowCount: function getSelectedRowCount() {
- return 0;
- },
- isCheckboxAtRowIndexChecked: function isCheckboxAtRowIndexChecked() {
- return false;
- },
- isHeaderRowCheckboxChecked: function isHeaderRowCheckboxChecked() {
- return false;
- },
- isRowsSelectable: function isRowsSelectable() {
- return false;
- },
- notifyRowSelectionChanged: function notifyRowSelectionChanged() {
- return undefined;
- },
- notifySelectedAll: function notifySelectedAll() {
- return undefined;
- },
- notifyUnselectedAll: function notifyUnselectedAll() {
- return undefined;
- },
- registerHeaderRowCheckbox: function registerHeaderRowCheckbox() {
- return undefined;
- },
- registerRowCheckboxes: function registerRowCheckboxes() {
- return undefined;
- },
- removeClassAtRowIndex: function removeClassAtRowIndex() {
- return undefined;
- },
- setAttributeAtRowIndex: function setAttributeAtRowIndex() {
- return undefined;
- },
- setHeaderRowCheckboxChecked: function setHeaderRowCheckboxChecked() {
- return undefined;
- },
- setHeaderRowCheckboxIndeterminate: function setHeaderRowCheckboxIndeterminate() {
- return undefined;
- },
- setRowCheckboxCheckedAtIndex: function setRowCheckboxCheckedAtIndex() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
- * Use this if registering checkbox is synchronous.
- */
- MDCDataTableFoundation.prototype.layout = function () {
- if (this.adapter_.isRowsSelectable()) {
- this.adapter_.registerHeaderRowCheckbox();
- this.adapter_.registerRowCheckboxes();
- this.setHeaderRowCheckboxState_();
- }
- };
- /**
- * Re-initializes header row checkbox and row checkboxes when selectable rows are added or removed from table.
- * Use this if registering checkbox is asynchronous.
- */
- MDCDataTableFoundation.prototype.layoutAsync = function () {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- if (!this.adapter_.isRowsSelectable()) return [3 /*break*/, 3];
- return [4 /*yield*/, this.adapter_.registerHeaderRowCheckbox()];
- case 1:
- _a.sent();
- return [4 /*yield*/, this.adapter_.registerRowCheckboxes()];
- case 2:
- _a.sent();
- this.setHeaderRowCheckboxState_();
- _a.label = 3;
- case 3:
- return [2 /*return*/];
- }
- });
- });
- };
- /**
- * @return Returns array of row elements.
- */
- MDCDataTableFoundation.prototype.getRows = function () {
- return this.adapter_.getRowElements();
- };
- /**
- * Sets selected row ids. Overwrites previously selected rows.
- * @param rowIds Array of row ids that needs to be selected.
- */
- MDCDataTableFoundation.prototype.setSelectedRowIds = function (rowIds) {
- for (var rowIndex = 0; rowIndex < this.adapter_.getRowCount(); rowIndex++) {
- var rowId = this.adapter_.getRowIdAtIndex(rowIndex);
- var isSelected = false;
- if (rowId && rowIds.indexOf(rowId) >= 0) {
- isSelected = true;
- }
- this.adapter_.setRowCheckboxCheckedAtIndex(rowIndex, isSelected);
- this.selectRowAtIndex_(rowIndex, isSelected);
- }
- this.setHeaderRowCheckboxState_();
- };
- /**
- * @return Returns array of selected row ids.
- */
- MDCDataTableFoundation.prototype.getSelectedRowIds = function () {
- var selectedRowIds = [];
- for (var rowIndex = 0; rowIndex < this.adapter_.getRowCount(); rowIndex++) {
- if (this.adapter_.isCheckboxAtRowIndexChecked(rowIndex)) {
- selectedRowIds.push(this.adapter_.getRowIdAtIndex(rowIndex));
- }
- }
- return selectedRowIds;
- };
- /**
- * Handles header row checkbox change event.
- */
- MDCDataTableFoundation.prototype.handleHeaderRowCheckboxChange = function () {
- var isHeaderChecked = this.adapter_.isHeaderRowCheckboxChecked();
- for (var rowIndex = 0; rowIndex < this.adapter_.getRowCount(); rowIndex++) {
- this.adapter_.setRowCheckboxCheckedAtIndex(rowIndex, isHeaderChecked);
- this.selectRowAtIndex_(rowIndex, isHeaderChecked);
- }
- if (isHeaderChecked) {
- this.adapter_.notifySelectedAll();
- } else {
- this.adapter_.notifyUnselectedAll();
- }
- };
- /**
- * Handles change event originated from row checkboxes.
- */
- MDCDataTableFoundation.prototype.handleRowCheckboxChange = function (event) {
- var rowIndex = this.adapter_.getRowIndexByChildElement(event.target);
- if (rowIndex === -1) {
- return;
- }
- var selected = this.adapter_.isCheckboxAtRowIndexChecked(rowIndex);
- this.selectRowAtIndex_(rowIndex, selected);
- this.setHeaderRowCheckboxState_();
- var rowId = this.adapter_.getRowIdAtIndex(rowIndex);
- this.adapter_.notifyRowSelectionChanged({ rowId: rowId, rowIndex: rowIndex, selected: selected });
- };
- /**
- * Updates header row checkbox state based on number of rows selected.
- */
- MDCDataTableFoundation.prototype.setHeaderRowCheckboxState_ = function () {
- if (this.adapter_.getSelectedRowCount() === this.adapter_.getRowCount()) {
- this.adapter_.setHeaderRowCheckboxChecked(true);
- this.adapter_.setHeaderRowCheckboxIndeterminate(false);
- } else if (this.adapter_.getSelectedRowCount() === 0) {
- this.adapter_.setHeaderRowCheckboxIndeterminate(false);
- this.adapter_.setHeaderRowCheckboxChecked(false);
- } else {
- this.adapter_.setHeaderRowCheckboxIndeterminate(true);
- this.adapter_.setHeaderRowCheckboxChecked(false);
- }
- };
- /**
- * Sets the attributes of row element based on selection state.
- */
- MDCDataTableFoundation.prototype.selectRowAtIndex_ = function (rowIndex, selected) {
- if (selected) {
- this.adapter_.addClassAtRowIndex(rowIndex, constants_1.cssClasses.ROW_SELECTED);
- this.adapter_.setAttributeAtRowIndex(rowIndex, constants_1.strings.ARIA_SELECTED, 'true');
- } else {
- this.adapter_.removeClassAtRowIndex(rowIndex, constants_1.cssClasses.ROW_SELECTED);
- this.adapter_.setAttributeAtRowIndex(rowIndex, constants_1.strings.ARIA_SELECTED, 'false');
- }
- };
- return MDCDataTableFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCDataTableFoundation = MDCDataTableFoundation;
- /***/ }),
- /***/ "./packages/mdc-data-table/index.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-data-table/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-data-table/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-data-table/foundation.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-data-table/constants.ts"));
- /***/ }),
- /***/ "./packages/mdc-dialog/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-dialog/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __values = this && this.__values || function (o) {
- var m = typeof Symbol === "function" && o[Symbol.iterator],
- i = 0;
- if (m) return m.call(o);
- return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- };
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts");
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
- var strings = foundation_1.MDCDialogFoundation.strings;
- var MDCDialog = /** @class */function (_super) {
- __extends(MDCDialog, _super);
- function MDCDialog() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- Object.defineProperty(MDCDialog.prototype, "isOpen", {
- get: function get() {
- return this.foundation_.isOpen();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDialog.prototype, "escapeKeyAction", {
- get: function get() {
- return this.foundation_.getEscapeKeyAction();
- },
- set: function set(action) {
- this.foundation_.setEscapeKeyAction(action);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDialog.prototype, "scrimClickAction", {
- get: function get() {
- return this.foundation_.getScrimClickAction();
- },
- set: function set(action) {
- this.foundation_.setScrimClickAction(action);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDialog.prototype, "autoStackButtons", {
- get: function get() {
- return this.foundation_.getAutoStackButtons();
- },
- set: function set(autoStack) {
- this.foundation_.setAutoStackButtons(autoStack);
- },
- enumerable: true,
- configurable: true
- });
- MDCDialog.attachTo = function (root) {
- return new MDCDialog(root);
- };
- MDCDialog.prototype.initialize = function (focusTrapFactory) {
- var e_1, _a;
- if (focusTrapFactory === void 0) {
- focusTrapFactory = function focusTrapFactory(el, focusOptions) {
- return new focus_trap_1.FocusTrap(el, focusOptions);
- };
- }
- var container = this.root_.querySelector(strings.CONTAINER_SELECTOR);
- if (!container) {
- throw new Error("Dialog component requires a " + strings.CONTAINER_SELECTOR + " container element");
- }
- this.container_ = container;
- this.content_ = this.root_.querySelector(strings.CONTENT_SELECTOR);
- this.buttons_ = [].slice.call(this.root_.querySelectorAll(strings.BUTTON_SELECTOR));
- this.defaultButton_ = this.root_.querySelector("[" + strings.BUTTON_DEFAULT_ATTRIBUTE + "]");
- this.focusTrapFactory_ = focusTrapFactory;
- this.buttonRipples_ = [];
- try {
- for (var _b = __values(this.buttons_), _c = _b.next(); !_c.done; _c = _b.next()) {
- var buttonEl = _c.value;
- this.buttonRipples_.push(new component_2.MDCRipple(buttonEl));
- }
- } catch (e_1_1) {
- e_1 = { error: e_1_1 };
- } finally {
- try {
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
- } finally {
- if (e_1) throw e_1.error;
- }
- }
- };
- MDCDialog.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.focusTrap_ = util.createFocusTrapInstance(this.container_, this.focusTrapFactory_, this.getInitialFocusEl_() || undefined);
- this.handleClick_ = this.foundation_.handleClick.bind(this.foundation_);
- this.handleKeydown_ = this.foundation_.handleKeydown.bind(this.foundation_);
- this.handleDocumentKeydown_ = this.foundation_.handleDocumentKeydown.bind(this.foundation_);
- this.handleLayout_ = this.layout.bind(this);
- var LAYOUT_EVENTS = ['resize', 'orientationchange'];
- this.handleOpening_ = function () {
- LAYOUT_EVENTS.forEach(function (evtType) {
- return window.addEventListener(evtType, _this.handleLayout_);
- });
- document.addEventListener('keydown', _this.handleDocumentKeydown_);
- };
- this.handleClosing_ = function () {
- LAYOUT_EVENTS.forEach(function (evtType) {
- return window.removeEventListener(evtType, _this.handleLayout_);
- });
- document.removeEventListener('keydown', _this.handleDocumentKeydown_);
- };
- this.listen('click', this.handleClick_);
- this.listen('keydown', this.handleKeydown_);
- this.listen(strings.OPENING_EVENT, this.handleOpening_);
- this.listen(strings.CLOSING_EVENT, this.handleClosing_);
- };
- MDCDialog.prototype.destroy = function () {
- this.unlisten('click', this.handleClick_);
- this.unlisten('keydown', this.handleKeydown_);
- this.unlisten(strings.OPENING_EVENT, this.handleOpening_);
- this.unlisten(strings.CLOSING_EVENT, this.handleClosing_);
- this.handleClosing_();
- this.buttonRipples_.forEach(function (ripple) {
- return ripple.destroy();
- });
- _super.prototype.destroy.call(this);
- };
- MDCDialog.prototype.layout = function () {
- this.foundation_.layout();
- };
- MDCDialog.prototype.open = function () {
- this.foundation_.open();
- };
- MDCDialog.prototype.close = function (action) {
- if (action === void 0) {
- action = '';
- }
- this.foundation_.close(action);
- };
- MDCDialog.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 = {
- addBodyClass: function addBodyClass(className) {
- return document.body.classList.add(className);
- },
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- areButtonsStacked: function areButtonsStacked() {
- return util.areTopsMisaligned(_this.buttons_);
- },
- clickDefaultButton: function clickDefaultButton() {
- return _this.defaultButton_ && _this.defaultButton_.click();
- },
- eventTargetMatches: function eventTargetMatches(target, selector) {
- return target ? ponyfill_1.matches(target, selector) : false;
- },
- getActionFromEvent: function getActionFromEvent(evt) {
- if (!evt.target) {
- return '';
- }
- var element = ponyfill_1.closest(evt.target, "[" + strings.ACTION_ATTRIBUTE + "]");
- return element && element.getAttribute(strings.ACTION_ATTRIBUTE);
- },
- getInitialFocusEl: function getInitialFocusEl() {
- return _this.getInitialFocusEl_();
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- isContentScrollable: function isContentScrollable() {
- return util.isScrollable(_this.content_);
- },
- notifyClosed: function notifyClosed(action) {
- return _this.emit(strings.CLOSED_EVENT, action ? { action: action } : {});
- },
- notifyClosing: function notifyClosing(action) {
- return _this.emit(strings.CLOSING_EVENT, action ? { action: action } : {});
- },
- notifyOpened: function notifyOpened() {
- return _this.emit(strings.OPENED_EVENT, {});
- },
- notifyOpening: function notifyOpening() {
- return _this.emit(strings.OPENING_EVENT, {});
- },
- releaseFocus: function releaseFocus() {
- return _this.focusTrap_.releaseFocus();
- },
- removeBodyClass: function removeBodyClass(className) {
- return document.body.classList.remove(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- reverseButtons: function reverseButtons() {
- _this.buttons_.reverse();
- _this.buttons_.forEach(function (button) {
- button.parentElement.appendChild(button);
- });
- },
- trapFocus: function trapFocus() {
- return _this.focusTrap_.trapFocus();
- }
- };
- return new foundation_1.MDCDialogFoundation(adapter);
- };
- MDCDialog.prototype.getInitialFocusEl_ = function () {
- return document.querySelector("[" + strings.INITIAL_FOCUS_ATTRIBUTE + "]");
- };
- return MDCDialog;
- }(component_1.MDCComponent);
- exports.MDCDialog = MDCDialog;
- /***/ }),
- /***/ "./packages/mdc-dialog/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-dialog/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 = {
- CLOSING: 'mdc-dialog--closing',
- OPEN: 'mdc-dialog--open',
- OPENING: 'mdc-dialog--opening',
- SCROLLABLE: 'mdc-dialog--scrollable',
- SCROLL_LOCK: 'mdc-dialog-scroll-lock',
- STACKED: 'mdc-dialog--stacked'
- };
- exports.strings = {
- ACTION_ATTRIBUTE: 'data-mdc-dialog-action',
- BUTTON_DEFAULT_ATTRIBUTE: 'data-mdc-dialog-button-default',
- BUTTON_SELECTOR: '.mdc-dialog__button',
- CLOSED_EVENT: 'MDCDialog:closed',
- CLOSE_ACTION: 'close',
- CLOSING_EVENT: 'MDCDialog:closing',
- CONTAINER_SELECTOR: '.mdc-dialog__container',
- CONTENT_SELECTOR: '.mdc-dialog__content',
- DESTROY_ACTION: 'destroy',
- INITIAL_FOCUS_ATTRIBUTE: 'data-mdc-dialog-initial-focus',
- OPENED_EVENT: 'MDCDialog:opened',
- OPENING_EVENT: 'MDCDialog:opening',
- SCRIM_SELECTOR: '.mdc-dialog__scrim',
- SUPPRESS_DEFAULT_PRESS_SELECTOR: ['textarea', '.mdc-menu .mdc-list-item'].join(', '),
- SURFACE_SELECTOR: '.mdc-dialog__surface'
- };
- exports.numbers = {
- DIALOG_ANIMATION_CLOSE_TIME_MS: 75,
- DIALOG_ANIMATION_OPEN_TIME_MS: 150
- };
- /***/ }),
- /***/ "./packages/mdc-dialog/foundation.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-dialog/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts");
- var MDCDialogFoundation = /** @class */function (_super) {
- __extends(MDCDialogFoundation, _super);
- function MDCDialogFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCDialogFoundation.defaultAdapter, adapter)) || this;
- _this.isOpen_ = false;
- _this.animationFrame_ = 0;
- _this.animationTimer_ = 0;
- _this.layoutFrame_ = 0;
- _this.escapeKeyAction_ = constants_1.strings.CLOSE_ACTION;
- _this.scrimClickAction_ = constants_1.strings.CLOSE_ACTION;
- _this.autoStackButtons_ = true;
- _this.areButtonsStacked_ = false;
- return _this;
- }
- Object.defineProperty(MDCDialogFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDialogFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDialogFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDialogFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addBodyClass: function addBodyClass() {
- return undefined;
- },
- addClass: function addClass() {
- return undefined;
- },
- areButtonsStacked: function areButtonsStacked() {
- return false;
- },
- clickDefaultButton: function clickDefaultButton() {
- return undefined;
- },
- eventTargetMatches: function eventTargetMatches() {
- return false;
- },
- getActionFromEvent: function getActionFromEvent() {
- return '';
- },
- getInitialFocusEl: function getInitialFocusEl() {
- return null;
- },
- hasClass: function hasClass() {
- return false;
- },
- isContentScrollable: function isContentScrollable() {
- return false;
- },
- notifyClosed: function notifyClosed() {
- return undefined;
- },
- notifyClosing: function notifyClosing() {
- return undefined;
- },
- notifyOpened: function notifyOpened() {
- return undefined;
- },
- notifyOpening: function notifyOpening() {
- return undefined;
- },
- releaseFocus: function releaseFocus() {
- return undefined;
- },
- removeBodyClass: function removeBodyClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- reverseButtons: function reverseButtons() {
- return undefined;
- },
- trapFocus: function trapFocus() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCDialogFoundation.prototype.init = function () {
- if (this.adapter_.hasClass(constants_1.cssClasses.STACKED)) {
- this.setAutoStackButtons(false);
- }
- };
- MDCDialogFoundation.prototype.destroy = function () {
- if (this.isOpen_) {
- this.close(constants_1.strings.DESTROY_ACTION);
- }
- if (this.animationTimer_) {
- clearTimeout(this.animationTimer_);
- this.handleAnimationTimerEnd_();
- }
- if (this.layoutFrame_) {
- cancelAnimationFrame(this.layoutFrame_);
- this.layoutFrame_ = 0;
- }
- };
- MDCDialogFoundation.prototype.open = function () {
- var _this = this;
- this.isOpen_ = true;
- this.adapter_.notifyOpening();
- this.adapter_.addClass(constants_1.cssClasses.OPENING);
- // Wait a frame once display is no longer "none", to establish basis for animation
- this.runNextAnimationFrame_(function () {
- _this.adapter_.addClass(constants_1.cssClasses.OPEN);
- _this.adapter_.addBodyClass(constants_1.cssClasses.SCROLL_LOCK);
- _this.layout();
- _this.animationTimer_ = setTimeout(function () {
- _this.handleAnimationTimerEnd_();
- _this.adapter_.trapFocus(_this.adapter_.getInitialFocusEl());
- _this.adapter_.notifyOpened();
- }, constants_1.numbers.DIALOG_ANIMATION_OPEN_TIME_MS);
- });
- };
- MDCDialogFoundation.prototype.close = function (action) {
- var _this = this;
- if (action === void 0) {
- action = '';
- }
- if (!this.isOpen_) {
- // Avoid redundant close calls (and events), e.g. from keydown on elements that inherently emit click
- return;
- }
- this.isOpen_ = false;
- this.adapter_.notifyClosing(action);
- this.adapter_.addClass(constants_1.cssClasses.CLOSING);
- this.adapter_.removeClass(constants_1.cssClasses.OPEN);
- this.adapter_.removeBodyClass(constants_1.cssClasses.SCROLL_LOCK);
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = 0;
- clearTimeout(this.animationTimer_);
- this.animationTimer_ = setTimeout(function () {
- _this.adapter_.releaseFocus();
- _this.handleAnimationTimerEnd_();
- _this.adapter_.notifyClosed(action);
- }, constants_1.numbers.DIALOG_ANIMATION_CLOSE_TIME_MS);
- };
- MDCDialogFoundation.prototype.isOpen = function () {
- return this.isOpen_;
- };
- MDCDialogFoundation.prototype.getEscapeKeyAction = function () {
- return this.escapeKeyAction_;
- };
- MDCDialogFoundation.prototype.setEscapeKeyAction = function (action) {
- this.escapeKeyAction_ = action;
- };
- MDCDialogFoundation.prototype.getScrimClickAction = function () {
- return this.scrimClickAction_;
- };
- MDCDialogFoundation.prototype.setScrimClickAction = function (action) {
- this.scrimClickAction_ = action;
- };
- MDCDialogFoundation.prototype.getAutoStackButtons = function () {
- return this.autoStackButtons_;
- };
- MDCDialogFoundation.prototype.setAutoStackButtons = function (autoStack) {
- this.autoStackButtons_ = autoStack;
- };
- MDCDialogFoundation.prototype.layout = function () {
- var _this = this;
- if (this.layoutFrame_) {
- cancelAnimationFrame(this.layoutFrame_);
- }
- this.layoutFrame_ = requestAnimationFrame(function () {
- _this.layoutInternal_();
- _this.layoutFrame_ = 0;
- });
- };
- /** Handles click on the dialog root element. */
- MDCDialogFoundation.prototype.handleClick = function (evt) {
- var isScrim = this.adapter_.eventTargetMatches(evt.target, constants_1.strings.SCRIM_SELECTOR);
- // Check for scrim click first since it doesn't require querying ancestors.
- if (isScrim && this.scrimClickAction_ !== '') {
- this.close(this.scrimClickAction_);
- } else {
- var action = this.adapter_.getActionFromEvent(evt);
- if (action) {
- this.close(action);
- }
- }
- };
- /** Handles keydown on the dialog root element. */
- MDCDialogFoundation.prototype.handleKeydown = function (evt) {
- var isEnter = evt.key === 'Enter' || evt.keyCode === 13;
- if (!isEnter) {
- return;
- }
- var action = this.adapter_.getActionFromEvent(evt);
- if (action) {
- // Action button callback is handled in `handleClick`,
- // since space/enter keydowns on buttons trigger click events.
- return;
- }
- var isDefault = !this.adapter_.eventTargetMatches(evt.target, constants_1.strings.SUPPRESS_DEFAULT_PRESS_SELECTOR);
- if (isEnter && isDefault) {
- this.adapter_.clickDefaultButton();
- }
- };
- /** Handles keydown on the document. */
- MDCDialogFoundation.prototype.handleDocumentKeydown = function (evt) {
- var isEscape = evt.key === 'Escape' || evt.keyCode === 27;
- if (isEscape && this.escapeKeyAction_ !== '') {
- this.close(this.escapeKeyAction_);
- }
- };
- MDCDialogFoundation.prototype.layoutInternal_ = function () {
- if (this.autoStackButtons_) {
- this.detectStackedButtons_();
- }
- this.detectScrollableContent_();
- };
- MDCDialogFoundation.prototype.handleAnimationTimerEnd_ = function () {
- this.animationTimer_ = 0;
- this.adapter_.removeClass(constants_1.cssClasses.OPENING);
- this.adapter_.removeClass(constants_1.cssClasses.CLOSING);
- };
- /**
- * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
- */
- MDCDialogFoundation.prototype.runNextAnimationFrame_ = function (callback) {
- var _this = this;
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = requestAnimationFrame(function () {
- _this.animationFrame_ = 0;
- clearTimeout(_this.animationTimer_);
- _this.animationTimer_ = setTimeout(callback, 0);
- });
- };
- MDCDialogFoundation.prototype.detectStackedButtons_ = function () {
- // Remove the class first to let us measure the buttons' natural positions.
- this.adapter_.removeClass(constants_1.cssClasses.STACKED);
- var areButtonsStacked = this.adapter_.areButtonsStacked();
- if (areButtonsStacked) {
- this.adapter_.addClass(constants_1.cssClasses.STACKED);
- }
- if (areButtonsStacked !== this.areButtonsStacked_) {
- this.adapter_.reverseButtons();
- this.areButtonsStacked_ = areButtonsStacked;
- }
- };
- MDCDialogFoundation.prototype.detectScrollableContent_ = function () {
- // Remove the class first to let us measure the natural height of the content.
- this.adapter_.removeClass(constants_1.cssClasses.SCROLLABLE);
- if (this.adapter_.isContentScrollable()) {
- this.adapter_.addClass(constants_1.cssClasses.SCROLLABLE);
- }
- };
- return MDCDialogFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCDialogFoundation = MDCDialogFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCDialogFoundation;
- /***/ }),
- /***/ "./packages/mdc-dialog/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-dialog/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-dialog/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-dialog/util.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-dialog/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 });
- function createFocusTrapInstance(surfaceEl, focusTrapFactory, initialFocusEl) {
- return focusTrapFactory(surfaceEl, { initialFocusEl: initialFocusEl });
- }
- exports.createFocusTrapInstance = createFocusTrapInstance;
- function isScrollable(el) {
- return el ? el.scrollHeight > el.offsetHeight : false;
- }
- exports.isScrollable = isScrollable;
- function areTopsMisaligned(els) {
- var tops = new Set();
- [].forEach.call(els, function (el) {
- return tops.add(el.offsetTop);
- });
- return tops.size > 1;
- }
- exports.areTopsMisaligned = areTopsMisaligned;
- /***/ }),
- /***/ "./packages/mdc-dom/announce.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-dom/announce.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 });
- /**
- * Priorities for the announce function
- */
- var AnnouncerPriority;
- (function (AnnouncerPriority) {
- AnnouncerPriority["POLITE"] = "polite";
- AnnouncerPriority["ASSERTIVE"] = "assertive";
- })(AnnouncerPriority = exports.AnnouncerPriority || (exports.AnnouncerPriority = {}));
- /**
- * Announces the given message with optional priority, defaulting to "polite"
- */
- function announce(message, priority) {
- Announcer.getInstance().say(message, priority);
- }
- exports.announce = announce;
- var Announcer = /** @class */function () {
- // Constructor made private to ensure only the singleton is used
- function Announcer() {
- this.liveRegions = new Map();
- }
- Announcer.getInstance = function () {
- if (!Announcer.instance) {
- Announcer.instance = new Announcer();
- }
- return Announcer.instance;
- };
- Announcer.prototype.say = function (message, priority) {
- if (priority === void 0) {
- priority = AnnouncerPriority.POLITE;
- }
- var liveRegion = this.getLiveRegion(priority);
- // Reset the region to pick up the message, even if the message is the
- // exact same as before.
- liveRegion.textContent = '';
- // Timeout is necessary for screen readers like NVDA and VoiceOver.
- setTimeout(function () {
- liveRegion.textContent = message;
- }, 1);
- };
- Announcer.prototype.getLiveRegion = function (priority) {
- var existingLiveRegion = this.liveRegions.get(priority);
- if (existingLiveRegion && document.body.contains(existingLiveRegion)) {
- return existingLiveRegion;
- }
- var liveRegion = this.createLiveRegion(priority);
- this.liveRegions.set(priority, liveRegion);
- return liveRegion;
- };
- Announcer.prototype.createLiveRegion = function (priority) {
- var el = document.createElement('div');
- el.style.position = 'absolute';
- el.style.top = '-9999px';
- el.style.left = '-9999px';
- el.style.height = '1px';
- el.style.overflow = 'hidden';
- el.setAttribute('aria-atomic', 'true');
- el.setAttribute('aria-live', priority);
- document.body.appendChild(el);
- return el;
- };
- return Announcer;
- }();
- /***/ }),
- /***/ "./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 });
- /**
- * 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/focus-trap.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-dom/focus-trap.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 });
- var FOCUS_SENTINEL_CLASS = 'mdc-dom-focus-sentinel';
- /**
- * Utility to trap focus in a given root element, e.g. for modal components such
- * as dialogs. The root should have at least one focusable child element,
- * for setting initial focus when trapping focus.
- * Also tracks the previously focused element, and restores focus to that
- * element when releasing focus.
- */
- var FocusTrap = /** @class */function () {
- function FocusTrap(root, options) {
- if (options === void 0) {
- options = {};
- }
- this.root = root;
- this.options = options;
- // Previously focused element before trapping focus.
- this.elFocusedBeforeTrapFocus = null;
- }
- /**
- * Traps focus in `root`. Also focuses on either `initialFocusEl` if set;
- * otherwises sets initial focus to the first focusable child element.
- */
- FocusTrap.prototype.trapFocus = function () {
- var focusableEls = this.getFocusableElements(this.root);
- if (focusableEls.length === 0) {
- throw new Error('FocusTrap: Element must have at least one focusable child.');
- }
- this.elFocusedBeforeTrapFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
- this.wrapTabFocus(this.root, focusableEls);
- if (!this.options.skipInitialFocus) {
- this.focusInitialElement(focusableEls, this.options.initialFocusEl);
- }
- };
- /**
- * Releases focus from `root`. Also restores focus to the previously focused
- * element.
- */
- FocusTrap.prototype.releaseFocus = function () {
- [].slice.call(this.root.querySelectorAll("." + FOCUS_SENTINEL_CLASS)).forEach(function (sentinelEl) {
- sentinelEl.parentElement.removeChild(sentinelEl);
- });
- if (this.elFocusedBeforeTrapFocus) {
- this.elFocusedBeforeTrapFocus.focus();
- }
- };
- /**
- * Wraps tab focus within `el` by adding two hidden sentinel divs which are
- * used to mark the beginning and the end of the tabbable region. When
- * focused, these sentinel elements redirect focus to the first/last
- * children elements of the tabbable region, ensuring that focus is trapped
- * within that region.
- */
- FocusTrap.prototype.wrapTabFocus = function (el, focusableEls) {
- var sentinelStart = this.createSentinel();
- var sentinelEnd = this.createSentinel();
- sentinelStart.addEventListener('focus', function () {
- if (focusableEls.length > 0) {
- focusableEls[focusableEls.length - 1].focus();
- }
- });
- sentinelEnd.addEventListener('focus', function () {
- if (focusableEls.length > 0) {
- focusableEls[0].focus();
- }
- });
- el.insertBefore(sentinelStart, el.children[0]);
- el.appendChild(sentinelEnd);
- };
- /**
- * Focuses on `initialFocusEl` if defined and a child of the root element.
- * Otherwise, focuses on the first focusable child element of the root.
- */
- FocusTrap.prototype.focusInitialElement = function (focusableEls, initialFocusEl) {
- var focusIndex = 0;
- if (initialFocusEl) {
- focusIndex = Math.max(focusableEls.indexOf(initialFocusEl), 0);
- }
- focusableEls[focusIndex].focus();
- };
- FocusTrap.prototype.getFocusableElements = function (root) {
- var focusableEls = [].slice.call(root.querySelectorAll('[autofocus], [tabindex], a, input, textarea, select, button'));
- return focusableEls.filter(function (el) {
- var isDisabledOrHidden = el.getAttribute('aria-disabled') === 'true' || el.getAttribute('disabled') != null || el.getAttribute('hidden') != null || el.getAttribute('aria-hidden') === 'true';
- var isTabbableAndVisible = el.tabIndex >= 0 && el.getBoundingClientRect().width > 0 && !el.classList.contains(FOCUS_SENTINEL_CLASS) && !isDisabledOrHidden;
- var isProgrammaticallyHidden = false;
- if (isTabbableAndVisible) {
- var style = getComputedStyle(el);
- isProgrammaticallyHidden = style.display === 'none' || style.visibility === 'hidden';
- }
- return isTabbableAndVisible && !isProgrammaticallyHidden;
- });
- };
- FocusTrap.prototype.createSentinel = function () {
- var sentinel = document.createElement('div');
- sentinel.setAttribute('tabindex', '0');
- // Don't announce in screen readers.
- sentinel.setAttribute('aria-hidden', 'true');
- sentinel.classList.add(FOCUS_SENTINEL_CLASS);
- return sentinel;
- };
- return FocusTrap;
- }();
- exports.FocusTrap = FocusTrap;
- /***/ }),
- /***/ "./packages/mdc-dom/index.ts":
- /*!***********************************!*\
- !*** ./packages/mdc-dom/index.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 __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var events = __importStar(__webpack_require__(/*! ./events */ "./packages/mdc-dom/events.ts"));
- exports.events = events;
- var focusTrap = __importStar(__webpack_require__(/*! ./focus-trap */ "./packages/mdc-dom/focus-trap.ts"));
- exports.focusTrap = focusTrap;
- var ponyfill = __importStar(__webpack_require__(/*! ./ponyfill */ "./packages/mdc-dom/ponyfill.ts"));
- exports.ponyfill = ponyfill;
- /***/ }),
- /***/ "./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 });
- /**
- * @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;
- 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-drawer/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-drawer/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
- var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/list/foundation */ "./packages/mdc-list/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
- var foundation_3 = __webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts");
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
- var cssClasses = foundation_2.MDCDismissibleDrawerFoundation.cssClasses,
- strings = foundation_2.MDCDismissibleDrawerFoundation.strings;
- /**
- * @events `MDCDrawer:closed {}` Emits when the navigation drawer has closed.
- * @events `MDCDrawer:opened {}` Emits when the navigation drawer has opened.
- */
- var MDCDrawer = /** @class */function (_super) {
- __extends(MDCDrawer, _super);
- function MDCDrawer() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCDrawer.attachTo = function (root) {
- return new MDCDrawer(root);
- };
- Object.defineProperty(MDCDrawer.prototype, "open", {
- /**
- * @return boolean Proxies to the foundation's `open`/`close` methods.
- * Also returns true if drawer is in the open position.
- */
- get: function get() {
- return this.foundation_.isOpen();
- },
- /**
- * Toggles the drawer open and closed.
- */
- set: function set(isOpen) {
- if (isOpen) {
- this.foundation_.open();
- } else {
- this.foundation_.close();
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDrawer.prototype, "list", {
- get: function get() {
- return this.list_;
- },
- enumerable: true,
- configurable: true
- });
- MDCDrawer.prototype.initialize = function (focusTrapFactory, listFactory) {
- if (focusTrapFactory === void 0) {
- focusTrapFactory = function focusTrapFactory(el) {
- return new focus_trap_1.FocusTrap(el);
- };
- }
- if (listFactory === void 0) {
- listFactory = function listFactory(el) {
- return new component_2.MDCList(el);
- };
- }
- var listEl = this.root_.querySelector("." + foundation_1.MDCListFoundation.cssClasses.ROOT);
- if (listEl) {
- this.list_ = listFactory(listEl);
- this.list_.wrapFocus = true;
- }
- this.focusTrapFactory_ = focusTrapFactory;
- };
- MDCDrawer.prototype.initialSyncWithDOM = function () {
- var _this = this;
- var MODAL = cssClasses.MODAL;
- var SCRIM_SELECTOR = strings.SCRIM_SELECTOR;
- this.scrim_ = this.root_.parentNode.querySelector(SCRIM_SELECTOR);
- if (this.scrim_ && this.root_.classList.contains(MODAL)) {
- this.handleScrimClick_ = function () {
- return _this.foundation_.handleScrimClick();
- };
- this.scrim_.addEventListener('click', this.handleScrimClick_);
- this.focusTrap_ = util.createFocusTrapInstance(this.root_, this.focusTrapFactory_);
- }
- this.handleKeydown_ = function (evt) {
- return _this.foundation_.handleKeydown(evt);
- };
- this.handleTransitionEnd_ = function (evt) {
- return _this.foundation_.handleTransitionEnd(evt);
- };
- this.listen('keydown', this.handleKeydown_);
- this.listen('transitionend', this.handleTransitionEnd_);
- };
- MDCDrawer.prototype.destroy = function () {
- this.unlisten('keydown', this.handleKeydown_);
- this.unlisten('transitionend', this.handleTransitionEnd_);
- if (this.list_) {
- this.list_.destroy();
- }
- var MODAL = cssClasses.MODAL;
- if (this.scrim_ && this.handleScrimClick_ && this.root_.classList.contains(MODAL)) {
- this.scrim_.removeEventListener('click', this.handleScrimClick_);
- // Ensure drawer is closed to hide scrim and release focus
- this.open = false;
- }
- };
- MDCDrawer.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) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- elementHasClass: function elementHasClass(element, className) {
- return element.classList.contains(className);
- },
- saveFocus: function saveFocus() {
- return _this.previousFocus_ = document.activeElement;
- },
- restoreFocus: function restoreFocus() {
- var previousFocus = _this.previousFocus_;
- if (previousFocus && previousFocus.focus && _this.root_.contains(document.activeElement)) {
- previousFocus.focus();
- }
- },
- focusActiveNavigationItem: function focusActiveNavigationItem() {
- var activeNavItemEl = _this.root_.querySelector("." + foundation_1.MDCListFoundation.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
- if (activeNavItemEl) {
- activeNavItemEl.focus();
- }
- },
- notifyClose: function notifyClose() {
- return _this.emit(strings.CLOSE_EVENT, {}, true /* shouldBubble */);
- },
- notifyOpen: function notifyOpen() {
- return _this.emit(strings.OPEN_EVENT, {}, true /* shouldBubble */);
- },
- trapFocus: function trapFocus() {
- return _this.focusTrap_.trapFocus();
- },
- releaseFocus: function releaseFocus() {
- return _this.focusTrap_.releaseFocus();
- }
- };
- // tslint:enable:object-literal-sort-keys
- var DISMISSIBLE = cssClasses.DISMISSIBLE,
- MODAL = cssClasses.MODAL;
- if (this.root_.classList.contains(DISMISSIBLE)) {
- return new foundation_2.MDCDismissibleDrawerFoundation(adapter);
- } else if (this.root_.classList.contains(MODAL)) {
- return new foundation_3.MDCModalDrawerFoundation(adapter);
- } else {
- throw new Error("MDCDrawer: Failed to instantiate component. Supported variants are " + DISMISSIBLE + " and " + MODAL + ".");
- }
- };
- return MDCDrawer;
- }(component_1.MDCComponent);
- exports.MDCDrawer = MDCDrawer;
- /***/ }),
- /***/ "./packages/mdc-drawer/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-drawer/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 });
- var cssClasses = {
- ANIMATE: 'mdc-drawer--animate',
- CLOSING: 'mdc-drawer--closing',
- DISMISSIBLE: 'mdc-drawer--dismissible',
- MODAL: 'mdc-drawer--modal',
- OPEN: 'mdc-drawer--open',
- OPENING: 'mdc-drawer--opening',
- ROOT: 'mdc-drawer'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- APP_CONTENT_SELECTOR: '.mdc-drawer-app-content',
- CLOSE_EVENT: 'MDCDrawer:closed',
- OPEN_EVENT: 'MDCDrawer:opened',
- SCRIM_SELECTOR: '.mdc-drawer-scrim'
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-drawer/dismissible/foundation.ts":
- /*!*******************************************************!*\
- !*** ./packages/mdc-drawer/dismissible/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-drawer/constants.ts");
- var MDCDismissibleDrawerFoundation = /** @class */function (_super) {
- __extends(MDCDismissibleDrawerFoundation, _super);
- function MDCDismissibleDrawerFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCDismissibleDrawerFoundation.defaultAdapter, adapter)) || this;
- _this.animationFrame_ = 0;
- _this.animationTimer_ = 0;
- return _this;
- }
- Object.defineProperty(MDCDismissibleDrawerFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDismissibleDrawerFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDismissibleDrawerFoundation, "defaultAdapter", {
- 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;
- },
- elementHasClass: function elementHasClass() {
- return false;
- },
- notifyClose: function notifyClose() {
- return undefined;
- },
- notifyOpen: function notifyOpen() {
- return undefined;
- },
- saveFocus: function saveFocus() {
- return undefined;
- },
- restoreFocus: function restoreFocus() {
- return undefined;
- },
- focusActiveNavigationItem: function focusActiveNavigationItem() {
- return undefined;
- },
- trapFocus: function trapFocus() {
- return undefined;
- },
- releaseFocus: function releaseFocus() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCDismissibleDrawerFoundation.prototype.destroy = function () {
- if (this.animationFrame_) {
- cancelAnimationFrame(this.animationFrame_);
- }
- if (this.animationTimer_) {
- clearTimeout(this.animationTimer_);
- }
- };
- /**
- * Opens the drawer from the closed state.
- */
- MDCDismissibleDrawerFoundation.prototype.open = function () {
- var _this = this;
- if (this.isOpen() || this.isOpening() || this.isClosing()) {
- return;
- }
- this.adapter_.addClass(constants_1.cssClasses.OPEN);
- this.adapter_.addClass(constants_1.cssClasses.ANIMATE);
- // Wait a frame once display is no longer "none", to establish basis for animation
- this.runNextAnimationFrame_(function () {
- _this.adapter_.addClass(constants_1.cssClasses.OPENING);
- });
- this.adapter_.saveFocus();
- };
- /**
- * Closes the drawer from the open state.
- */
- MDCDismissibleDrawerFoundation.prototype.close = function () {
- if (!this.isOpen() || this.isOpening() || this.isClosing()) {
- return;
- }
- this.adapter_.addClass(constants_1.cssClasses.CLOSING);
- };
- /**
- * Returns true if the drawer is in the open position.
- * @return true if drawer is in open state.
- */
- MDCDismissibleDrawerFoundation.prototype.isOpen = function () {
- return this.adapter_.hasClass(constants_1.cssClasses.OPEN);
- };
- /**
- * Returns true if the drawer is animating open.
- * @return true if drawer is animating open.
- */
- MDCDismissibleDrawerFoundation.prototype.isOpening = function () {
- return this.adapter_.hasClass(constants_1.cssClasses.OPENING) || this.adapter_.hasClass(constants_1.cssClasses.ANIMATE);
- };
- /**
- * Returns true if the drawer is animating closed.
- * @return true if drawer is animating closed.
- */
- MDCDismissibleDrawerFoundation.prototype.isClosing = function () {
- return this.adapter_.hasClass(constants_1.cssClasses.CLOSING);
- };
- /**
- * Keydown handler to close drawer when key is escape.
- */
- MDCDismissibleDrawerFoundation.prototype.handleKeydown = function (evt) {
- var keyCode = evt.keyCode,
- key = evt.key;
- var isEscape = key === 'Escape' || keyCode === 27;
- if (isEscape) {
- this.close();
- }
- };
- /**
- * Handles the `transitionend` event when the drawer finishes opening/closing.
- */
- MDCDismissibleDrawerFoundation.prototype.handleTransitionEnd = function (evt) {
- var OPENING = constants_1.cssClasses.OPENING,
- CLOSING = constants_1.cssClasses.CLOSING,
- OPEN = constants_1.cssClasses.OPEN,
- ANIMATE = constants_1.cssClasses.ANIMATE,
- ROOT = constants_1.cssClasses.ROOT;
- // In Edge, transitionend on ripple pseudo-elements yields a target without classList, so check for Element first.
- var isRootElement = this.isElement_(evt.target) && this.adapter_.elementHasClass(evt.target, ROOT);
- if (!isRootElement) {
- return;
- }
- if (this.isClosing()) {
- this.adapter_.removeClass(OPEN);
- this.closed_();
- this.adapter_.restoreFocus();
- this.adapter_.notifyClose();
- } else {
- this.adapter_.focusActiveNavigationItem();
- this.opened_();
- this.adapter_.notifyOpen();
- }
- this.adapter_.removeClass(ANIMATE);
- this.adapter_.removeClass(OPENING);
- this.adapter_.removeClass(CLOSING);
- };
- /**
- * Extension point for when drawer finishes open animation.
- */
- MDCDismissibleDrawerFoundation.prototype.opened_ = function () {}; // tslint:disable-line:no-empty
- /**
- * Extension point for when drawer finishes close animation.
- */
- MDCDismissibleDrawerFoundation.prototype.closed_ = function () {}; // tslint:disable-line:no-empty
- /**
- * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
- */
- MDCDismissibleDrawerFoundation.prototype.runNextAnimationFrame_ = function (callback) {
- var _this = this;
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = requestAnimationFrame(function () {
- _this.animationFrame_ = 0;
- clearTimeout(_this.animationTimer_);
- _this.animationTimer_ = setTimeout(callback, 0);
- });
- };
- MDCDismissibleDrawerFoundation.prototype.isElement_ = function (element) {
- // In Edge, transitionend on ripple pseudo-elements yields a target without classList.
- return Boolean(element.classList);
- };
- return MDCDismissibleDrawerFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCDismissibleDrawerFoundation = MDCDismissibleDrawerFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCDismissibleDrawerFoundation;
- /***/ }),
- /***/ "./packages/mdc-drawer/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-drawer/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-drawer/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-drawer/constants.ts"));
- __export(__webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts"));
- __export(__webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-drawer/modal/foundation.ts":
- /*!*************************************************!*\
- !*** ./packages/mdc-drawer/modal/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! ../dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
- /* istanbul ignore next: subclass is not a branch statement */
- var MDCModalDrawerFoundation = /** @class */function (_super) {
- __extends(MDCModalDrawerFoundation, _super);
- function MDCModalDrawerFoundation() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * Handles click event on scrim.
- */
- MDCModalDrawerFoundation.prototype.handleScrimClick = function () {
- this.close();
- };
- /**
- * Called when drawer finishes open animation.
- */
- MDCModalDrawerFoundation.prototype.opened_ = function () {
- this.adapter_.trapFocus();
- };
- /**
- * Called when drawer finishes close animation.
- */
- MDCModalDrawerFoundation.prototype.closed_ = function () {
- this.adapter_.releaseFocus();
- };
- return MDCModalDrawerFoundation;
- }(foundation_1.MDCDismissibleDrawerFoundation);
- exports.MDCModalDrawerFoundation = MDCModalDrawerFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCModalDrawerFoundation;
- /***/ }),
- /***/ "./packages/mdc-drawer/util.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-drawer/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 });
- function createFocusTrapInstance(surfaceEl, focusTrapFactory) {
- return focusTrapFactory(surfaceEl, {
- // Component handles focusing on active nav item.
- skipInitialFocus: true
- });
- }
- exports.createFocusTrapInstance = createFocusTrapInstance;
- /***/ }),
- /***/ "./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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- 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");
- 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);
- };
- 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) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- getWidth: function getWidth() {
- return ponyfill_1.estimateScrollWidth(_this.root_);
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return _this.listen(evtType, handler);
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return _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 = {
- LABEL_FLOAT_ABOVE: 'mdc-floating-label--float-above',
- 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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- 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");
- var MDCFloatingLabelFoundation = /** @class */function (_super) {
- __extends(MDCFloatingLabelFoundation, _super);
- function MDCFloatingLabelFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCFloatingLabelFoundation.defaultAdapter, adapter)) || this;
- _this.shakeAnimationEndHandler_ = function () {
- return _this.handleShakeAnimationEnd_();
- };
- return _this;
- }
- Object.defineProperty(MDCFloatingLabelFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- 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;
- },
- getWidth: function getWidth() {
- return 0;
- },
- registerInteractionHandler: function registerInteractionHandler() {
- return undefined;
- },
- deregisterInteractionHandler: function deregisterInteractionHandler() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- 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);
- }
- };
- 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-floating-label/index.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-floating-label/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-floating-label/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-form-field/component.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-form-field/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-form-field/foundation.ts");
- var MDCFormField = /** @class */function (_super) {
- __extends(MDCFormField, _super);
- function MDCFormField() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCFormField.attachTo = function (root) {
- return new MDCFormField(root);
- };
- Object.defineProperty(MDCFormField.prototype, "input", {
- get: function get() {
- return this.input_;
- },
- set: function set(input) {
- this.input_ = input;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCFormField.prototype, "label_", {
- get: function get() {
- var LABEL_SELECTOR = foundation_1.MDCFormFieldFoundation.strings.LABEL_SELECTOR;
- return this.root_.querySelector(LABEL_SELECTOR);
- },
- enumerable: true,
- configurable: true
- });
- MDCFormField.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 = {
- activateInputRipple: function activateInputRipple() {
- if (_this.input_ && _this.input_.ripple) {
- _this.input_.ripple.activate();
- }
- },
- deactivateInputRipple: function deactivateInputRipple() {
- if (_this.input_ && _this.input_.ripple) {
- _this.input_.ripple.deactivate();
- }
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- if (_this.label_) {
- _this.label_.removeEventListener(evtType, handler);
- }
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- if (_this.label_) {
- _this.label_.addEventListener(evtType, handler);
- }
- }
- };
- return new foundation_1.MDCFormFieldFoundation(adapter);
- };
- return MDCFormField;
- }(component_1.MDCComponent);
- exports.MDCFormField = MDCFormField;
- /***/ }),
- /***/ "./packages/mdc-form-field/constants.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-form-field/constants.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.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.cssClasses = {
- ROOT: 'mdc-form-field'
- };
- exports.strings = {
- LABEL_SELECTOR: '.mdc-form-field > label'
- };
- /***/ }),
- /***/ "./packages/mdc-form-field/foundation.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-form-field/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-form-field/constants.ts");
- var MDCFormFieldFoundation = /** @class */function (_super) {
- __extends(MDCFormFieldFoundation, _super);
- function MDCFormFieldFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCFormFieldFoundation.defaultAdapter, adapter)) || this;
- _this.clickHandler_ = function () {
- return _this.handleClick_();
- };
- return _this;
- }
- Object.defineProperty(MDCFormFieldFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCFormFieldFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCFormFieldFoundation, "defaultAdapter", {
- get: function get() {
- return {
- activateInputRipple: function activateInputRipple() {
- return undefined;
- },
- deactivateInputRipple: function deactivateInputRipple() {
- return undefined;
- },
- deregisterInteractionHandler: function deregisterInteractionHandler() {
- return undefined;
- },
- registerInteractionHandler: function registerInteractionHandler() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCFormFieldFoundation.prototype.init = function () {
- this.adapter_.registerInteractionHandler('click', this.clickHandler_);
- };
- MDCFormFieldFoundation.prototype.destroy = function () {
- this.adapter_.deregisterInteractionHandler('click', this.clickHandler_);
- };
- MDCFormFieldFoundation.prototype.handleClick_ = function () {
- var _this = this;
- this.adapter_.activateInputRipple();
- requestAnimationFrame(function () {
- return _this.adapter_.deactivateInputRipple();
- });
- };
- return MDCFormFieldFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCFormFieldFoundation = MDCFormFieldFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCFormFieldFoundation;
- /***/ }),
- /***/ "./packages/mdc-form-field/index.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-form-field/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-form-field/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-form-field/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-form-field/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-icon-button/component.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-icon-button/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-icon-button/foundation.ts");
- var strings = foundation_1.MDCIconButtonToggleFoundation.strings;
- var MDCIconButtonToggle = /** @class */function (_super) {
- __extends(MDCIconButtonToggle, _super);
- function MDCIconButtonToggle() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.ripple_ = _this.createRipple_();
- return _this;
- }
- MDCIconButtonToggle.attachTo = function (root) {
- return new MDCIconButtonToggle(root);
- };
- MDCIconButtonToggle.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleClick_ = function () {
- return _this.foundation_.handleClick();
- };
- this.listen('click', this.handleClick_);
- };
- MDCIconButtonToggle.prototype.destroy = function () {
- this.unlisten('click', this.handleClick_);
- this.ripple_.destroy();
- _super.prototype.destroy.call(this);
- };
- MDCIconButtonToggle.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 = {
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- notifyChange: function notifyChange(evtData) {
- return _this.emit(strings.CHANGE_EVENT, evtData);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- setAttr: function setAttr(attrName, attrValue) {
- return _this.root_.setAttribute(attrName, attrValue);
- }
- };
- return new foundation_1.MDCIconButtonToggleFoundation(adapter);
- };
- Object.defineProperty(MDCIconButtonToggle.prototype, "ripple", {
- get: function get() {
- return this.ripple_;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCIconButtonToggle.prototype, "on", {
- get: function get() {
- return this.foundation_.isOn();
- },
- set: function set(isOn) {
- this.foundation_.toggle(isOn);
- },
- enumerable: true,
- configurable: true
- });
- MDCIconButtonToggle.prototype.createRipple_ = function () {
- var ripple = new component_2.MDCRipple(this.root_);
- ripple.unbounded = true;
- return ripple;
- };
- return MDCIconButtonToggle;
- }(component_1.MDCComponent);
- exports.MDCIconButtonToggle = MDCIconButtonToggle;
- /***/ }),
- /***/ "./packages/mdc-icon-button/constants.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-icon-button/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 = {
- ICON_BUTTON_ON: 'mdc-icon-button--on',
- ROOT: 'mdc-icon-button'
- };
- exports.strings = {
- ARIA_PRESSED: 'aria-pressed',
- CHANGE_EVENT: 'MDCIconButtonToggle:change'
- };
- /***/ }),
- /***/ "./packages/mdc-icon-button/foundation.ts":
- /*!************************************************!*\
- !*** ./packages/mdc-icon-button/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-icon-button/constants.ts");
- var MDCIconButtonToggleFoundation = /** @class */function (_super) {
- __extends(MDCIconButtonToggleFoundation, _super);
- function MDCIconButtonToggleFoundation(adapter) {
- return _super.call(this, __assign({}, MDCIconButtonToggleFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCIconButtonToggleFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCIconButtonToggleFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCIconButtonToggleFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return false;
- },
- notifyChange: function notifyChange() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- setAttr: function setAttr() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCIconButtonToggleFoundation.prototype.init = function () {
- this.adapter_.setAttr(constants_1.strings.ARIA_PRESSED, "" + this.isOn());
- };
- MDCIconButtonToggleFoundation.prototype.handleClick = function () {
- this.toggle();
- this.adapter_.notifyChange({ isOn: this.isOn() });
- };
- MDCIconButtonToggleFoundation.prototype.isOn = function () {
- return this.adapter_.hasClass(constants_1.cssClasses.ICON_BUTTON_ON);
- };
- MDCIconButtonToggleFoundation.prototype.toggle = function (isOn) {
- if (isOn === void 0) {
- isOn = !this.isOn();
- }
- if (isOn) {
- this.adapter_.addClass(constants_1.cssClasses.ICON_BUTTON_ON);
- } else {
- this.adapter_.removeClass(constants_1.cssClasses.ICON_BUTTON_ON);
- }
- this.adapter_.setAttr(constants_1.strings.ARIA_PRESSED, "" + isOn);
- };
- return MDCIconButtonToggleFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCIconButtonToggleFoundation = MDCIconButtonToggleFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCIconButtonToggleFoundation;
- /***/ }),
- /***/ "./packages/mdc-icon-button/index.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-icon-button/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-icon-button/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-icon-button/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-icon-button/foundation.ts"));
- /***/ }),
- /***/ "./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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- 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");
- 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) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- setStyle: function setStyle(propertyName, value) {
- return _this.root_.style.setProperty(propertyName, value);
- },
- registerEventHandler: function registerEventHandler(evtType, handler) {
- return _this.listen(evtType, handler);
- },
- deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
- return _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 });
- 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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- 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");
- var MDCLineRippleFoundation = /** @class */function (_super) {
- __extends(MDCLineRippleFoundation, _super);
- function MDCLineRippleFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCLineRippleFoundation.defaultAdapter, adapter)) || this;
- _this.transitionEndHandler_ = function (evt) {
- return _this.handleTransitionEnd(evt);
- };
- return _this;
- }
- Object.defineProperty(MDCLineRippleFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- 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: true,
- 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-line-ripple/index.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-line-ripple/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-line-ripple/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-line-ripple/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-line-ripple/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-linear-progress/component.ts":
- /*!***************************************************!*\
- !*** ./packages/mdc-linear-progress/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-linear-progress/foundation.ts");
- var MDCLinearProgress = /** @class */function (_super) {
- __extends(MDCLinearProgress, _super);
- function MDCLinearProgress() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCLinearProgress.attachTo = function (root) {
- return new MDCLinearProgress(root);
- };
- Object.defineProperty(MDCLinearProgress.prototype, "determinate", {
- set: function set(value) {
- this.foundation_.setDeterminate(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCLinearProgress.prototype, "progress", {
- set: function set(value) {
- this.foundation_.setProgress(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCLinearProgress.prototype, "buffer", {
- set: function set(value) {
- this.foundation_.setBuffer(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCLinearProgress.prototype, "reverse", {
- set: function set(value) {
- this.foundation_.setReverse(value);
- },
- enumerable: true,
- configurable: true
- });
- MDCLinearProgress.prototype.open = function () {
- this.foundation_.open();
- };
- MDCLinearProgress.prototype.close = function () {
- this.foundation_.close();
- };
- MDCLinearProgress.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 = {
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- forceLayout: function forceLayout() {
- return _this.root_.offsetWidth;
- },
- getBuffer: function getBuffer() {
- return _this.root_.querySelector(foundation_1.MDCLinearProgressFoundation.strings.BUFFER_SELECTOR);
- },
- getPrimaryBar: function getPrimaryBar() {
- return _this.root_.querySelector(foundation_1.MDCLinearProgressFoundation.strings.PRIMARY_BAR_SELECTOR);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- removeAttribute: function removeAttribute(attributeName) {
- _this.root_.removeAttribute(attributeName);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- setAttribute: function setAttribute(attributeName, value) {
- _this.root_.setAttribute(attributeName, value);
- },
- setStyle: function setStyle(el, styleProperty, value) {
- return el.style.setProperty(styleProperty, value);
- }
- };
- return new foundation_1.MDCLinearProgressFoundation(adapter);
- };
- return MDCLinearProgress;
- }(component_1.MDCComponent);
- exports.MDCLinearProgress = MDCLinearProgress;
- /***/ }),
- /***/ "./packages/mdc-linear-progress/constants.ts":
- /*!***************************************************!*\
- !*** ./packages/mdc-linear-progress/constants.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.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.cssClasses = {
- CLOSED_CLASS: 'mdc-linear-progress--closed',
- INDETERMINATE_CLASS: 'mdc-linear-progress--indeterminate',
- REVERSED_CLASS: 'mdc-linear-progress--reversed'
- };
- exports.strings = {
- ARIA_VALUENOW: 'aria-valuenow',
- BUFFER_SELECTOR: '.mdc-linear-progress__buffer',
- PRIMARY_BAR_SELECTOR: '.mdc-linear-progress__primary-bar'
- };
- /***/ }),
- /***/ "./packages/mdc-linear-progress/foundation.ts":
- /*!****************************************************!*\
- !*** ./packages/mdc-linear-progress/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-linear-progress/constants.ts");
- var MDCLinearProgressFoundation = /** @class */function (_super) {
- __extends(MDCLinearProgressFoundation, _super);
- function MDCLinearProgressFoundation(adapter) {
- return _super.call(this, __assign({}, MDCLinearProgressFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCLinearProgressFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCLinearProgressFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCLinearProgressFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- forceLayout: function forceLayout() {
- return undefined;
- },
- getBuffer: function getBuffer() {
- return null;
- },
- getPrimaryBar: function getPrimaryBar() {
- return null;
- },
- hasClass: function hasClass() {
- return false;
- },
- removeAttribute: function removeAttribute() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- setAttribute: function setAttribute() {
- return undefined;
- },
- setStyle: function setStyle() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCLinearProgressFoundation.prototype.init = function () {
- this.isDeterminate_ = !this.adapter_.hasClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.isReversed_ = this.adapter_.hasClass(constants_1.cssClasses.REVERSED_CLASS);
- this.progress_ = 0;
- this.buffer_ = 1;
- };
- MDCLinearProgressFoundation.prototype.setDeterminate = function (isDeterminate) {
- this.isDeterminate_ = isDeterminate;
- if (this.isDeterminate_) {
- this.adapter_.removeClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.adapter_.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress_.toString());
- this.setScale_(this.adapter_.getPrimaryBar(), this.progress_);
- this.setScale_(this.adapter_.getBuffer(), this.buffer_);
- } else {
- if (this.isReversed_) {
- // Adding/removing REVERSED_CLASS starts a translate animation, while
- // adding INDETERMINATE_CLASS starts a scale animation. Here, we reset
- // the translate animation in order to keep it in sync with the new
- // scale animation that will start from adding INDETERMINATE_CLASS
- // below.
- this.adapter_.removeClass(constants_1.cssClasses.REVERSED_CLASS);
- this.adapter_.forceLayout();
- this.adapter_.addClass(constants_1.cssClasses.REVERSED_CLASS);
- }
- this.adapter_.addClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.adapter_.removeAttribute(constants_1.strings.ARIA_VALUENOW);
- this.setScale_(this.adapter_.getPrimaryBar(), 1);
- this.setScale_(this.adapter_.getBuffer(), 1);
- }
- };
- MDCLinearProgressFoundation.prototype.setProgress = function (value) {
- this.progress_ = value;
- if (this.isDeterminate_) {
- this.setScale_(this.adapter_.getPrimaryBar(), value);
- this.adapter_.setAttribute(constants_1.strings.ARIA_VALUENOW, value.toString());
- }
- };
- MDCLinearProgressFoundation.prototype.setBuffer = function (value) {
- this.buffer_ = value;
- if (this.isDeterminate_) {
- this.setScale_(this.adapter_.getBuffer(), value);
- }
- };
- MDCLinearProgressFoundation.prototype.setReverse = function (isReversed) {
- this.isReversed_ = isReversed;
- if (!this.isDeterminate_) {
- // Adding INDETERMINATE_CLASS starts a scale animation, while
- // adding/removing REVERSED_CLASS starts a translate animation. Here, we
- // reset the scale animation in order to keep it in sync with the new
- // translate animation that will start from adding/removing REVERSED_CLASS
- // below.
- this.adapter_.removeClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.adapter_.forceLayout();
- this.adapter_.addClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- }
- if (this.isReversed_) {
- this.adapter_.addClass(constants_1.cssClasses.REVERSED_CLASS);
- } else {
- this.adapter_.removeClass(constants_1.cssClasses.REVERSED_CLASS);
- }
- };
- MDCLinearProgressFoundation.prototype.open = function () {
- this.adapter_.removeClass(constants_1.cssClasses.CLOSED_CLASS);
- };
- MDCLinearProgressFoundation.prototype.close = function () {
- this.adapter_.addClass(constants_1.cssClasses.CLOSED_CLASS);
- };
- MDCLinearProgressFoundation.prototype.setScale_ = function (el, scaleValue) {
- if (!el) {
- return;
- }
- var value = "scaleX(" + scaleValue + ")";
- this.adapter_.setStyle(el, util_1.getCorrectPropertyName(window, 'transform'), value);
- };
- return MDCLinearProgressFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCLinearProgressFoundation = MDCLinearProgressFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCLinearProgressFoundation;
- /***/ }),
- /***/ "./packages/mdc-linear-progress/index.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-linear-progress/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-linear-progress/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-linear-progress/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-linear-progress/foundation.ts"));
- /***/ }),
- /***/ "./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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- 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");
- 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: true,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "listElements", {
- get: function get() {
- return [].slice.call(this.root_.querySelectorAll("." + constants_1.cssClasses.LIST_ITEM_CLASS));
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "wrapFocus", {
- set: function set(value) {
- this.foundation_.setWrapFocus(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "singleSelection", {
- set: function set(isSingleSelectionList) {
- this.foundation_.setSingleSelection(isSingleSelectionList);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "selectedIndex", {
- get: function get() {
- return this.foundation_.getSelectedIndex();
- },
- set: function set(index) {
- this.foundation_.setSelectedIndex(index);
- },
- enumerable: true,
- configurable: true
- });
- MDCList.attachTo = function (root) {
- return new MDCList(root);
- };
- MDCList.prototype.initialSyncWithDOM = function () {
- 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();
- };
- 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;
- // List items need to have at least tabindex=-1 to be focusable.
- [].slice.call(this.root_.querySelectorAll('.mdc-list-item:not([tabindex])')).forEach(function (el) {
- el.setAttribute('tabindex', '-1');
- });
- // Child button/a elements are not tabbable until the list item is focused.
- [].slice.call(this.root_.querySelectorAll(constants_1.strings.FOCUSABLE_CHILD_ELEMENTS)).forEach(function (el) {
- return el.setAttribute('tabindex', '-1');
- });
- this.foundation_.layout();
- };
- /**
- * Initialize selectedIndex value based on pre-selected checkbox list items, single selection or radio.
- */
- MDCList.prototype.initializeListType = function () {
- var _this = this;
- var checkboxListItems = this.root_.querySelectorAll(constants_1.strings.ARIA_ROLE_CHECKBOX_SELECTOR);
- var singleSelectedListItem = this.root_.querySelector("\n ." + constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS + ",\n ." + constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS + "\n ");
- 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 = [].map.call(preselectedItems, function (listItem) {
- return _this.listElements.indexOf(listItem);
- });
- } else if (singleSelectedListItem) {
- if (singleSelectedListItem.classList.contains(constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS)) {
- this.foundation_.setUseActivatedClass(true);
- }
- this.singleSelection = true;
- this.selectedIndex = this.listElements.indexOf(singleSelectedListItem);
- } 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);
- };
- 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(className);
- }
- },
- focusItemAtIndex: function focusItemAtIndex(index) {
- var element = _this.listElements[index];
- if (element) {
- element.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;
- },
- 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_.contains(document.activeElement);
- },
- isRootFocused: function isRootFocused() {
- return document.activeElement === _this.root_;
- },
- listItemAtIndexHasClass: function listItemAtIndexHasClass(index, className) {
- return _this.listElements[index].classList.contains(className);
- },
- notifyAction: function notifyAction(index) {
- _this.emit(constants_1.strings.ACTION_EVENT, { index: index }, /** shouldBubble */true);
- },
- removeClassForElementIndex: function removeClassForElementIndex(index, className) {
- var element = _this.listElements[index];
- if (element) {
- element.classList.remove(className);
- }
- },
- setAttributeForElementIndex: function setAttributeForElementIndex(index, attr, value) {
- var element = _this.listElements[index];
- if (element) {
- element.setAttribute(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 listItemChildren = [].slice.call(element.querySelectorAll(constants_1.strings.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX));
- listItemChildren.forEach(function (el) {
- return el.setAttribute('tabindex', tabIndexValue);
- });
- }
- };
- return new foundation_1.MDCListFoundation(adapter);
- };
- /**
- * Used to figure out which list item this event is targetting. Or returns -1 if
- * there is no list item
- */
- MDCList.prototype.getListItemIndex_ = function (evt) {
- var eventTarget = evt.target;
- var nearestParent = ponyfill_1.closest(eventTarget, "." + constants_1.cssClasses.LIST_ITEM_CLASS + ", ." + constants_1.cssClasses.ROOT);
- // Get the index of the element if it is a list item.
- if (nearestParent && ponyfill_1.matches(nearestParent, "." + 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);
- this.foundation_.handleFocusIn(evt, 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);
- this.foundation_.handleFocusOut(evt, 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);
- var target = evt.target;
- this.foundation_.handleKeydown(evt, target.classList.contains(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);
- var target = evt.target;
- // Toggle the checkbox only if it's not the target of the event, or the checkbox will have 2 change events.
- var toggleCheckbox = !ponyfill_1.matches(target, constants_1.strings.CHECKBOX_RADIO_SELECTOR);
- this.foundation_.handleClick(index, toggleCheckbox);
- };
- 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.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- 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',
- ROOT: 'mdc-list'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ACTION_EVENT: 'MDCList:action',
- 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',
- 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 ",
- 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 ",
- RADIO_SELECTOR: 'input[type="radio"]'
- };
- exports.strings = strings;
- var numbers = {
- UNSET_INDEX: -1
- };
- exports.numbers = numbers;
- /***/ }),
- /***/ "./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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
- var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select'];
- function isNumberArray(selectedIndex) {
- return selectedIndex instanceof Array;
- }
- var MDCListFoundation = /** @class */function (_super) {
- __extends(MDCListFoundation, _super);
- function MDCListFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCListFoundation.defaultAdapter, adapter)) || this;
- _this.wrapFocus_ = false;
- _this.isVertical_ = true;
- _this.isSingleSelectionList_ = false;
- _this.selectedIndex_ = constants_1.numbers.UNSET_INDEX;
- _this.focusedItemIndex_ = constants_1.numbers.UNSET_INDEX;
- _this.useActivatedClass_ = false;
- _this.ariaCurrentAttrValue_ = null;
- _this.isCheckboxList_ = false;
- _this.isRadioList_ = false;
- return _this;
- }
- Object.defineProperty(MDCListFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCListFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCListFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- 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;
- },
- removeClassForElementIndex: function removeClassForElementIndex() {
- return undefined;
- },
- setAttributeForElementIndex: function setAttributeForElementIndex() {
- return undefined;
- },
- setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex() {
- return undefined;
- },
- setTabIndexForListItemChildren: function setTabIndexForListItemChildren() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCListFoundation.prototype.layout = function () {
- if (this.adapter_.getListItemCount() === 0) {
- return;
- }
- if (this.adapter_.hasCheckboxAtIndex(0)) {
- this.isCheckboxList_ = true;
- } else if (this.adapter_.hasRadioAtIndex(0)) {
- this.isRadioList_ = true;
- }
- };
- /**
- * Sets the private wrapFocus_ variable.
- */
- MDCListFoundation.prototype.setWrapFocus = function (value) {
- this.wrapFocus_ = value;
- };
- /**
- * Sets the isVertical_ private variable.
- */
- MDCListFoundation.prototype.setVerticalOrientation = function (value) {
- this.isVertical_ = value;
- };
- /**
- * Sets the isSingleSelectionList_ private variable.
- */
- MDCListFoundation.prototype.setSingleSelection = function (value) {
- this.isSingleSelectionList_ = value;
- };
- /**
- * Sets the useActivatedClass_ private variable.
- */
- MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) {
- this.useActivatedClass_ = useActivated;
- };
- MDCListFoundation.prototype.getSelectedIndex = function () {
- return this.selectedIndex_;
- };
- MDCListFoundation.prototype.setSelectedIndex = function (index) {
- if (!this.isIndexValid_(index)) {
- return;
- }
- if (this.isCheckboxList_) {
- this.setCheckboxAtIndex_(index);
- } else if (this.isRadioList_) {
- this.setRadioAtIndex_(index);
- } else {
- this.setSingleSelectionAtIndex_(index);
- }
- };
- /**
- * Focus in handler for the list items.
- */
- MDCListFoundation.prototype.handleFocusIn = function (_, listItemIndex) {
- if (listItemIndex >= 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_.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.setTabindexToFirstSelectedItem_();
- }
- }, 0);
- };
- /**
- * Key handler for the list.
- */
- MDCListFoundation.prototype.handleKeydown = function (evt, isRootListItem, listItemIndex) {
- var isArrowLeft = evt.key === 'ArrowLeft' || evt.keyCode === 37;
- var isArrowUp = evt.key === 'ArrowUp' || evt.keyCode === 38;
- var isArrowRight = evt.key === 'ArrowRight' || evt.keyCode === 39;
- var isArrowDown = evt.key === 'ArrowDown' || evt.keyCode === 40;
- var isHome = evt.key === 'Home' || evt.keyCode === 36;
- var isEnd = evt.key === 'End' || evt.keyCode === 35;
- var isEnter = evt.key === 'Enter' || evt.keyCode === 13;
- var isSpace = evt.key === 'Space' || evt.keyCode === 32;
- if (this.adapter_.isRootFocused()) {
- if (isArrowUp || isEnd) {
- evt.preventDefault();
- this.focusLastElement();
- } else if (isArrowDown || isHome) {
- evt.preventDefault();
- this.focusFirstElement();
- }
- 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;
- }
- }
- var nextIndex;
- if (this.isVertical_ && isArrowDown || !this.isVertical_ && isArrowRight) {
- this.preventDefaultEvent_(evt);
- nextIndex = this.focusNextElement(currentIndex);
- } else if (this.isVertical_ && isArrowUp || !this.isVertical_ && isArrowLeft) {
- this.preventDefaultEvent_(evt);
- nextIndex = this.focusPrevElement(currentIndex);
- } else if (isHome) {
- this.preventDefaultEvent_(evt);
- nextIndex = this.focusFirstElement();
- } else if (isEnd) {
- this.preventDefaultEvent_(evt);
- nextIndex = this.focusLastElement();
- } else if (isEnter || isSpace) {
- if (isRootListItem) {
- // Return early if enter key is pressed on anchor element which triggers synthetic MouseEvent event.
- var target = evt.target;
- if (target && target.tagName === 'A' && isEnter) {
- return;
- }
- this.preventDefaultEvent_(evt);
- if (this.isSelectableList_()) {
- this.setSelectedIndexOnAction_(currentIndex);
- }
- this.adapter_.notifyAction(currentIndex);
- }
- }
- this.focusedItemIndex_ = currentIndex;
- if (nextIndex !== undefined) {
- this.setTabindexAtIndex_(nextIndex);
- this.focusedItemIndex_ = nextIndex;
- }
- };
- /**
- * Click handler for the list.
- */
- MDCListFoundation.prototype.handleClick = function (index, toggleCheckbox) {
- if (index === constants_1.numbers.UNSET_INDEX) {
- return;
- }
- if (this.isSelectableList_()) {
- this.setSelectedIndexOnAction_(index, toggleCheckbox);
- }
- this.adapter_.notifyAction(index);
- this.setTabindexAtIndex_(index);
- this.focusedItemIndex_ = index;
- };
- /**
- * Focuses the next element on the list.
- */
- MDCListFoundation.prototype.focusNextElement = function (index) {
- var count = this.adapter_.getListItemCount();
- var nextIndex = index + 1;
- if (nextIndex >= count) {
- if (this.wrapFocus_) {
- nextIndex = 0;
- } else {
- // Return early because last item is already focused.
- return index;
- }
- }
- this.adapter_.focusItemAtIndex(nextIndex);
- return nextIndex;
- };
- /**
- * Focuses the previous element on the list.
- */
- MDCListFoundation.prototype.focusPrevElement = function (index) {
- var prevIndex = index - 1;
- if (prevIndex < 0) {
- if (this.wrapFocus_) {
- prevIndex = this.adapter_.getListItemCount() - 1;
- } else {
- // Return early because first item is already focused.
- return index;
- }
- }
- this.adapter_.focusItemAtIndex(prevIndex);
- return prevIndex;
- };
- MDCListFoundation.prototype.focusFirstElement = function () {
- this.adapter_.focusItemAtIndex(0);
- return 0;
- };
- MDCListFoundation.prototype.focusLastElement = function () {
- var lastIndex = this.adapter_.getListItemCount() - 1;
- this.adapter_.focusItemAtIndex(lastIndex);
- return lastIndex;
- };
- /**
- * @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)) {
- 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');
- }
- };
- /**
- * Ensures that preventDefault is only called if the containing element doesn't
- * consume the event, and it will cause an unintended scroll.
- */
- MDCListFoundation.prototype.preventDefaultEvent_ = function (evt) {
- var target = evt.target;
- var tagName = ("" + target.tagName).toLowerCase();
- if (ELEMENTS_KEY_ALLOWED_IN.indexOf(tagName) === -1) {
- evt.preventDefault();
- }
- };
- MDCListFoundation.prototype.setSingleSelectionAtIndex_ = function (index) {
- if (this.selectedIndex_ === index) {
- 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.adapter_.addClassForElementIndex(index, selectedClassName);
- this.setAriaForSingleSelectionAtIndex_(index);
- this.selectedIndex_ = 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) {
- 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');
- }
- var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue_ : 'true';
- this.adapter_.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
- };
- /**
- * Toggles radio at give index. Radio doesn't change the checked state if it is already checked.
- */
- MDCListFoundation.prototype.setRadioAtIndex_ = function (index) {
- this.adapter_.setCheckedCheckboxOrRadioAtIndex(index, true);
- if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
- this.adapter_.setAttributeForElementIndex(this.selectedIndex_, constants_1.strings.ARIA_CHECKED, 'false');
- }
- this.adapter_.setAttributeForElementIndex(index, constants_1.strings.ARIA_CHECKED, 'true');
- this.selectedIndex_ = index;
- };
- MDCListFoundation.prototype.setCheckboxAtIndex_ = function (index) {
- for (var i = 0; i < this.adapter_.getListItemCount(); i++) {
- var isChecked = false;
- if (index.indexOf(i) >= 0) {
- isChecked = true;
- }
- this.adapter_.setCheckedCheckboxOrRadioAtIndex(i, isChecked);
- this.adapter_.setAttributeForElementIndex(i, constants_1.strings.ARIA_CHECKED, isChecked ? 'true' : 'false');
- }
- this.selectedIndex_ = index;
- };
- MDCListFoundation.prototype.setTabindexAtIndex_ = function (index) {
- if (this.focusedItemIndex_ === constants_1.numbers.UNSET_INDEX && index !== 0) {
- // If no 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');
- }
- 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.setTabindexToFirstSelectedItem_ = function () {
- var targetIndex = 0;
- if (this.isSelectableList_()) {
- if (typeof this.selectedIndex_ === 'number' && this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
- targetIndex = this.selectedIndex_;
- } else if (isNumberArray(this.selectedIndex_) && this.selectedIndex_.length > 0) {
- targetIndex = this.selectedIndex_.reduce(function (currentIndex, minIndex) {
- return Math.min(currentIndex, minIndex);
- });
- }
- }
- this.setTabindexAtIndex_(targetIndex);
- };
- MDCListFoundation.prototype.isIndexValid_ = function (index) {
- var _this = this;
- if (index instanceof Array) {
- if (!this.isCheckboxList_) {
- 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_) {
- throw new Error('MDCListFoundation: Expected array of index for checkbox based list but got number: ' + index);
- }
- return this.isIndexInRange_(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 checkbox / radio based on toggleCheckbox value.
- * User interaction should not toggle list item(s) when disabled.
- */
- MDCListFoundation.prototype.setSelectedIndexOnAction_ = function (index, toggleCheckbox) {
- if (toggleCheckbox === void 0) {
- toggleCheckbox = true;
- }
- if (this.adapter_.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS)) {
- return;
- }
- if (this.isCheckboxList_) {
- this.toggleCheckboxAtIndex_(index, toggleCheckbox);
- } else {
- this.setSelectedIndex(index);
- }
- };
- MDCListFoundation.prototype.toggleCheckboxAtIndex_ = function (index, toggleCheckbox) {
- var isChecked = this.adapter_.isCheckboxCheckedAtIndex(index);
- if (toggleCheckbox) {
- isChecked = !isChecked;
- this.adapter_.setCheckedCheckboxOrRadioAtIndex(index, isChecked);
- }
- this.adapter_.setAttributeForElementIndex(index, constants_1.strings.ARIA_CHECKED, isChecked ? '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 (isChecked) {
- selectedIndexes.push(index);
- } else {
- selectedIndexes = selectedIndexes.filter(function (i) {
- return i !== index;
- });
- }
- this.selectedIndex_ = selectedIndexes;
- };
- 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/index.ts":
- /*!************************************!*\
- !*** ./packages/mdc-list/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-list/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-list/foundation.ts"));
- /***/ }),
- /***/ "./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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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");
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-menu-surface/util.ts"));
- 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 (evt) {
- return _this.foundation_.handleKeydown(evt);
- };
- this.handleBodyClick_ = function (evt) {
- return _this.foundation_.handleBodyClick(evt);
- };
- this.registerBodyClickListener_ = function () {
- return document.body.addEventListener('click', _this.handleBodyClick_);
- };
- this.deregisterBodyClickListener_ = function () {
- return document.body.removeEventListener('click', _this.handleBodyClick_);
- };
- 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: true,
- configurable: true
- });
- /** Sets the foundation to use page offsets for an 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) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- hasAnchor: function hasAnchor() {
- return !!_this.anchorElement;
- },
- notifyClose: function notifyClose() {
- return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {});
- },
- notifyOpen: function notifyOpen() {
- return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENED_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.getTransformPropertyName(window) + "-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;
- },
- getWindowDimensions: function getWindowDimensions() {
- 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) {
- _this.root_.style.left = 'left' in position ? position.left + "px" : '';
- _this.root_.style.right = 'right' in position ? position.right + "px" : '';
- _this.root_.style.top = 'top' in position ? position.top + "px" : '';
- _this.root_.style.bottom = 'bottom' in position ? position.bottom + "px" : '';
- },
- setMaxHeight: function setMaxHeight(height) {
- _this.root_.style.maxHeight = height;
- }
- };
- // 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 });
- 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',
- OPEN: 'mdc-menu-surface--open',
- ROOT: 'mdc-menu-surface'
- };
- exports.cssClasses = cssClasses;
- // tslint:disable:object-literal-sort-keys
- var strings = {
- CLOSED_EVENT: 'MDCMenuSurface:closed',
- OPENED_EVENT: 'MDCMenuSurface:opened',
- 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. */
- 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
- };
- 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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 m = typeof Symbol === "function" && o[Symbol.iterator],
- i = 0;
- if (m) return m.call(o);
- return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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");
- var MDCMenuSurfaceFoundation = /** @class */function (_super) {
- __extends(MDCMenuSurfaceFoundation, _super);
- function MDCMenuSurfaceFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCMenuSurfaceFoundation.defaultAdapter, adapter)) || this;
- _this.isOpen_ = false;
- _this.isQuickOpen_ = false;
- _this.isHoistedElement_ = false;
- _this.isFixedPosition_ = false;
- _this.openAnimationEndTimerId_ = 0;
- _this.closeAnimationEndTimerId_ = 0;
- _this.animationRequestId_ = 0;
- _this.anchorCorner_ = 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: true,
- configurable: true
- });
- Object.defineProperty(MDCMenuSurfaceFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", {
- get: function get() {
- return constants_1.Corner;
- },
- enumerable: true,
- 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;
- },
- getWindowDimensions: function getWindowDimensions() {
- 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;
- },
- notifyOpen: function notifyOpen() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- 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.isOpen_ = true;
- }
- };
- MDCMenuSurfaceFoundation.prototype.destroy = function () {
- clearTimeout(this.openAnimationEndTimerId_);
- clearTimeout(this.closeAnimationEndTimerId_);
- // Cancel any currently running animations.
- cancelAnimationFrame(this.animationRequestId_);
- };
- /**
- * @param corner Default anchor corner alignment of top-left menu surface corner.
- */
- MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) {
- this.anchorCorner_ = corner;
- };
- /**
- * @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;
- };
- /** 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;
- };
- MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) {
- this.isQuickOpen_ = quickOpen;
- };
- MDCMenuSurfaceFoundation.prototype.isOpen = function () {
- return this.isOpen_;
- };
- /**
- * Open the menu surface.
- */
- MDCMenuSurfaceFoundation.prototype.open = function () {
- var _this = this;
- this.adapter_.saveFocus();
- if (!this.isQuickOpen_) {
- this.adapter_.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
- }
- this.animationRequestId_ = requestAnimationFrame(function () {
- _this.adapter_.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
- _this.dimensions_ = _this.adapter_.getInnerDimensions();
- _this.autoPosition_();
- if (_this.isQuickOpen_) {
- _this.adapter_.notifyOpen();
- } else {
- _this.openAnimationEndTimerId_ = setTimeout(function () {
- _this.openAnimationEndTimerId_ = 0;
- _this.adapter_.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
- _this.adapter_.notifyOpen();
- }, constants_1.numbers.TRANSITION_OPEN_DURATION);
- }
- });
- this.isOpen_ = true;
- };
- /**
- * Closes the menu surface.
- */
- MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) {
- var _this = this;
- if (skipRestoreFocus === void 0) {
- skipRestoreFocus = false;
- }
- if (!this.isQuickOpen_) {
- this.adapter_.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
- }
- requestAnimationFrame(function () {
- _this.adapter_.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
- if (_this.isQuickOpen_) {
- _this.adapter_.notifyClose();
- } else {
- _this.closeAnimationEndTimerId_ = setTimeout(function () {
- _this.closeAnimationEndTimerId_ = 0;
- _this.adapter_.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
- _this.adapter_.notifyClose();
- }, constants_1.numbers.TRANSITION_CLOSE_DURATION);
- }
- });
- this.isOpen_ = 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();
- }
- };
- 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' : '');
- };
- /**
- * @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_.getWindowDimensions();
- 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.
- */
- MDCMenuSurfaceFoundation.prototype.getOriginCorner_ = function () {
- // Defaults: open from the top left.
- var corner = constants_1.Corner.TOP_LEFT;
- var _a = this.measurements_,
- viewportDistance = _a.viewportDistance,
- anchorSize = _a.anchorSize,
- surfaceSize = _a.surfaceSize;
- var isBottomAligned = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.BOTTOM);
- var availableTop = isBottomAligned ? viewportDistance.top + anchorSize.height + this.anchorMargin_.bottom : viewportDistance.top + this.anchorMargin_.top;
- var availableBottom = isBottomAligned ? viewportDistance.bottom - this.anchorMargin_.bottom : viewportDistance.bottom + anchorSize.height - this.anchorMargin_.top;
- var topOverflow = surfaceSize.height - availableTop;
- var bottomOverflow = surfaceSize.height - availableBottom;
- if (bottomOverflow > 0 && topOverflow < bottomOverflow) {
- 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 avoidHorizontalOverlap = this.hasBit_(this.anchorCorner_, constants_1.CornerBit.RIGHT);
- var isAlignedRight = avoidHorizontalOverlap && !isRtl || !avoidHorizontalOverlap && isFlipRtl && isRtl;
- var availableLeft = isAlignedRight ? viewportDistance.left + anchorSize.width + this.anchorMargin_.right : viewportDistance.left + this.anchorMargin_.left;
- var availableRight = isAlignedRight ? viewportDistance.right - this.anchorMargin_.right : viewportDistance.right + anchorSize.width - this.anchorMargin_.left;
- var leftOverflow = surfaceSize.width - availableLeft;
- var rightOverflow = surfaceSize.width - availableRight;
- if (leftOverflow < 0 && isAlignedRight && isRtl || avoidHorizontalOverlap && !isAlignedRight && leftOverflow < 0 || rightOverflow > 0 && leftOverflow < rightOverflow) {
- 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) {
- 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;
- 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;
- // 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 isRootFocused = this.adapter_.isFocused();
- var childHasFocus = document.activeElement && this.adapter_.isElementInContainer(document.activeElement);
- if (isRootFocused || childHasFocus) {
- this.adapter_.restoreFocus();
- }
- };
- 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
- };
- /**
- * 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-surface/index.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-menu-surface/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-menu-surface/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-menu-surface/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-menu-surface/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-menu-surface/util.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-menu-surface/util.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 });
- var cachedCssTransformPropertyName_;
- /**
- * Returns the name of the correct transform property to use on the current browser.
- */
- function getTransformPropertyName(globalObj, forceRefresh) {
- if (forceRefresh === void 0) {
- forceRefresh = false;
- }
- if (cachedCssTransformPropertyName_ === undefined || forceRefresh) {
- var el = globalObj.document.createElement('div');
- cachedCssTransformPropertyName_ = 'transform' in el.style ? 'transform' : 'webkitTransform';
- }
- return cachedCssTransformPropertyName_;
- }
- exports.getTransformPropertyName = getTransformPropertyName;
- /***/ }),
- /***/ "./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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- 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 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_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
- var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts");
- 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_1.strings.LIST_SELECTOR);
- if (list) {
- this.list_ = this.listFactory_(list);
- this.list_.wrapFocus = true;
- } else {
- this.list_ = null;
- }
- this.handleKeydown_ = function (evt) {
- return _this.foundation_.handleKeydown(evt);
- };
- this.handleItemAction_ = function (evt) {
- return _this.foundation_.handleItemAction(_this.items[evt.detail.index]);
- };
- this.handleMenuSurfaceOpened_ = function () {
- return _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: true,
- 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: true,
- configurable: true
- });
- 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: true,
- configurable: true
- });
- Object.defineProperty(MDCMenu.prototype, "quickOpen", {
- set: function set(quickOpen) {
- this.menuSurface_.quickOpen = quickOpen;
- },
- enumerable: true,
- 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;
- }
- };
- 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;
- list[index].setAttribute(attr, value);
- },
- removeAttributeFromElementAtIndex: function removeAttributeFromElementAtIndex(index, attr) {
- var list = _this.items;
- list[index].removeAttribute(attr);
- },
- elementContainsClass: function elementContainsClass(element, className) {
- return element.classList.contains(className);
- },
- closeSurface: function closeSurface(skipRestoreFocus) {
- return _this.menuSurface_.close(skipRestoreFocus);
- },
- getElementIndex: function getElementIndex(element) {
- return _this.items.indexOf(element);
- },
- notifySelected: function notifySelected(evtData) {
- return _this.emit(constants_1.strings.SELECTED_EVENT, {
- index: evtData.index,
- item: _this.items[evtData.index]
- });
- },
- getMenuItemCount: function getMenuItemCount() {
- return _this.items.length;
- },
- focusItemAtIndex: function focusItemAtIndex(index) {
- return _this.items[index].focus();
- },
- focusListRoot: function focusListRoot() {
- return _this.root_.querySelector(constants_1.strings.LIST_SELECTOR).focus();
- },
- isSelectableItemAtIndex: function isSelectableItemAtIndex(index) {
- return !!ponyfill_1.closest(_this.items[index], "." + constants_1.cssClasses.MENU_SELECTION_GROUP);
- },
- getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex(index) {
- var selectionGroupEl = ponyfill_1.closest(_this.items[index], "." + constants_1.cssClasses.MENU_SELECTION_GROUP);
- var selectedItemEl = selectionGroupEl.querySelector("." + constants_1.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 });
- 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',
- SELECTED_EVENT: 'MDCMenu:selected'
- };
- 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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- 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 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 MDCMenuFoundation = /** @class */function (_super) {
- __extends(MDCMenuFoundation, _super);
- function MDCMenuFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCMenuFoundation.defaultAdapter, adapter)) || this;
- _this.closeAnimationEndTimerId_ = 0;
- _this.defaultFocusState_ = constants_2.DefaultFocusState.LIST_ROOT;
- return _this;
- }
- Object.defineProperty(MDCMenuFoundation, "cssClasses", {
- get: function get() {
- return constants_2.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCMenuFoundation, "strings", {
- get: function get() {
- return constants_2.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCMenuFoundation, "numbers", {
- get: function get() {
- return constants_2.numbers;
- },
- enumerable: true,
- 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;
- },
- 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: true,
- configurable: true
- });
- MDCMenuFoundation.prototype.destroy = function () {
- if (this.closeAnimationEndTimerId_) {
- clearTimeout(this.closeAnimationEndTimerId_);
- }
- 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 _this = this;
- var index = this.adapter_.getElementIndex(listItem);
- if (index < 0) {
- return;
- }
- this.adapter_.notifySelected({ index: index });
- this.adapter_.closeSurface();
- // Wait for the menu to close before adding/removing classes that affect styles.
- this.closeAnimationEndTimerId_ = setTimeout(function () {
- // Recompute the index in case the menu contents have changed.
- var recomputedIndex = _this.adapter_.getElementIndex(listItem);
- if (_this.adapter_.isSelectableItemAtIndex(recomputedIndex)) {
- _this.setSelectedIndex(recomputedIndex);
- }
- }, foundation_2.MDCMenuSurfaceFoundation.numbers.TRANSITION_CLOSE_DURATION);
- };
- 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;
- };
- /**
- * 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');
- };
- /**
- * 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-menu/index.ts":
- /*!************************************!*\
- !*** ./packages/mdc-menu/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- var constants_1 = __webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts"); // for backward compatibility
- exports.Corner = constants_1.Corner;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-menu/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts"));
- /***/ }),
- /***/ "./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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- 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");
- 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) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- setNotchWidthProperty: function setNotchWidthProperty(width) {
- return _this.notchElement_.style.setProperty('width', width + 'px');
- },
- removeNotchWidthProperty: function removeNotchWidthProperty() {
- return _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 });
- 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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- 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");
- var MDCNotchedOutlineFoundation = /** @class */function (_super) {
- __extends(MDCNotchedOutlineFoundation, _super);
- function MDCNotchedOutlineFoundation(adapter) {
- return _super.call(this, __assign({}, MDCNotchedOutlineFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCNotchedOutlineFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCNotchedOutlineFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCNotchedOutlineFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- 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: true,
- 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-notched-outline/index.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-notched-outline/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-notched-outline/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-notched-outline/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-notched-outline/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-radio/component.ts":
- /*!*****************************************!*\
- !*** ./packages/mdc-radio/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- 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 component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-radio/foundation.ts");
- var MDCRadio = /** @class */function (_super) {
- __extends(MDCRadio, _super);
- function MDCRadio() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.ripple_ = _this.createRipple_();
- return _this;
- }
- MDCRadio.attachTo = function (root) {
- return new MDCRadio(root);
- };
- Object.defineProperty(MDCRadio.prototype, "checked", {
- get: function get() {
- return this.nativeControl_.checked;
- },
- set: function set(checked) {
- this.nativeControl_.checked = checked;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRadio.prototype, "disabled", {
- get: function get() {
- return this.nativeControl_.disabled;
- },
- set: function set(disabled) {
- this.foundation_.setDisabled(disabled);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRadio.prototype, "value", {
- get: function get() {
- return this.nativeControl_.value;
- },
- set: function set(value) {
- this.nativeControl_.value = value;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRadio.prototype, "ripple", {
- get: function get() {
- return this.ripple_;
- },
- enumerable: true,
- configurable: true
- });
- MDCRadio.prototype.destroy = function () {
- this.ripple_.destroy();
- _super.prototype.destroy.call(this);
- };
- MDCRadio.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 = {
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- setNativeControlDisabled: function setNativeControlDisabled(disabled) {
- return _this.nativeControl_.disabled = disabled;
- }
- };
- return new foundation_2.MDCRadioFoundation(adapter);
- };
- MDCRadio.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({}, component_2.MDCRipple.createAdapter(this), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
- }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return _this.nativeControl_.removeEventListener(evtType, handler, events_1.applyPassive());
- },
- // Radio buttons technically go "active" whenever there is *any* keyboard interaction.
- // This is not the UI we desire.
- isSurfaceActive: function isSurfaceActive() {
- return false;
- }, isUnbounded: function isUnbounded() {
- return true;
- } });
- // tslint:enable:object-literal-sort-keys
- return new component_2.MDCRipple(this.root_, new foundation_1.MDCRippleFoundation(adapter));
- };
- Object.defineProperty(MDCRadio.prototype, "nativeControl_", {
- get: function get() {
- var NATIVE_CONTROL_SELECTOR = foundation_2.MDCRadioFoundation.strings.NATIVE_CONTROL_SELECTOR;
- var el = this.root_.querySelector(NATIVE_CONTROL_SELECTOR);
- if (!el) {
- throw new Error("Radio component requires a " + NATIVE_CONTROL_SELECTOR + " element");
- }
- return el;
- },
- enumerable: true,
- configurable: true
- });
- return MDCRadio;
- }(component_1.MDCComponent);
- exports.MDCRadio = MDCRadio;
- /***/ }),
- /***/ "./packages/mdc-radio/constants.ts":
- /*!*****************************************!*\
- !*** ./packages/mdc-radio/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 });
- var strings = {
- NATIVE_CONTROL_SELECTOR: '.mdc-radio__native-control'
- };
- exports.strings = strings;
- var cssClasses = {
- DISABLED: 'mdc-radio--disabled',
- ROOT: 'mdc-radio'
- };
- exports.cssClasses = cssClasses;
- /***/ }),
- /***/ "./packages/mdc-radio/foundation.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-radio/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-radio/constants.ts");
- var MDCRadioFoundation = /** @class */function (_super) {
- __extends(MDCRadioFoundation, _super);
- function MDCRadioFoundation(adapter) {
- return _super.call(this, __assign({}, MDCRadioFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCRadioFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRadioFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRadioFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- setNativeControlDisabled: function setNativeControlDisabled() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCRadioFoundation.prototype.setDisabled = function (disabled) {
- var DISABLED = MDCRadioFoundation.cssClasses.DISABLED;
- this.adapter_.setNativeControlDisabled(disabled);
- if (disabled) {
- this.adapter_.addClass(DISABLED);
- } else {
- this.adapter_.removeClass(DISABLED);
- }
- };
- return MDCRadioFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCRadioFoundation = MDCRadioFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCRadioFoundation;
- /***/ }),
- /***/ "./packages/mdc-radio/index.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-radio/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-radio/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-radio/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-radio/foundation.ts"));
- /***/ }),
- /***/ "./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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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"));
- 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) {
- return 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) {
- return document.documentElement.removeEventListener(evtType, handler, events_1.applyPassive());
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return instance.root_.removeEventListener(evtType, handler, events_1.applyPassive());
- },
- deregisterResizeHandler: function deregisterResizeHandler(handler) {
- return 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) {
- return document.documentElement.addEventListener(evtType, handler, events_1.applyPassive());
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return instance.root_.addEventListener(evtType, handler, events_1.applyPassive());
- },
- registerResizeHandler: function registerResizeHandler(handler) {
- return window.addEventListener('resize', handler);
- },
- removeClass: function removeClass(className) {
- return instance.root_.classList.remove(className);
- },
- updateCssVariable: function updateCssVariable(varName, value) {
- return instance.root_.style.setProperty(varName, value);
- }
- };
- };
- Object.defineProperty(MDCRipple.prototype, "unbounded", {
- get: function get() {
- return Boolean(this.unbounded_);
- },
- set: function set(unbounded) {
- this.unbounded_ = Boolean(unbounded);
- this.setUnbounded_();
- },
- enumerable: true,
- 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.unbounded = '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.unbounded_));
- };
- 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.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,
- FG_DEACTIVATION_MS: 150,
- 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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- 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 = [];
- var MDCRippleFoundation = /** @class */function (_super) {
- __extends(MDCRippleFoundation, _super);
- function MDCRippleFoundation(adapter) {
- var _this = _super.call(this, __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) {
- return _this.activate_(e);
- };
- _this.deactivateHandler_ = function () {
- return _this.deactivate_();
- };
- _this.focusHandler_ = function () {
- return _this.handleFocus();
- };
- _this.blurHandler_ = function () {
- return _this.handleBlur();
- };
- _this.resizeHandler_ = function () {
- return _this.layout();
- };
- return _this;
- }
- Object.defineProperty(MDCRippleFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- 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: true,
- 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.activate_(evt);
- };
- MDCRippleFoundation.prototype.deactivate = function () {
- this.deactivate_();
- };
- 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 () {
- return _this.adapter_.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
- });
- };
- MDCRippleFoundation.prototype.handleBlur = function () {
- var _this = this;
- requestAnimationFrame(function () {
- return _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 _this = this;
- if (supportsPressRipple) {
- ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter_.registerInteractionHandler(evtType, _this.activateHandler_);
- });
- 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 _this = this;
- if (evt.type === 'keydown') {
- this.adapter_.registerInteractionHandler('keyup', this.deactivateHandler_);
- } else {
- POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter_.registerDocumentInteractionHandler(evtType, _this.deactivateHandler_);
- });
- }
- };
- MDCRippleFoundation.prototype.deregisterRootHandlers_ = function () {
- var _this = this;
- ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter_.deregisterInteractionHandler(evtType, _this.activateHandler_);
- });
- 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 _this = this;
- this.adapter_.deregisterInteractionHandler('keyup', this.deactivateHandler_);
- POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter_.deregisterDocumentInteractionHandler(evtType, _this.deactivateHandler_);
- });
- };
- 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.activate_ = 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 () {
- return _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.deactivate_ = 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 () {
- return _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/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-ripple/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-ripple/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts"));
- /***/ }),
- /***/ "./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 });
- /**
- * 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/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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");
- 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);
- if (!this.selectedText_) {
- throw new Error('MDCSelect: Missing required element: The following selector must be present: ' + ("'" + constants_1.strings.SELECTED_TEXT_SELECTOR + "'"));
- }
- if (this.selectedText_.hasAttribute(constants_1.strings.ARIA_CONTROLS)) {
- var helperTextElement = document.getElementById(this.selectedText_.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.handleChange_ = function () {
- return _this.foundation_.handleChange();
- };
- this.handleFocus_ = function () {
- return _this.foundation_.handleFocus();
- };
- this.handleBlur_ = function () {
- return _this.foundation_.handleBlur();
- };
- this.handleClick_ = function (evt) {
- _this.selectedText_.focus();
- _this.foundation_.handleClick(_this.getNormalizedXCoordinate_(evt));
- };
- this.handleKeydown_ = function (evt) {
- return _this.foundation_.handleKeydown(evt);
- };
- this.handleMenuItemAction_ = function (evt) {
- return _this.foundation_.handleMenuItemAction(evt.detail.index);
- };
- this.handleMenuOpened_ = function () {
- return _this.foundation_.handleMenuOpened();
- };
- this.handleMenuClosed_ = function () {
- return _this.foundation_.handleMenuClosed();
- };
- this.selectedText_.addEventListener('focus', this.handleFocus_);
- this.selectedText_.addEventListener('blur', this.handleBlur_);
- this.selectedText_.addEventListener('click', this.handleClick_);
- this.selectedText_.addEventListener('keydown', this.handleKeydown_);
- this.menu_.listen(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed_);
- this.menu_.listen(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened_);
- this.menu_.listen(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction_);
- this.foundation_.init();
- // Sets disabled state in foundation
- this.disabled = this.root_.classList.contains(constants_1.cssClasses.DISABLED);
- };
- MDCSelect.prototype.destroy = function () {
- this.selectedText_.removeEventListener('change', this.handleChange_);
- this.selectedText_.removeEventListener('focus', this.handleFocus_);
- this.selectedText_.removeEventListener('blur', this.handleBlur_);
- this.selectedText_.removeEventListener('keydown', this.handleKeydown_);
- this.selectedText_.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: true,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "selectedIndex", {
- get: function get() {
- return this.foundation_.getSelectedIndex();
- },
- set: function set(selectedIndex) {
- this.foundation_.setSelectedIndex(selectedIndex, /** closeMenu */true);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "disabled", {
- get: function get() {
- return this.foundation_.getDisabled();
- },
- set: function set(disabled) {
- this.foundation_.setDisabled(disabled);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "leadingIconAriaLabel", {
- set: function set(label) {
- this.foundation_.setLeadingIconAriaLabel(label);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "leadingIconContent", {
- /**
- * Sets the text content of the leading icon.
- */
- set: function set(content) {
- this.foundation_.setLeadingIconContent(content);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "helperTextContent", {
- /**
- * Sets the text content of the helper text.
- */
- set: function set(content) {
- this.foundation_.setHelperTextContent(content);
- },
- enumerable: true,
- 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: true,
- 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: true,
- configurable: true
- });
- /**
- * Recomputes the outline SVG path for the outline element.
- */
- MDCSelect.prototype.layout = function () {
- this.foundation_.layout();
- };
- 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({}, 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_);
- };
- 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({}, component_6.MDCRipple.createAdapter({ root_: this.selectAnchor_ }), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return _this.selectedText_.addEventListener(evtType, handler);
- }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return _this.selectedText_.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 {
- getSelectedMenuItem: function getSelectedMenuItem() {
- return _this.menuElement_.querySelector(constants_1.strings.SELECTED_ITEM_SELECTOR);
- },
- getMenuItemAttr: function getMenuItemAttr(menuItem, attr) {
- return menuItem.getAttribute(attr);
- },
- setSelectedText: function setSelectedText(text) {
- return _this.selectedText_.textContent = text;
- },
- isSelectedTextFocused: function isSelectedTextFocused() {
- return document.activeElement === _this.selectedText_;
- },
- getSelectedTextAttr: function getSelectedTextAttr(attr) {
- return _this.selectedText_.getAttribute(attr);
- },
- setSelectedTextAttr: function setSelectedTextAttr(attr, value) {
- return _this.selectedText_.setAttribute(attr, value);
- },
- openMenu: function openMenu() {
- return _this.menu_.open = true;
- },
- closeMenu: function closeMenu() {
- return _this.menu_.open = false;
- },
- getAnchorElement: function getAnchorElement() {
- return _this.root_.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
- },
- setMenuAnchorElement: function setMenuAnchorElement(anchorEl) {
- return _this.menu_.setAnchorElement(anchorEl);
- },
- setMenuAnchorCorner: function setMenuAnchorCorner(anchorCorner) {
- return _this.menu_.setAnchorCorner(anchorCorner);
- },
- setMenuWrapFocus: function setMenuWrapFocus(wrapFocus) {
- return _this.menu_.wrapFocus = wrapFocus;
- },
- setAttributeAtIndex: function setAttributeAtIndex(index, attributeName, attributeValue) {
- return _this.menu_.items[index].setAttribute(attributeName, attributeValue);
- },
- removeAttributeAtIndex: function removeAttributeAtIndex(index, attributeName) {
- return _this.menu_.items[index].removeAttribute(attributeName);
- },
- focusMenuItemAtIndex: function focusMenuItemAtIndex(index) {
- return _this.menu_.items[index].focus();
- },
- getMenuItemCount: function getMenuItemCount() {
- return _this.menu_.items.length;
- },
- getMenuItemValues: function getMenuItemValues() {
- return _this.menu_.items.map(function (el) {
- return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
- });
- },
- getMenuItemTextAtIndex: function getMenuItemTextAtIndex(index) {
- return _this.menu_.items[index].textContent;
- },
- addClassAtIndex: function addClassAtIndex(index, className) {
- return _this.menu_.items[index].classList.add(className);
- },
- removeClassAtIndex: function removeClassAtIndex(index, className) {
- return _this.menu_.items[index].classList.remove(className);
- }
- };
- // 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) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- setRippleCenter: function setRippleCenter(normalizedX) {
- return _this.lineRipple_ && _this.lineRipple_.setRippleCenter(normalizedX);
- },
- activateBottomLine: function activateBottomLine() {
- return _this.lineRipple_ && _this.lineRipple_.activate();
- },
- deactivateBottomLine: function deactivateBottomLine() {
- return _this.lineRipple_ && _this.lineRipple_.deactivate();
- },
- notifyChange: function notifyChange(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) {
- return _this.outline_ && _this.outline_.notch(labelWidth);
- },
- closeOutline: function closeOutline() {
- return _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) {
- return _this.label_ && _this.label_.float(shouldFloat);
- },
- getLabelWidth: function getLabelWidth() {
- return _this.label_ ? _this.label_.getWidth() : 0;
- }
- };
- // 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_.foundation : undefined,
- leadingIcon: this.leadingIcon_ ? this.leadingIcon_.foundation : 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 });
- var cssClasses = {
- ACTIVATED: 'mdc-select--activated',
- DISABLED: 'mdc-select--disabled',
- FOCUSED: 'mdc-select--focused',
- INVALID: 'mdc-select--invalid',
- OUTLINED: 'mdc-select--outlined',
- REQUIRED: 'mdc-select--required',
- ROOT: 'mdc-select',
- SELECTED_ITEM_CLASS: 'mdc-list-item--selected',
- WITH_LEADING_ICON: 'mdc-select--with-leading-icon'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ARIA_CONTROLS: 'aria-controls',
- ARIA_SELECTED_ATTR: 'aria-selected',
- CHANGE_EVENT: 'MDCSelect:change',
- 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_ITEM_SELECTOR: "." + cssClasses.SELECTED_ITEM_CLASS,
- 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
- };
- 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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.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");
- 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 _this = _super.call(this, __assign({}, MDCSelectFoundation.defaultAdapter, adapter)) || this;
- // Index of the currently selected menu item.
- _this.selectedIndex_ = constants_2.numbers.UNSET_INDEX;
- // 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;
- _this.leadingIcon_ = foundationMap.leadingIcon;
- _this.helperText_ = foundationMap.helperText;
- _this.menuItemValues_ = _this.adapter_.getMenuItemValues();
- return _this;
- }
- Object.defineProperty(MDCSelectFoundation, "cssClasses", {
- get: function get() {
- return constants_2.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelectFoundation, "numbers", {
- get: function get() {
- return constants_2.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelectFoundation, "strings", {
- get: function get() {
- return constants_2.strings;
- },
- enumerable: true,
- 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;
- },
- getSelectedMenuItem: function getSelectedMenuItem() {
- return null;
- },
- hasLabel: function hasLabel() {
- return false;
- },
- floatLabel: function floatLabel() {
- return undefined;
- },
- getLabelWidth: function getLabelWidth() {
- return 0;
- },
- 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;
- },
- isSelectedTextFocused: function isSelectedTextFocused() {
- return false;
- },
- getSelectedTextAttr: function getSelectedTextAttr() {
- return '';
- },
- setSelectedTextAttr: function setSelectedTextAttr() {
- 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;
- },
- setAttributeAtIndex: function setAttributeAtIndex() {
- return undefined;
- },
- removeAttributeAtIndex: function removeAttributeAtIndex() {
- return undefined;
- },
- focusMenuItemAtIndex: function focusMenuItemAtIndex() {
- return undefined;
- },
- getMenuItemCount: function getMenuItemCount() {
- return 0;
- },
- getMenuItemValues: function getMenuItemValues() {
- return [];
- },
- getMenuItemTextAtIndex: function getMenuItemTextAtIndex() {
- return '';
- },
- getMenuItemAttr: function getMenuItemAttr() {
- return '';
- },
- addClassAtIndex: function addClassAtIndex() {
- return undefined;
- },
- removeClassAtIndex: function removeClassAtIndex() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- /** Returns the index of the currently selected menu item, or -1 if none. */
- MDCSelectFoundation.prototype.getSelectedIndex = function () {
- return this.selectedIndex_;
- };
- MDCSelectFoundation.prototype.setSelectedIndex = function (index, closeMenu) {
- if (closeMenu === void 0) {
- closeMenu = false;
- }
- if (index >= this.adapter_.getMenuItemCount()) {
- return;
- }
- var previouslySelectedIndex = this.selectedIndex_;
- this.selectedIndex_ = index;
- if (this.selectedIndex_ === constants_2.numbers.UNSET_INDEX) {
- this.adapter_.setSelectedText('');
- } else {
- this.adapter_.setSelectedText(this.adapter_.getMenuItemTextAtIndex(this.selectedIndex_).trim());
- }
- if (previouslySelectedIndex !== constants_2.numbers.UNSET_INDEX) {
- this.adapter_.removeClassAtIndex(previouslySelectedIndex, constants_2.cssClasses.SELECTED_ITEM_CLASS);
- this.adapter_.removeAttributeAtIndex(previouslySelectedIndex, constants_2.strings.ARIA_SELECTED_ATTR);
- }
- if (this.selectedIndex_ !== constants_2.numbers.UNSET_INDEX) {
- this.adapter_.addClassAtIndex(this.selectedIndex_, constants_2.cssClasses.SELECTED_ITEM_CLASS);
- this.adapter_.setAttributeAtIndex(this.selectedIndex_, constants_2.strings.ARIA_SELECTED_ATTR, 'true');
- }
- this.layout();
- if (closeMenu) {
- this.adapter_.closeMenu();
- }
- this.handleChange();
- };
- MDCSelectFoundation.prototype.setValue = function (value) {
- var index = this.menuItemValues_.indexOf(value);
- this.setSelectedIndex(index);
- this.handleChange();
- };
- MDCSelectFoundation.prototype.getValue = function () {
- var listItem = this.adapter_.getSelectedMenuItem();
- if (listItem) {
- return this.adapter_.getMenuItemAttr(listItem, constants_2.strings.VALUE_ATTR) || '';
- }
- return '';
- };
- 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_);
- }
- this.adapter_.setSelectedTextAttr('tabindex', this.disabled_ ? '-1' : '0');
- this.adapter_.setSelectedTextAttr('aria-disabled', this.disabled_.toString());
- };
- /**
- * @param content Sets the content of the helper text.
- */
- MDCSelectFoundation.prototype.setHelperTextContent = function (content) {
- if (this.helperText_) {
- this.helperText_.setContent(content);
- }
- };
- MDCSelectFoundation.prototype.layout = function () {
- if (this.adapter_.hasLabel()) {
- var openNotch = this.getValue().length > 0;
- this.notchOutline(openNotch);
- }
- };
- MDCSelectFoundation.prototype.handleMenuOpened = function () {
- if (this.adapter_.getMenuItemValues().length === 0) {
- return;
- }
- this.adapter_.addClass(constants_2.cssClasses.ACTIVATED);
- // Menu should open to the last selected element, should open to first menu item otherwise.
- var focusItemIndex = this.selectedIndex_ >= 0 ? this.selectedIndex_ : 0;
- this.adapter_.focusMenuItemAtIndex(focusItemIndex);
- };
- MDCSelectFoundation.prototype.handleMenuClosed = function () {
- this.adapter_.removeClass(constants_2.cssClasses.ACTIVATED);
- this.isMenuOpen_ = false;
- this.adapter_.setSelectedTextAttr('aria-expanded', 'false');
- // Unfocus the select if menu is closed without a selection
- if (!this.adapter_.isSelectedTextFocused()) {
- this.blur_();
- }
- };
- /**
- * Handles value changes, via change event or programmatic updates.
- */
- MDCSelectFoundation.prototype.handleChange = function () {
- this.updateLabel_();
- this.adapter_.notifyChange(this.getValue());
- var isRequired = this.adapter_.hasClass(constants_2.cssClasses.REQUIRED);
- if (isRequired) {
- this.setValid(this.isValid());
- if (this.helperText_) {
- this.helperText_.setValidity(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);
- if (this.adapter_.hasLabel()) {
- this.notchOutline(true);
- this.adapter_.floatLabel(true);
- }
- this.adapter_.activateBottomLine();
- if (this.helperText_) {
- this.helperText_.showToScreenReader();
- }
- };
- /**
- * Handles blur events from select element.
- */
- MDCSelectFoundation.prototype.handleBlur = function () {
- if (this.isMenuOpen_) {
- return;
- }
- this.blur_();
- };
- MDCSelectFoundation.prototype.handleClick = function (normalizedX) {
- if (this.isMenuOpen_) {
- return;
- }
- this.adapter_.setRippleCenter(normalizedX);
- this.adapter_.openMenu();
- this.isMenuOpen_ = true;
- this.adapter_.setSelectedTextAttr('aria-expanded', 'true');
- };
- MDCSelectFoundation.prototype.handleKeydown = function (event) {
- if (this.isMenuOpen_) {
- return;
- }
- var isEnter = event.key === 'Enter' || event.keyCode === 13;
- var isSpace = event.key === 'Space' || event.keyCode === 32;
- var arrowUp = event.key === 'ArrowUp' || event.keyCode === 38;
- var arrowDown = event.key === 'ArrowDown' || event.keyCode === 40;
- if (this.adapter_.hasClass(constants_2.cssClasses.FOCUSED) && (isEnter || isSpace || arrowUp || arrowDown)) {
- this.adapter_.openMenu();
- this.isMenuOpen_ = true;
- this.adapter_.setSelectedTextAttr('aria-expanded', 'true');
- 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.setValid = function (isValid) {
- this.adapter_.setSelectedTextAttr('aria-invalid', (!isValid).toString());
- if (isValid) {
- this.adapter_.removeClass(constants_2.cssClasses.INVALID);
- } else {
- this.adapter_.addClass(constants_2.cssClasses.INVALID);
- }
- };
- MDCSelectFoundation.prototype.isValid = function () {
- if (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.selectedIndex_ !== constants_2.numbers.UNSET_INDEX && (this.selectedIndex_ !== 0 || Boolean(this.getValue()));
- }
- return true;
- };
- MDCSelectFoundation.prototype.setRequired = function (isRequired) {
- if (isRequired) {
- this.adapter_.addClass(constants_2.cssClasses.REQUIRED);
- } else {
- this.adapter_.removeClass(constants_2.cssClasses.REQUIRED);
- }
- this.adapter_.setSelectedTextAttr('aria-required', isRequired.toString());
- };
- MDCSelectFoundation.prototype.getRequired = function () {
- return this.adapter_.getSelectedTextAttr('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);
- var value = this.getValue();
- if (value) {
- this.setValue(value);
- }
- // Initially sync floating label
- this.updateLabel_();
- };
- /**
- * Notches the outline and floats the label when appropriate.
- */
- MDCSelectFoundation.prototype.updateLabel_ = function () {
- var value = this.getValue();
- var optionHasValue = value.length > 0;
- if (this.adapter_.hasLabel()) {
- this.notchOutline(optionHasValue);
- if (!this.adapter_.hasClass(constants_2.cssClasses.FOCUSED)) {
- this.adapter_.floatLabel(optionHasValue);
- }
- }
- };
- /**
- * Unfocuses the select component.
- */
- MDCSelectFoundation.prototype.blur_ = function () {
- this.adapter_.removeClass(constants_2.cssClasses.FOCUSED);
- this.updateLabel_();
- this.adapter_.deactivateBottomLine();
- var isRequired = this.adapter_.hasClass(constants_2.cssClasses.REQUIRED);
- if (isRequired) {
- this.setValid(this.isValid());
- if (this.helperText_) {
- this.helperText_.setValidity(this.isValid());
- }
- }
- };
- 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/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- 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");
- 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, "foundation", {
- get: function get() {
- return this.foundation_;
- },
- enumerable: true,
- 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) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- setAttr: function setAttr(attr, value) {
- return _this.root_.setAttribute(attr, value);
- },
- removeAttr: function removeAttr(attr) {
- return _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 });
- var strings = {
- ARIA_HIDDEN: 'aria-hidden',
- ROLE: 'role'
- };
- exports.strings = strings;
- var cssClasses = {
- HELPER_TEXT_PERSISTENT: 'mdc-select-helper-text--persistent',
- HELPER_TEXT_VALIDATION_MSG: 'mdc-select-helper-text--validation-msg'
- };
- 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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- 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");
- var MDCSelectHelperTextFoundation = /** @class */function (_super) {
- __extends(MDCSelectHelperTextFoundation, _super);
- function MDCSelectHelperTextFoundation(adapter) {
- return _super.call(this, __assign({}, MDCSelectHelperTextFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCSelectHelperTextFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelectHelperTextFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- 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;
- },
- removeAttr: function removeAttr() {
- return undefined;
- },
- setContent: function setContent() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Sets the content of the helper text field.
- */
- MDCSelectHelperTextFoundation.prototype.setContent = function (content) {
- this.adapter_.setContent(content);
- };
- /**
- * Sets the persistency of the helper text.
- */
- MDCSelectHelperTextFoundation.prototype.setPersistent = function (isPersistent) {
- if (isPersistent) {
- this.adapter_.addClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
- } else {
- this.adapter_.removeClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
- }
- };
- /**
- * @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);
- }
- };
- /**
- * Makes the helper text visible to screen readers.
- */
- MDCSelectHelperTextFoundation.prototype.showToScreenReader = function () {
- this.adapter_.removeAttr(constants_1.strings.ARIA_HIDDEN);
- };
- /**
- * Sets the validity of the helper text based on the select validity.
- */
- MDCSelectHelperTextFoundation.prototype.setValidity = function (selectIsValid) {
- var helperTextIsPersistent = this.adapter_.hasClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
- var helperTextIsValidationMsg = this.adapter_.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
- var validationMsgNeedsDisplay = helperTextIsValidationMsg && !selectIsValid;
- if (validationMsgNeedsDisplay) {
- this.adapter_.setAttr(constants_1.strings.ROLE, 'alert');
- } else {
- this.adapter_.removeAttr(constants_1.strings.ROLE);
- }
- if (!helperTextIsPersistent && !validationMsgNeedsDisplay) {
- this.hide_();
- }
- };
- /**
- * 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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-select/helper-text/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/helper-text/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/helper-text/constants.ts");
- exports.helperTextCssClasses = constants_1.cssClasses;
- exports.helperTextStrings = constants_1.strings;
- /***/ }),
- /***/ "./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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- 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");
- 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, "foundation", {
- get: function get() {
- return this.foundation_;
- },
- enumerable: true,
- 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) {
- return _this.root_.setAttribute(attr, value);
- },
- removeAttr: function removeAttr(attr) {
- return _this.root_.removeAttribute(attr);
- },
- setContent: function setContent(content) {
- _this.root_.textContent = content;
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return _this.listen(evtType, handler);
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return _this.unlisten(evtType, handler);
- },
- notifyIconAction: function notifyIconAction() {
- return _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 });
- 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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- 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'];
- var MDCSelectIconFoundation = /** @class */function (_super) {
- __extends(MDCSelectIconFoundation, _super);
- function MDCSelectIconFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCSelectIconFoundation.defaultAdapter, adapter)) || this;
- _this.savedTabIndex_ = null;
- _this.interactionHandler_ = function (evt) {
- return _this.handleInteraction(evt);
- };
- return _this;
- }
- Object.defineProperty(MDCSelectIconFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- 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: true,
- configurable: true
- });
- MDCSelectIconFoundation.prototype.init = function () {
- var _this = this;
- this.savedTabIndex_ = this.adapter_.getAttr('tabindex');
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.adapter_.registerInteractionHandler(evtType, _this.interactionHandler_);
- });
- };
- MDCSelectIconFoundation.prototype.destroy = function () {
- var _this = this;
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.adapter_.deregisterInteractionHandler(evtType, _this.interactionHandler_);
- });
- };
- 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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-select/icon/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/icon/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/icon/constants.ts");
- exports.iconStrings = 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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-select/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts"));
- __export(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-select/helper-text/index.ts"));
- __export(__webpack_require__(/*! ./icon/index */ "./packages/mdc-select/icon/index.ts"));
- /***/ }),
- /***/ "./packages/mdc-slider/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-slider/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- 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 constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts");
- var MDCSlider = /** @class */function (_super) {
- __extends(MDCSlider, _super);
- function MDCSlider() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCSlider.attachTo = function (root) {
- return new MDCSlider(root);
- };
- Object.defineProperty(MDCSlider.prototype, "value", {
- get: function get() {
- return this.foundation_.getValue();
- },
- set: function set(value) {
- this.foundation_.setValue(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSlider.prototype, "min", {
- get: function get() {
- return this.foundation_.getMin();
- },
- set: function set(min) {
- this.foundation_.setMin(min);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSlider.prototype, "max", {
- get: function get() {
- return this.foundation_.getMax();
- },
- set: function set(max) {
- this.foundation_.setMax(max);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSlider.prototype, "step", {
- get: function get() {
- return this.foundation_.getStep();
- },
- set: function set(step) {
- this.foundation_.setStep(step);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSlider.prototype, "disabled", {
- get: function get() {
- return this.foundation_.isDisabled();
- },
- set: function set(disabled) {
- this.foundation_.setDisabled(disabled);
- },
- enumerable: true,
- configurable: true
- });
- MDCSlider.prototype.initialize = function () {
- this.thumbContainer_ = this.root_.querySelector(constants_1.strings.THUMB_CONTAINER_SELECTOR);
- this.track_ = this.root_.querySelector(constants_1.strings.TRACK_SELECTOR);
- this.pinValueMarker_ = this.root_.querySelector(constants_1.strings.PIN_VALUE_MARKER_SELECTOR);
- this.trackMarkerContainer_ = this.root_.querySelector(constants_1.strings.TRACK_MARKER_CONTAINER_SELECTOR);
- };
- MDCSlider.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 = {
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- getAttribute: function getAttribute(name) {
- return _this.root_.getAttribute(name);
- },
- setAttribute: function setAttribute(name, value) {
- return _this.root_.setAttribute(name, value);
- },
- removeAttribute: function removeAttribute(name) {
- return _this.root_.removeAttribute(name);
- },
- computeBoundingRect: function computeBoundingRect() {
- return _this.root_.getBoundingClientRect();
- },
- getTabIndex: function getTabIndex() {
- return _this.root_.tabIndex;
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return _this.listen(evtType, handler, events_1.applyPassive());
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return _this.unlisten(evtType, handler, events_1.applyPassive());
- },
- registerThumbContainerInteractionHandler: function registerThumbContainerInteractionHandler(evtType, handler) {
- _this.thumbContainer_.addEventListener(evtType, handler, events_1.applyPassive());
- },
- deregisterThumbContainerInteractionHandler: function deregisterThumbContainerInteractionHandler(evtType, handler) {
- _this.thumbContainer_.removeEventListener(evtType, handler, events_1.applyPassive());
- },
- registerBodyInteractionHandler: function registerBodyInteractionHandler(evtType, handler) {
- return document.body.addEventListener(evtType, handler);
- },
- deregisterBodyInteractionHandler: function deregisterBodyInteractionHandler(evtType, handler) {
- return document.body.removeEventListener(evtType, handler);
- },
- registerResizeHandler: function registerResizeHandler(handler) {
- return window.addEventListener('resize', handler);
- },
- deregisterResizeHandler: function deregisterResizeHandler(handler) {
- return window.removeEventListener('resize', handler);
- },
- notifyInput: function notifyInput() {
- return _this.emit(constants_1.strings.INPUT_EVENT, _this);
- },
- notifyChange: function notifyChange() {
- return _this.emit(constants_1.strings.CHANGE_EVENT, _this);
- },
- setThumbContainerStyleProperty: function setThumbContainerStyleProperty(propertyName, value) {
- _this.thumbContainer_.style.setProperty(propertyName, value);
- },
- setTrackStyleProperty: function setTrackStyleProperty(propertyName, value) {
- return _this.track_.style.setProperty(propertyName, value);
- },
- setMarkerValue: function setMarkerValue(value) {
- return _this.pinValueMarker_.innerText = value.toLocaleString();
- },
- setTrackMarkers: function setTrackMarkers(step, max, min) {
- var stepStr = step.toLocaleString();
- var maxStr = max.toLocaleString();
- var minStr = min.toLocaleString();
- // keep calculation in css for better rounding/subpixel behavior
- var markerAmount = "((" + maxStr + " - " + minStr + ") / " + stepStr + ")";
- var markerWidth = "2px";
- var markerBkgdImage = "linear-gradient(to right, currentColor " + markerWidth + ", transparent 0)";
- var markerBkgdLayout = "0 center / calc((100% - " + markerWidth + ") / " + markerAmount + ") 100% repeat-x";
- var markerBkgdShorthand = markerBkgdImage + " " + markerBkgdLayout;
- _this.trackMarkerContainer_.style.setProperty('background', markerBkgdShorthand);
- },
- isRTL: function isRTL() {
- return getComputedStyle(_this.root_).direction === 'rtl';
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCSliderFoundation(adapter);
- };
- MDCSlider.prototype.initialSyncWithDOM = function () {
- var origValueNow = this.parseFloat_(this.root_.getAttribute(constants_1.strings.ARIA_VALUENOW), this.value);
- var min = this.parseFloat_(this.root_.getAttribute(constants_1.strings.ARIA_VALUEMIN), this.min);
- var max = this.parseFloat_(this.root_.getAttribute(constants_1.strings.ARIA_VALUEMAX), this.max);
- // min and max need to be set in the right order to avoid throwing an error
- // when the new min is greater than the default max.
- if (min >= this.max) {
- this.max = max;
- this.min = min;
- } else {
- this.min = min;
- this.max = max;
- }
- this.step = this.parseFloat_(this.root_.getAttribute(constants_1.strings.STEP_DATA_ATTR), this.step);
- this.value = origValueNow;
- this.disabled = this.root_.hasAttribute(constants_1.strings.ARIA_DISABLED) && this.root_.getAttribute(constants_1.strings.ARIA_DISABLED) !== 'false';
- this.foundation_.setupTrackMarker();
- };
- MDCSlider.prototype.layout = function () {
- this.foundation_.layout();
- };
- MDCSlider.prototype.stepUp = function (amount) {
- if (amount === void 0) {
- amount = this.step || 1;
- }
- this.value += amount;
- };
- MDCSlider.prototype.stepDown = function (amount) {
- if (amount === void 0) {
- amount = this.step || 1;
- }
- this.value -= amount;
- };
- MDCSlider.prototype.parseFloat_ = function (str, defaultValue) {
- var num = parseFloat(str); // tslint:disable-line:ban
- var isNumeric = typeof num === 'number' && isFinite(num);
- return isNumeric ? num : defaultValue;
- };
- return MDCSlider;
- }(component_1.MDCComponent);
- exports.MDCSlider = MDCSlider;
- /***/ }),
- /***/ "./packages/mdc-slider/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-slider/constants.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.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var cssClasses = {
- ACTIVE: 'mdc-slider--active',
- DISABLED: 'mdc-slider--disabled',
- DISCRETE: 'mdc-slider--discrete',
- FOCUS: 'mdc-slider--focus',
- HAS_TRACK_MARKER: 'mdc-slider--display-markers',
- IN_TRANSIT: 'mdc-slider--in-transit',
- IS_DISCRETE: 'mdc-slider--discrete'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ARIA_DISABLED: 'aria-disabled',
- ARIA_VALUEMAX: 'aria-valuemax',
- ARIA_VALUEMIN: 'aria-valuemin',
- ARIA_VALUENOW: 'aria-valuenow',
- CHANGE_EVENT: 'MDCSlider:change',
- INPUT_EVENT: 'MDCSlider:input',
- PIN_VALUE_MARKER_SELECTOR: '.mdc-slider__pin-value-marker',
- STEP_DATA_ATTR: 'data-step',
- THUMB_CONTAINER_SELECTOR: '.mdc-slider__thumb-container',
- TRACK_MARKER_CONTAINER_SELECTOR: '.mdc-slider__track-marker-container',
- TRACK_SELECTOR: '.mdc-slider__track'
- };
- exports.strings = strings;
- var numbers = {
- PAGE_FACTOR: 4
- };
- exports.numbers = numbers;
- /***/ }),
- /***/ "./packages/mdc-slider/foundation.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-slider/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var util_1 = __webpack_require__(/*! @material/animation/util */ "./packages/mdc-animation/util.ts");
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
- var DOWN_EVENTS = ['mousedown', 'pointerdown', 'touchstart'];
- var UP_EVENTS = ['mouseup', 'pointerup', 'touchend'];
- var MOVE_EVENT_MAP = {
- mousedown: 'mousemove',
- pointerdown: 'pointermove',
- touchstart: 'touchmove'
- };
- var KEY_IDS = {
- ARROW_DOWN: 'ArrowDown',
- ARROW_LEFT: 'ArrowLeft',
- ARROW_RIGHT: 'ArrowRight',
- ARROW_UP: 'ArrowUp',
- END: 'End',
- HOME: 'Home',
- PAGE_DOWN: 'PageDown',
- PAGE_UP: 'PageUp'
- };
- var MDCSliderFoundation = /** @class */function (_super) {
- __extends(MDCSliderFoundation, _super);
- function MDCSliderFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCSliderFoundation.defaultAdapter, adapter)) || this;
- /**
- * We set this to NaN since we want it to be a number, but we can't use '0' or
- * '-1' because those could be valid tabindices set by the client code.
- */
- _this.savedTabIndex_ = NaN;
- _this.active_ = false;
- _this.inTransit_ = false;
- _this.isDiscrete_ = false;
- _this.hasTrackMarker_ = false;
- _this.handlingThumbTargetEvt_ = false;
- _this.min_ = 0;
- _this.max_ = 100;
- _this.step_ = 0;
- _this.value_ = 0;
- _this.disabled_ = false;
- _this.preventFocusState_ = false;
- _this.thumbContainerPointerHandler_ = function () {
- return _this.handlingThumbTargetEvt_ = true;
- };
- _this.interactionStartHandler_ = function (evt) {
- return _this.handleDown_(evt);
- };
- _this.keydownHandler_ = function (evt) {
- return _this.handleKeydown_(evt);
- };
- _this.focusHandler_ = function () {
- return _this.handleFocus_();
- };
- _this.blurHandler_ = function () {
- return _this.handleBlur_();
- };
- _this.resizeHandler_ = function () {
- return _this.layout();
- };
- return _this;
- }
- Object.defineProperty(MDCSliderFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSliderFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSliderFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSliderFoundation, "defaultAdapter", {
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same
- // order as the adapter interface.
- return {
- hasClass: function hasClass() {
- return false;
- },
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- getAttribute: function getAttribute() {
- return null;
- },
- setAttribute: function setAttribute() {
- return undefined;
- },
- removeAttribute: function removeAttribute() {
- return undefined;
- },
- computeBoundingRect: function computeBoundingRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- getTabIndex: function getTabIndex() {
- return 0;
- },
- registerInteractionHandler: function registerInteractionHandler() {
- return undefined;
- },
- deregisterInteractionHandler: function deregisterInteractionHandler() {
- return undefined;
- },
- registerThumbContainerInteractionHandler: function registerThumbContainerInteractionHandler() {
- return undefined;
- },
- deregisterThumbContainerInteractionHandler: function deregisterThumbContainerInteractionHandler() {
- return undefined;
- },
- registerBodyInteractionHandler: function registerBodyInteractionHandler() {
- return undefined;
- },
- deregisterBodyInteractionHandler: function deregisterBodyInteractionHandler() {
- return undefined;
- },
- registerResizeHandler: function registerResizeHandler() {
- return undefined;
- },
- deregisterResizeHandler: function deregisterResizeHandler() {
- return undefined;
- },
- notifyInput: function notifyInput() {
- return undefined;
- },
- notifyChange: function notifyChange() {
- return undefined;
- },
- setThumbContainerStyleProperty: function setThumbContainerStyleProperty() {
- return undefined;
- },
- setTrackStyleProperty: function setTrackStyleProperty() {
- return undefined;
- },
- setMarkerValue: function setMarkerValue() {
- return undefined;
- },
- setTrackMarkers: function setTrackMarkers() {
- return undefined;
- },
- isRTL: function isRTL() {
- return false;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCSliderFoundation.prototype.init = function () {
- var _this = this;
- this.isDiscrete_ = this.adapter_.hasClass(constants_1.cssClasses.IS_DISCRETE);
- this.hasTrackMarker_ = this.adapter_.hasClass(constants_1.cssClasses.HAS_TRACK_MARKER);
- DOWN_EVENTS.forEach(function (evtName) {
- _this.adapter_.registerInteractionHandler(evtName, _this.interactionStartHandler_);
- _this.adapter_.registerThumbContainerInteractionHandler(evtName, _this.thumbContainerPointerHandler_);
- });
- this.adapter_.registerInteractionHandler('keydown', this.keydownHandler_);
- this.adapter_.registerInteractionHandler('focus', this.focusHandler_);
- this.adapter_.registerInteractionHandler('blur', this.blurHandler_);
- this.adapter_.registerResizeHandler(this.resizeHandler_);
- this.layout();
- // At last step, provide a reasonable default value to discrete slider
- if (this.isDiscrete_ && this.getStep() === 0) {
- this.step_ = 1;
- }
- };
- MDCSliderFoundation.prototype.destroy = function () {
- var _this = this;
- DOWN_EVENTS.forEach(function (evtName) {
- _this.adapter_.deregisterInteractionHandler(evtName, _this.interactionStartHandler_);
- _this.adapter_.deregisterThumbContainerInteractionHandler(evtName, _this.thumbContainerPointerHandler_);
- });
- this.adapter_.deregisterInteractionHandler('keydown', this.keydownHandler_);
- this.adapter_.deregisterInteractionHandler('focus', this.focusHandler_);
- this.adapter_.deregisterInteractionHandler('blur', this.blurHandler_);
- this.adapter_.deregisterResizeHandler(this.resizeHandler_);
- };
- MDCSliderFoundation.prototype.setupTrackMarker = function () {
- if (this.isDiscrete_ && this.hasTrackMarker_ && this.getStep() !== 0) {
- this.adapter_.setTrackMarkers(this.getStep(), this.getMax(), this.getMin());
- }
- };
- MDCSliderFoundation.prototype.layout = function () {
- this.rect_ = this.adapter_.computeBoundingRect();
- this.updateUIForCurrentValue_();
- };
- MDCSliderFoundation.prototype.getValue = function () {
- return this.value_;
- };
- MDCSliderFoundation.prototype.setValue = function (value) {
- this.setValue_(value, false);
- };
- MDCSliderFoundation.prototype.getMax = function () {
- return this.max_;
- };
- MDCSliderFoundation.prototype.setMax = function (max) {
- if (max < this.min_) {
- throw new Error('Cannot set max to be less than the slider\'s minimum value');
- }
- this.max_ = max;
- this.setValue_(this.value_, false, true);
- this.adapter_.setAttribute(constants_1.strings.ARIA_VALUEMAX, String(this.max_));
- this.setupTrackMarker();
- };
- MDCSliderFoundation.prototype.getMin = function () {
- return this.min_;
- };
- MDCSliderFoundation.prototype.setMin = function (min) {
- if (min > this.max_) {
- throw new Error('Cannot set min to be greater than the slider\'s maximum value');
- }
- this.min_ = min;
- this.setValue_(this.value_, false, true);
- this.adapter_.setAttribute(constants_1.strings.ARIA_VALUEMIN, String(this.min_));
- this.setupTrackMarker();
- };
- MDCSliderFoundation.prototype.getStep = function () {
- return this.step_;
- };
- MDCSliderFoundation.prototype.setStep = function (step) {
- if (step < 0) {
- throw new Error('Step cannot be set to a negative number');
- }
- if (this.isDiscrete_ && (typeof step !== 'number' || step < 1)) {
- step = 1;
- }
- this.step_ = step;
- this.setValue_(this.value_, false, true);
- this.setupTrackMarker();
- };
- MDCSliderFoundation.prototype.isDisabled = function () {
- return this.disabled_;
- };
- MDCSliderFoundation.prototype.setDisabled = function (disabled) {
- this.disabled_ = disabled;
- this.toggleClass_(constants_1.cssClasses.DISABLED, this.disabled_);
- if (this.disabled_) {
- this.savedTabIndex_ = this.adapter_.getTabIndex();
- this.adapter_.setAttribute(constants_1.strings.ARIA_DISABLED, 'true');
- this.adapter_.removeAttribute('tabindex');
- } else {
- this.adapter_.removeAttribute(constants_1.strings.ARIA_DISABLED);
- if (!isNaN(this.savedTabIndex_)) {
- this.adapter_.setAttribute('tabindex', String(this.savedTabIndex_));
- }
- }
- };
- /**
- * Called when the user starts interacting with the slider
- */
- MDCSliderFoundation.prototype.handleDown_ = function (downEvent) {
- var _this = this;
- if (this.disabled_) {
- return;
- }
- this.preventFocusState_ = true;
- this.setInTransit_(!this.handlingThumbTargetEvt_);
- this.handlingThumbTargetEvt_ = false;
- this.setActive_(true);
- var moveHandler = function moveHandler(moveEvent) {
- _this.handleMove_(moveEvent);
- };
- var moveEventType = MOVE_EVENT_MAP[downEvent.type];
- // Note: upHandler is [de]registered on ALL potential pointer-related
- // release event types, since some browsers do not always fire these
- // consistently in pairs. (See
- // https://github.com/material-components/material-components-web/issues/1192)
- var upHandler = function upHandler() {
- _this.handleUp_();
- _this.adapter_.deregisterBodyInteractionHandler(moveEventType, moveHandler);
- UP_EVENTS.forEach(function (evtName) {
- return _this.adapter_.deregisterBodyInteractionHandler(evtName, upHandler);
- });
- };
- this.adapter_.registerBodyInteractionHandler(moveEventType, moveHandler);
- UP_EVENTS.forEach(function (evtName) {
- return _this.adapter_.registerBodyInteractionHandler(evtName, upHandler);
- });
- this.setValueFromEvt_(downEvent);
- };
- /**
- * Called when the user moves the slider
- */
- MDCSliderFoundation.prototype.handleMove_ = function (evt) {
- evt.preventDefault();
- this.setValueFromEvt_(evt);
- };
- /**
- * Called when the user's interaction with the slider ends
- */
- MDCSliderFoundation.prototype.handleUp_ = function () {
- this.setActive_(false);
- this.adapter_.notifyChange();
- };
- /**
- * Returns the clientX of the event
- */
- MDCSliderFoundation.prototype.getClientX_ = function (evt) {
- if (evt.targetTouches && evt.targetTouches.length > 0) {
- return evt.targetTouches[0].clientX;
- }
- return evt.clientX;
- };
- /**
- * Sets the slider value from an event
- */
- MDCSliderFoundation.prototype.setValueFromEvt_ = function (evt) {
- var clientX = this.getClientX_(evt);
- var value = this.computeValueFromClientX_(clientX);
- this.setValue_(value, true);
- };
- /**
- * Computes the new value from the clientX position
- */
- MDCSliderFoundation.prototype.computeValueFromClientX_ = function (clientX) {
- var _a = this,
- max = _a.max_,
- min = _a.min_;
- var xPos = clientX - this.rect_.left;
- var pctComplete = xPos / this.rect_.width;
- if (this.adapter_.isRTL()) {
- pctComplete = 1 - pctComplete;
- }
- // Fit the percentage complete between the range [min,max]
- // by remapping from [0, 1] to [min, min+(max-min)].
- return min + pctComplete * (max - min);
- };
- /**
- * Handles keydown events
- */
- MDCSliderFoundation.prototype.handleKeydown_ = function (evt) {
- var keyId = this.getKeyId_(evt);
- var value = this.getValueForKeyId_(keyId);
- if (isNaN(value)) {
- return;
- }
- // Prevent page from scrolling due to key presses that would normally scroll
- // the page
- evt.preventDefault();
- this.adapter_.addClass(constants_1.cssClasses.FOCUS);
- this.setValue_(value, true);
- this.adapter_.notifyChange();
- };
- /**
- * Returns the computed name of the event
- */
- MDCSliderFoundation.prototype.getKeyId_ = function (kbdEvt) {
- if (kbdEvt.key === KEY_IDS.ARROW_LEFT || kbdEvt.keyCode === 37) {
- return KEY_IDS.ARROW_LEFT;
- }
- if (kbdEvt.key === KEY_IDS.ARROW_RIGHT || kbdEvt.keyCode === 39) {
- return KEY_IDS.ARROW_RIGHT;
- }
- if (kbdEvt.key === KEY_IDS.ARROW_UP || kbdEvt.keyCode === 38) {
- return KEY_IDS.ARROW_UP;
- }
- if (kbdEvt.key === KEY_IDS.ARROW_DOWN || kbdEvt.keyCode === 40) {
- return KEY_IDS.ARROW_DOWN;
- }
- if (kbdEvt.key === KEY_IDS.HOME || kbdEvt.keyCode === 36) {
- return KEY_IDS.HOME;
- }
- if (kbdEvt.key === KEY_IDS.END || kbdEvt.keyCode === 35) {
- return KEY_IDS.END;
- }
- if (kbdEvt.key === KEY_IDS.PAGE_UP || kbdEvt.keyCode === 33) {
- return KEY_IDS.PAGE_UP;
- }
- if (kbdEvt.key === KEY_IDS.PAGE_DOWN || kbdEvt.keyCode === 34) {
- return KEY_IDS.PAGE_DOWN;
- }
- return '';
- };
- /**
- * Computes the value given a keyboard key ID
- */
- MDCSliderFoundation.prototype.getValueForKeyId_ = function (keyId) {
- var _a = this,
- max = _a.max_,
- min = _a.min_,
- step = _a.step_;
- var delta = step || (max - min) / 100;
- var valueNeedsToBeFlipped = this.adapter_.isRTL() && (keyId === KEY_IDS.ARROW_LEFT || keyId === KEY_IDS.ARROW_RIGHT);
- if (valueNeedsToBeFlipped) {
- delta = -delta;
- }
- switch (keyId) {
- case KEY_IDS.ARROW_LEFT:
- case KEY_IDS.ARROW_DOWN:
- return this.value_ - delta;
- case KEY_IDS.ARROW_RIGHT:
- case KEY_IDS.ARROW_UP:
- return this.value_ + delta;
- case KEY_IDS.HOME:
- return this.min_;
- case KEY_IDS.END:
- return this.max_;
- case KEY_IDS.PAGE_UP:
- return this.value_ + delta * constants_1.numbers.PAGE_FACTOR;
- case KEY_IDS.PAGE_DOWN:
- return this.value_ - delta * constants_1.numbers.PAGE_FACTOR;
- default:
- return NaN;
- }
- };
- MDCSliderFoundation.prototype.handleFocus_ = function () {
- if (this.preventFocusState_) {
- return;
- }
- this.adapter_.addClass(constants_1.cssClasses.FOCUS);
- };
- MDCSliderFoundation.prototype.handleBlur_ = function () {
- this.preventFocusState_ = false;
- this.adapter_.removeClass(constants_1.cssClasses.FOCUS);
- };
- /**
- * Sets the value of the slider
- */
- MDCSliderFoundation.prototype.setValue_ = function (value, shouldFireInput, force) {
- if (force === void 0) {
- force = false;
- }
- if (value === this.value_ && !force) {
- return;
- }
- var _a = this,
- min = _a.min_,
- max = _a.max_;
- var valueSetToBoundary = value === min || value === max;
- if (this.step_ && !valueSetToBoundary) {
- value = this.quantize_(value);
- }
- if (value < min) {
- value = min;
- } else if (value > max) {
- value = max;
- }
- value = value || 0; // coerce -0 to 0
- this.value_ = value;
- this.adapter_.setAttribute(constants_1.strings.ARIA_VALUENOW, String(this.value_));
- this.updateUIForCurrentValue_();
- if (shouldFireInput) {
- this.adapter_.notifyInput();
- if (this.isDiscrete_) {
- this.adapter_.setMarkerValue(value);
- }
- }
- };
- /**
- * Calculates the quantized value
- */
- MDCSliderFoundation.prototype.quantize_ = function (value) {
- var numSteps = Math.round(value / this.step_);
- return numSteps * this.step_;
- };
- MDCSliderFoundation.prototype.updateUIForCurrentValue_ = function () {
- var _this = this;
- var _a = this,
- max = _a.max_,
- min = _a.min_,
- value = _a.value_;
- var pctComplete = (value - min) / (max - min);
- var translatePx = pctComplete * this.rect_.width;
- if (this.adapter_.isRTL()) {
- translatePx = this.rect_.width - translatePx;
- }
- var transformProp = util_1.getCorrectPropertyName(window, 'transform');
- var transitionendEvtName = util_1.getCorrectEventName(window, 'transitionend');
- if (this.inTransit_) {
- var onTransitionEnd_1 = function onTransitionEnd_1() {
- _this.setInTransit_(false);
- _this.adapter_.deregisterThumbContainerInteractionHandler(transitionendEvtName, onTransitionEnd_1);
- };
- this.adapter_.registerThumbContainerInteractionHandler(transitionendEvtName, onTransitionEnd_1);
- }
- requestAnimationFrame(function () {
- // NOTE(traviskaufman): It would be nice to use calc() here,
- // but IE cannot handle calcs in transforms correctly.
- // See: https://goo.gl/NC2itk
- // Also note that the -50% offset is used to center the slider thumb.
- _this.adapter_.setThumbContainerStyleProperty(transformProp, "translateX(" + translatePx + "px) translateX(-50%)");
- _this.adapter_.setTrackStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
- });
- };
- /**
- * Toggles the active state of the slider
- */
- MDCSliderFoundation.prototype.setActive_ = function (active) {
- this.active_ = active;
- this.toggleClass_(constants_1.cssClasses.ACTIVE, this.active_);
- };
- /**
- * Toggles the inTransit state of the slider
- */
- MDCSliderFoundation.prototype.setInTransit_ = function (inTransit) {
- this.inTransit_ = inTransit;
- this.toggleClass_(constants_1.cssClasses.IN_TRANSIT, this.inTransit_);
- };
- /**
- * Conditionally adds or removes a class based on shouldBePresent
- */
- MDCSliderFoundation.prototype.toggleClass_ = function (className, shouldBePresent) {
- if (shouldBePresent) {
- this.adapter_.addClass(className);
- } else {
- this.adapter_.removeClass(className);
- }
- };
- return MDCSliderFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSliderFoundation = MDCSliderFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility
- // with MDC Web v0.44.0 and earlier.
- exports.default = MDCSliderFoundation;
- /***/ }),
- /***/ "./packages/mdc-slider/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-slider/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-slider/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-snackbar/component.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-snackbar/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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-snackbar/constants.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts");
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
- var SURFACE_SELECTOR = constants_1.strings.SURFACE_SELECTOR,
- LABEL_SELECTOR = constants_1.strings.LABEL_SELECTOR,
- ACTION_SELECTOR = constants_1.strings.ACTION_SELECTOR,
- DISMISS_SELECTOR = constants_1.strings.DISMISS_SELECTOR,
- OPENING_EVENT = constants_1.strings.OPENING_EVENT,
- OPENED_EVENT = constants_1.strings.OPENED_EVENT,
- CLOSING_EVENT = constants_1.strings.CLOSING_EVENT,
- CLOSED_EVENT = constants_1.strings.CLOSED_EVENT;
- var MDCSnackbar = /** @class */function (_super) {
- __extends(MDCSnackbar, _super);
- function MDCSnackbar() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCSnackbar.attachTo = function (root) {
- return new MDCSnackbar(root);
- };
- MDCSnackbar.prototype.initialize = function (announcerFactory) {
- if (announcerFactory === void 0) {
- announcerFactory = function announcerFactory() {
- return util.announce;
- };
- }
- this.announce_ = announcerFactory();
- };
- MDCSnackbar.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.surfaceEl_ = this.root_.querySelector(SURFACE_SELECTOR);
- this.labelEl_ = this.root_.querySelector(LABEL_SELECTOR);
- this.actionEl_ = this.root_.querySelector(ACTION_SELECTOR);
- this.handleKeyDown_ = function (evt) {
- return _this.foundation_.handleKeyDown(evt);
- };
- this.handleSurfaceClick_ = function (evt) {
- var target = evt.target;
- if (_this.isActionButton_(target)) {
- _this.foundation_.handleActionButtonClick(evt);
- } else if (_this.isActionIcon_(target)) {
- _this.foundation_.handleActionIconClick(evt);
- }
- };
- this.registerKeyDownHandler_(this.handleKeyDown_);
- this.registerSurfaceClickHandler_(this.handleSurfaceClick_);
- };
- MDCSnackbar.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.deregisterKeyDownHandler_(this.handleKeyDown_);
- this.deregisterSurfaceClickHandler_(this.handleSurfaceClick_);
- };
- MDCSnackbar.prototype.open = function () {
- this.foundation_.open();
- };
- /**
- * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
- * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
- * client-specific values may also be used if desired.
- */
- MDCSnackbar.prototype.close = function (reason) {
- if (reason === void 0) {
- reason = '';
- }
- this.foundation_.close(reason);
- };
- MDCSnackbar.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 = {
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- announce: function announce() {
- return _this.announce_(_this.labelEl_);
- },
- notifyClosed: function notifyClosed(reason) {
- return _this.emit(CLOSED_EVENT, reason ? { reason: reason } : {});
- },
- notifyClosing: function notifyClosing(reason) {
- return _this.emit(CLOSING_EVENT, reason ? { reason: reason } : {});
- },
- notifyOpened: function notifyOpened() {
- return _this.emit(OPENED_EVENT, {});
- },
- notifyOpening: function notifyOpening() {
- return _this.emit(OPENING_EVENT, {});
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- }
- };
- return new foundation_1.MDCSnackbarFoundation(adapter);
- };
- Object.defineProperty(MDCSnackbar.prototype, "timeoutMs", {
- get: function get() {
- return this.foundation_.getTimeoutMs();
- },
- set: function set(timeoutMs) {
- this.foundation_.setTimeoutMs(timeoutMs);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbar.prototype, "closeOnEscape", {
- get: function get() {
- return this.foundation_.getCloseOnEscape();
- },
- set: function set(closeOnEscape) {
- this.foundation_.setCloseOnEscape(closeOnEscape);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbar.prototype, "isOpen", {
- get: function get() {
- return this.foundation_.isOpen();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbar.prototype, "labelText", {
- get: function get() {
- // This property only returns null if the node is a document, DOCTYPE, or notation.
- // On Element nodes, it always returns a string.
- return this.labelEl_.textContent;
- },
- set: function set(labelText) {
- this.labelEl_.textContent = labelText;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbar.prototype, "actionButtonText", {
- get: function get() {
- return this.actionEl_.textContent;
- },
- set: function set(actionButtonText) {
- this.actionEl_.textContent = actionButtonText;
- },
- enumerable: true,
- configurable: true
- });
- MDCSnackbar.prototype.registerKeyDownHandler_ = function (handler) {
- this.listen('keydown', handler);
- };
- MDCSnackbar.prototype.deregisterKeyDownHandler_ = function (handler) {
- this.unlisten('keydown', handler);
- };
- MDCSnackbar.prototype.registerSurfaceClickHandler_ = function (handler) {
- this.surfaceEl_.addEventListener('click', handler);
- };
- MDCSnackbar.prototype.deregisterSurfaceClickHandler_ = function (handler) {
- this.surfaceEl_.removeEventListener('click', handler);
- };
- MDCSnackbar.prototype.isActionButton_ = function (target) {
- return Boolean(ponyfill_1.closest(target, ACTION_SELECTOR));
- };
- MDCSnackbar.prototype.isActionIcon_ = function (target) {
- return Boolean(ponyfill_1.closest(target, DISMISS_SELECTOR));
- };
- return MDCSnackbar;
- }(component_1.MDCComponent);
- exports.MDCSnackbar = MDCSnackbar;
- /***/ }),
- /***/ "./packages/mdc-snackbar/constants.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-snackbar/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 });
- var cssClasses = {
- CLOSING: 'mdc-snackbar--closing',
- OPEN: 'mdc-snackbar--open',
- OPENING: 'mdc-snackbar--opening'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ACTION_SELECTOR: '.mdc-snackbar__action',
- ARIA_LIVE_LABEL_TEXT_ATTR: 'data-mdc-snackbar-label-text',
- CLOSED_EVENT: 'MDCSnackbar:closed',
- CLOSING_EVENT: 'MDCSnackbar:closing',
- DISMISS_SELECTOR: '.mdc-snackbar__dismiss',
- LABEL_SELECTOR: '.mdc-snackbar__label',
- OPENED_EVENT: 'MDCSnackbar:opened',
- OPENING_EVENT: 'MDCSnackbar:opening',
- REASON_ACTION: 'action',
- REASON_DISMISS: 'dismiss',
- SURFACE_SELECTOR: '.mdc-snackbar__surface'
- };
- exports.strings = strings;
- var numbers = {
- DEFAULT_AUTO_DISMISS_TIMEOUT_MS: 5000,
- INDETERMINATE: -1,
- MAX_AUTO_DISMISS_TIMEOUT_MS: 10000,
- MIN_AUTO_DISMISS_TIMEOUT_MS: 4000,
- // These variables need to be kept in sync with the values in _variables.scss.
- SNACKBAR_ANIMATION_CLOSE_TIME_MS: 75,
- SNACKBAR_ANIMATION_OPEN_TIME_MS: 150,
- /**
- * Number of milliseconds to wait between temporarily clearing the label text
- * in the DOM and subsequently restoring it. This is necessary to force IE 11
- * to pick up the `aria-live` content change and announce it to the user.
- */
- ARIA_LIVE_DELAY_MS: 1000
- };
- exports.numbers = numbers;
- /***/ }),
- /***/ "./packages/mdc-snackbar/foundation.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-snackbar/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
- var OPENING = constants_1.cssClasses.OPENING,
- OPEN = constants_1.cssClasses.OPEN,
- CLOSING = constants_1.cssClasses.CLOSING;
- var REASON_ACTION = constants_1.strings.REASON_ACTION,
- REASON_DISMISS = constants_1.strings.REASON_DISMISS;
- var MDCSnackbarFoundation = /** @class */function (_super) {
- __extends(MDCSnackbarFoundation, _super);
- function MDCSnackbarFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCSnackbarFoundation.defaultAdapter, adapter)) || this;
- _this.isOpen_ = false;
- _this.animationFrame_ = 0;
- _this.animationTimer_ = 0;
- _this.autoDismissTimer_ = 0;
- _this.autoDismissTimeoutMs_ = constants_1.numbers.DEFAULT_AUTO_DISMISS_TIMEOUT_MS;
- _this.closeOnEscape_ = true;
- return _this;
- }
- Object.defineProperty(MDCSnackbarFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbarFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbarFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbarFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- announce: function announce() {
- return undefined;
- },
- notifyClosed: function notifyClosed() {
- return undefined;
- },
- notifyClosing: function notifyClosing() {
- return undefined;
- },
- notifyOpened: function notifyOpened() {
- return undefined;
- },
- notifyOpening: function notifyOpening() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCSnackbarFoundation.prototype.destroy = function () {
- this.clearAutoDismissTimer_();
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = 0;
- clearTimeout(this.animationTimer_);
- this.animationTimer_ = 0;
- this.adapter_.removeClass(OPENING);
- this.adapter_.removeClass(OPEN);
- this.adapter_.removeClass(CLOSING);
- };
- MDCSnackbarFoundation.prototype.open = function () {
- var _this = this;
- this.clearAutoDismissTimer_();
- this.isOpen_ = true;
- this.adapter_.notifyOpening();
- this.adapter_.removeClass(CLOSING);
- this.adapter_.addClass(OPENING);
- this.adapter_.announce();
- // Wait a frame once display is no longer "none", to establish basis for animation
- this.runNextAnimationFrame_(function () {
- _this.adapter_.addClass(OPEN);
- _this.animationTimer_ = setTimeout(function () {
- var timeoutMs = _this.getTimeoutMs();
- _this.handleAnimationTimerEnd_();
- _this.adapter_.notifyOpened();
- if (timeoutMs !== constants_1.numbers.INDETERMINATE) {
- _this.autoDismissTimer_ = setTimeout(function () {
- _this.close(REASON_DISMISS);
- }, timeoutMs);
- }
- }, constants_1.numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS);
- });
- };
- /**
- * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
- * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
- * client-specific values may also be used if desired.
- */
- MDCSnackbarFoundation.prototype.close = function (reason) {
- var _this = this;
- if (reason === void 0) {
- reason = '';
- }
- if (!this.isOpen_) {
- // Avoid redundant close calls (and events), e.g. repeated interactions as the snackbar is animating closed
- return;
- }
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = 0;
- this.clearAutoDismissTimer_();
- this.isOpen_ = false;
- this.adapter_.notifyClosing(reason);
- this.adapter_.addClass(constants_1.cssClasses.CLOSING);
- this.adapter_.removeClass(constants_1.cssClasses.OPEN);
- this.adapter_.removeClass(constants_1.cssClasses.OPENING);
- clearTimeout(this.animationTimer_);
- this.animationTimer_ = setTimeout(function () {
- _this.handleAnimationTimerEnd_();
- _this.adapter_.notifyClosed(reason);
- }, constants_1.numbers.SNACKBAR_ANIMATION_CLOSE_TIME_MS);
- };
- MDCSnackbarFoundation.prototype.isOpen = function () {
- return this.isOpen_;
- };
- MDCSnackbarFoundation.prototype.getTimeoutMs = function () {
- return this.autoDismissTimeoutMs_;
- };
- MDCSnackbarFoundation.prototype.setTimeoutMs = function (timeoutMs) {
- // Use shorter variable names to make the code more readable
- var minValue = constants_1.numbers.MIN_AUTO_DISMISS_TIMEOUT_MS;
- var maxValue = constants_1.numbers.MAX_AUTO_DISMISS_TIMEOUT_MS;
- var indeterminateValue = constants_1.numbers.INDETERMINATE;
- if (timeoutMs === constants_1.numbers.INDETERMINATE || timeoutMs <= maxValue && timeoutMs >= minValue) {
- this.autoDismissTimeoutMs_ = timeoutMs;
- } else {
- throw new Error("\n timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + "\n (or " + indeterminateValue + " to disable), but got '" + timeoutMs + "'");
- }
- };
- MDCSnackbarFoundation.prototype.getCloseOnEscape = function () {
- return this.closeOnEscape_;
- };
- MDCSnackbarFoundation.prototype.setCloseOnEscape = function (closeOnEscape) {
- this.closeOnEscape_ = closeOnEscape;
- };
- MDCSnackbarFoundation.prototype.handleKeyDown = function (evt) {
- var isEscapeKey = evt.key === 'Escape' || evt.keyCode === 27;
- if (isEscapeKey && this.getCloseOnEscape()) {
- this.close(REASON_DISMISS);
- }
- };
- MDCSnackbarFoundation.prototype.handleActionButtonClick = function (_evt) {
- this.close(REASON_ACTION);
- };
- MDCSnackbarFoundation.prototype.handleActionIconClick = function (_evt) {
- this.close(REASON_DISMISS);
- };
- MDCSnackbarFoundation.prototype.clearAutoDismissTimer_ = function () {
- clearTimeout(this.autoDismissTimer_);
- this.autoDismissTimer_ = 0;
- };
- MDCSnackbarFoundation.prototype.handleAnimationTimerEnd_ = function () {
- this.animationTimer_ = 0;
- this.adapter_.removeClass(constants_1.cssClasses.OPENING);
- this.adapter_.removeClass(constants_1.cssClasses.CLOSING);
- };
- /**
- * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
- */
- MDCSnackbarFoundation.prototype.runNextAnimationFrame_ = function (callback) {
- var _this = this;
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = requestAnimationFrame(function () {
- _this.animationFrame_ = 0;
- clearTimeout(_this.animationTimer_);
- _this.animationTimer_ = setTimeout(callback, 0);
- });
- };
- return MDCSnackbarFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSnackbarFoundation = MDCSnackbarFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCSnackbarFoundation;
- /***/ }),
- /***/ "./packages/mdc-snackbar/index.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-snackbar/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-snackbar/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-snackbar/util.ts":
- /*!***************************************!*\
- !*** ./packages/mdc-snackbar/util.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 });
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
- var ARIA_LIVE_DELAY_MS = constants_1.numbers.ARIA_LIVE_DELAY_MS;
- var ARIA_LIVE_LABEL_TEXT_ATTR = constants_1.strings.ARIA_LIVE_LABEL_TEXT_ATTR;
- function announce(ariaEl, labelEl) {
- if (labelEl === void 0) {
- labelEl = ariaEl;
- }
- var priority = ariaEl.getAttribute('aria-live');
- // Trim text to ignore ` ` (see below).
- // textContent is only null if the node is a document, DOCTYPE, or notation.
- var labelText = labelEl.textContent.trim();
- if (!labelText || !priority) {
- return;
- }
- // Temporarily disable `aria-live` to prevent JAWS+Firefox from announcing the message twice.
- ariaEl.setAttribute('aria-live', 'off');
- // Temporarily clear `textContent` to force a DOM mutation event that will be detected by screen readers.
- // `aria-live` elements are only announced when the element's `textContent` *changes*, so snackbars
- // sent to the browser in the initial HTML response won't be read unless we clear the element's `textContent` first.
- // Similarly, displaying the same snackbar message twice in a row doesn't trigger a DOM mutation event,
- // so screen readers won't announce the second message unless we first clear `textContent`.
- //
- // We have to clear the label text two different ways to make it work in all browsers and screen readers:
- //
- // 1. `textContent = ''` is required for IE11 + JAWS
- // 2. `innerHTML = ' '` is required for Chrome + JAWS and NVDA
- //
- // All other browser/screen reader combinations support both methods.
- //
- // The wrapper `<span>` visually hides the space character so that it doesn't cause jank when added/removed.
- // N.B.: Setting `position: absolute`, `opacity: 0`, or `height: 0` prevents Chrome from detecting the DOM change.
- //
- // This technique has been tested in:
- //
- // * JAWS 2019:
- // - Chrome 70
- // - Firefox 60 (ESR)
- // - IE 11
- // * NVDA 2018:
- // - Chrome 70
- // - Firefox 60 (ESR)
- // - IE 11
- // * ChromeVox 53
- labelEl.textContent = '';
- labelEl.innerHTML = '<span style="display: inline-block; width: 0; height: 1px;"> </span>';
- // Prevent visual jank by temporarily displaying the label text in the ::before pseudo-element.
- // CSS generated content is normally announced by screen readers
- // (except in IE 11; see https://tink.uk/accessibility-support-for-css-generated-content/);
- // however, `aria-live` is turned off, so this DOM update will be ignored by screen readers.
- labelEl.setAttribute(ARIA_LIVE_LABEL_TEXT_ATTR, labelText);
- setTimeout(function () {
- // Allow screen readers to announce changes to the DOM again.
- ariaEl.setAttribute('aria-live', priority);
- // Remove the message from the ::before pseudo-element.
- labelEl.removeAttribute(ARIA_LIVE_LABEL_TEXT_ATTR);
- // Restore the original label text, which will be announced by screen readers.
- labelEl.textContent = labelText;
- }, ARIA_LIVE_DELAY_MS);
- }
- exports.announce = announce;
- /***/ }),
- /***/ "./packages/mdc-switch/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-switch/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 __spread = this && this.__spread || function () {
- for (var ar = [], i = 0; i < arguments.length; i++) {
- ar = ar.concat(__read(arguments[i]));
- }return ar;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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 component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-switch/foundation.ts");
- var MDCSwitch = /** @class */function (_super) {
- __extends(MDCSwitch, _super);
- function MDCSwitch() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.ripple_ = _this.createRipple_();
- return _this;
- }
- MDCSwitch.attachTo = function (root) {
- return new MDCSwitch(root);
- };
- MDCSwitch.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.ripple_.destroy();
- this.nativeControl_.removeEventListener('change', this.changeHandler_);
- };
- MDCSwitch.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.changeHandler_ = function () {
- var _a;
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return (_a = _this.foundation_).handleChange.apply(_a, __spread(args));
- };
- this.nativeControl_.addEventListener('change', this.changeHandler_);
- // Sometimes the checked state of the input element is saved in the history.
- // The switch styling should match the checked state of the input element.
- // Do an initial sync between the native control and the foundation.
- this.checked = this.checked;
- };
- MDCSwitch.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 = {
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- setNativeControlChecked: function setNativeControlChecked(checked) {
- return _this.nativeControl_.checked = checked;
- },
- setNativeControlDisabled: function setNativeControlDisabled(disabled) {
- return _this.nativeControl_.disabled = disabled;
- },
- setNativeControlAttr: function setNativeControlAttr(attr, value) {
- return _this.nativeControl_.setAttribute(attr, value);
- }
- };
- return new foundation_2.MDCSwitchFoundation(adapter);
- };
- Object.defineProperty(MDCSwitch.prototype, "ripple", {
- get: function get() {
- return this.ripple_;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSwitch.prototype, "checked", {
- get: function get() {
- return this.nativeControl_.checked;
- },
- set: function set(checked) {
- this.foundation_.setChecked(checked);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSwitch.prototype, "disabled", {
- get: function get() {
- return this.nativeControl_.disabled;
- },
- set: function set(disabled) {
- this.foundation_.setDisabled(disabled);
- },
- enumerable: true,
- configurable: true
- });
- MDCSwitch.prototype.createRipple_ = function () {
- var _this = this;
- var RIPPLE_SURFACE_SELECTOR = foundation_2.MDCSwitchFoundation.strings.RIPPLE_SURFACE_SELECTOR;
- var rippleSurface = this.root_.querySelector(RIPPLE_SURFACE_SELECTOR);
- // 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({}, component_2.MDCRipple.createAdapter(this), { addClass: function addClass(className) {
- return rippleSurface.classList.add(className);
- }, computeBoundingRect: function computeBoundingRect() {
- return rippleSurface.getBoundingClientRect();
- }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- _this.nativeControl_.removeEventListener(evtType, handler, events_1.applyPassive());
- }, isSurfaceActive: function isSurfaceActive() {
- return ponyfill_1.matches(_this.nativeControl_, ':active');
- }, isUnbounded: function isUnbounded() {
- return true;
- }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
- }, removeClass: function removeClass(className) {
- rippleSurface.classList.remove(className);
- }, updateCssVariable: function updateCssVariable(varName, value) {
- rippleSurface.style.setProperty(varName, value);
- } });
- return new component_2.MDCRipple(this.root_, new foundation_1.MDCRippleFoundation(adapter));
- };
- Object.defineProperty(MDCSwitch.prototype, "nativeControl_", {
- get: function get() {
- var NATIVE_CONTROL_SELECTOR = foundation_2.MDCSwitchFoundation.strings.NATIVE_CONTROL_SELECTOR;
- return this.root_.querySelector(NATIVE_CONTROL_SELECTOR);
- },
- enumerable: true,
- configurable: true
- });
- return MDCSwitch;
- }(component_1.MDCComponent);
- exports.MDCSwitch = MDCSwitch;
- /***/ }),
- /***/ "./packages/mdc-switch/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-switch/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 });
- /** CSS classes used by the switch. */
- var cssClasses = {
- /** Class used for a switch that is in the "checked" (on) position. */
- CHECKED: 'mdc-switch--checked',
- /** Class used for a switch that is disabled. */
- DISABLED: 'mdc-switch--disabled'
- };
- exports.cssClasses = cssClasses;
- /** String constants used by the switch. */
- var strings = {
- /** Aria attribute for checked or unchecked state of switch */
- ARIA_CHECKED_ATTR: 'aria-checked',
- /** A CSS selector used to locate the native HTML control for the switch. */
- NATIVE_CONTROL_SELECTOR: '.mdc-switch__native-control',
- /** A CSS selector used to locate the ripple surface element for the switch. */
- RIPPLE_SURFACE_SELECTOR: '.mdc-switch__thumb-underlay'
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-switch/foundation.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-switch/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts");
- var MDCSwitchFoundation = /** @class */function (_super) {
- __extends(MDCSwitchFoundation, _super);
- function MDCSwitchFoundation(adapter) {
- return _super.call(this, __assign({}, MDCSwitchFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCSwitchFoundation, "strings", {
- /** The string constants used by the switch. */
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSwitchFoundation, "cssClasses", {
- /** The CSS classes used by the switch. */
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSwitchFoundation, "defaultAdapter", {
- /** The default Adapter for the switch. */
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- setNativeControlChecked: function setNativeControlChecked() {
- return undefined;
- },
- setNativeControlDisabled: function setNativeControlDisabled() {
- return undefined;
- },
- setNativeControlAttr: function setNativeControlAttr() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- /** Sets the checked state of the switch. */
- MDCSwitchFoundation.prototype.setChecked = function (checked) {
- this.adapter_.setNativeControlChecked(checked);
- this.updateAriaChecked_(checked);
- this.updateCheckedStyling_(checked);
- };
- /** Sets the disabled state of the switch. */
- MDCSwitchFoundation.prototype.setDisabled = function (disabled) {
- this.adapter_.setNativeControlDisabled(disabled);
- if (disabled) {
- this.adapter_.addClass(constants_1.cssClasses.DISABLED);
- } else {
- this.adapter_.removeClass(constants_1.cssClasses.DISABLED);
- }
- };
- /** Handles the change event for the switch native control. */
- MDCSwitchFoundation.prototype.handleChange = function (evt) {
- var nativeControl = evt.target;
- this.updateAriaChecked_(nativeControl.checked);
- this.updateCheckedStyling_(nativeControl.checked);
- };
- /** Updates the styling of the switch based on its checked state. */
- MDCSwitchFoundation.prototype.updateCheckedStyling_ = function (checked) {
- if (checked) {
- this.adapter_.addClass(constants_1.cssClasses.CHECKED);
- } else {
- this.adapter_.removeClass(constants_1.cssClasses.CHECKED);
- }
- };
- MDCSwitchFoundation.prototype.updateAriaChecked_ = function (checked) {
- this.adapter_.setNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR, "" + !!checked);
- };
- return MDCSwitchFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSwitchFoundation = MDCSwitchFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCSwitchFoundation;
- /***/ }),
- /***/ "./packages/mdc-switch/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-switch/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-switch/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-switch/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-tab-bar/component.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-tab-bar/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/tab-scroller/component */ "./packages/mdc-tab-scroller/component.ts");
- var component_3 = __webpack_require__(/*! @material/tab/component */ "./packages/mdc-tab/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/tab/foundation */ "./packages/mdc-tab/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-bar/foundation.ts");
- var strings = foundation_2.MDCTabBarFoundation.strings;
- var tabIdCounter = 0;
- var MDCTabBar = /** @class */function (_super) {
- __extends(MDCTabBar, _super);
- function MDCTabBar() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTabBar.attachTo = function (root) {
- return new MDCTabBar(root);
- };
- Object.defineProperty(MDCTabBar.prototype, "focusOnActivate", {
- set: function set(focusOnActivate) {
- this.tabList_.forEach(function (tab) {
- return tab.focusOnActivate = focusOnActivate;
- });
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabBar.prototype, "useAutomaticActivation", {
- set: function set(useAutomaticActivation) {
- this.foundation_.setUseAutomaticActivation(useAutomaticActivation);
- },
- enumerable: true,
- configurable: true
- });
- MDCTabBar.prototype.initialize = function (tabFactory, tabScrollerFactory) {
- if (tabFactory === void 0) {
- tabFactory = function tabFactory(el) {
- return new component_3.MDCTab(el);
- };
- }
- if (tabScrollerFactory === void 0) {
- tabScrollerFactory = function tabScrollerFactory(el) {
- return new component_2.MDCTabScroller(el);
- };
- }
- this.tabList_ = this.instantiateTabs_(tabFactory);
- this.tabScroller_ = this.instantiateTabScroller_(tabScrollerFactory);
- };
- MDCTabBar.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleTabInteraction_ = function (evt) {
- return _this.foundation_.handleTabInteraction(evt);
- };
- this.handleKeyDown_ = function (evt) {
- return _this.foundation_.handleKeyDown(evt);
- };
- this.listen(foundation_1.MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_);
- this.listen('keydown', this.handleKeyDown_);
- for (var i = 0; i < this.tabList_.length; i++) {
- if (this.tabList_[i].active) {
- this.scrollIntoView(i);
- break;
- }
- }
- };
- MDCTabBar.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.unlisten(foundation_1.MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_);
- this.unlisten('keydown', this.handleKeyDown_);
- this.tabList_.forEach(function (tab) {
- return tab.destroy();
- });
- if (this.tabScroller_) {
- this.tabScroller_.destroy();
- }
- };
- MDCTabBar.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 = {
- scrollTo: function scrollTo(scrollX) {
- return _this.tabScroller_.scrollTo(scrollX);
- },
- incrementScroll: function incrementScroll(scrollXIncrement) {
- return _this.tabScroller_.incrementScroll(scrollXIncrement);
- },
- getScrollPosition: function getScrollPosition() {
- return _this.tabScroller_.getScrollPosition();
- },
- getScrollContentWidth: function getScrollContentWidth() {
- return _this.tabScroller_.getScrollContentWidth();
- },
- getOffsetWidth: function getOffsetWidth() {
- return _this.root_.offsetWidth;
- },
- isRTL: function isRTL() {
- return window.getComputedStyle(_this.root_).getPropertyValue('direction') === 'rtl';
- },
- setActiveTab: function setActiveTab(index) {
- return _this.foundation_.activateTab(index);
- },
- activateTabAtIndex: function activateTabAtIndex(index, clientRect) {
- return _this.tabList_[index].activate(clientRect);
- },
- deactivateTabAtIndex: function deactivateTabAtIndex(index) {
- return _this.tabList_[index].deactivate();
- },
- focusTabAtIndex: function focusTabAtIndex(index) {
- return _this.tabList_[index].focus();
- },
- getTabIndicatorClientRectAtIndex: function getTabIndicatorClientRectAtIndex(index) {
- return _this.tabList_[index].computeIndicatorClientRect();
- },
- getTabDimensionsAtIndex: function getTabDimensionsAtIndex(index) {
- return _this.tabList_[index].computeDimensions();
- },
- getPreviousActiveTabIndex: function getPreviousActiveTabIndex() {
- for (var i = 0; i < _this.tabList_.length; i++) {
- if (_this.tabList_[i].active) {
- return i;
- }
- }
- return -1;
- },
- getFocusedTabIndex: function getFocusedTabIndex() {
- var tabElements = _this.getTabElements_();
- var activeElement = document.activeElement;
- return tabElements.indexOf(activeElement);
- },
- getIndexOfTabById: function getIndexOfTabById(id) {
- for (var i = 0; i < _this.tabList_.length; i++) {
- if (_this.tabList_[i].id === id) {
- return i;
- }
- }
- return -1;
- },
- getTabListLength: function getTabListLength() {
- return _this.tabList_.length;
- },
- notifyTabActivated: function notifyTabActivated(index) {
- return _this.emit(strings.TAB_ACTIVATED_EVENT, { index: index }, true);
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_2.MDCTabBarFoundation(adapter);
- };
- /**
- * Activates the tab at the given index
- * @param index The index of the tab
- */
- MDCTabBar.prototype.activateTab = function (index) {
- this.foundation_.activateTab(index);
- };
- /**
- * Scrolls the tab at the given index into view
- * @param index THe index of the tab
- */
- MDCTabBar.prototype.scrollIntoView = function (index) {
- this.foundation_.scrollIntoView(index);
- };
- /**
- * Returns all the tab elements in a nice clean array
- */
- MDCTabBar.prototype.getTabElements_ = function () {
- return [].slice.call(this.root_.querySelectorAll(strings.TAB_SELECTOR));
- };
- /**
- * Instantiates tab components on all child tab elements
- */
- MDCTabBar.prototype.instantiateTabs_ = function (tabFactory) {
- return this.getTabElements_().map(function (el) {
- el.id = el.id || "mdc-tab-" + ++tabIdCounter;
- return tabFactory(el);
- });
- };
- /**
- * Instantiates tab scroller component on the child tab scroller element
- */
- MDCTabBar.prototype.instantiateTabScroller_ = function (tabScrollerFactory) {
- var tabScrollerElement = this.root_.querySelector(strings.TAB_SCROLLER_SELECTOR);
- if (tabScrollerElement) {
- return tabScrollerFactory(tabScrollerElement);
- }
- return null;
- };
- return MDCTabBar;
- }(component_1.MDCComponent);
- exports.MDCTabBar = MDCTabBar;
- /***/ }),
- /***/ "./packages/mdc-tab-bar/constants.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-tab-bar/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 });
- var strings = {
- ARROW_LEFT_KEY: 'ArrowLeft',
- ARROW_RIGHT_KEY: 'ArrowRight',
- END_KEY: 'End',
- ENTER_KEY: 'Enter',
- HOME_KEY: 'Home',
- SPACE_KEY: 'Space',
- TAB_ACTIVATED_EVENT: 'MDCTabBar:activated',
- TAB_SCROLLER_SELECTOR: '.mdc-tab-scroller',
- TAB_SELECTOR: '.mdc-tab'
- };
- exports.strings = strings;
- var numbers = {
- ARROW_LEFT_KEYCODE: 37,
- ARROW_RIGHT_KEYCODE: 39,
- END_KEYCODE: 35,
- ENTER_KEYCODE: 13,
- EXTRA_SCROLL_AMOUNT: 20,
- HOME_KEYCODE: 36,
- SPACE_KEYCODE: 32
- };
- exports.numbers = numbers;
- /***/ }),
- /***/ "./packages/mdc-tab-bar/foundation.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-tab-bar/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-bar/constants.ts");
- var ACCEPTABLE_KEYS = new Set();
- // IE11 has no support for new Set with iterable so we need to initialize this by hand
- ACCEPTABLE_KEYS.add(constants_1.strings.ARROW_LEFT_KEY);
- ACCEPTABLE_KEYS.add(constants_1.strings.ARROW_RIGHT_KEY);
- ACCEPTABLE_KEYS.add(constants_1.strings.END_KEY);
- ACCEPTABLE_KEYS.add(constants_1.strings.HOME_KEY);
- ACCEPTABLE_KEYS.add(constants_1.strings.ENTER_KEY);
- ACCEPTABLE_KEYS.add(constants_1.strings.SPACE_KEY);
- var KEYCODE_MAP = new Map();
- // IE11 has no support for new Map with iterable so we need to initialize this by hand
- KEYCODE_MAP.set(constants_1.numbers.ARROW_LEFT_KEYCODE, constants_1.strings.ARROW_LEFT_KEY);
- KEYCODE_MAP.set(constants_1.numbers.ARROW_RIGHT_KEYCODE, constants_1.strings.ARROW_RIGHT_KEY);
- KEYCODE_MAP.set(constants_1.numbers.END_KEYCODE, constants_1.strings.END_KEY);
- KEYCODE_MAP.set(constants_1.numbers.HOME_KEYCODE, constants_1.strings.HOME_KEY);
- KEYCODE_MAP.set(constants_1.numbers.ENTER_KEYCODE, constants_1.strings.ENTER_KEY);
- KEYCODE_MAP.set(constants_1.numbers.SPACE_KEYCODE, constants_1.strings.SPACE_KEY);
- var MDCTabBarFoundation = /** @class */function (_super) {
- __extends(MDCTabBarFoundation, _super);
- function MDCTabBarFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCTabBarFoundation.defaultAdapter, adapter)) || this;
- _this.useAutomaticActivation_ = false;
- return _this;
- }
- Object.defineProperty(MDCTabBarFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabBarFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabBarFoundation, "defaultAdapter", {
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- scrollTo: function scrollTo() {
- return undefined;
- },
- incrementScroll: function incrementScroll() {
- return undefined;
- },
- getScrollPosition: function getScrollPosition() {
- return 0;
- },
- getScrollContentWidth: function getScrollContentWidth() {
- return 0;
- },
- getOffsetWidth: function getOffsetWidth() {
- return 0;
- },
- isRTL: function isRTL() {
- return false;
- },
- setActiveTab: function setActiveTab() {
- return undefined;
- },
- activateTabAtIndex: function activateTabAtIndex() {
- return undefined;
- },
- deactivateTabAtIndex: function deactivateTabAtIndex() {
- return undefined;
- },
- focusTabAtIndex: function focusTabAtIndex() {
- return undefined;
- },
- getTabIndicatorClientRectAtIndex: function getTabIndicatorClientRectAtIndex() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- getTabDimensionsAtIndex: function getTabDimensionsAtIndex() {
- return { rootLeft: 0, rootRight: 0, contentLeft: 0, contentRight: 0 };
- },
- getPreviousActiveTabIndex: function getPreviousActiveTabIndex() {
- return -1;
- },
- getFocusedTabIndex: function getFocusedTabIndex() {
- return -1;
- },
- getIndexOfTabById: function getIndexOfTabById() {
- return -1;
- },
- getTabListLength: function getTabListLength() {
- return 0;
- },
- notifyTabActivated: function notifyTabActivated() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Switches between automatic and manual activation modes.
- * See https://www.w3.org/TR/wai-aria-practices/#tabpanel for examples.
- */
- MDCTabBarFoundation.prototype.setUseAutomaticActivation = function (useAutomaticActivation) {
- this.useAutomaticActivation_ = useAutomaticActivation;
- };
- MDCTabBarFoundation.prototype.activateTab = function (index) {
- var previousActiveIndex = this.adapter_.getPreviousActiveTabIndex();
- if (!this.indexIsInRange_(index) || index === previousActiveIndex) {
- return;
- }
- var previousClientRect;
- if (previousActiveIndex !== -1) {
- this.adapter_.deactivateTabAtIndex(previousActiveIndex);
- previousClientRect = this.adapter_.getTabIndicatorClientRectAtIndex(previousActiveIndex);
- }
- this.adapter_.activateTabAtIndex(index, previousClientRect);
- this.scrollIntoView(index);
- this.adapter_.notifyTabActivated(index);
- };
- MDCTabBarFoundation.prototype.handleKeyDown = function (evt) {
- // Get the key from the event
- var key = this.getKeyFromEvent_(evt);
- // Early exit if the event key isn't one of the keyboard navigation keys
- if (key === undefined) {
- return;
- }
- // Prevent default behavior for movement keys, but not for activation keys, since :active is used to apply ripple
- if (!this.isActivationKey_(key)) {
- evt.preventDefault();
- }
- if (this.useAutomaticActivation_) {
- if (this.isActivationKey_(key)) {
- return;
- }
- var index = this.determineTargetFromKey_(this.adapter_.getPreviousActiveTabIndex(), key);
- this.adapter_.setActiveTab(index);
- this.scrollIntoView(index);
- } else {
- var focusedTabIndex = this.adapter_.getFocusedTabIndex();
- if (this.isActivationKey_(key)) {
- this.adapter_.setActiveTab(focusedTabIndex);
- } else {
- var index = this.determineTargetFromKey_(focusedTabIndex, key);
- this.adapter_.focusTabAtIndex(index);
- this.scrollIntoView(index);
- }
- }
- };
- /**
- * Handles the MDCTab:interacted event
- */
- MDCTabBarFoundation.prototype.handleTabInteraction = function (evt) {
- this.adapter_.setActiveTab(this.adapter_.getIndexOfTabById(evt.detail.tabId));
- };
- /**
- * Scrolls the tab at the given index into view
- * @param index The tab index to make visible
- */
- MDCTabBarFoundation.prototype.scrollIntoView = function (index) {
- // Early exit if the index is out of range
- if (!this.indexIsInRange_(index)) {
- return;
- }
- // Always scroll to 0 if scrolling to the 0th index
- if (index === 0) {
- return this.adapter_.scrollTo(0);
- }
- // Always scroll to the max value if scrolling to the Nth index
- // MDCTabScroller.scrollTo() will never scroll past the max possible value
- if (index === this.adapter_.getTabListLength() - 1) {
- return this.adapter_.scrollTo(this.adapter_.getScrollContentWidth());
- }
- if (this.isRTL_()) {
- return this.scrollIntoViewRTL_(index);
- }
- this.scrollIntoView_(index);
- };
- /**
- * Private method for determining the index of the destination tab based on what key was pressed
- * @param origin The original index from which to determine the destination
- * @param key The name of the key
- */
- MDCTabBarFoundation.prototype.determineTargetFromKey_ = function (origin, key) {
- var isRTL = this.isRTL_();
- var maxIndex = this.adapter_.getTabListLength() - 1;
- var shouldGoToEnd = key === constants_1.strings.END_KEY;
- var shouldDecrement = key === constants_1.strings.ARROW_LEFT_KEY && !isRTL || key === constants_1.strings.ARROW_RIGHT_KEY && isRTL;
- var shouldIncrement = key === constants_1.strings.ARROW_RIGHT_KEY && !isRTL || key === constants_1.strings.ARROW_LEFT_KEY && isRTL;
- var index = origin;
- if (shouldGoToEnd) {
- index = maxIndex;
- } else if (shouldDecrement) {
- index -= 1;
- } else if (shouldIncrement) {
- index += 1;
- } else {
- index = 0;
- }
- if (index < 0) {
- index = maxIndex;
- } else if (index > maxIndex) {
- index = 0;
- }
- return index;
- };
- /**
- * Calculates the scroll increment that will make the tab at the given index visible
- * @param index The index of the tab
- * @param nextIndex The index of the next tab
- * @param scrollPosition The current scroll position
- * @param barWidth The width of the Tab Bar
- */
- MDCTabBarFoundation.prototype.calculateScrollIncrement_ = function (index, nextIndex, scrollPosition, barWidth) {
- var nextTabDimensions = this.adapter_.getTabDimensionsAtIndex(nextIndex);
- var relativeContentLeft = nextTabDimensions.contentLeft - scrollPosition - barWidth;
- var relativeContentRight = nextTabDimensions.contentRight - scrollPosition;
- var leftIncrement = relativeContentRight - constants_1.numbers.EXTRA_SCROLL_AMOUNT;
- var rightIncrement = relativeContentLeft + constants_1.numbers.EXTRA_SCROLL_AMOUNT;
- if (nextIndex < index) {
- return Math.min(leftIncrement, 0);
- }
- return Math.max(rightIncrement, 0);
- };
- /**
- * Calculates the scroll increment that will make the tab at the given index visible in RTL
- * @param index The index of the tab
- * @param nextIndex The index of the next tab
- * @param scrollPosition The current scroll position
- * @param barWidth The width of the Tab Bar
- * @param scrollContentWidth The width of the scroll content
- */
- MDCTabBarFoundation.prototype.calculateScrollIncrementRTL_ = function (index, nextIndex, scrollPosition, barWidth, scrollContentWidth) {
- var nextTabDimensions = this.adapter_.getTabDimensionsAtIndex(nextIndex);
- var relativeContentLeft = scrollContentWidth - nextTabDimensions.contentLeft - scrollPosition;
- var relativeContentRight = scrollContentWidth - nextTabDimensions.contentRight - scrollPosition - barWidth;
- var leftIncrement = relativeContentRight + constants_1.numbers.EXTRA_SCROLL_AMOUNT;
- var rightIncrement = relativeContentLeft - constants_1.numbers.EXTRA_SCROLL_AMOUNT;
- if (nextIndex > index) {
- return Math.max(leftIncrement, 0);
- }
- return Math.min(rightIncrement, 0);
- };
- /**
- * Determines the index of the adjacent tab closest to either edge of the Tab Bar
- * @param index The index of the tab
- * @param tabDimensions The dimensions of the tab
- * @param scrollPosition The current scroll position
- * @param barWidth The width of the tab bar
- */
- MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdge_ = function (index, tabDimensions, scrollPosition, barWidth) {
- /**
- * Tabs are laid out in the Tab Scroller like this:
- *
- * Scroll Position
- * +---+
- * | | Bar Width
- * | +-----------------------------------+
- * | | |
- * | V V
- * | +-----------------------------------+
- * V | Tab Scroller |
- * +------------+--------------+-------------------+
- * | Tab | Tab | Tab |
- * +------------+--------------+-------------------+
- * | |
- * +-----------------------------------+
- *
- * To determine the next adjacent index, we look at the Tab root left and
- * Tab root right, both relative to the scroll position. If the Tab root
- * left is less than 0, then we know it's out of view to the left. If the
- * Tab root right minus the bar width is greater than 0, we know the Tab is
- * out of view to the right. From there, we either increment or decrement
- * the index.
- */
- var relativeRootLeft = tabDimensions.rootLeft - scrollPosition;
- var relativeRootRight = tabDimensions.rootRight - scrollPosition - barWidth;
- var relativeRootDelta = relativeRootLeft + relativeRootRight;
- var leftEdgeIsCloser = relativeRootLeft < 0 || relativeRootDelta < 0;
- var rightEdgeIsCloser = relativeRootRight > 0 || relativeRootDelta > 0;
- if (leftEdgeIsCloser) {
- return index - 1;
- }
- if (rightEdgeIsCloser) {
- return index + 1;
- }
- return -1;
- };
- /**
- * Determines the index of the adjacent tab closest to either edge of the Tab Bar in RTL
- * @param index The index of the tab
- * @param tabDimensions The dimensions of the tab
- * @param scrollPosition The current scroll position
- * @param barWidth The width of the tab bar
- * @param scrollContentWidth The width of the scroller content
- */
- MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdgeRTL_ = function (index, tabDimensions, scrollPosition, barWidth, scrollContentWidth) {
- var rootLeft = scrollContentWidth - tabDimensions.rootLeft - barWidth - scrollPosition;
- var rootRight = scrollContentWidth - tabDimensions.rootRight - scrollPosition;
- var rootDelta = rootLeft + rootRight;
- var leftEdgeIsCloser = rootLeft > 0 || rootDelta > 0;
- var rightEdgeIsCloser = rootRight < 0 || rootDelta < 0;
- if (leftEdgeIsCloser) {
- return index + 1;
- }
- if (rightEdgeIsCloser) {
- return index - 1;
- }
- return -1;
- };
- /**
- * Returns the key associated with a keydown event
- * @param evt The keydown event
- */
- MDCTabBarFoundation.prototype.getKeyFromEvent_ = function (evt) {
- if (ACCEPTABLE_KEYS.has(evt.key)) {
- return evt.key;
- }
- return KEYCODE_MAP.get(evt.keyCode);
- };
- MDCTabBarFoundation.prototype.isActivationKey_ = function (key) {
- return key === constants_1.strings.SPACE_KEY || key === constants_1.strings.ENTER_KEY;
- };
- /**
- * Returns whether a given index is inclusively between the ends
- * @param index The index to test
- */
- MDCTabBarFoundation.prototype.indexIsInRange_ = function (index) {
- return index >= 0 && index < this.adapter_.getTabListLength();
- };
- /**
- * Returns the view's RTL property
- */
- MDCTabBarFoundation.prototype.isRTL_ = function () {
- return this.adapter_.isRTL();
- };
- /**
- * Scrolls the tab at the given index into view for left-to-right user agents.
- * @param index The index of the tab to scroll into view
- */
- MDCTabBarFoundation.prototype.scrollIntoView_ = function (index) {
- var scrollPosition = this.adapter_.getScrollPosition();
- var barWidth = this.adapter_.getOffsetWidth();
- var tabDimensions = this.adapter_.getTabDimensionsAtIndex(index);
- var nextIndex = this.findAdjacentTabIndexClosestToEdge_(index, tabDimensions, scrollPosition, barWidth);
- if (!this.indexIsInRange_(nextIndex)) {
- return;
- }
- var scrollIncrement = this.calculateScrollIncrement_(index, nextIndex, scrollPosition, barWidth);
- this.adapter_.incrementScroll(scrollIncrement);
- };
- /**
- * Scrolls the tab at the given index into view in RTL
- * @param index The tab index to make visible
- */
- MDCTabBarFoundation.prototype.scrollIntoViewRTL_ = function (index) {
- var scrollPosition = this.adapter_.getScrollPosition();
- var barWidth = this.adapter_.getOffsetWidth();
- var tabDimensions = this.adapter_.getTabDimensionsAtIndex(index);
- var scrollWidth = this.adapter_.getScrollContentWidth();
- var nextIndex = this.findAdjacentTabIndexClosestToEdgeRTL_(index, tabDimensions, scrollPosition, barWidth, scrollWidth);
- if (!this.indexIsInRange_(nextIndex)) {
- return;
- }
- var scrollIncrement = this.calculateScrollIncrementRTL_(index, nextIndex, scrollPosition, barWidth, scrollWidth);
- this.adapter_.incrementScroll(scrollIncrement);
- };
- return MDCTabBarFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTabBarFoundation = MDCTabBarFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabBarFoundation;
- /***/ }),
- /***/ "./packages/mdc-tab-bar/index.ts":
- /*!***************************************!*\
- !*** ./packages/mdc-tab-bar/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab-bar/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-bar/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-bar/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-tab-indicator/component.ts":
- /*!*************************************************!*\
- !*** ./packages/mdc-tab-indicator/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var fading_foundation_1 = __webpack_require__(/*! ./fading-foundation */ "./packages/mdc-tab-indicator/fading-foundation.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
- var sliding_foundation_1 = __webpack_require__(/*! ./sliding-foundation */ "./packages/mdc-tab-indicator/sliding-foundation.ts");
- var MDCTabIndicator = /** @class */function (_super) {
- __extends(MDCTabIndicator, _super);
- function MDCTabIndicator() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTabIndicator.attachTo = function (root) {
- return new MDCTabIndicator(root);
- };
- MDCTabIndicator.prototype.initialize = function () {
- this.content_ = this.root_.querySelector(foundation_1.MDCTabIndicatorFoundation.strings.CONTENT_SELECTOR);
- };
- MDCTabIndicator.prototype.computeContentClientRect = function () {
- return this.foundation_.computeContentClientRect();
- };
- MDCTabIndicator.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) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- computeContentClientRect: function computeContentClientRect() {
- return _this.content_.getBoundingClientRect();
- },
- setContentStyleProperty: function setContentStyleProperty(prop, value) {
- return _this.content_.style.setProperty(prop, value);
- }
- };
- // tslint:enable:object-literal-sort-keys
- if (this.root_.classList.contains(foundation_1.MDCTabIndicatorFoundation.cssClasses.FADE)) {
- return new fading_foundation_1.MDCFadingTabIndicatorFoundation(adapter);
- }
- // Default to the sliding indicator
- return new sliding_foundation_1.MDCSlidingTabIndicatorFoundation(adapter);
- };
- MDCTabIndicator.prototype.activate = function (previousIndicatorClientRect) {
- this.foundation_.activate(previousIndicatorClientRect);
- };
- MDCTabIndicator.prototype.deactivate = function () {
- this.foundation_.deactivate();
- };
- return MDCTabIndicator;
- }(component_1.MDCComponent);
- exports.MDCTabIndicator = MDCTabIndicator;
- /***/ }),
- /***/ "./packages/mdc-tab-indicator/constants.ts":
- /*!*************************************************!*\
- !*** ./packages/mdc-tab-indicator/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 });
- var cssClasses = {
- ACTIVE: 'mdc-tab-indicator--active',
- FADE: 'mdc-tab-indicator--fade',
- NO_TRANSITION: 'mdc-tab-indicator--no-transition'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- CONTENT_SELECTOR: '.mdc-tab-indicator__content'
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-tab-indicator/fading-foundation.ts":
- /*!*********************************************************!*\
- !*** ./packages/mdc-tab-indicator/fading-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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
- /* istanbul ignore next: subclass is not a branch statement */
- var MDCFadingTabIndicatorFoundation = /** @class */function (_super) {
- __extends(MDCFadingTabIndicatorFoundation, _super);
- function MDCFadingTabIndicatorFoundation() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCFadingTabIndicatorFoundation.prototype.activate = function () {
- this.adapter_.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
- };
- MDCFadingTabIndicatorFoundation.prototype.deactivate = function () {
- this.adapter_.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
- };
- return MDCFadingTabIndicatorFoundation;
- }(foundation_1.MDCTabIndicatorFoundation);
- exports.MDCFadingTabIndicatorFoundation = MDCFadingTabIndicatorFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCFadingTabIndicatorFoundation;
- /***/ }),
- /***/ "./packages/mdc-tab-indicator/foundation.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-tab-indicator/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-indicator/constants.ts");
- var MDCTabIndicatorFoundation = /** @class */function (_super) {
- __extends(MDCTabIndicatorFoundation, _super);
- function MDCTabIndicatorFoundation(adapter) {
- return _super.call(this, __assign({}, MDCTabIndicatorFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCTabIndicatorFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabIndicatorFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabIndicatorFoundation, "defaultAdapter", {
- 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;
- },
- computeContentClientRect: function computeContentClientRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- setContentStyleProperty: function setContentStyleProperty() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCTabIndicatorFoundation.prototype.computeContentClientRect = function () {
- return this.adapter_.computeContentClientRect();
- };
- return MDCTabIndicatorFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTabIndicatorFoundation = MDCTabIndicatorFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabIndicatorFoundation;
- /***/ }),
- /***/ "./packages/mdc-tab-indicator/index.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-tab-indicator/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab-indicator/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-indicator/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts"));
- __export(__webpack_require__(/*! ./fading-foundation */ "./packages/mdc-tab-indicator/fading-foundation.ts"));
- __export(__webpack_require__(/*! ./sliding-foundation */ "./packages/mdc-tab-indicator/sliding-foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-tab-indicator/sliding-foundation.ts":
- /*!**********************************************************!*\
- !*** ./packages/mdc-tab-indicator/sliding-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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-indicator/foundation.ts");
- /* istanbul ignore next: subclass is not a branch statement */
- var MDCSlidingTabIndicatorFoundation = /** @class */function (_super) {
- __extends(MDCSlidingTabIndicatorFoundation, _super);
- function MDCSlidingTabIndicatorFoundation() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCSlidingTabIndicatorFoundation.prototype.activate = function (previousIndicatorClientRect) {
- // Early exit if no indicator is present to handle cases where an indicator
- // may be activated without a prior indicator state
- if (!previousIndicatorClientRect) {
- this.adapter_.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
- return;
- }
- // This animation uses the FLIP approach. You can read more about it at the link below:
- // https://aerotwist.com/blog/flip-your-animations/
- // Calculate the dimensions based on the dimensions of the previous indicator
- var currentClientRect = this.computeContentClientRect();
- var widthDelta = previousIndicatorClientRect.width / currentClientRect.width;
- var xPosition = previousIndicatorClientRect.left - currentClientRect.left;
- this.adapter_.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION);
- this.adapter_.setContentStyleProperty('transform', "translateX(" + xPosition + "px) scaleX(" + widthDelta + ")");
- // Force repaint before updating classes and transform to ensure the transform properly takes effect
- this.computeContentClientRect();
- this.adapter_.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION);
- this.adapter_.addClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
- this.adapter_.setContentStyleProperty('transform', '');
- };
- MDCSlidingTabIndicatorFoundation.prototype.deactivate = function () {
- this.adapter_.removeClass(foundation_1.MDCTabIndicatorFoundation.cssClasses.ACTIVE);
- };
- return MDCSlidingTabIndicatorFoundation;
- }(foundation_1.MDCTabIndicatorFoundation);
- exports.MDCSlidingTabIndicatorFoundation = MDCSlidingTabIndicatorFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCSlidingTabIndicatorFoundation;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/component.ts":
- /*!************************************************!*\
- !*** ./packages/mdc-tab-scroller/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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-tab-scroller/foundation.ts");
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-tab-scroller/util.ts"));
- var MDCTabScroller = /** @class */function (_super) {
- __extends(MDCTabScroller, _super);
- function MDCTabScroller() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTabScroller.attachTo = function (root) {
- return new MDCTabScroller(root);
- };
- MDCTabScroller.prototype.initialize = function () {
- this.area_ = this.root_.querySelector(foundation_1.MDCTabScrollerFoundation.strings.AREA_SELECTOR);
- this.content_ = this.root_.querySelector(foundation_1.MDCTabScrollerFoundation.strings.CONTENT_SELECTOR);
- };
- MDCTabScroller.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleInteraction_ = function () {
- return _this.foundation_.handleInteraction();
- };
- this.handleTransitionEnd_ = function (evt) {
- return _this.foundation_.handleTransitionEnd(evt);
- };
- this.area_.addEventListener('wheel', this.handleInteraction_, events_1.applyPassive());
- this.area_.addEventListener('touchstart', this.handleInteraction_, events_1.applyPassive());
- this.area_.addEventListener('pointerdown', this.handleInteraction_, events_1.applyPassive());
- this.area_.addEventListener('mousedown', this.handleInteraction_, events_1.applyPassive());
- this.area_.addEventListener('keydown', this.handleInteraction_, events_1.applyPassive());
- this.content_.addEventListener('transitionend', this.handleTransitionEnd_);
- };
- MDCTabScroller.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.area_.removeEventListener('wheel', this.handleInteraction_, events_1.applyPassive());
- this.area_.removeEventListener('touchstart', this.handleInteraction_, events_1.applyPassive());
- this.area_.removeEventListener('pointerdown', this.handleInteraction_, events_1.applyPassive());
- this.area_.removeEventListener('mousedown', this.handleInteraction_, events_1.applyPassive());
- this.area_.removeEventListener('keydown', this.handleInteraction_, events_1.applyPassive());
- this.content_.removeEventListener('transitionend', this.handleTransitionEnd_);
- };
- MDCTabScroller.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 = {
- eventTargetMatchesSelector: function eventTargetMatchesSelector(evtTarget, selector) {
- return ponyfill_1.matches(evtTarget, selector);
- },
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- addScrollAreaClass: function addScrollAreaClass(className) {
- return _this.area_.classList.add(className);
- },
- setScrollAreaStyleProperty: function setScrollAreaStyleProperty(prop, value) {
- return _this.area_.style.setProperty(prop, value);
- },
- setScrollContentStyleProperty: function setScrollContentStyleProperty(prop, value) {
- return _this.content_.style.setProperty(prop, value);
- },
- getScrollContentStyleValue: function getScrollContentStyleValue(propName) {
- return window.getComputedStyle(_this.content_).getPropertyValue(propName);
- },
- setScrollAreaScrollLeft: function setScrollAreaScrollLeft(scrollX) {
- return _this.area_.scrollLeft = scrollX;
- },
- getScrollAreaScrollLeft: function getScrollAreaScrollLeft() {
- return _this.area_.scrollLeft;
- },
- getScrollContentOffsetWidth: function getScrollContentOffsetWidth() {
- return _this.content_.offsetWidth;
- },
- getScrollAreaOffsetWidth: function getScrollAreaOffsetWidth() {
- return _this.area_.offsetWidth;
- },
- computeScrollAreaClientRect: function computeScrollAreaClientRect() {
- return _this.area_.getBoundingClientRect();
- },
- computeScrollContentClientRect: function computeScrollContentClientRect() {
- return _this.content_.getBoundingClientRect();
- },
- computeHorizontalScrollbarHeight: function computeHorizontalScrollbarHeight() {
- return util.computeHorizontalScrollbarHeight(document);
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCTabScrollerFoundation(adapter);
- };
- /**
- * Returns the current visual scroll position
- */
- MDCTabScroller.prototype.getScrollPosition = function () {
- return this.foundation_.getScrollPosition();
- };
- /**
- * Returns the width of the scroll content
- */
- MDCTabScroller.prototype.getScrollContentWidth = function () {
- return this.content_.offsetWidth;
- };
- /**
- * Increments the scroll value by the given amount
- * @param scrollXIncrement The pixel value by which to increment the scroll value
- */
- MDCTabScroller.prototype.incrementScroll = function (scrollXIncrement) {
- this.foundation_.incrementScroll(scrollXIncrement);
- };
- /**
- * Scrolls to the given pixel position
- * @param scrollX The pixel value to scroll to
- */
- MDCTabScroller.prototype.scrollTo = function (scrollX) {
- this.foundation_.scrollTo(scrollX);
- };
- return MDCTabScroller;
- }(component_1.MDCComponent);
- exports.MDCTabScroller = MDCTabScroller;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/constants.ts":
- /*!************************************************!*\
- !*** ./packages/mdc-tab-scroller/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 });
- var cssClasses = {
- ANIMATING: 'mdc-tab-scroller--animating',
- SCROLL_AREA_SCROLL: 'mdc-tab-scroller__scroll-area--scroll',
- SCROLL_TEST: 'mdc-tab-scroller__test'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- AREA_SELECTOR: '.mdc-tab-scroller__scroll-area',
- CONTENT_SELECTOR: '.mdc-tab-scroller__scroll-content'
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/foundation.ts":
- /*!*************************************************!*\
- !*** ./packages/mdc-tab-scroller/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts");
- var rtl_default_scroller_1 = __webpack_require__(/*! ./rtl-default-scroller */ "./packages/mdc-tab-scroller/rtl-default-scroller.ts");
- var rtl_negative_scroller_1 = __webpack_require__(/*! ./rtl-negative-scroller */ "./packages/mdc-tab-scroller/rtl-negative-scroller.ts");
- var rtl_reverse_scroller_1 = __webpack_require__(/*! ./rtl-reverse-scroller */ "./packages/mdc-tab-scroller/rtl-reverse-scroller.ts");
- var MDCTabScrollerFoundation = /** @class */function (_super) {
- __extends(MDCTabScrollerFoundation, _super);
- function MDCTabScrollerFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCTabScrollerFoundation.defaultAdapter, adapter)) || this;
- /**
- * Controls whether we should handle the transitionend and interaction events during the animation.
- */
- _this.isAnimating_ = false;
- return _this;
- }
- Object.defineProperty(MDCTabScrollerFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabScrollerFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabScrollerFoundation, "defaultAdapter", {
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- eventTargetMatchesSelector: function eventTargetMatchesSelector() {
- return false;
- },
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- addScrollAreaClass: function addScrollAreaClass() {
- return undefined;
- },
- setScrollAreaStyleProperty: function setScrollAreaStyleProperty() {
- return undefined;
- },
- setScrollContentStyleProperty: function setScrollContentStyleProperty() {
- return undefined;
- },
- getScrollContentStyleValue: function getScrollContentStyleValue() {
- return '';
- },
- setScrollAreaScrollLeft: function setScrollAreaScrollLeft() {
- return undefined;
- },
- getScrollAreaScrollLeft: function getScrollAreaScrollLeft() {
- return 0;
- },
- getScrollContentOffsetWidth: function getScrollContentOffsetWidth() {
- return 0;
- },
- getScrollAreaOffsetWidth: function getScrollAreaOffsetWidth() {
- return 0;
- },
- computeScrollAreaClientRect: function computeScrollAreaClientRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- computeScrollContentClientRect: function computeScrollContentClientRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- computeHorizontalScrollbarHeight: function computeHorizontalScrollbarHeight() {
- return 0;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCTabScrollerFoundation.prototype.init = function () {
- // Compute horizontal scrollbar height on scroller with overflow initially hidden, then update overflow to scroll
- // and immediately adjust bottom margin to avoid the scrollbar initially appearing before JS runs.
- var horizontalScrollbarHeight = this.adapter_.computeHorizontalScrollbarHeight();
- this.adapter_.setScrollAreaStyleProperty('margin-bottom', -horizontalScrollbarHeight + 'px');
- this.adapter_.addScrollAreaClass(MDCTabScrollerFoundation.cssClasses.SCROLL_AREA_SCROLL);
- };
- /**
- * Computes the current visual scroll position
- */
- MDCTabScrollerFoundation.prototype.getScrollPosition = function () {
- if (this.isRTL_()) {
- return this.computeCurrentScrollPositionRTL_();
- }
- var currentTranslateX = this.calculateCurrentTranslateX_();
- var scrollLeft = this.adapter_.getScrollAreaScrollLeft();
- return scrollLeft - currentTranslateX;
- };
- /**
- * Handles interaction events that occur during transition
- */
- MDCTabScrollerFoundation.prototype.handleInteraction = function () {
- // Early exit if we aren't animating
- if (!this.isAnimating_) {
- return;
- }
- // Prevent other event listeners from handling this event
- this.stopScrollAnimation_();
- };
- /**
- * Handles the transitionend event
- */
- MDCTabScrollerFoundation.prototype.handleTransitionEnd = function (evt) {
- // Early exit if we aren't animating or the event was triggered by a different element.
- var evtTarget = evt.target;
- if (!this.isAnimating_ || !this.adapter_.eventTargetMatchesSelector(evtTarget, MDCTabScrollerFoundation.strings.CONTENT_SELECTOR)) {
- return;
- }
- this.isAnimating_ = false;
- this.adapter_.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
- };
- /**
- * Increment the scroll value by the scrollXIncrement using animation.
- * @param scrollXIncrement The value by which to increment the scroll position
- */
- MDCTabScrollerFoundation.prototype.incrementScroll = function (scrollXIncrement) {
- // Early exit for non-operational increment values
- if (scrollXIncrement === 0) {
- return;
- }
- this.animate_(this.getIncrementScrollOperation_(scrollXIncrement));
- };
- /**
- * Increment the scroll value by the scrollXIncrement without animation.
- * @param scrollXIncrement The value by which to increment the scroll position
- */
- MDCTabScrollerFoundation.prototype.incrementScrollImmediate = function (scrollXIncrement) {
- // Early exit for non-operational increment values
- if (scrollXIncrement === 0) {
- return;
- }
- var operation = this.getIncrementScrollOperation_(scrollXIncrement);
- if (operation.scrollDelta === 0) {
- return;
- }
- this.stopScrollAnimation_();
- this.adapter_.setScrollAreaScrollLeft(operation.finalScrollPosition);
- };
- /**
- * Scrolls to the given scrollX value
- */
- MDCTabScrollerFoundation.prototype.scrollTo = function (scrollX) {
- if (this.isRTL_()) {
- return this.scrollToRTL_(scrollX);
- }
- this.scrollTo_(scrollX);
- };
- /**
- * @return Browser-specific {@link MDCTabScrollerRTL} instance.
- */
- MDCTabScrollerFoundation.prototype.getRTLScroller = function () {
- if (!this.rtlScrollerInstance_) {
- this.rtlScrollerInstance_ = this.rtlScrollerFactory_();
- }
- return this.rtlScrollerInstance_;
- };
- /**
- * @return translateX value from a CSS matrix transform function string.
- */
- MDCTabScrollerFoundation.prototype.calculateCurrentTranslateX_ = function () {
- var transformValue = this.adapter_.getScrollContentStyleValue('transform');
- // Early exit if no transform is present
- if (transformValue === 'none') {
- return 0;
- }
- // The transform value comes back as a matrix transformation in the form
- // of `matrix(a, b, c, d, tx, ty)`. We only care about tx (translateX) so
- // we're going to grab all the parenthesized values, strip out tx, and
- // parse it.
- var match = /\((.+?)\)/.exec(transformValue);
- if (!match) {
- return 0;
- }
- var matrixParams = match[1];
- // tslint:disable-next-line:ban-ts-ignore "Unused vars" should be a linter warning, not a compiler error.
- // @ts-ignore These unused variables should retain their semantic names for clarity.
- var _a = __read(matrixParams.split(','), 6),
- a = _a[0],
- b = _a[1],
- c = _a[2],
- d = _a[3],
- tx = _a[4],
- ty = _a[5];
- return parseFloat(tx); // tslint:disable-line:ban
- };
- /**
- * Calculates a safe scroll value that is > 0 and < the max scroll value
- * @param scrollX The distance to scroll
- */
- MDCTabScrollerFoundation.prototype.clampScrollValue_ = function (scrollX) {
- var edges = this.calculateScrollEdges_();
- return Math.min(Math.max(edges.left, scrollX), edges.right);
- };
- MDCTabScrollerFoundation.prototype.computeCurrentScrollPositionRTL_ = function () {
- var translateX = this.calculateCurrentTranslateX_();
- return this.getRTLScroller().getScrollPositionRTL(translateX);
- };
- MDCTabScrollerFoundation.prototype.calculateScrollEdges_ = function () {
- var contentWidth = this.adapter_.getScrollContentOffsetWidth();
- var rootWidth = this.adapter_.getScrollAreaOffsetWidth();
- return {
- left: 0,
- right: contentWidth - rootWidth
- };
- };
- /**
- * Internal scroll method
- * @param scrollX The new scroll position
- */
- MDCTabScrollerFoundation.prototype.scrollTo_ = function (scrollX) {
- var currentScrollX = this.getScrollPosition();
- var safeScrollX = this.clampScrollValue_(scrollX);
- var scrollDelta = safeScrollX - currentScrollX;
- this.animate_({
- finalScrollPosition: safeScrollX,
- scrollDelta: scrollDelta
- });
- };
- /**
- * Internal RTL scroll method
- * @param scrollX The new scroll position
- */
- MDCTabScrollerFoundation.prototype.scrollToRTL_ = function (scrollX) {
- var animation = this.getRTLScroller().scrollToRTL(scrollX);
- this.animate_(animation);
- };
- /**
- * Internal method to compute the increment scroll operation values.
- * @param scrollX The desired scroll position increment
- * @return MDCTabScrollerAnimation with the sanitized values for performing the scroll operation.
- */
- MDCTabScrollerFoundation.prototype.getIncrementScrollOperation_ = function (scrollX) {
- if (this.isRTL_()) {
- return this.getRTLScroller().incrementScrollRTL(scrollX);
- }
- var currentScrollX = this.getScrollPosition();
- var targetScrollX = scrollX + currentScrollX;
- var safeScrollX = this.clampScrollValue_(targetScrollX);
- var scrollDelta = safeScrollX - currentScrollX;
- return {
- finalScrollPosition: safeScrollX,
- scrollDelta: scrollDelta
- };
- };
- /**
- * Animates the tab scrolling
- * @param animation The animation to apply
- */
- MDCTabScrollerFoundation.prototype.animate_ = function (animation) {
- var _this = this;
- // Early exit if translateX is 0, which means there's no animation to perform
- if (animation.scrollDelta === 0) {
- return;
- }
- this.stopScrollAnimation_();
- // This animation uses the FLIP approach.
- // Read more here: https://aerotwist.com/blog/flip-your-animations/
- this.adapter_.setScrollAreaScrollLeft(animation.finalScrollPosition);
- this.adapter_.setScrollContentStyleProperty('transform', "translateX(" + animation.scrollDelta + "px)");
- // Force repaint
- this.adapter_.computeScrollAreaClientRect();
- requestAnimationFrame(function () {
- _this.adapter_.addClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
- _this.adapter_.setScrollContentStyleProperty('transform', 'none');
- });
- this.isAnimating_ = true;
- };
- /**
- * Stops scroll animation
- */
- MDCTabScrollerFoundation.prototype.stopScrollAnimation_ = function () {
- this.isAnimating_ = false;
- var currentScrollPosition = this.getAnimatingScrollPosition_();
- this.adapter_.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
- this.adapter_.setScrollContentStyleProperty('transform', 'translateX(0px)');
- this.adapter_.setScrollAreaScrollLeft(currentScrollPosition);
- };
- /**
- * Gets the current scroll position during animation
- */
- MDCTabScrollerFoundation.prototype.getAnimatingScrollPosition_ = function () {
- var currentTranslateX = this.calculateCurrentTranslateX_();
- var scrollLeft = this.adapter_.getScrollAreaScrollLeft();
- if (this.isRTL_()) {
- return this.getRTLScroller().getAnimatingScrollPosition(scrollLeft, currentTranslateX);
- }
- return scrollLeft - currentTranslateX;
- };
- /**
- * Determines the RTL Scroller to use
- */
- MDCTabScrollerFoundation.prototype.rtlScrollerFactory_ = function () {
- // Browsers have three different implementations of scrollLeft in RTL mode,
- // dependent on the browser. The behavior is based off the max LTR
- // scrollLeft value and 0.
- //
- // * Default scrolling in RTL *
- // - Left-most value: 0
- // - Right-most value: Max LTR scrollLeft value
- //
- // * Negative scrolling in RTL *
- // - Left-most value: Negated max LTR scrollLeft value
- // - Right-most value: 0
- //
- // * Reverse scrolling in RTL *
- // - Left-most value: Max LTR scrollLeft value
- // - Right-most value: 0
- //
- // We use those principles below to determine which RTL scrollLeft
- // behavior is implemented in the current browser.
- var initialScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- this.adapter_.setScrollAreaScrollLeft(initialScrollLeft - 1);
- var newScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- // If the newScrollLeft value is negative,then we know that the browser has
- // implemented negative RTL scrolling, since all other implementations have
- // only positive values.
- if (newScrollLeft < 0) {
- // Undo the scrollLeft test check
- this.adapter_.setScrollAreaScrollLeft(initialScrollLeft);
- return new rtl_negative_scroller_1.MDCTabScrollerRTLNegative(this.adapter_);
- }
- var rootClientRect = this.adapter_.computeScrollAreaClientRect();
- var contentClientRect = this.adapter_.computeScrollContentClientRect();
- var rightEdgeDelta = Math.round(contentClientRect.right - rootClientRect.right);
- // Undo the scrollLeft test check
- this.adapter_.setScrollAreaScrollLeft(initialScrollLeft);
- // By calculating the clientRect of the root element and the clientRect of
- // the content element, we can determine how much the scroll value changed
- // when we performed the scrollLeft subtraction above.
- if (rightEdgeDelta === newScrollLeft) {
- return new rtl_reverse_scroller_1.MDCTabScrollerRTLReverse(this.adapter_);
- }
- return new rtl_default_scroller_1.MDCTabScrollerRTLDefault(this.adapter_);
- };
- MDCTabScrollerFoundation.prototype.isRTL_ = function () {
- return this.adapter_.getScrollContentStyleValue('direction') === 'rtl';
- };
- return MDCTabScrollerFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTabScrollerFoundation = MDCTabScrollerFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabScrollerFoundation;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/index.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-tab-scroller/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-tab-scroller/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab-scroller/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-scroller/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/rtl-default-scroller.ts":
- /*!***********************************************************!*\
- !*** ./packages/mdc-tab-scroller/rtl-default-scroller.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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
- var MDCTabScrollerRTLDefault = /** @class */function (_super) {
- __extends(MDCTabScrollerRTLDefault, _super);
- function MDCTabScrollerRTLDefault() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTabScrollerRTLDefault.prototype.getScrollPositionRTL = function () {
- var currentScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- var right = this.calculateScrollEdges_().right;
- // Scroll values on most browsers are ints instead of floats so we round
- return Math.round(right - currentScrollLeft);
- };
- MDCTabScrollerRTLDefault.prototype.scrollToRTL = function (scrollX) {
- var edges = this.calculateScrollEdges_();
- var currentScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(edges.right - scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: clampedScrollLeft - currentScrollLeft
- };
- };
- MDCTabScrollerRTLDefault.prototype.incrementScrollRTL = function (scrollX) {
- var currentScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft - scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: clampedScrollLeft - currentScrollLeft
- };
- };
- MDCTabScrollerRTLDefault.prototype.getAnimatingScrollPosition = function (scrollX) {
- return scrollX;
- };
- MDCTabScrollerRTLDefault.prototype.calculateScrollEdges_ = function () {
- var contentWidth = this.adapter_.getScrollContentOffsetWidth();
- var rootWidth = this.adapter_.getScrollAreaOffsetWidth();
- return {
- left: 0,
- right: contentWidth - rootWidth
- };
- };
- MDCTabScrollerRTLDefault.prototype.clampScrollValue_ = function (scrollX) {
- var edges = this.calculateScrollEdges_();
- return Math.min(Math.max(edges.left, scrollX), edges.right);
- };
- return MDCTabScrollerRTLDefault;
- }(rtl_scroller_1.MDCTabScrollerRTL);
- exports.MDCTabScrollerRTLDefault = MDCTabScrollerRTLDefault;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabScrollerRTLDefault;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/rtl-negative-scroller.ts":
- /*!************************************************************!*\
- !*** ./packages/mdc-tab-scroller/rtl-negative-scroller.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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
- var MDCTabScrollerRTLNegative = /** @class */function (_super) {
- __extends(MDCTabScrollerRTLNegative, _super);
- function MDCTabScrollerRTLNegative() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTabScrollerRTLNegative.prototype.getScrollPositionRTL = function (translateX) {
- var currentScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- return Math.round(translateX - currentScrollLeft);
- };
- MDCTabScrollerRTLNegative.prototype.scrollToRTL = function (scrollX) {
- var currentScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(-scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: clampedScrollLeft - currentScrollLeft
- };
- };
- MDCTabScrollerRTLNegative.prototype.incrementScrollRTL = function (scrollX) {
- var currentScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft - scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: clampedScrollLeft - currentScrollLeft
- };
- };
- MDCTabScrollerRTLNegative.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
- return scrollX - translateX;
- };
- MDCTabScrollerRTLNegative.prototype.calculateScrollEdges_ = function () {
- var contentWidth = this.adapter_.getScrollContentOffsetWidth();
- var rootWidth = this.adapter_.getScrollAreaOffsetWidth();
- return {
- left: rootWidth - contentWidth,
- right: 0
- };
- };
- MDCTabScrollerRTLNegative.prototype.clampScrollValue_ = function (scrollX) {
- var edges = this.calculateScrollEdges_();
- return Math.max(Math.min(edges.right, scrollX), edges.left);
- };
- return MDCTabScrollerRTLNegative;
- }(rtl_scroller_1.MDCTabScrollerRTL);
- exports.MDCTabScrollerRTLNegative = MDCTabScrollerRTLNegative;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabScrollerRTLNegative;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/rtl-reverse-scroller.ts":
- /*!***********************************************************!*\
- !*** ./packages/mdc-tab-scroller/rtl-reverse-scroller.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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
- var MDCTabScrollerRTLReverse = /** @class */function (_super) {
- __extends(MDCTabScrollerRTLReverse, _super);
- function MDCTabScrollerRTLReverse() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTabScrollerRTLReverse.prototype.getScrollPositionRTL = function (translateX) {
- var currentScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- // Scroll values on most browsers are ints instead of floats so we round
- return Math.round(currentScrollLeft - translateX);
- };
- MDCTabScrollerRTLReverse.prototype.scrollToRTL = function (scrollX) {
- var currentScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: currentScrollLeft - clampedScrollLeft
- };
- };
- MDCTabScrollerRTLReverse.prototype.incrementScrollRTL = function (scrollX) {
- var currentScrollLeft = this.adapter_.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft + scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: currentScrollLeft - clampedScrollLeft
- };
- };
- MDCTabScrollerRTLReverse.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
- return scrollX + translateX;
- };
- MDCTabScrollerRTLReverse.prototype.calculateScrollEdges_ = function () {
- var contentWidth = this.adapter_.getScrollContentOffsetWidth();
- var rootWidth = this.adapter_.getScrollAreaOffsetWidth();
- return {
- left: contentWidth - rootWidth,
- right: 0
- };
- };
- MDCTabScrollerRTLReverse.prototype.clampScrollValue_ = function (scrollX) {
- var edges = this.calculateScrollEdges_();
- return Math.min(Math.max(edges.right, scrollX), edges.left);
- };
- return MDCTabScrollerRTLReverse;
- }(rtl_scroller_1.MDCTabScrollerRTL);
- exports.MDCTabScrollerRTLReverse = MDCTabScrollerRTLReverse;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabScrollerRTLReverse;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/rtl-scroller.ts":
- /*!***************************************************!*\
- !*** ./packages/mdc-tab-scroller/rtl-scroller.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 });
- var MDCTabScrollerRTL = /** @class */function () {
- function MDCTabScrollerRTL(adapter) {
- this.adapter_ = adapter;
- }
- return MDCTabScrollerRTL;
- }();
- exports.MDCTabScrollerRTL = MDCTabScrollerRTL;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabScrollerRTL;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/util.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-tab-scroller/util.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 });
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts");
- /**
- * Stores result from computeHorizontalScrollbarHeight to avoid redundant processing.
- */
- var horizontalScrollbarHeight_;
- /**
- * Computes the height of browser-rendered horizontal scrollbars using a self-created test element.
- * May return 0 (e.g. on OS X browsers under default configuration).
- */
- function computeHorizontalScrollbarHeight(documentObj, shouldCacheResult) {
- if (shouldCacheResult === void 0) {
- shouldCacheResult = true;
- }
- if (shouldCacheResult && typeof horizontalScrollbarHeight_ !== 'undefined') {
- return horizontalScrollbarHeight_;
- }
- var el = documentObj.createElement('div');
- el.classList.add(constants_1.cssClasses.SCROLL_TEST);
- documentObj.body.appendChild(el);
- var horizontalScrollbarHeight = el.offsetHeight - el.clientHeight;
- documentObj.body.removeChild(el);
- if (shouldCacheResult) {
- horizontalScrollbarHeight_ = horizontalScrollbarHeight;
- }
- return horizontalScrollbarHeight;
- }
- exports.computeHorizontalScrollbarHeight = computeHorizontalScrollbarHeight;
- /***/ }),
- /***/ "./packages/mdc-tab/component.ts":
- /*!***************************************!*\
- !*** ./packages/mdc-tab/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var component_3 = __webpack_require__(/*! @material/tab-indicator/component */ "./packages/mdc-tab-indicator/component.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab/foundation.ts");
- var MDCTab = /** @class */function (_super) {
- __extends(MDCTab, _super);
- function MDCTab() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTab.attachTo = function (root) {
- return new MDCTab(root);
- };
- MDCTab.prototype.initialize = function (rippleFactory, tabIndicatorFactory) {
- if (rippleFactory === void 0) {
- rippleFactory = function rippleFactory(el, foundation) {
- return new component_2.MDCRipple(el, foundation);
- };
- }
- if (tabIndicatorFactory === void 0) {
- tabIndicatorFactory = function tabIndicatorFactory(el) {
- return new component_3.MDCTabIndicator(el);
- };
- }
- this.id = this.root_.id;
- var rippleSurface = this.root_.querySelector(foundation_2.MDCTabFoundation.strings.RIPPLE_SELECTOR);
- var rippleAdapter = __assign({}, component_2.MDCRipple.createAdapter(this), { addClass: function addClass(className) {
- return rippleSurface.classList.add(className);
- }, removeClass: function removeClass(className) {
- return rippleSurface.classList.remove(className);
- }, updateCssVariable: function updateCssVariable(varName, value) {
- return rippleSurface.style.setProperty(varName, value);
- } });
- var rippleFoundation = new foundation_1.MDCRippleFoundation(rippleAdapter);
- this.ripple_ = rippleFactory(this.root_, rippleFoundation);
- var tabIndicatorElement = this.root_.querySelector(foundation_2.MDCTabFoundation.strings.TAB_INDICATOR_SELECTOR);
- this.tabIndicator_ = tabIndicatorFactory(tabIndicatorElement);
- this.content_ = this.root_.querySelector(foundation_2.MDCTabFoundation.strings.CONTENT_SELECTOR);
- };
- MDCTab.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleClick_ = function () {
- return _this.foundation_.handleClick();
- };
- this.listen('click', this.handleClick_);
- };
- MDCTab.prototype.destroy = function () {
- this.unlisten('click', this.handleClick_);
- this.ripple_.destroy();
- _super.prototype.destroy.call(this);
- };
- MDCTab.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 = {
- setAttr: function setAttr(attr, value) {
- return _this.root_.setAttribute(attr, value);
- },
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- activateIndicator: function activateIndicator(previousIndicatorClientRect) {
- return _this.tabIndicator_.activate(previousIndicatorClientRect);
- },
- deactivateIndicator: function deactivateIndicator() {
- return _this.tabIndicator_.deactivate();
- },
- notifyInteracted: function notifyInteracted() {
- return _this.emit(foundation_2.MDCTabFoundation.strings.INTERACTED_EVENT, { tabId: _this.id }, true /* bubble */);
- },
- getOffsetLeft: function getOffsetLeft() {
- return _this.root_.offsetLeft;
- },
- getOffsetWidth: function getOffsetWidth() {
- return _this.root_.offsetWidth;
- },
- getContentOffsetLeft: function getContentOffsetLeft() {
- return _this.content_.offsetLeft;
- },
- getContentOffsetWidth: function getContentOffsetWidth() {
- return _this.content_.offsetWidth;
- },
- focus: function focus() {
- return _this.root_.focus();
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_2.MDCTabFoundation(adapter);
- };
- Object.defineProperty(MDCTab.prototype, "active", {
- /**
- * Getter for the active state of the tab
- */
- get: function get() {
- return this.foundation_.isActive();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTab.prototype, "focusOnActivate", {
- set: function set(focusOnActivate) {
- this.foundation_.setFocusOnActivate(focusOnActivate);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Activates the tab
- */
- MDCTab.prototype.activate = function (computeIndicatorClientRect) {
- this.foundation_.activate(computeIndicatorClientRect);
- };
- /**
- * Deactivates the tab
- */
- MDCTab.prototype.deactivate = function () {
- this.foundation_.deactivate();
- };
- /**
- * Returns the indicator's client rect
- */
- MDCTab.prototype.computeIndicatorClientRect = function () {
- return this.tabIndicator_.computeContentClientRect();
- };
- MDCTab.prototype.computeDimensions = function () {
- return this.foundation_.computeDimensions();
- };
- /**
- * Focuses the tab
- */
- MDCTab.prototype.focus = function () {
- this.root_.focus();
- };
- return MDCTab;
- }(component_1.MDCComponent);
- exports.MDCTab = MDCTab;
- /***/ }),
- /***/ "./packages/mdc-tab/constants.ts":
- /*!***************************************!*\
- !*** ./packages/mdc-tab/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 });
- var cssClasses = {
- ACTIVE: 'mdc-tab--active'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ARIA_SELECTED: 'aria-selected',
- CONTENT_SELECTOR: '.mdc-tab__content',
- INTERACTED_EVENT: 'MDCTab:interacted',
- RIPPLE_SELECTOR: '.mdc-tab__ripple',
- TABINDEX: 'tabIndex',
- TAB_INDICATOR_SELECTOR: '.mdc-tab-indicator'
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-tab/foundation.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-tab/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab/constants.ts");
- var MDCTabFoundation = /** @class */function (_super) {
- __extends(MDCTabFoundation, _super);
- function MDCTabFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCTabFoundation.defaultAdapter, adapter)) || this;
- _this.focusOnActivate_ = true;
- return _this;
- }
- Object.defineProperty(MDCTabFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabFoundation, "defaultAdapter", {
- 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;
- },
- activateIndicator: function activateIndicator() {
- return undefined;
- },
- deactivateIndicator: function deactivateIndicator() {
- return undefined;
- },
- notifyInteracted: function notifyInteracted() {
- return undefined;
- },
- getOffsetLeft: function getOffsetLeft() {
- return 0;
- },
- getOffsetWidth: function getOffsetWidth() {
- return 0;
- },
- getContentOffsetLeft: function getContentOffsetLeft() {
- return 0;
- },
- getContentOffsetWidth: function getContentOffsetWidth() {
- return 0;
- },
- focus: function focus() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCTabFoundation.prototype.handleClick = function () {
- // It's up to the parent component to keep track of the active Tab and
- // ensure we don't activate a Tab that's already active.
- this.adapter_.notifyInteracted();
- };
- MDCTabFoundation.prototype.isActive = function () {
- return this.adapter_.hasClass(constants_1.cssClasses.ACTIVE);
- };
- /**
- * Sets whether the tab should focus itself when activated
- */
- MDCTabFoundation.prototype.setFocusOnActivate = function (focusOnActivate) {
- this.focusOnActivate_ = focusOnActivate;
- };
- /**
- * Activates the Tab
- */
- MDCTabFoundation.prototype.activate = function (previousIndicatorClientRect) {
- this.adapter_.addClass(constants_1.cssClasses.ACTIVE);
- this.adapter_.setAttr(constants_1.strings.ARIA_SELECTED, 'true');
- this.adapter_.setAttr(constants_1.strings.TABINDEX, '0');
- this.adapter_.activateIndicator(previousIndicatorClientRect);
- if (this.focusOnActivate_) {
- this.adapter_.focus();
- }
- };
- /**
- * Deactivates the Tab
- */
- MDCTabFoundation.prototype.deactivate = function () {
- // Early exit
- if (!this.isActive()) {
- return;
- }
- this.adapter_.removeClass(constants_1.cssClasses.ACTIVE);
- this.adapter_.setAttr(constants_1.strings.ARIA_SELECTED, 'false');
- this.adapter_.setAttr(constants_1.strings.TABINDEX, '-1');
- this.adapter_.deactivateIndicator();
- };
- /**
- * Returns the dimensions of the Tab
- */
- MDCTabFoundation.prototype.computeDimensions = function () {
- var rootWidth = this.adapter_.getOffsetWidth();
- var rootLeft = this.adapter_.getOffsetLeft();
- var contentWidth = this.adapter_.getContentOffsetWidth();
- var contentLeft = this.adapter_.getContentOffsetLeft();
- return {
- contentLeft: rootLeft + contentLeft,
- contentRight: rootLeft + contentLeft + contentWidth,
- rootLeft: rootLeft,
- rootRight: rootLeft + rootWidth
- };
- };
- return MDCTabFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTabFoundation = MDCTabFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabFoundation;
- /***/ }),
- /***/ "./packages/mdc-tab/index.ts":
- /*!***********************************!*\
- !*** ./packages/mdc-tab/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-textfield/character-counter/component.ts":
- /*!***************************************************************!*\
- !*** ./packages/mdc-textfield/character-counter/component.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 __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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/character-counter/foundation.ts");
- var MDCTextFieldCharacterCounter = /** @class */function (_super) {
- __extends(MDCTextFieldCharacterCounter, _super);
- function MDCTextFieldCharacterCounter() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTextFieldCharacterCounter.attachTo = function (root) {
- return new MDCTextFieldCharacterCounter(root);
- };
- Object.defineProperty(MDCTextFieldCharacterCounter.prototype, "foundation", {
- get: function get() {
- return this.foundation_;
- },
- enumerable: true,
- configurable: true
- });
- MDCTextFieldCharacterCounter.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 = {
- setContent: function setContent(content) {
- _this.root_.textContent = content;
- }
- };
- return new foundation_1.MDCTextFieldCharacterCounterFoundation(adapter);
- };
- return MDCTextFieldCharacterCounter;
- }(component_1.MDCComponent);
- exports.MDCTextFieldCharacterCounter = MDCTextFieldCharacterCounter;
- /***/ }),
- /***/ "./packages/mdc-textfield/character-counter/constants.ts":
- /*!***************************************************************!*\
- !*** ./packages/mdc-textfield/character-counter/constants.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 });
- var cssClasses = {
- ROOT: 'mdc-text-field-character-counter'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ROOT_SELECTOR: "." + cssClasses.ROOT
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-textfield/character-counter/foundation.ts":
- /*!****************************************************************!*\
- !*** ./packages/mdc-textfield/character-counter/foundation.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 __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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/character-counter/constants.ts");
- var MDCTextFieldCharacterCounterFoundation = /** @class */function (_super) {
- __extends(MDCTextFieldCharacterCounterFoundation, _super);
- function MDCTextFieldCharacterCounterFoundation(adapter) {
- return _super.call(this, __assign({}, MDCTextFieldCharacterCounterFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "defaultAdapter", {
- /**
- * See {@link MDCTextFieldCharacterCounterAdapter} for typing information on parameters and return types.
- */
- get: function get() {
- return {
- setContent: function setContent() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCTextFieldCharacterCounterFoundation.prototype.setCounterValue = function (currentLength, maxLength) {
- currentLength = Math.min(currentLength, maxLength);
- this.adapter_.setContent(currentLength + " / " + maxLength);
- };
- return MDCTextFieldCharacterCounterFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTextFieldCharacterCounterFoundation = MDCTextFieldCharacterCounterFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTextFieldCharacterCounterFoundation;
- /***/ }),
- /***/ "./packages/mdc-textfield/character-counter/index.ts":
- /*!***********************************************************!*\
- !*** ./packages/mdc-textfield/character-counter/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/character-counter/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/character-counter/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/character-counter/constants.ts");
- exports.characterCountCssClasses = constants_1.cssClasses;
- exports.characterCountStrings = constants_1.strings;
- /***/ }),
- /***/ "./packages/mdc-textfield/component.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-textfield/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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 = __importStar(__webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.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 component_4 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
- var component_5 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var component_6 = __webpack_require__(/*! ./character-counter/component */ "./packages/mdc-textfield/character-counter/component.ts");
- var foundation_2 = __webpack_require__(/*! ./character-counter/foundation */ "./packages/mdc-textfield/character-counter/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts");
- var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/foundation.ts");
- var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-textfield/helper-text/component.ts");
- var foundation_4 = __webpack_require__(/*! ./helper-text/foundation */ "./packages/mdc-textfield/helper-text/foundation.ts");
- var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-textfield/icon/component.ts");
- var MDCTextField = /** @class */function (_super) {
- __extends(MDCTextField, _super);
- function MDCTextField() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTextField.attachTo = function (root) {
- return new MDCTextField(root);
- };
- MDCTextField.prototype.initialize = function (rippleFactory, lineRippleFactory, helperTextFactory, characterCounterFactory, iconFactory, labelFactory, outlineFactory) {
- if (rippleFactory === void 0) {
- rippleFactory = function rippleFactory(el, foundation) {
- return new component_5.MDCRipple(el, foundation);
- };
- }
- if (lineRippleFactory === void 0) {
- lineRippleFactory = function lineRippleFactory(el) {
- return new component_3.MDCLineRipple(el);
- };
- }
- if (helperTextFactory === void 0) {
- helperTextFactory = function helperTextFactory(el) {
- return new component_7.MDCTextFieldHelperText(el);
- };
- }
- if (characterCounterFactory === void 0) {
- characterCounterFactory = function characterCounterFactory(el) {
- return new component_6.MDCTextFieldCharacterCounter(el);
- };
- }
- if (iconFactory === void 0) {
- iconFactory = function iconFactory(el) {
- return new component_8.MDCTextFieldIcon(el);
- };
- }
- if (labelFactory === void 0) {
- labelFactory = function labelFactory(el) {
- return new component_2.MDCFloatingLabel(el);
- };
- }
- if (outlineFactory === void 0) {
- outlineFactory = function outlineFactory(el) {
- return new component_4.MDCNotchedOutline(el);
- };
- }
- this.input_ = this.root_.querySelector(constants_1.strings.INPUT_SELECTOR);
- 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;
- // Helper text
- var helperTextStrings = foundation_4.MDCTextFieldHelperTextFoundation.strings;
- var nextElementSibling = this.root_.nextElementSibling;
- var hasHelperLine = nextElementSibling && nextElementSibling.classList.contains(constants_1.cssClasses.HELPER_LINE);
- var helperTextEl = hasHelperLine && nextElementSibling && nextElementSibling.querySelector(helperTextStrings.ROOT_SELECTOR);
- this.helperText_ = helperTextEl ? helperTextFactory(helperTextEl) : null;
- // Character counter
- var characterCounterStrings = foundation_2.MDCTextFieldCharacterCounterFoundation.strings;
- var characterCounterEl = this.root_.querySelector(characterCounterStrings.ROOT_SELECTOR);
- // If character counter is not found in root element search in sibling element.
- if (!characterCounterEl && hasHelperLine && nextElementSibling) {
- characterCounterEl = nextElementSibling.querySelector(characterCounterStrings.ROOT_SELECTOR);
- }
- this.characterCounter_ = characterCounterEl ? characterCounterFactory(characterCounterEl) : null;
- // Leading icon
- var leadingIconEl = this.root_.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
- this.leadingIcon_ = leadingIconEl ? iconFactory(leadingIconEl) : null;
- // Trailing icon
- var trailingIconEl = this.root_.querySelector(constants_1.strings.TRAILING_ICON_SELECTOR);
- this.trailingIcon_ = trailingIconEl ? iconFactory(trailingIconEl) : null;
- this.ripple = this.createRipple_(rippleFactory);
- };
- MDCTextField.prototype.destroy = function () {
- if (this.ripple) {
- this.ripple.destroy();
- }
- if (this.lineRipple_) {
- this.lineRipple_.destroy();
- }
- if (this.helperText_) {
- this.helperText_.destroy();
- }
- if (this.characterCounter_) {
- this.characterCounter_.destroy();
- }
- if (this.leadingIcon_) {
- this.leadingIcon_.destroy();
- }
- if (this.trailingIcon_) {
- this.trailingIcon_.destroy();
- }
- if (this.label_) {
- this.label_.destroy();
- }
- if (this.outline_) {
- this.outline_.destroy();
- }
- _super.prototype.destroy.call(this);
- };
- /**
- * Initializes the Text Field's internal state based on the environment's
- * state.
- */
- MDCTextField.prototype.initialSyncWithDOM = function () {
- this.disabled = this.input_.disabled;
- };
- Object.defineProperty(MDCTextField.prototype, "value", {
- get: function get() {
- return this.foundation_.getValue();
- },
- /**
- * @param value The value to set on the input.
- */
- set: function set(value) {
- this.foundation_.setValue(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "disabled", {
- get: function get() {
- return this.foundation_.isDisabled();
- },
- /**
- * @param disabled Sets the Text Field disabled or enabled.
- */
- set: function set(disabled) {
- this.foundation_.setDisabled(disabled);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "valid", {
- get: function get() {
- return this.foundation_.isValid();
- },
- /**
- * @param valid Sets the Text Field valid or invalid.
- */
- set: function set(valid) {
- this.foundation_.setValid(valid);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "required", {
- get: function get() {
- return this.input_.required;
- },
- /**
- * @param required Sets the Text Field to required.
- */
- set: function set(required) {
- this.input_.required = required;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "pattern", {
- get: function get() {
- return this.input_.pattern;
- },
- /**
- * @param pattern Sets the input element's validation pattern.
- */
- set: function set(pattern) {
- this.input_.pattern = pattern;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "minLength", {
- get: function get() {
- return this.input_.minLength;
- },
- /**
- * @param minLength Sets the input element's minLength.
- */
- set: function set(minLength) {
- this.input_.minLength = minLength;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "maxLength", {
- get: function get() {
- return this.input_.maxLength;
- },
- /**
- * @param maxLength Sets the input element's maxLength.
- */
- set: function set(maxLength) {
- // Chrome throws exception if maxLength is set to a value less than zero
- if (maxLength < 0) {
- this.input_.removeAttribute('maxLength');
- } else {
- this.input_.maxLength = maxLength;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "min", {
- get: function get() {
- return this.input_.min;
- },
- /**
- * @param min Sets the input element's min.
- */
- set: function set(min) {
- this.input_.min = min;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "max", {
- get: function get() {
- return this.input_.max;
- },
- /**
- * @param max Sets the input element's max.
- */
- set: function set(max) {
- this.input_.max = max;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "step", {
- get: function get() {
- return this.input_.step;
- },
- /**
- * @param step Sets the input element's step.
- */
- set: function set(step) {
- this.input_.step = step;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "helperTextContent", {
- /**
- * Sets the helper text element content.
- */
- set: function set(content) {
- this.foundation_.setHelperTextContent(content);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "leadingIconAriaLabel", {
- /**
- * Sets the aria label of the leading icon.
- */
- set: function set(label) {
- this.foundation_.setLeadingIconAriaLabel(label);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "leadingIconContent", {
- /**
- * Sets the text content of the leading icon.
- */
- set: function set(content) {
- this.foundation_.setLeadingIconContent(content);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "trailingIconAriaLabel", {
- /**
- * Sets the aria label of the trailing icon.
- */
- set: function set(label) {
- this.foundation_.setTrailingIconAriaLabel(label);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "trailingIconContent", {
- /**
- * Sets the text content of the trailing icon.
- */
- set: function set(content) {
- this.foundation_.setTrailingIconContent(content);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "useNativeValidation", {
- /**
- * Enables or disables the use of native validation. Use this for custom validation.
- * @param useNativeValidation Set this to false to ignore native input validation.
- */
- set: function set(useNativeValidation) {
- this.foundation_.setUseNativeValidation(useNativeValidation);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Focuses the input element.
- */
- MDCTextField.prototype.focus = function () {
- this.input_.focus();
- };
- /**
- * Recomputes the outline SVG path for the outline element.
- */
- MDCTextField.prototype.layout = function () {
- var openNotch = this.foundation_.shouldFloat;
- this.foundation_.notchOutline(openNotch);
- };
- MDCTextField.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.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = __assign({}, this.getRootAdapterMethods_(), this.getInputAdapterMethods_(), this.getLabelAdapterMethods_(), this.getLineRippleAdapterMethods_(), this.getOutlineAdapterMethods_());
- // tslint:enable:object-literal-sort-keys
- return new foundation_3.MDCTextFieldFoundation(adapter, this.getFoundationMap_());
- };
- MDCTextField.prototype.getRootAdapterMethods_ = 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) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- registerTextFieldInteractionHandler: function registerTextFieldInteractionHandler(evtType, handler) {
- return _this.listen(evtType, handler);
- },
- deregisterTextFieldInteractionHandler: function deregisterTextFieldInteractionHandler(evtType, handler) {
- return _this.unlisten(evtType, handler);
- },
- registerValidationAttributeChangeHandler: function registerValidationAttributeChangeHandler(handler) {
- var getAttributesList = function getAttributesList(mutationsList) {
- return mutationsList.map(function (mutation) {
- return mutation.attributeName;
- }).filter(function (attributeName) {
- return attributeName;
- });
- };
- var observer = new MutationObserver(function (mutationsList) {
- return handler(getAttributesList(mutationsList));
- });
- var config = { attributes: true };
- observer.observe(_this.input_, config);
- return observer;
- },
- deregisterValidationAttributeChangeHandler: function deregisterValidationAttributeChangeHandler(observer) {
- return observer.disconnect();
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- MDCTextField.prototype.getInputAdapterMethods_ = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- getNativeInput: function getNativeInput() {
- return _this.input_;
- },
- isFocused: function isFocused() {
- return document.activeElement === _this.input_;
- },
- registerInputInteractionHandler: function registerInputInteractionHandler(evtType, handler) {
- return _this.input_.addEventListener(evtType, handler, events_1.applyPassive());
- },
- deregisterInputInteractionHandler: function deregisterInputInteractionHandler(evtType, handler) {
- return _this.input_.removeEventListener(evtType, handler, events_1.applyPassive());
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- MDCTextField.prototype.getLabelAdapterMethods_ = function () {
- var _this = this;
- return {
- floatLabel: function floatLabel(shouldFloat) {
- return _this.label_ && _this.label_.float(shouldFloat);
- },
- getLabelWidth: function getLabelWidth() {
- return _this.label_ ? _this.label_.getWidth() : 0;
- },
- hasLabel: function hasLabel() {
- return Boolean(_this.label_);
- },
- shakeLabel: function shakeLabel(shouldShake) {
- return _this.label_ && _this.label_.shake(shouldShake);
- }
- };
- };
- MDCTextField.prototype.getLineRippleAdapterMethods_ = function () {
- var _this = this;
- return {
- activateLineRipple: function activateLineRipple() {
- if (_this.lineRipple_) {
- _this.lineRipple_.activate();
- }
- },
- deactivateLineRipple: function deactivateLineRipple() {
- if (_this.lineRipple_) {
- _this.lineRipple_.deactivate();
- }
- },
- setLineRippleTransformOrigin: function setLineRippleTransformOrigin(normalizedX) {
- if (_this.lineRipple_) {
- _this.lineRipple_.setRippleCenter(normalizedX);
- }
- }
- };
- };
- MDCTextField.prototype.getOutlineAdapterMethods_ = function () {
- var _this = this;
- return {
- closeOutline: function closeOutline() {
- return _this.outline_ && _this.outline_.closeNotch();
- },
- hasOutline: function hasOutline() {
- return Boolean(_this.outline_);
- },
- notchOutline: function notchOutline(labelWidth) {
- return _this.outline_ && _this.outline_.notch(labelWidth);
- }
- };
- };
- /**
- * @return A map of all subcomponents to subfoundations.
- */
- MDCTextField.prototype.getFoundationMap_ = function () {
- return {
- characterCounter: this.characterCounter_ ? this.characterCounter_.foundation : undefined,
- helperText: this.helperText_ ? this.helperText_.foundation : undefined,
- leadingIcon: this.leadingIcon_ ? this.leadingIcon_.foundation : undefined,
- trailingIcon: this.trailingIcon_ ? this.trailingIcon_.foundation : undefined
- };
- };
- MDCTextField.prototype.createRipple_ = function (rippleFactory) {
- var _this = this;
- var isTextArea = this.root_.classList.contains(constants_1.cssClasses.TEXTAREA);
- var isOutlined = this.root_.classList.contains(constants_1.cssClasses.OUTLINED);
- if (isTextArea || isOutlined) {
- return null;
- }
- // 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({}, component_5.MDCRipple.createAdapter(this), { isSurfaceActive: function isSurfaceActive() {
- return ponyfill.matches(_this.input_, ':active');
- }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return _this.input_.addEventListener(evtType, handler, events_1.applyPassive());
- }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return _this.input_.removeEventListener(evtType, handler, events_1.applyPassive());
- } });
- // tslint:enable:object-literal-sort-keys
- return rippleFactory(this.root_, new foundation_1.MDCRippleFoundation(adapter));
- };
- return MDCTextField;
- }(component_1.MDCComponent);
- exports.MDCTextField = MDCTextField;
- /***/ }),
- /***/ "./packages/mdc-textfield/constants.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-textfield/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 });
- var strings = {
- ARIA_CONTROLS: 'aria-controls',
- INPUT_SELECTOR: '.mdc-text-field__input',
- LABEL_SELECTOR: '.mdc-floating-label',
- LEADING_ICON_SELECTOR: '.mdc-text-field__icon--leading',
- LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
- OUTLINE_SELECTOR: '.mdc-notched-outline',
- TRAILING_ICON_SELECTOR: '.mdc-text-field__icon--trailing'
- };
- exports.strings = strings;
- var cssClasses = {
- DENSE: 'mdc-text-field--dense',
- DISABLED: 'mdc-text-field--disabled',
- FOCUSED: 'mdc-text-field--focused',
- FULLWIDTH: 'mdc-text-field--fullwidth',
- HELPER_LINE: 'mdc-text-field-helper-line',
- INVALID: 'mdc-text-field--invalid',
- NO_LABEL: 'mdc-text-field--no-label',
- OUTLINED: 'mdc-text-field--outlined',
- ROOT: 'mdc-text-field',
- TEXTAREA: 'mdc-text-field--textarea',
- WITH_LEADING_ICON: 'mdc-text-field--with-leading-icon',
- WITH_TRAILING_ICON: 'mdc-text-field--with-trailing-icon'
- };
- exports.cssClasses = cssClasses;
- var numbers = {
- DENSE_LABEL_SCALE: 0.923,
- LABEL_SCALE: 0.75
- };
- exports.numbers = numbers;
- /**
- * Whitelist based off of https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation
- * under the "Validation-related attributes" section.
- */
- var VALIDATION_ATTR_WHITELIST = ['pattern', 'min', 'max', 'required', 'step', 'minlength', 'maxlength'];
- exports.VALIDATION_ATTR_WHITELIST = VALIDATION_ATTR_WHITELIST;
- /**
- * Label should always float for these types as they show some UI even if value is empty.
- */
- var ALWAYS_FLOAT_TYPES = ['color', 'date', 'datetime-local', 'month', 'range', 'time', 'week'];
- exports.ALWAYS_FLOAT_TYPES = ALWAYS_FLOAT_TYPES;
- /***/ }),
- /***/ "./packages/mdc-textfield/foundation.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-textfield/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts");
- var POINTERDOWN_EVENTS = ['mousedown', 'touchstart'];
- var INTERACTION_EVENTS = ['click', 'keydown'];
- var MDCTextFieldFoundation = /** @class */function (_super) {
- __extends(MDCTextFieldFoundation, _super);
- /**
- * @param adapter
- * @param foundationMap Map from subcomponent names to their subfoundations.
- */
- function MDCTextFieldFoundation(adapter, foundationMap) {
- if (foundationMap === void 0) {
- foundationMap = {};
- }
- var _this = _super.call(this, __assign({}, MDCTextFieldFoundation.defaultAdapter, adapter)) || this;
- _this.isFocused_ = false;
- _this.receivedUserInput_ = false;
- _this.isValid_ = true;
- _this.useNativeValidation_ = true;
- _this.helperText_ = foundationMap.helperText;
- _this.characterCounter_ = foundationMap.characterCounter;
- _this.leadingIcon_ = foundationMap.leadingIcon;
- _this.trailingIcon_ = foundationMap.trailingIcon;
- _this.inputFocusHandler_ = function () {
- return _this.activateFocus();
- };
- _this.inputBlurHandler_ = function () {
- return _this.deactivateFocus();
- };
- _this.inputInputHandler_ = function () {
- return _this.handleInput();
- };
- _this.setPointerXOffset_ = function (evt) {
- return _this.setTransformOrigin(evt);
- };
- _this.textFieldInteractionHandler_ = function () {
- return _this.handleTextFieldInteraction();
- };
- _this.validationAttributeChangeHandler_ = function (attributesList) {
- return _this.handleValidationAttributeChange(attributesList);
- };
- return _this;
- }
- Object.defineProperty(MDCTextFieldFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldAlwaysFloat_", {
- get: function get() {
- var type = this.getNativeInput_().type;
- return constants_1.ALWAYS_FLOAT_TYPES.indexOf(type) >= 0;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldFloat", {
- get: function get() {
- return this.shouldAlwaysFloat_ || this.isFocused_ || !!this.getValue() || this.isBadInput_();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldShake", {
- get: function get() {
- return !this.isFocused_ && !this.isValid() && !!this.getValue();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation, "defaultAdapter", {
- /**
- * See {@link MDCTextFieldAdapter} 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 true;
- },
- registerTextFieldInteractionHandler: function registerTextFieldInteractionHandler() {
- return undefined;
- },
- deregisterTextFieldInteractionHandler: function deregisterTextFieldInteractionHandler() {
- return undefined;
- },
- registerInputInteractionHandler: function registerInputInteractionHandler() {
- return undefined;
- },
- deregisterInputInteractionHandler: function deregisterInputInteractionHandler() {
- return undefined;
- },
- registerValidationAttributeChangeHandler: function registerValidationAttributeChangeHandler() {
- return new MutationObserver(function () {
- return undefined;
- });
- },
- deregisterValidationAttributeChangeHandler: function deregisterValidationAttributeChangeHandler() {
- return undefined;
- },
- getNativeInput: function getNativeInput() {
- return null;
- },
- isFocused: function isFocused() {
- return false;
- },
- activateLineRipple: function activateLineRipple() {
- return undefined;
- },
- deactivateLineRipple: function deactivateLineRipple() {
- return undefined;
- },
- setLineRippleTransformOrigin: function setLineRippleTransformOrigin() {
- return undefined;
- },
- shakeLabel: function shakeLabel() {
- return undefined;
- },
- floatLabel: function floatLabel() {
- return undefined;
- },
- hasLabel: function hasLabel() {
- return false;
- },
- getLabelWidth: function getLabelWidth() {
- return 0;
- },
- hasOutline: function hasOutline() {
- return false;
- },
- notchOutline: function notchOutline() {
- return undefined;
- },
- closeOutline: function closeOutline() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCTextFieldFoundation.prototype.init = function () {
- var _this = this;
- if (this.adapter_.isFocused()) {
- this.inputFocusHandler_();
- } else if (this.adapter_.hasLabel() && this.shouldFloat) {
- this.notchOutline(true);
- this.adapter_.floatLabel(true);
- }
- this.adapter_.registerInputInteractionHandler('focus', this.inputFocusHandler_);
- this.adapter_.registerInputInteractionHandler('blur', this.inputBlurHandler_);
- this.adapter_.registerInputInteractionHandler('input', this.inputInputHandler_);
- POINTERDOWN_EVENTS.forEach(function (evtType) {
- _this.adapter_.registerInputInteractionHandler(evtType, _this.setPointerXOffset_);
- });
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.adapter_.registerTextFieldInteractionHandler(evtType, _this.textFieldInteractionHandler_);
- });
- this.validationObserver_ = this.adapter_.registerValidationAttributeChangeHandler(this.validationAttributeChangeHandler_);
- this.setCharacterCounter_(this.getValue().length);
- };
- MDCTextFieldFoundation.prototype.destroy = function () {
- var _this = this;
- this.adapter_.deregisterInputInteractionHandler('focus', this.inputFocusHandler_);
- this.adapter_.deregisterInputInteractionHandler('blur', this.inputBlurHandler_);
- this.adapter_.deregisterInputInteractionHandler('input', this.inputInputHandler_);
- POINTERDOWN_EVENTS.forEach(function (evtType) {
- _this.adapter_.deregisterInputInteractionHandler(evtType, _this.setPointerXOffset_);
- });
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.adapter_.deregisterTextFieldInteractionHandler(evtType, _this.textFieldInteractionHandler_);
- });
- this.adapter_.deregisterValidationAttributeChangeHandler(this.validationObserver_);
- };
- /**
- * Handles user interactions with the Text Field.
- */
- MDCTextFieldFoundation.prototype.handleTextFieldInteraction = function () {
- var nativeInput = this.adapter_.getNativeInput();
- if (nativeInput && nativeInput.disabled) {
- return;
- }
- this.receivedUserInput_ = true;
- };
- /**
- * Handles validation attribute changes
- */
- MDCTextFieldFoundation.prototype.handleValidationAttributeChange = function (attributesList) {
- var _this = this;
- attributesList.some(function (attributeName) {
- if (constants_1.VALIDATION_ATTR_WHITELIST.indexOf(attributeName) > -1) {
- _this.styleValidity_(true);
- return true;
- }
- return false;
- });
- if (attributesList.indexOf('maxlength') > -1) {
- this.setCharacterCounter_(this.getValue().length);
- }
- };
- /**
- * Opens/closes the notched outline.
- */
- MDCTextFieldFoundation.prototype.notchOutline = function (openNotch) {
- if (!this.adapter_.hasOutline()) {
- return;
- }
- if (openNotch) {
- var isDense = this.adapter_.hasClass(constants_1.cssClasses.DENSE);
- var labelScale = isDense ? constants_1.numbers.DENSE_LABEL_SCALE : constants_1.numbers.LABEL_SCALE;
- var labelWidth = this.adapter_.getLabelWidth() * labelScale;
- this.adapter_.notchOutline(labelWidth);
- } else {
- this.adapter_.closeOutline();
- }
- };
- /**
- * Activates the text field focus state.
- */
- MDCTextFieldFoundation.prototype.activateFocus = function () {
- this.isFocused_ = true;
- this.styleFocused_(this.isFocused_);
- this.adapter_.activateLineRipple();
- if (this.adapter_.hasLabel()) {
- this.notchOutline(this.shouldFloat);
- this.adapter_.floatLabel(this.shouldFloat);
- this.adapter_.shakeLabel(this.shouldShake);
- }
- if (this.helperText_) {
- this.helperText_.showToScreenReader();
- }
- };
- /**
- * Sets the line ripple's transform origin, so that the line ripple activate
- * animation will animate out from the user's click location.
- */
- MDCTextFieldFoundation.prototype.setTransformOrigin = function (evt) {
- var touches = evt.touches;
- var targetEvent = touches ? touches[0] : evt;
- var targetClientRect = targetEvent.target.getBoundingClientRect();
- var normalizedX = targetEvent.clientX - targetClientRect.left;
- this.adapter_.setLineRippleTransformOrigin(normalizedX);
- };
- /**
- * Handles input change of text input and text area.
- */
- MDCTextFieldFoundation.prototype.handleInput = function () {
- this.autoCompleteFocus();
- this.setCharacterCounter_(this.getValue().length);
- };
- /**
- * Activates the Text Field's focus state in cases when the input value
- * changes without user input (e.g. programmatically).
- */
- MDCTextFieldFoundation.prototype.autoCompleteFocus = function () {
- if (!this.receivedUserInput_) {
- this.activateFocus();
- }
- };
- /**
- * Deactivates the Text Field's focus state.
- */
- MDCTextFieldFoundation.prototype.deactivateFocus = function () {
- this.isFocused_ = false;
- this.adapter_.deactivateLineRipple();
- var isValid = this.isValid();
- this.styleValidity_(isValid);
- this.styleFocused_(this.isFocused_);
- if (this.adapter_.hasLabel()) {
- this.notchOutline(this.shouldFloat);
- this.adapter_.floatLabel(this.shouldFloat);
- this.adapter_.shakeLabel(this.shouldShake);
- }
- if (!this.shouldFloat) {
- this.receivedUserInput_ = false;
- }
- };
- MDCTextFieldFoundation.prototype.getValue = function () {
- return this.getNativeInput_().value;
- };
- /**
- * @param value The value to set on the input Element.
- */
- MDCTextFieldFoundation.prototype.setValue = function (value) {
- // Prevent Safari from moving the caret to the end of the input when the value has not changed.
- if (this.getValue() !== value) {
- this.getNativeInput_().value = value;
- }
- this.setCharacterCounter_(value.length);
- var isValid = this.isValid();
- this.styleValidity_(isValid);
- if (this.adapter_.hasLabel()) {
- this.notchOutline(this.shouldFloat);
- this.adapter_.floatLabel(this.shouldFloat);
- this.adapter_.shakeLabel(this.shouldShake);
- }
- };
- /**
- * @return The custom validity state, if set; otherwise, the result of a native validity check.
- */
- MDCTextFieldFoundation.prototype.isValid = function () {
- return this.useNativeValidation_ ? this.isNativeInputValid_() : this.isValid_;
- };
- /**
- * @param isValid Sets the custom validity state of the Text Field.
- */
- MDCTextFieldFoundation.prototype.setValid = function (isValid) {
- this.isValid_ = isValid;
- this.styleValidity_(isValid);
- var shouldShake = !isValid && !this.isFocused_ && !!this.getValue();
- if (this.adapter_.hasLabel()) {
- this.adapter_.shakeLabel(shouldShake);
- }
- };
- /**
- * Enables or disables the use of native validation. Use this for custom validation.
- * @param useNativeValidation Set this to false to ignore native input validation.
- */
- MDCTextFieldFoundation.prototype.setUseNativeValidation = function (useNativeValidation) {
- this.useNativeValidation_ = useNativeValidation;
- };
- MDCTextFieldFoundation.prototype.isDisabled = function () {
- return this.getNativeInput_().disabled;
- };
- /**
- * @param disabled Sets the text-field disabled or enabled.
- */
- MDCTextFieldFoundation.prototype.setDisabled = function (disabled) {
- this.getNativeInput_().disabled = disabled;
- this.styleDisabled_(disabled);
- };
- /**
- * @param content Sets the content of the helper text.
- */
- MDCTextFieldFoundation.prototype.setHelperTextContent = function (content) {
- if (this.helperText_) {
- this.helperText_.setContent(content);
- }
- };
- /**
- * Sets the aria label of the leading icon.
- */
- MDCTextFieldFoundation.prototype.setLeadingIconAriaLabel = function (label) {
- if (this.leadingIcon_) {
- this.leadingIcon_.setAriaLabel(label);
- }
- };
- /**
- * Sets the text content of the leading icon.
- */
- MDCTextFieldFoundation.prototype.setLeadingIconContent = function (content) {
- if (this.leadingIcon_) {
- this.leadingIcon_.setContent(content);
- }
- };
- /**
- * Sets the aria label of the trailing icon.
- */
- MDCTextFieldFoundation.prototype.setTrailingIconAriaLabel = function (label) {
- if (this.trailingIcon_) {
- this.trailingIcon_.setAriaLabel(label);
- }
- };
- /**
- * Sets the text content of the trailing icon.
- */
- MDCTextFieldFoundation.prototype.setTrailingIconContent = function (content) {
- if (this.trailingIcon_) {
- this.trailingIcon_.setContent(content);
- }
- };
- /**
- * Sets character counter values that shows characters used and the total character limit.
- */
- MDCTextFieldFoundation.prototype.setCharacterCounter_ = function (currentLength) {
- if (!this.characterCounter_) {
- return;
- }
- var maxLength = this.getNativeInput_().maxLength;
- if (maxLength === -1) {
- throw new Error('MDCTextFieldFoundation: Expected maxlength html property on text input or textarea.');
- }
- this.characterCounter_.setCounterValue(currentLength, maxLength);
- };
- /**
- * @return True if the Text Field input fails in converting the user-supplied value.
- */
- MDCTextFieldFoundation.prototype.isBadInput_ = function () {
- // The badInput property is not supported in IE 11 💩.
- return this.getNativeInput_().validity.badInput || false;
- };
- /**
- * @return The result of native validity checking (ValidityState.valid).
- */
- MDCTextFieldFoundation.prototype.isNativeInputValid_ = function () {
- return this.getNativeInput_().validity.valid;
- };
- /**
- * Styles the component based on the validity state.
- */
- MDCTextFieldFoundation.prototype.styleValidity_ = function (isValid) {
- var INVALID = MDCTextFieldFoundation.cssClasses.INVALID;
- if (isValid) {
- this.adapter_.removeClass(INVALID);
- } else {
- this.adapter_.addClass(INVALID);
- }
- if (this.helperText_) {
- this.helperText_.setValidity(isValid);
- }
- };
- /**
- * Styles the component based on the focused state.
- */
- MDCTextFieldFoundation.prototype.styleFocused_ = function (isFocused) {
- var FOCUSED = MDCTextFieldFoundation.cssClasses.FOCUSED;
- if (isFocused) {
- this.adapter_.addClass(FOCUSED);
- } else {
- this.adapter_.removeClass(FOCUSED);
- }
- };
- /**
- * Styles the component based on the disabled state.
- */
- MDCTextFieldFoundation.prototype.styleDisabled_ = function (isDisabled) {
- var _a = MDCTextFieldFoundation.cssClasses,
- DISABLED = _a.DISABLED,
- INVALID = _a.INVALID;
- if (isDisabled) {
- this.adapter_.addClass(DISABLED);
- this.adapter_.removeClass(INVALID);
- } else {
- this.adapter_.removeClass(DISABLED);
- }
- if (this.leadingIcon_) {
- this.leadingIcon_.setDisabled(isDisabled);
- }
- if (this.trailingIcon_) {
- this.trailingIcon_.setDisabled(isDisabled);
- }
- };
- /**
- * @return The native text input element from the host environment, or an object with the same shape for unit tests.
- */
- MDCTextFieldFoundation.prototype.getNativeInput_ = function () {
- // this.adapter_ may be undefined in foundation unit tests. This happens when testdouble is creating a mock object
- // and invokes the shouldShake/shouldFloat getters (which in turn call getValue(), which calls this method) before
- // init() has been called from the MDCTextField constructor. To work around that issue, we return a dummy object.
- var nativeInput = this.adapter_ ? this.adapter_.getNativeInput() : null;
- return nativeInput || {
- disabled: false,
- maxLength: -1,
- type: 'input',
- validity: {
- badInput: false,
- valid: true
- },
- value: ''
- };
- };
- return MDCTextFieldFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTextFieldFoundation = MDCTextFieldFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTextFieldFoundation;
- /***/ }),
- /***/ "./packages/mdc-textfield/helper-text/component.ts":
- /*!*********************************************************!*\
- !*** ./packages/mdc-textfield/helper-text/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/helper-text/foundation.ts");
- var MDCTextFieldHelperText = /** @class */function (_super) {
- __extends(MDCTextFieldHelperText, _super);
- function MDCTextFieldHelperText() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTextFieldHelperText.attachTo = function (root) {
- return new MDCTextFieldHelperText(root);
- };
- Object.defineProperty(MDCTextFieldHelperText.prototype, "foundation", {
- get: function get() {
- return this.foundation_;
- },
- enumerable: true,
- configurable: true
- });
- MDCTextFieldHelperText.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) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- setAttr: function setAttr(attr, value) {
- return _this.root_.setAttribute(attr, value);
- },
- removeAttr: function removeAttr(attr) {
- return _this.root_.removeAttribute(attr);
- },
- setContent: function setContent(content) {
- _this.root_.textContent = content;
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCTextFieldHelperTextFoundation(adapter);
- };
- return MDCTextFieldHelperText;
- }(component_1.MDCComponent);
- exports.MDCTextFieldHelperText = MDCTextFieldHelperText;
- /***/ }),
- /***/ "./packages/mdc-textfield/helper-text/constants.ts":
- /*!*********************************************************!*\
- !*** ./packages/mdc-textfield/helper-text/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 });
- var cssClasses = {
- HELPER_TEXT_PERSISTENT: 'mdc-text-field-helper-text--persistent',
- HELPER_TEXT_VALIDATION_MSG: 'mdc-text-field-helper-text--validation-msg',
- ROOT: 'mdc-text-field-helper-text'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ARIA_HIDDEN: 'aria-hidden',
- ROLE: 'role',
- ROOT_SELECTOR: "." + cssClasses.ROOT
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-textfield/helper-text/foundation.ts":
- /*!**********************************************************!*\
- !*** ./packages/mdc-textfield/helper-text/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/helper-text/constants.ts");
- var MDCTextFieldHelperTextFoundation = /** @class */function (_super) {
- __extends(MDCTextFieldHelperTextFoundation, _super);
- function MDCTextFieldHelperTextFoundation(adapter) {
- return _super.call(this, __assign({}, MDCTextFieldHelperTextFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCTextFieldHelperTextFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldHelperTextFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldHelperTextFoundation, "defaultAdapter", {
- /**
- * See {@link MDCTextFieldHelperTextAdapter} 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;
- },
- removeAttr: function removeAttr() {
- return undefined;
- },
- setContent: function setContent() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Sets the content of the helper text field.
- */
- MDCTextFieldHelperTextFoundation.prototype.setContent = function (content) {
- this.adapter_.setContent(content);
- };
- /**
- * @param isPersistent Sets the persistency of the helper text.
- */
- MDCTextFieldHelperTextFoundation.prototype.setPersistent = function (isPersistent) {
- if (isPersistent) {
- this.adapter_.addClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
- } else {
- this.adapter_.removeClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
- }
- };
- /**
- * @param isValidation True to make the helper text act as an error validation message.
- */
- MDCTextFieldHelperTextFoundation.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);
- }
- };
- /**
- * Makes the helper text visible to the screen reader.
- */
- MDCTextFieldHelperTextFoundation.prototype.showToScreenReader = function () {
- this.adapter_.removeAttr(constants_1.strings.ARIA_HIDDEN);
- };
- /**
- * Sets the validity of the helper text based on the input validity.
- */
- MDCTextFieldHelperTextFoundation.prototype.setValidity = function (inputIsValid) {
- var helperTextIsPersistent = this.adapter_.hasClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
- var helperTextIsValidationMsg = this.adapter_.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
- var validationMsgNeedsDisplay = helperTextIsValidationMsg && !inputIsValid;
- if (validationMsgNeedsDisplay) {
- this.adapter_.setAttr(constants_1.strings.ROLE, 'alert');
- } else {
- this.adapter_.removeAttr(constants_1.strings.ROLE);
- }
- if (!helperTextIsPersistent && !validationMsgNeedsDisplay) {
- this.hide_();
- }
- };
- /**
- * Hides the help text from screen readers.
- */
- MDCTextFieldHelperTextFoundation.prototype.hide_ = function () {
- this.adapter_.setAttr(constants_1.strings.ARIA_HIDDEN, 'true');
- };
- return MDCTextFieldHelperTextFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTextFieldHelperTextFoundation = MDCTextFieldHelperTextFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTextFieldHelperTextFoundation;
- /***/ }),
- /***/ "./packages/mdc-textfield/helper-text/index.ts":
- /*!*****************************************************!*\
- !*** ./packages/mdc-textfield/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/helper-text/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/helper-text/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/helper-text/constants.ts");
- exports.helperTextCssClasses = constants_1.cssClasses;
- exports.helperTextStrings = constants_1.strings;
- /***/ }),
- /***/ "./packages/mdc-textfield/icon/component.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-textfield/icon/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/icon/foundation.ts");
- var MDCTextFieldIcon = /** @class */function (_super) {
- __extends(MDCTextFieldIcon, _super);
- function MDCTextFieldIcon() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTextFieldIcon.attachTo = function (root) {
- return new MDCTextFieldIcon(root);
- };
- Object.defineProperty(MDCTextFieldIcon.prototype, "foundation", {
- get: function get() {
- return this.foundation_;
- },
- enumerable: true,
- configurable: true
- });
- MDCTextFieldIcon.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) {
- return _this.root_.setAttribute(attr, value);
- },
- removeAttr: function removeAttr(attr) {
- return _this.root_.removeAttribute(attr);
- },
- setContent: function setContent(content) {
- _this.root_.textContent = content;
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return _this.listen(evtType, handler);
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return _this.unlisten(evtType, handler);
- },
- notifyIconAction: function notifyIconAction() {
- return _this.emit(foundation_1.MDCTextFieldIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */);
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCTextFieldIconFoundation(adapter);
- };
- return MDCTextFieldIcon;
- }(component_1.MDCComponent);
- exports.MDCTextFieldIcon = MDCTextFieldIcon;
- /***/ }),
- /***/ "./packages/mdc-textfield/icon/constants.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-textfield/icon/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 });
- var strings = {
- ICON_EVENT: 'MDCTextField:icon',
- ICON_ROLE: 'button'
- };
- exports.strings = strings;
- var cssClasses = {
- ROOT: 'mdc-text-field__icon'
- };
- exports.cssClasses = cssClasses;
- /***/ }),
- /***/ "./packages/mdc-textfield/icon/foundation.ts":
- /*!***************************************************!*\
- !*** ./packages/mdc-textfield/icon/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/icon/constants.ts");
- var INTERACTION_EVENTS = ['click', 'keydown'];
- var MDCTextFieldIconFoundation = /** @class */function (_super) {
- __extends(MDCTextFieldIconFoundation, _super);
- function MDCTextFieldIconFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCTextFieldIconFoundation.defaultAdapter, adapter)) || this;
- _this.savedTabIndex_ = null;
- _this.interactionHandler_ = function (evt) {
- return _this.handleInteraction(evt);
- };
- return _this;
- }
- Object.defineProperty(MDCTextFieldIconFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldIconFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldIconFoundation, "defaultAdapter", {
- /**
- * See {@link MDCTextFieldIconAdapter} 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: true,
- configurable: true
- });
- MDCTextFieldIconFoundation.prototype.init = function () {
- var _this = this;
- this.savedTabIndex_ = this.adapter_.getAttr('tabindex');
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.adapter_.registerInteractionHandler(evtType, _this.interactionHandler_);
- });
- };
- MDCTextFieldIconFoundation.prototype.destroy = function () {
- var _this = this;
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.adapter_.deregisterInteractionHandler(evtType, _this.interactionHandler_);
- });
- };
- MDCTextFieldIconFoundation.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);
- }
- };
- MDCTextFieldIconFoundation.prototype.setAriaLabel = function (label) {
- this.adapter_.setAttr('aria-label', label);
- };
- MDCTextFieldIconFoundation.prototype.setContent = function (content) {
- this.adapter_.setContent(content);
- };
- MDCTextFieldIconFoundation.prototype.handleInteraction = function (evt) {
- var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
- if (evt.type === 'click' || isEnterKey) {
- evt.preventDefault(); // stop click from causing host label to focus
- // input
- this.adapter_.notifyIconAction();
- }
- };
- return MDCTextFieldIconFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTextFieldIconFoundation = MDCTextFieldIconFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTextFieldIconFoundation;
- /***/ }),
- /***/ "./packages/mdc-textfield/icon/index.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-textfield/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/icon/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/icon/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/icon/constants.ts");
- exports.iconCssClasses = constants_1.cssClasses;
- exports.iconStrings = constants_1.strings;
- /***/ }),
- /***/ "./packages/mdc-textfield/index.ts":
- /*!*****************************************!*\
- !*** ./packages/mdc-textfield/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/foundation.ts"));
- __export(__webpack_require__(/*! ./character-counter/index */ "./packages/mdc-textfield/character-counter/index.ts"));
- __export(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-textfield/helper-text/index.ts"));
- __export(__webpack_require__(/*! ./icon/index */ "./packages/mdc-textfield/icon/index.ts"));
- /***/ }),
- /***/ "./packages/mdc-top-app-bar/component.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-top-app-bar/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts");
- var foundation_1 = __webpack_require__(/*! ./fixed/foundation */ "./packages/mdc-top-app-bar/fixed/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./short/foundation */ "./packages/mdc-top-app-bar/short/foundation.ts");
- var foundation_3 = __webpack_require__(/*! ./standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts");
- var MDCTopAppBar = /** @class */function (_super) {
- __extends(MDCTopAppBar, _super);
- function MDCTopAppBar() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTopAppBar.attachTo = function (root) {
- return new MDCTopAppBar(root);
- };
- MDCTopAppBar.prototype.initialize = function (rippleFactory) {
- if (rippleFactory === void 0) {
- rippleFactory = function rippleFactory(el) {
- return component_2.MDCRipple.attachTo(el);
- };
- }
- this.navIcon_ = this.root_.querySelector(constants_1.strings.NAVIGATION_ICON_SELECTOR);
- // Get all icons in the toolbar and instantiate the ripples
- var icons = [].slice.call(this.root_.querySelectorAll(constants_1.strings.ACTION_ITEM_SELECTOR));
- if (this.navIcon_) {
- icons.push(this.navIcon_);
- }
- this.iconRipples_ = icons.map(function (icon) {
- var ripple = rippleFactory(icon);
- ripple.unbounded = true;
- return ripple;
- });
- this.scrollTarget_ = window;
- };
- MDCTopAppBar.prototype.initialSyncWithDOM = function () {
- this.handleNavigationClick_ = this.foundation_.handleNavigationClick.bind(this.foundation_);
- this.handleWindowResize_ = this.foundation_.handleWindowResize.bind(this.foundation_);
- this.handleTargetScroll_ = this.foundation_.handleTargetScroll.bind(this.foundation_);
- this.scrollTarget_.addEventListener('scroll', this.handleTargetScroll_);
- if (this.navIcon_) {
- this.navIcon_.addEventListener('click', this.handleNavigationClick_);
- }
- var isFixed = this.root_.classList.contains(constants_1.cssClasses.FIXED_CLASS);
- var isShort = this.root_.classList.contains(constants_1.cssClasses.SHORT_CLASS);
- if (!isShort && !isFixed) {
- window.addEventListener('resize', this.handleWindowResize_);
- }
- };
- MDCTopAppBar.prototype.destroy = function () {
- this.iconRipples_.forEach(function (iconRipple) {
- return iconRipple.destroy();
- });
- this.scrollTarget_.removeEventListener('scroll', this.handleTargetScroll_);
- if (this.navIcon_) {
- this.navIcon_.removeEventListener('click', this.handleNavigationClick_);
- }
- var isFixed = this.root_.classList.contains(constants_1.cssClasses.FIXED_CLASS);
- var isShort = this.root_.classList.contains(constants_1.cssClasses.SHORT_CLASS);
- if (!isShort && !isFixed) {
- window.removeEventListener('resize', this.handleWindowResize_);
- }
- _super.prototype.destroy.call(this);
- };
- MDCTopAppBar.prototype.setScrollTarget = function (target) {
- // Remove scroll handler from the previous scroll target
- this.scrollTarget_.removeEventListener('scroll', this.handleTargetScroll_);
- this.scrollTarget_ = target;
- // Initialize scroll handler on the new scroll target
- this.handleTargetScroll_ = this.foundation_.handleTargetScroll.bind(this.foundation_);
- this.scrollTarget_.addEventListener('scroll', this.handleTargetScroll_);
- };
- MDCTopAppBar.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 = {
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- addClass: function addClass(className) {
- return _this.root_.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- setStyle: function setStyle(property, value) {
- return _this.root_.style.setProperty(property, value);
- },
- getTopAppBarHeight: function getTopAppBarHeight() {
- return _this.root_.clientHeight;
- },
- notifyNavigationIconClicked: function notifyNavigationIconClicked() {
- return _this.emit(constants_1.strings.NAVIGATION_EVENT, {});
- },
- getViewportScrollY: function getViewportScrollY() {
- var win = _this.scrollTarget_;
- var el = _this.scrollTarget_;
- return win.pageYOffset !== undefined ? win.pageYOffset : el.scrollTop;
- },
- getTotalActionItems: function getTotalActionItems() {
- return _this.root_.querySelectorAll(constants_1.strings.ACTION_ITEM_SELECTOR).length;
- }
- };
- // tslint:enable:object-literal-sort-keys
- var foundation;
- if (this.root_.classList.contains(constants_1.cssClasses.SHORT_CLASS)) {
- foundation = new foundation_2.MDCShortTopAppBarFoundation(adapter);
- } else if (this.root_.classList.contains(constants_1.cssClasses.FIXED_CLASS)) {
- foundation = new foundation_1.MDCFixedTopAppBarFoundation(adapter);
- } else {
- foundation = new foundation_3.MDCTopAppBarFoundation(adapter);
- }
- return foundation;
- };
- return MDCTopAppBar;
- }(component_1.MDCComponent);
- exports.MDCTopAppBar = MDCTopAppBar;
- /***/ }),
- /***/ "./packages/mdc-top-app-bar/constants.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-top-app-bar/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 });
- var cssClasses = {
- FIXED_CLASS: 'mdc-top-app-bar--fixed',
- FIXED_SCROLLED_CLASS: 'mdc-top-app-bar--fixed-scrolled',
- SHORT_CLASS: 'mdc-top-app-bar--short',
- SHORT_COLLAPSED_CLASS: 'mdc-top-app-bar--short-collapsed',
- SHORT_HAS_ACTION_ITEM_CLASS: 'mdc-top-app-bar--short-has-action-item'
- };
- exports.cssClasses = cssClasses;
- var numbers = {
- DEBOUNCE_THROTTLE_RESIZE_TIME_MS: 100,
- MAX_TOP_APP_BAR_HEIGHT: 128
- };
- exports.numbers = numbers;
- var strings = {
- ACTION_ITEM_SELECTOR: '.mdc-top-app-bar__action-item',
- NAVIGATION_EVENT: 'MDCTopAppBar:nav',
- NAVIGATION_ICON_SELECTOR: '.mdc-top-app-bar__navigation-icon',
- ROOT_SELECTOR: '.mdc-top-app-bar',
- TITLE_SELECTOR: '.mdc-top-app-bar__title'
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-top-app-bar/fixed/foundation.ts":
- /*!******************************************************!*\
- !*** ./packages/mdc-top-app-bar/fixed/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
- var foundation_1 = __webpack_require__(/*! ../standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts");
- var MDCFixedTopAppBarFoundation = /** @class */function (_super) {
- __extends(MDCFixedTopAppBarFoundation, _super);
- function MDCFixedTopAppBarFoundation() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- /**
- * State variable for the previous scroll iteration top app bar state
- */
- _this.wasScrolled_ = false;
- return _this;
- }
- /**
- * Scroll handler for applying/removing the modifier class on the fixed top app bar.
- * @override
- */
- MDCFixedTopAppBarFoundation.prototype.handleTargetScroll = function () {
- var currentScroll = this.adapter_.getViewportScrollY();
- if (currentScroll <= 0) {
- if (this.wasScrolled_) {
- this.adapter_.removeClass(constants_1.cssClasses.FIXED_SCROLLED_CLASS);
- this.wasScrolled_ = false;
- }
- } else {
- if (!this.wasScrolled_) {
- this.adapter_.addClass(constants_1.cssClasses.FIXED_SCROLLED_CLASS);
- this.wasScrolled_ = true;
- }
- }
- };
- return MDCFixedTopAppBarFoundation;
- }(foundation_1.MDCTopAppBarFoundation);
- exports.MDCFixedTopAppBarFoundation = MDCFixedTopAppBarFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCFixedTopAppBarFoundation;
- /***/ }),
- /***/ "./packages/mdc-top-app-bar/foundation.ts":
- /*!************************************************!*\
- !*** ./packages/mdc-top-app-bar/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _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 });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts");
- var MDCTopAppBarBaseFoundation = /** @class */function (_super) {
- __extends(MDCTopAppBarBaseFoundation, _super);
- /* istanbul ignore next: optional argument is not a branch statement */
- function MDCTopAppBarBaseFoundation(adapter) {
- return _super.call(this, __assign({}, MDCTopAppBarBaseFoundation.defaultAdapter, adapter)) || this;
- }
- Object.defineProperty(MDCTopAppBarBaseFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTopAppBarBaseFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTopAppBarBaseFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTopAppBarBaseFoundation, "defaultAdapter", {
- /**
- * See {@link MDCTopAppBarAdapter} 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;
- },
- getTopAppBarHeight: function getTopAppBarHeight() {
- return 0;
- },
- notifyNavigationIconClicked: function notifyNavigationIconClicked() {
- return undefined;
- },
- getViewportScrollY: function getViewportScrollY() {
- return 0;
- },
- getTotalActionItems: function getTotalActionItems() {
- return 0;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- /** Other variants of TopAppBar foundation overrides this method */
- MDCTopAppBarBaseFoundation.prototype.handleTargetScroll = function () {}; // tslint:disable-line:no-empty
- /** Other variants of TopAppBar foundation overrides this method */
- MDCTopAppBarBaseFoundation.prototype.handleWindowResize = function () {}; // tslint:disable-line:no-empty
- MDCTopAppBarBaseFoundation.prototype.handleNavigationClick = function () {
- this.adapter_.notifyNavigationIconClicked();
- };
- return MDCTopAppBarBaseFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTopAppBarBaseFoundation = MDCTopAppBarBaseFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTopAppBarBaseFoundation;
- /***/ }),
- /***/ "./packages/mdc-top-app-bar/index.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-top-app-bar/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.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-top-app-bar/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-top-app-bar/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-top-app-bar/foundation.ts"));
- __export(__webpack_require__(/*! ./fixed/foundation */ "./packages/mdc-top-app-bar/fixed/foundation.ts"));
- __export(__webpack_require__(/*! ./short/foundation */ "./packages/mdc-top-app-bar/short/foundation.ts"));
- __export(__webpack_require__(/*! ./standard/foundation */ "./packages/mdc-top-app-bar/standard/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-top-app-bar/short/foundation.ts":
- /*!******************************************************!*\
- !*** ./packages/mdc-top-app-bar/short/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
- var foundation_1 = __webpack_require__(/*! ../foundation */ "./packages/mdc-top-app-bar/foundation.ts");
- var MDCShortTopAppBarFoundation = /** @class */function (_super) {
- __extends(MDCShortTopAppBarFoundation, _super);
- /* istanbul ignore next: optional argument is not a branch statement */
- function MDCShortTopAppBarFoundation(adapter) {
- var _this = _super.call(this, adapter) || this;
- _this.isCollapsed_ = false;
- _this.isAlwaysCollapsed_ = false;
- return _this;
- }
- Object.defineProperty(MDCShortTopAppBarFoundation.prototype, "isCollapsed", {
- // Public visibility for backward compatibility.
- get: function get() {
- return this.isCollapsed_;
- },
- enumerable: true,
- configurable: true
- });
- MDCShortTopAppBarFoundation.prototype.init = function () {
- _super.prototype.init.call(this);
- if (this.adapter_.getTotalActionItems() > 0) {
- this.adapter_.addClass(constants_1.cssClasses.SHORT_HAS_ACTION_ITEM_CLASS);
- }
- // If initialized with SHORT_COLLAPSED_CLASS, the bar should always be collapsed
- this.setAlwaysCollapsed(this.adapter_.hasClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS));
- };
- /**
- * Set if the short top app bar should always be collapsed.
- *
- * @param value When `true`, bar will always be collapsed. When `false`, bar may collapse or expand based on scroll.
- */
- MDCShortTopAppBarFoundation.prototype.setAlwaysCollapsed = function (value) {
- this.isAlwaysCollapsed_ = !!value;
- if (this.isAlwaysCollapsed_) {
- this.collapse_();
- } else {
- // let maybeCollapseBar_ determine if the bar should be collapsed
- this.maybeCollapseBar_();
- }
- };
- MDCShortTopAppBarFoundation.prototype.getAlwaysCollapsed = function () {
- return this.isAlwaysCollapsed_;
- };
- /**
- * Scroll handler for applying/removing the collapsed modifier class on the short top app bar.
- * @override
- */
- MDCShortTopAppBarFoundation.prototype.handleTargetScroll = function () {
- this.maybeCollapseBar_();
- };
- MDCShortTopAppBarFoundation.prototype.maybeCollapseBar_ = function () {
- if (this.isAlwaysCollapsed_) {
- return;
- }
- var currentScroll = this.adapter_.getViewportScrollY();
- if (currentScroll <= 0) {
- if (this.isCollapsed_) {
- this.uncollapse_();
- }
- } else {
- if (!this.isCollapsed_) {
- this.collapse_();
- }
- }
- };
- MDCShortTopAppBarFoundation.prototype.uncollapse_ = function () {
- this.adapter_.removeClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS);
- this.isCollapsed_ = false;
- };
- MDCShortTopAppBarFoundation.prototype.collapse_ = function () {
- this.adapter_.addClass(constants_1.cssClasses.SHORT_COLLAPSED_CLASS);
- this.isCollapsed_ = true;
- };
- return MDCShortTopAppBarFoundation;
- }(foundation_1.MDCTopAppBarBaseFoundation);
- exports.MDCShortTopAppBarFoundation = MDCShortTopAppBarFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCShortTopAppBarFoundation;
- /***/ }),
- /***/ "./packages/mdc-top-app-bar/standard/foundation.ts":
- /*!*********************************************************!*\
- !*** ./packages/mdc-top-app-bar/standard/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 (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-top-app-bar/constants.ts");
- var foundation_1 = __webpack_require__(/*! ../foundation */ "./packages/mdc-top-app-bar/foundation.ts");
- var INITIAL_VALUE = 0;
- var MDCTopAppBarFoundation = /** @class */function (_super) {
- __extends(MDCTopAppBarFoundation, _super);
- /* istanbul ignore next: optional argument is not a branch statement */
- function MDCTopAppBarFoundation(adapter) {
- var _this = _super.call(this, adapter) || this;
- /**
- * Indicates if the top app bar was docked in the previous scroll handler iteration.
- */
- _this.wasDocked_ = true;
- /**
- * Indicates if the top app bar is docked in the fully shown position.
- */
- _this.isDockedShowing_ = true;
- /**
- * Variable for current scroll position of the top app bar
- */
- _this.currentAppBarOffsetTop_ = 0;
- /**
- * Used to prevent the top app bar from being scrolled out of view during resize events
- */
- _this.isCurrentlyBeingResized_ = false;
- /**
- * The timeout that's used to throttle the resize events
- */
- _this.resizeThrottleId_ = INITIAL_VALUE;
- /**
- * The timeout that's used to debounce toggling the isCurrentlyBeingResized_ variable after a resize
- */
- _this.resizeDebounceId_ = INITIAL_VALUE;
- _this.lastScrollPosition_ = _this.adapter_.getViewportScrollY();
- _this.topAppBarHeight_ = _this.adapter_.getTopAppBarHeight();
- return _this;
- }
- MDCTopAppBarFoundation.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.adapter_.setStyle('top', '');
- };
- /**
- * Scroll handler for the default scroll behavior of the top app bar.
- * @override
- */
- MDCTopAppBarFoundation.prototype.handleTargetScroll = function () {
- var currentScrollPosition = Math.max(this.adapter_.getViewportScrollY(), 0);
- var diff = currentScrollPosition - this.lastScrollPosition_;
- this.lastScrollPosition_ = currentScrollPosition;
- // If the window is being resized the lastScrollPosition_ needs to be updated but the
- // current scroll of the top app bar should stay in the same position.
- if (!this.isCurrentlyBeingResized_) {
- this.currentAppBarOffsetTop_ -= diff;
- if (this.currentAppBarOffsetTop_ > 0) {
- this.currentAppBarOffsetTop_ = 0;
- } else if (Math.abs(this.currentAppBarOffsetTop_) > this.topAppBarHeight_) {
- this.currentAppBarOffsetTop_ = -this.topAppBarHeight_;
- }
- this.moveTopAppBar_();
- }
- };
- /**
- * Top app bar resize handler that throttle/debounce functions that execute updates.
- * @override
- */
- MDCTopAppBarFoundation.prototype.handleWindowResize = function () {
- var _this = this;
- // Throttle resize events 10 p/s
- if (!this.resizeThrottleId_) {
- this.resizeThrottleId_ = setTimeout(function () {
- _this.resizeThrottleId_ = INITIAL_VALUE;
- _this.throttledResizeHandler_();
- }, constants_1.numbers.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
- }
- this.isCurrentlyBeingResized_ = true;
- if (this.resizeDebounceId_) {
- clearTimeout(this.resizeDebounceId_);
- }
- this.resizeDebounceId_ = setTimeout(function () {
- _this.handleTargetScroll();
- _this.isCurrentlyBeingResized_ = false;
- _this.resizeDebounceId_ = INITIAL_VALUE;
- }, constants_1.numbers.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
- };
- /**
- * Function to determine if the DOM needs to update.
- */
- MDCTopAppBarFoundation.prototype.checkForUpdate_ = function () {
- var offscreenBoundaryTop = -this.topAppBarHeight_;
- var hasAnyPixelsOffscreen = this.currentAppBarOffsetTop_ < 0;
- var hasAnyPixelsOnscreen = this.currentAppBarOffsetTop_ > offscreenBoundaryTop;
- var partiallyShowing = hasAnyPixelsOffscreen && hasAnyPixelsOnscreen;
- // If it's partially showing, it can't be docked.
- if (partiallyShowing) {
- this.wasDocked_ = false;
- } else {
- // Not previously docked and not partially showing, it's now docked.
- if (!this.wasDocked_) {
- this.wasDocked_ = true;
- return true;
- } else if (this.isDockedShowing_ !== hasAnyPixelsOnscreen) {
- this.isDockedShowing_ = hasAnyPixelsOnscreen;
- return true;
- }
- }
- return partiallyShowing;
- };
- /**
- * Function to move the top app bar if needed.
- */
- MDCTopAppBarFoundation.prototype.moveTopAppBar_ = function () {
- if (this.checkForUpdate_()) {
- // Once the top app bar is fully hidden we use the max potential top app bar height as our offset
- // so the top app bar doesn't show if the window resizes and the new height > the old height.
- var offset = this.currentAppBarOffsetTop_;
- if (Math.abs(offset) >= this.topAppBarHeight_) {
- offset = -constants_1.numbers.MAX_TOP_APP_BAR_HEIGHT;
- }
- this.adapter_.setStyle('top', offset + 'px');
- }
- };
- /**
- * Throttled function that updates the top app bar scrolled values if the
- * top app bar height changes.
- */
- MDCTopAppBarFoundation.prototype.throttledResizeHandler_ = function () {
- var currentHeight = this.adapter_.getTopAppBarHeight();
- if (this.topAppBarHeight_ !== currentHeight) {
- this.wasDocked_ = false;
- // Since the top app bar has a different height depending on the screen width, this
- // will ensure that the top app bar remains in the correct location if
- // completely hidden and a resize makes the top app bar a different height.
- this.currentAppBarOffsetTop_ -= this.topAppBarHeight_ - currentHeight;
- this.topAppBarHeight_ = currentHeight;
- }
- this.handleTargetScroll();
- };
- return MDCTopAppBarFoundation;
- }(foundation_1.MDCTopAppBarBaseFoundation);
- exports.MDCTopAppBarFoundation = MDCTopAppBarFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTopAppBarFoundation;
- /***/ })
- /******/ });
- });
- //# sourceMappingURL=material-components-web.js.map
|