1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295 |
- /**
- * @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 gridList = __importStar(__webpack_require__(/*! @material/grid-list/index */ "./packages/mdc-grid-list/index.ts"));
- exports.gridList = gridList;
- 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('MDCGridList', gridList.MDCGridList);
- 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 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;
- 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.chipId);
- };
- this.handleChipSelection_ = function (evt) {
- return _this.foundation_.handleChipSelection(evt.detail.chipId, evt.detail.selected);
- };
- this.handleChipRemoval_ = function (evt) {
- return _this.foundation_.handleChipRemoval(evt.detail.chipId);
- };
- this.listen(INTERACTION_EVENT, this.handleChipInteraction_);
- this.listen(SELECTION_EVENT, this.handleChipSelection_);
- this.listen(REMOVAL_EVENT, this.handleChipRemoval_);
- };
- 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_);
- _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 = {
- hasClass: function hasClass(className) {
- return _this.root_.classList.contains(className);
- },
- removeChip: function removeChip(chipId) {
- var index = _this.findChipIndex_(chipId);
- if (index >= 0) {
- _this.chips_[index].destroy();
- _this.chips_.splice(index, 1);
- }
- },
- setSelected: function setSelected(chipId, selected) {
- var index = _this.findChipIndex_(chipId);
- if (index >= 0) {
- _this.chips_[index].selected = selected;
- }
- }
- };
- 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__(/*! ./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_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipSetFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipSetFoundation, "defaultAdapter", {
- get: function get() {
- return {
- hasClass: function hasClass() {
- return false;
- },
- removeChip: function removeChip() {
- return undefined;
- },
- setSelected: function setSelected() {
- 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.
- */
- MDCChipSetFoundation.prototype.select = function (chipId) {
- if (this.selectedChipIds_.indexOf(chipId) >= 0) {
- return;
- }
- if (this.adapter_.hasClass(constants_1.cssClasses.CHOICE) && this.selectedChipIds_.length > 0) {
- var previouslySelectedChip = this.selectedChipIds_[0];
- this.selectedChipIds_.length = 0;
- this.adapter_.setSelected(previouslySelectedChip, false);
- }
- this.selectedChipIds_.push(chipId);
- this.adapter_.setSelected(chipId, true);
- };
- /**
- * Handles a chip interaction event
- */
- MDCChipSetFoundation.prototype.handleChipInteraction = function (chipId) {
- if (this.adapter_.hasClass(constants_1.cssClasses.CHOICE) || this.adapter_.hasClass(constants_1.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 (chipId, selected) {
- 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 (chipId) {
- this.deselect_(chipId);
- this.adapter_.removeChip(chipId);
- };
- /**
- * Deselects the chip with the given id.
- */
- MDCChipSetFoundation.prototype.deselect_ = function (chipId) {
- var index = this.selectedChipIds_.indexOf(chipId);
- if (index >= 0) {
- this.selectedChipIds_.splice(index, 1);
- this.adapter_.setSelected(chipId, false);
- }
- };
- /**
- * Toggles selection of the chip with the given id.
- */
- MDCChipSetFoundation.prototype.toggleSelect_ = function (chipId) {
- if (this.selectedChipIds_.indexOf(chipId) >= 0) {
- this.deselect_(chipId);
- } else {
- this.select(chipId);
- }
- };
- 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);
- // 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);
- };
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.listen(evtType, _this.handleInteraction_);
- });
- this.listen('transitionend', this.handleTransitionEnd_);
- 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_);
- 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;
- },
- 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_;
- },
- notifyInteraction: function notifyInteraction() {
- return _this.emit(constants_1.strings.INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */);
- },
- notifyRemoval: function notifyRemoval() {
- return _this.emit(constants_1.strings.REMOVAL_EVENT, { chipId: _this.id, root: _this.root_ }, true /* shouldBubble */);
- },
- notifySelection: function notifySelection(selected) {
- return _this.emit(constants_1.strings.SELECTION_EVENT, { chipId: _this.id, selected: selected }, 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);
- }
- },
- setAttr: function setAttr(attr, value) {
- return _this.root_.setAttribute(attr, value);
- },
- setStyleProperty: function setStyleProperty(propertyName, value) {
- return _this.root_.style.setProperty(propertyName, value);
- }
- };
- return new foundation_2.MDCChipFoundation(adapter);
- };
- 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 });
- exports.strings = {
- ARIA_CHECKED: 'aria-checked',
- CHECKMARK_SELECTOR: '.mdc-chip__checkmark',
- ENTRY_ANIMATION_NAME: 'mdc-chip-entry',
- INTERACTION_EVENT: 'MDCChip:interaction',
- LEADING_ICON_SELECTOR: '.mdc-chip__icon--leading',
- REMOVAL_EVENT: 'MDCChip:removal',
- SELECTION_EVENT: 'MDCChip:selection',
- TRAILING_ICON_INTERACTION_EVENT: 'MDCChip:trailingIconInteraction',
- TRAILING_ICON_SELECTOR: '.mdc-chip__icon--trailing'
- };
- exports.cssClasses = {
- CHECKMARK: 'mdc-chip__checkmark',
- CHIP_EXIT: 'mdc-chip--exit',
- HIDDEN_LEADING_ICON: 'mdc-chip__icon--leading-hidden',
- LEADING_ICON: 'mdc-chip__icon--leading',
- SELECTED: 'mdc-chip--selected',
- TRAILING_ICON: 'mdc-chip__icon--trailing'
- };
- /***/ }),
- /***/ "./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;
- },
- getCheckmarkBoundingClientRect: function getCheckmarkBoundingClientRect() {
- return emptyClientRect;
- },
- getComputedStyleValue: function getComputedStyleValue() {
- return '';
- },
- getRootBoundingClientRect: function getRootBoundingClientRect() {
- return emptyClientRect;
- },
- hasClass: function hasClass() {
- return false;
- },
- hasLeadingIcon: function hasLeadingIcon() {
- return false;
- },
- notifyInteraction: function notifyInteraction() {
- 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;
- },
- setAttr: function setAttr() {
- return undefined;
- },
- setStyleProperty: function setStyleProperty() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCChipFoundation.prototype.isSelected = function () {
- return this.adapter_.hasClass(constants_1.cssClasses.SELECTED);
- };
- MDCChipFoundation.prototype.setSelected = function (selected) {
- if (selected) {
- this.adapter_.addClass(constants_1.cssClasses.SELECTED);
- this.adapter_.setAttr(constants_1.strings.ARIA_CHECKED, 'true');
- } else {
- this.adapter_.removeClass(constants_1.cssClasses.SELECTED);
- this.adapter_.setAttr(constants_1.strings.ARIA_CHECKED, 'false');
- }
- this.adapter_.notifySelection(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) {
- var isEnter = evt.key === 'Enter' || evt.keyCode === 13;
- if (evt.type === 'click' || isEnter) {
- this.adapter_.notifyInteraction();
- }
- };
- /**
- * 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.
- if (this.adapter_.eventTargetHasClass(evt.target, constants_1.cssClasses.CHIP_EXIT)) {
- if (evt.propertyName === 'width') {
- this.adapter_.notifyRemoval();
- } else if (evt.propertyName === 'opacity') {
- // 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;
- }
- // Handle a transition end event on the leading icon or checkmark, since the transition end event bubbles.
- if (evt.propertyName !== 'opacity') {
- return;
- }
- if (this.adapter_.eventTargetHasClass(evt.target, constants_1.cssClasses.LEADING_ICON) && this.adapter_.hasClass(constants_1.cssClasses.SELECTED)) {
- this.adapter_.addClassToLeadingIcon(constants_1.cssClasses.HIDDEN_LEADING_ICON);
- } else if (this.adapter_.eventTargetHasClass(evt.target, constants_1.cssClasses.CHECKMARK) && !this.adapter_.hasClass(constants_1.cssClasses.SELECTED)) {
- 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) {
- var isEnter = evt.key === 'Enter' || evt.keyCode === 13;
- evt.stopPropagation();
- if (evt.type === 'click' || isEnter) {
- this.adapter_.notifyTrailingIconInteraction();
- if (this.shouldRemoveOnTrailingIconClick_) {
- this.beginExit();
- }
- }
- };
- 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 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;
- 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_.deactivate();
- },
- 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_.activate();
- }
- };
- 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/node_modules/focus-trap/index.js":
- /*!**************************************************************!*\
- !*** ./packages/mdc-dialog/node_modules/focus-trap/index.js ***!
- \**************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- var tabbable = __webpack_require__(/*! tabbable */ "./packages/mdc-dialog/node_modules/tabbable/index.js");
- var xtend = __webpack_require__(/*! xtend */ "./packages/mdc-dialog/node_modules/xtend/immutable.js");
- var activeFocusTraps = (function() {
- var trapQueue = [];
- return {
- activateTrap: function(trap) {
- if (trapQueue.length > 0) {
- var activeTrap = trapQueue[trapQueue.length - 1];
- if (activeTrap !== trap) {
- activeTrap.pause();
- }
- }
- var trapIndex = trapQueue.indexOf(trap);
- if (trapIndex === -1) {
- trapQueue.push(trap);
- } else {
- // move this existing trap to the front of the queue
- trapQueue.splice(trapIndex, 1);
- trapQueue.push(trap);
- }
- },
- deactivateTrap: function(trap) {
- var trapIndex = trapQueue.indexOf(trap);
- if (trapIndex !== -1) {
- trapQueue.splice(trapIndex, 1);
- }
- if (trapQueue.length > 0) {
- trapQueue[trapQueue.length - 1].unpause();
- }
- }
- };
- })();
- function focusTrap(element, userOptions) {
- var doc = document;
- var container =
- typeof element === 'string' ? doc.querySelector(element) : element;
- var config = xtend(
- {
- returnFocusOnDeactivate: true,
- escapeDeactivates: true
- },
- userOptions
- );
- var state = {
- firstTabbableNode: null,
- lastTabbableNode: null,
- nodeFocusedBeforeActivation: null,
- mostRecentlyFocusedNode: null,
- active: false,
- paused: false
- };
- var trap = {
- activate: activate,
- deactivate: deactivate,
- pause: pause,
- unpause: unpause
- };
- return trap;
- function activate(activateOptions) {
- if (state.active) return;
- updateTabbableNodes();
- state.active = true;
- state.paused = false;
- state.nodeFocusedBeforeActivation = doc.activeElement;
- var onActivate =
- activateOptions && activateOptions.onActivate
- ? activateOptions.onActivate
- : config.onActivate;
- if (onActivate) {
- onActivate();
- }
- addListeners();
- return trap;
- }
- function deactivate(deactivateOptions) {
- if (!state.active) return;
- removeListeners();
- state.active = false;
- state.paused = false;
- activeFocusTraps.deactivateTrap(trap);
- var onDeactivate =
- deactivateOptions && deactivateOptions.onDeactivate !== undefined
- ? deactivateOptions.onDeactivate
- : config.onDeactivate;
- if (onDeactivate) {
- onDeactivate();
- }
- var returnFocus =
- deactivateOptions && deactivateOptions.returnFocus !== undefined
- ? deactivateOptions.returnFocus
- : config.returnFocusOnDeactivate;
- if (returnFocus) {
- delay(function() {
- tryFocus(state.nodeFocusedBeforeActivation);
- });
- }
- return trap;
- }
- function pause() {
- if (state.paused || !state.active) return;
- state.paused = true;
- removeListeners();
- }
- function unpause() {
- if (!state.paused || !state.active) return;
- state.paused = false;
- updateTabbableNodes();
- addListeners();
- }
- function addListeners() {
- if (!state.active) return;
- // There can be only one listening focus trap at a time
- activeFocusTraps.activateTrap(trap);
- // Delay ensures that the focused element doesn't capture the event
- // that caused the focus trap activation.
- delay(function() {
- tryFocus(getInitialFocusNode());
- });
- doc.addEventListener('focusin', checkFocusIn, true);
- doc.addEventListener('mousedown', checkPointerDown, {
- capture: true,
- passive: false
- });
- doc.addEventListener('touchstart', checkPointerDown, {
- capture: true,
- passive: false
- });
- doc.addEventListener('click', checkClick, {
- capture: true,
- passive: false
- });
- doc.addEventListener('keydown', checkKey, {
- capture: true,
- passive: false
- });
- return trap;
- }
- function removeListeners() {
- if (!state.active) return;
- doc.removeEventListener('focusin', checkFocusIn, true);
- doc.removeEventListener('mousedown', checkPointerDown, true);
- doc.removeEventListener('touchstart', checkPointerDown, true);
- doc.removeEventListener('click', checkClick, true);
- doc.removeEventListener('keydown', checkKey, true);
- return trap;
- }
- function getNodeForOption(optionName) {
- var optionValue = config[optionName];
- var node = optionValue;
- if (!optionValue) {
- return null;
- }
- if (typeof optionValue === 'string') {
- node = doc.querySelector(optionValue);
- if (!node) {
- throw new Error('`' + optionName + '` refers to no known node');
- }
- }
- if (typeof optionValue === 'function') {
- node = optionValue();
- if (!node) {
- throw new Error('`' + optionName + '` did not return a node');
- }
- }
- return node;
- }
- function getInitialFocusNode() {
- var node;
- if (getNodeForOption('initialFocus') !== null) {
- node = getNodeForOption('initialFocus');
- } else if (container.contains(doc.activeElement)) {
- node = doc.activeElement;
- } else {
- node = state.firstTabbableNode || getNodeForOption('fallbackFocus');
- }
- if (!node) {
- throw new Error(
- "You can't have a focus-trap without at least one focusable element"
- );
- }
- return node;
- }
- // This needs to be done on mousedown and touchstart instead of click
- // so that it precedes the focus event.
- function checkPointerDown(e) {
- if (container.contains(e.target)) return;
- if (config.clickOutsideDeactivates) {
- deactivate({
- returnFocus: !tabbable.isFocusable(e.target)
- });
- } else {
- e.preventDefault();
- }
- }
- // In case focus escapes the trap for some strange reason, pull it back in.
- function checkFocusIn(e) {
- // In Firefox when you Tab out of an iframe the Document is briefly focused.
- if (container.contains(e.target) || e.target instanceof Document) {
- return;
- }
- e.stopImmediatePropagation();
- tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
- }
- function checkKey(e) {
- if (config.escapeDeactivates !== false && isEscapeEvent(e)) {
- e.preventDefault();
- deactivate();
- return;
- }
- if (isTabEvent(e)) {
- checkTab(e);
- return;
- }
- }
- // Hijack Tab events on the first and last focusable nodes of the trap,
- // in order to prevent focus from escaping. If it escapes for even a
- // moment it can end up scrolling the page and causing confusion so we
- // kind of need to capture the action at the keydown phase.
- function checkTab(e) {
- updateTabbableNodes();
- if (e.shiftKey && e.target === state.firstTabbableNode) {
- e.preventDefault();
- tryFocus(state.lastTabbableNode);
- return;
- }
- if (!e.shiftKey && e.target === state.lastTabbableNode) {
- e.preventDefault();
- tryFocus(state.firstTabbableNode);
- return;
- }
- }
- function checkClick(e) {
- if (config.clickOutsideDeactivates) return;
- if (container.contains(e.target)) return;
- e.preventDefault();
- e.stopImmediatePropagation();
- }
- function updateTabbableNodes() {
- var tabbableNodes = tabbable(container);
- state.firstTabbableNode = tabbableNodes[0] || getInitialFocusNode();
- state.lastTabbableNode =
- tabbableNodes[tabbableNodes.length - 1] || getInitialFocusNode();
- }
- function tryFocus(node) {
- if (node === doc.activeElement) return;
- if (!node || !node.focus) {
- tryFocus(getInitialFocusNode());
- return;
- }
- node.focus();
- state.mostRecentlyFocusedNode = node;
- if (isSelectableInput(node)) {
- node.select();
- }
- }
- }
- function isSelectableInput(node) {
- return (
- node.tagName &&
- node.tagName.toLowerCase() === 'input' &&
- typeof node.select === 'function'
- );
- }
- function isEscapeEvent(e) {
- return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
- }
- function isTabEvent(e) {
- return e.key === 'Tab' || e.keyCode === 9;
- }
- function delay(fn) {
- return setTimeout(fn, 0);
- }
- module.exports = focusTrap;
- /***/ }),
- /***/ "./packages/mdc-dialog/node_modules/tabbable/index.js":
- /*!************************************************************!*\
- !*** ./packages/mdc-dialog/node_modules/tabbable/index.js ***!
- \************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- var candidateSelectors = [
- 'input',
- 'select',
- 'textarea',
- 'a[href]',
- 'button',
- '[tabindex]',
- 'audio[controls]',
- 'video[controls]',
- '[contenteditable]:not([contenteditable="false"])',
- ];
- var candidateSelector = candidateSelectors.join(',');
- var matches = typeof Element === 'undefined'
- ? function () {}
- : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
- function tabbable(el, options) {
- options = options || {};
- var regularTabbables = [];
- var orderedTabbables = [];
- var candidates = el.querySelectorAll(candidateSelector);
- if (options.includeContainer) {
- if (matches.call(el, candidateSelector)) {
- candidates = Array.prototype.slice.apply(candidates);
- candidates.unshift(el);
- }
- }
- var i, candidate, candidateTabindex;
- for (i = 0; i < candidates.length; i++) {
- candidate = candidates[i];
- if (!isNodeMatchingSelectorTabbable(candidate)) continue;
- candidateTabindex = getTabindex(candidate);
- if (candidateTabindex === 0) {
- regularTabbables.push(candidate);
- } else {
- orderedTabbables.push({
- documentOrder: i,
- tabIndex: candidateTabindex,
- node: candidate,
- });
- }
- }
- var tabbableNodes = orderedTabbables
- .sort(sortOrderedTabbables)
- .map(function(a) { return a.node })
- .concat(regularTabbables);
- return tabbableNodes;
- }
- tabbable.isTabbable = isTabbable;
- tabbable.isFocusable = isFocusable;
- function isNodeMatchingSelectorTabbable(node) {
- if (
- !isNodeMatchingSelectorFocusable(node)
- || isNonTabbableRadio(node)
- || getTabindex(node) < 0
- ) {
- return false;
- }
- return true;
- }
- function isTabbable(node) {
- if (!node) throw new Error('No node provided');
- if (matches.call(node, candidateSelector) === false) return false;
- return isNodeMatchingSelectorTabbable(node);
- }
- function isNodeMatchingSelectorFocusable(node) {
- if (
- node.disabled
- || isHiddenInput(node)
- || isHidden(node)
- ) {
- return false;
- }
- return true;
- }
- var focusableCandidateSelector = candidateSelectors.concat('iframe').join(',');
- function isFocusable(node) {
- if (!node) throw new Error('No node provided');
- if (matches.call(node, focusableCandidateSelector) === false) return false;
- return isNodeMatchingSelectorFocusable(node);
- }
- function getTabindex(node) {
- var tabindexAttr = parseInt(node.getAttribute('tabindex'), 10);
- if (!isNaN(tabindexAttr)) return tabindexAttr;
- // Browsers do not return `tabIndex` correctly for contentEditable nodes;
- // so if they don't have a tabindex attribute specifically set, assume it's 0.
- if (isContentEditable(node)) return 0;
- return node.tabIndex;
- }
- function sortOrderedTabbables(a, b) {
- return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
- }
- function isContentEditable(node) {
- return node.contentEditable === 'true';
- }
- function isInput(node) {
- return node.tagName === 'INPUT';
- }
- function isHiddenInput(node) {
- return isInput(node) && node.type === 'hidden';
- }
- function isRadio(node) {
- return isInput(node) && node.type === 'radio';
- }
- function isNonTabbableRadio(node) {
- return isRadio(node) && !isTabbableRadio(node);
- }
- function getCheckedRadio(nodes) {
- for (var i = 0; i < nodes.length; i++) {
- if (nodes[i].checked) {
- return nodes[i];
- }
- }
- }
- function isTabbableRadio(node) {
- if (!node.name) return true;
- // This won't account for the edge case where you have radio groups with the same
- // in separate forms on the same page.
- var radioSet = node.ownerDocument.querySelectorAll('input[type="radio"][name="' + node.name + '"]');
- var checked = getCheckedRadio(radioSet);
- return !checked || checked === node;
- }
- function isHidden(node) {
- // offsetParent being null will allow detecting cases where an element is invisible or inside an invisible element,
- // as long as the element does not use position: fixed. For them, their visibility has to be checked directly as well.
- return node.offsetParent === null || getComputedStyle(node).visibility === 'hidden';
- }
- module.exports = tabbable;
- /***/ }),
- /***/ "./packages/mdc-dialog/node_modules/xtend/immutable.js":
- /*!*************************************************************!*\
- !*** ./packages/mdc-dialog/node_modules/xtend/immutable.js ***!
- \*************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- module.exports = extend
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- function extend() {
- var target = {}
- for (var i = 0; i < arguments.length; i++) {
- var source = arguments[i]
- for (var key in source) {
- if (hasOwnProperty.call(source, key)) {
- target[key] = source[key]
- }
- }
- }
- return target
- }
- /***/ }),
- /***/ "./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.
- */
- var __importDefault = this && this.__importDefault || function (mod) {
- return mod && mod.__esModule ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var focus_trap_1 = __importDefault(__webpack_require__(/*! focus-trap */ "./packages/mdc-dialog/node_modules/focus-trap/index.js"));
- function createFocusTrapInstance(surfaceEl, focusTrapFactory, initialFocusEl) {
- if (focusTrapFactory === void 0) {
- focusTrapFactory = focus_trap_1.default;
- }
- return focusTrapFactory(surfaceEl, {
- clickOutsideDeactivates: true,
- escapeDeactivates: false,
- initialFocus: 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/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 });
- /**
- * Stores result from applyPassive to avoid redundant processing to detect
- * passive event listener support.
- */
- var supportsPassive_;
- /**
- * Determine whether the current browser supports passive event listeners, and
- * if so, use them.
- */
- function applyPassive(globalObj, forceRefresh) {
- if (globalObj === void 0) {
- globalObj = window;
- }
- if (forceRefresh === void 0) {
- forceRefresh = false;
- }
- if (supportsPassive_ === undefined || forceRefresh) {
- var isSupported_1 = false;
- try {
- globalObj.document.addEventListener('test', function () {
- return undefined;
- }, {
- get passive() {
- isSupported_1 = true;
- return isSupported_1;
- }
- });
- } catch (e) {} // tslint:disable-line:no-empty cannot throw error due to tests. tslint also disables console.log.
- supportsPassive_ = isSupported_1;
- }
- return supportsPassive_ ? { passive: true } : false;
- }
- exports.applyPassive = applyPassive;
- /***/ }),
- /***/ "./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 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;
- /***/ }),
- /***/ "./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 __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 component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.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 focus_trap_1 = __importDefault(__webpack_require__(/*! focus-trap */ "./packages/mdc-drawer/node_modules/focus-trap/index.js"));
- 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 = focus_trap_1.default;
- }
- 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_.activate();
- },
- releaseFocus: function releaseFocus() {
- return _this.focusTrap_.deactivate();
- }
- };
- // 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/node_modules/focus-trap/index.js":
- /*!**************************************************************!*\
- !*** ./packages/mdc-drawer/node_modules/focus-trap/index.js ***!
- \**************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- var tabbable = __webpack_require__(/*! tabbable */ "./packages/mdc-drawer/node_modules/tabbable/index.js");
- var xtend = __webpack_require__(/*! xtend */ "./packages/mdc-drawer/node_modules/xtend/immutable.js");
- var activeFocusTraps = (function() {
- var trapQueue = [];
- return {
- activateTrap: function(trap) {
- if (trapQueue.length > 0) {
- var activeTrap = trapQueue[trapQueue.length - 1];
- if (activeTrap !== trap) {
- activeTrap.pause();
- }
- }
- var trapIndex = trapQueue.indexOf(trap);
- if (trapIndex === -1) {
- trapQueue.push(trap);
- } else {
- // move this existing trap to the front of the queue
- trapQueue.splice(trapIndex, 1);
- trapQueue.push(trap);
- }
- },
- deactivateTrap: function(trap) {
- var trapIndex = trapQueue.indexOf(trap);
- if (trapIndex !== -1) {
- trapQueue.splice(trapIndex, 1);
- }
- if (trapQueue.length > 0) {
- trapQueue[trapQueue.length - 1].unpause();
- }
- }
- };
- })();
- function focusTrap(element, userOptions) {
- var doc = document;
- var container =
- typeof element === 'string' ? doc.querySelector(element) : element;
- var config = xtend(
- {
- returnFocusOnDeactivate: true,
- escapeDeactivates: true
- },
- userOptions
- );
- var state = {
- firstTabbableNode: null,
- lastTabbableNode: null,
- nodeFocusedBeforeActivation: null,
- mostRecentlyFocusedNode: null,
- active: false,
- paused: false
- };
- var trap = {
- activate: activate,
- deactivate: deactivate,
- pause: pause,
- unpause: unpause
- };
- return trap;
- function activate(activateOptions) {
- if (state.active) return;
- updateTabbableNodes();
- state.active = true;
- state.paused = false;
- state.nodeFocusedBeforeActivation = doc.activeElement;
- var onActivate =
- activateOptions && activateOptions.onActivate
- ? activateOptions.onActivate
- : config.onActivate;
- if (onActivate) {
- onActivate();
- }
- addListeners();
- return trap;
- }
- function deactivate(deactivateOptions) {
- if (!state.active) return;
- removeListeners();
- state.active = false;
- state.paused = false;
- activeFocusTraps.deactivateTrap(trap);
- var onDeactivate =
- deactivateOptions && deactivateOptions.onDeactivate !== undefined
- ? deactivateOptions.onDeactivate
- : config.onDeactivate;
- if (onDeactivate) {
- onDeactivate();
- }
- var returnFocus =
- deactivateOptions && deactivateOptions.returnFocus !== undefined
- ? deactivateOptions.returnFocus
- : config.returnFocusOnDeactivate;
- if (returnFocus) {
- delay(function() {
- tryFocus(state.nodeFocusedBeforeActivation);
- });
- }
- return trap;
- }
- function pause() {
- if (state.paused || !state.active) return;
- state.paused = true;
- removeListeners();
- }
- function unpause() {
- if (!state.paused || !state.active) return;
- state.paused = false;
- updateTabbableNodes();
- addListeners();
- }
- function addListeners() {
- if (!state.active) return;
- // There can be only one listening focus trap at a time
- activeFocusTraps.activateTrap(trap);
- // Delay ensures that the focused element doesn't capture the event
- // that caused the focus trap activation.
- delay(function() {
- tryFocus(getInitialFocusNode());
- });
- doc.addEventListener('focusin', checkFocusIn, true);
- doc.addEventListener('mousedown', checkPointerDown, {
- capture: true,
- passive: false
- });
- doc.addEventListener('touchstart', checkPointerDown, {
- capture: true,
- passive: false
- });
- doc.addEventListener('click', checkClick, {
- capture: true,
- passive: false
- });
- doc.addEventListener('keydown', checkKey, {
- capture: true,
- passive: false
- });
- return trap;
- }
- function removeListeners() {
- if (!state.active) return;
- doc.removeEventListener('focusin', checkFocusIn, true);
- doc.removeEventListener('mousedown', checkPointerDown, true);
- doc.removeEventListener('touchstart', checkPointerDown, true);
- doc.removeEventListener('click', checkClick, true);
- doc.removeEventListener('keydown', checkKey, true);
- return trap;
- }
- function getNodeForOption(optionName) {
- var optionValue = config[optionName];
- var node = optionValue;
- if (!optionValue) {
- return null;
- }
- if (typeof optionValue === 'string') {
- node = doc.querySelector(optionValue);
- if (!node) {
- throw new Error('`' + optionName + '` refers to no known node');
- }
- }
- if (typeof optionValue === 'function') {
- node = optionValue();
- if (!node) {
- throw new Error('`' + optionName + '` did not return a node');
- }
- }
- return node;
- }
- function getInitialFocusNode() {
- var node;
- if (getNodeForOption('initialFocus') !== null) {
- node = getNodeForOption('initialFocus');
- } else if (container.contains(doc.activeElement)) {
- node = doc.activeElement;
- } else {
- node = state.firstTabbableNode || getNodeForOption('fallbackFocus');
- }
- if (!node) {
- throw new Error(
- "You can't have a focus-trap without at least one focusable element"
- );
- }
- return node;
- }
- // This needs to be done on mousedown and touchstart instead of click
- // so that it precedes the focus event.
- function checkPointerDown(e) {
- if (container.contains(e.target)) return;
- if (config.clickOutsideDeactivates) {
- deactivate({
- returnFocus: !tabbable.isFocusable(e.target)
- });
- } else {
- e.preventDefault();
- }
- }
- // In case focus escapes the trap for some strange reason, pull it back in.
- function checkFocusIn(e) {
- // In Firefox when you Tab out of an iframe the Document is briefly focused.
- if (container.contains(e.target) || e.target instanceof Document) {
- return;
- }
- e.stopImmediatePropagation();
- tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
- }
- function checkKey(e) {
- if (config.escapeDeactivates !== false && isEscapeEvent(e)) {
- e.preventDefault();
- deactivate();
- return;
- }
- if (isTabEvent(e)) {
- checkTab(e);
- return;
- }
- }
- // Hijack Tab events on the first and last focusable nodes of the trap,
- // in order to prevent focus from escaping. If it escapes for even a
- // moment it can end up scrolling the page and causing confusion so we
- // kind of need to capture the action at the keydown phase.
- function checkTab(e) {
- updateTabbableNodes();
- if (e.shiftKey && e.target === state.firstTabbableNode) {
- e.preventDefault();
- tryFocus(state.lastTabbableNode);
- return;
- }
- if (!e.shiftKey && e.target === state.lastTabbableNode) {
- e.preventDefault();
- tryFocus(state.firstTabbableNode);
- return;
- }
- }
- function checkClick(e) {
- if (config.clickOutsideDeactivates) return;
- if (container.contains(e.target)) return;
- e.preventDefault();
- e.stopImmediatePropagation();
- }
- function updateTabbableNodes() {
- var tabbableNodes = tabbable(container);
- state.firstTabbableNode = tabbableNodes[0] || getInitialFocusNode();
- state.lastTabbableNode =
- tabbableNodes[tabbableNodes.length - 1] || getInitialFocusNode();
- }
- function tryFocus(node) {
- if (node === doc.activeElement) return;
- if (!node || !node.focus) {
- tryFocus(getInitialFocusNode());
- return;
- }
- node.focus();
- state.mostRecentlyFocusedNode = node;
- if (isSelectableInput(node)) {
- node.select();
- }
- }
- }
- function isSelectableInput(node) {
- return (
- node.tagName &&
- node.tagName.toLowerCase() === 'input' &&
- typeof node.select === 'function'
- );
- }
- function isEscapeEvent(e) {
- return e.key === 'Escape' || e.key === 'Esc' || e.keyCode === 27;
- }
- function isTabEvent(e) {
- return e.key === 'Tab' || e.keyCode === 9;
- }
- function delay(fn) {
- return setTimeout(fn, 0);
- }
- module.exports = focusTrap;
- /***/ }),
- /***/ "./packages/mdc-drawer/node_modules/tabbable/index.js":
- /*!************************************************************!*\
- !*** ./packages/mdc-drawer/node_modules/tabbable/index.js ***!
- \************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- var candidateSelectors = [
- 'input',
- 'select',
- 'textarea',
- 'a[href]',
- 'button',
- '[tabindex]',
- 'audio[controls]',
- 'video[controls]',
- '[contenteditable]:not([contenteditable="false"])',
- ];
- var candidateSelector = candidateSelectors.join(',');
- var matches = typeof Element === 'undefined'
- ? function () {}
- : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
- function tabbable(el, options) {
- options = options || {};
- var regularTabbables = [];
- var orderedTabbables = [];
- var candidates = el.querySelectorAll(candidateSelector);
- if (options.includeContainer) {
- if (matches.call(el, candidateSelector)) {
- candidates = Array.prototype.slice.apply(candidates);
- candidates.unshift(el);
- }
- }
- var i, candidate, candidateTabindex;
- for (i = 0; i < candidates.length; i++) {
- candidate = candidates[i];
- if (!isNodeMatchingSelectorTabbable(candidate)) continue;
- candidateTabindex = getTabindex(candidate);
- if (candidateTabindex === 0) {
- regularTabbables.push(candidate);
- } else {
- orderedTabbables.push({
- documentOrder: i,
- tabIndex: candidateTabindex,
- node: candidate,
- });
- }
- }
- var tabbableNodes = orderedTabbables
- .sort(sortOrderedTabbables)
- .map(function(a) { return a.node })
- .concat(regularTabbables);
- return tabbableNodes;
- }
- tabbable.isTabbable = isTabbable;
- tabbable.isFocusable = isFocusable;
- function isNodeMatchingSelectorTabbable(node) {
- if (
- !isNodeMatchingSelectorFocusable(node)
- || isNonTabbableRadio(node)
- || getTabindex(node) < 0
- ) {
- return false;
- }
- return true;
- }
- function isTabbable(node) {
- if (!node) throw new Error('No node provided');
- if (matches.call(node, candidateSelector) === false) return false;
- return isNodeMatchingSelectorTabbable(node);
- }
- function isNodeMatchingSelectorFocusable(node) {
- if (
- node.disabled
- || isHiddenInput(node)
- || isHidden(node)
- ) {
- return false;
- }
- return true;
- }
- var focusableCandidateSelector = candidateSelectors.concat('iframe').join(',');
- function isFocusable(node) {
- if (!node) throw new Error('No node provided');
- if (matches.call(node, focusableCandidateSelector) === false) return false;
- return isNodeMatchingSelectorFocusable(node);
- }
- function getTabindex(node) {
- var tabindexAttr = parseInt(node.getAttribute('tabindex'), 10);
- if (!isNaN(tabindexAttr)) return tabindexAttr;
- // Browsers do not return `tabIndex` correctly for contentEditable nodes;
- // so if they don't have a tabindex attribute specifically set, assume it's 0.
- if (isContentEditable(node)) return 0;
- return node.tabIndex;
- }
- function sortOrderedTabbables(a, b) {
- return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
- }
- function isContentEditable(node) {
- return node.contentEditable === 'true';
- }
- function isInput(node) {
- return node.tagName === 'INPUT';
- }
- function isHiddenInput(node) {
- return isInput(node) && node.type === 'hidden';
- }
- function isRadio(node) {
- return isInput(node) && node.type === 'radio';
- }
- function isNonTabbableRadio(node) {
- return isRadio(node) && !isTabbableRadio(node);
- }
- function getCheckedRadio(nodes) {
- for (var i = 0; i < nodes.length; i++) {
- if (nodes[i].checked) {
- return nodes[i];
- }
- }
- }
- function isTabbableRadio(node) {
- if (!node.name) return true;
- // This won't account for the edge case where you have radio groups with the same
- // in separate forms on the same page.
- var radioSet = node.ownerDocument.querySelectorAll('input[type="radio"][name="' + node.name + '"]');
- var checked = getCheckedRadio(radioSet);
- return !checked || checked === node;
- }
- function isHidden(node) {
- // offsetParent being null will allow detecting cases where an element is invisible or inside an invisible element,
- // as long as the element does not use position: fixed. For them, their visibility has to be checked directly as well.
- return node.offsetParent === null || getComputedStyle(node).visibility === 'hidden';
- }
- module.exports = tabbable;
- /***/ }),
- /***/ "./packages/mdc-drawer/node_modules/xtend/immutable.js":
- /*!*************************************************************!*\
- !*** ./packages/mdc-drawer/node_modules/xtend/immutable.js ***!
- \*************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports) {
- module.exports = extend
- var hasOwnProperty = Object.prototype.hasOwnProperty;
- function extend() {
- var target = {}
- for (var i = 0; i < arguments.length; i++) {
- var source = arguments[i]
- for (var key in source) {
- if (hasOwnProperty.call(source, key)) {
- target[key] = source[key]
- }
- }
- }
- return target
- }
- /***/ }),
- /***/ "./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.
- */
- var __importDefault = this && this.__importDefault || function (mod) {
- return mod && mod.__esModule ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var focus_trap_1 = __importDefault(__webpack_require__(/*! focus-trap */ "./packages/mdc-drawer/node_modules/focus-trap/index.js"));
- function createFocusTrapInstance(surfaceEl, focusTrapFactory) {
- if (focusTrapFactory === void 0) {
- focusTrapFactory = focus_trap_1.default;
- }
- return focusTrapFactory(surfaceEl, {
- clickOutsideDeactivates: true,
- escapeDeactivates: false,
- initialFocus: undefined,
- returnFocusOnDeactivate: false
- });
- }
- 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 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 _this.root_.scrollWidth;
- },
- 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-grid-list/component.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-grid-list/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 foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-grid-list/foundation.ts");
- var MDCGridList = /** @class */function (_super) {
- __extends(MDCGridList, _super);
- function MDCGridList() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCGridList.attachTo = function (root) {
- return new MDCGridList(root);
- };
- MDCGridList.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 = {
- deregisterResizeHandler: function deregisterResizeHandler(handler) {
- return window.removeEventListener('resize', handler);
- },
- getNumberOfTiles: function getNumberOfTiles() {
- return _this.root_.querySelectorAll(foundation_1.MDCGridListFoundation.strings.TILE_SELECTOR).length;
- },
- getOffsetWidth: function getOffsetWidth() {
- return _this.root_.offsetWidth;
- },
- getOffsetWidthForTileAtIndex: function getOffsetWidthForTileAtIndex(index) {
- var tileEl = _this.root_.querySelectorAll(foundation_1.MDCGridListFoundation.strings.TILE_SELECTOR)[index];
- return tileEl.offsetWidth;
- },
- registerResizeHandler: function registerResizeHandler(handler) {
- return window.addEventListener('resize', handler);
- },
- setStyleForTilesElement: function setStyleForTilesElement(property, value) {
- var tilesEl = _this.root_.querySelector(foundation_1.MDCGridListFoundation.strings.TILES_SELECTOR);
- tilesEl.style[property] = value;
- }
- };
- return new foundation_1.MDCGridListFoundation(adapter);
- };
- return MDCGridList;
- }(component_1.MDCComponent);
- exports.MDCGridList = MDCGridList;
- /***/ }),
- /***/ "./packages/mdc-grid-list/constants.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-grid-list/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 = {
- TILES_SELECTOR: '.mdc-grid-list__tiles',
- TILE_SELECTOR: '.mdc-grid-tile'
- };
- /***/ }),
- /***/ "./packages/mdc-grid-list/foundation.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-grid-list/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-grid-list/constants.ts");
- var MDCGridListFoundation = /** @class */function (_super) {
- __extends(MDCGridListFoundation, _super);
- /* istanbul ignore next: optional argument is not a branch statement */
- function MDCGridListFoundation(adapter) {
- var _this = _super.call(this, __assign({}, MDCGridListFoundation.defaultAdapter, adapter)) || this;
- _this.resizeFrame_ = 0;
- _this.resizeHandler_ = _this.alignCenter.bind(_this);
- return _this;
- }
- Object.defineProperty(MDCGridListFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCGridListFoundation, "defaultAdapter", {
- get: function get() {
- return {
- deregisterResizeHandler: function deregisterResizeHandler() {
- return undefined;
- },
- getNumberOfTiles: function getNumberOfTiles() {
- return 0;
- },
- getOffsetWidth: function getOffsetWidth() {
- return 0;
- },
- getOffsetWidthForTileAtIndex: function getOffsetWidthForTileAtIndex() {
- return 0;
- },
- registerResizeHandler: function registerResizeHandler() {
- return undefined;
- },
- setStyleForTilesElement: function setStyleForTilesElement() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCGridListFoundation.prototype.init = function () {
- this.alignCenter();
- this.adapter_.registerResizeHandler(this.resizeHandler_);
- };
- MDCGridListFoundation.prototype.destroy = function () {
- this.adapter_.deregisterResizeHandler(this.resizeHandler_);
- };
- MDCGridListFoundation.prototype.alignCenter = function () {
- var _this = this;
- cancelAnimationFrame(this.resizeFrame_);
- this.resizeFrame_ = requestAnimationFrame(function () {
- _this.alignCenter_();
- _this.resizeFrame_ = 0;
- });
- };
- MDCGridListFoundation.prototype.alignCenter_ = function () {
- if (this.adapter_.getNumberOfTiles() === 0) {
- return;
- }
- var gridWidth = this.adapter_.getOffsetWidth();
- var itemWidth = this.adapter_.getOffsetWidthForTileAtIndex(0);
- var tilesWidth = itemWidth * Math.floor(gridWidth / itemWidth);
- this.adapter_.setStyleForTilesElement('width', tilesWidth + "px");
- };
- return MDCGridListFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCGridListFoundation = MDCGridListFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCGridListFoundation;
- /***/ }),
- /***/ "./packages/mdc-grid-list/index.ts":
- /*!*****************************************!*\
- !*** ./packages/mdc-grid-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-grid-list/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-grid-list/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-grid-list/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);
- },
- 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);
- },
- removeClass: function removeClass(className) {
- return _this.root_.classList.remove(className);
- },
- 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 = {
- 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;
- },
- getBuffer: function getBuffer() {
- return null;
- },
- getPrimaryBar: function getPrimaryBar() {
- return null;
- },
- hasClass: function hasClass() {
- return false;
- },
- removeClass: function removeClass() {
- 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;
- };
- MDCLinearProgressFoundation.prototype.setDeterminate = function (isDeterminate) {
- this.isDeterminate_ = isDeterminate;
- if (this.isDeterminate_) {
- this.adapter_.removeClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.setScale_(this.adapter_.getPrimaryBar(), this.progress_);
- } else {
- this.adapter_.addClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- 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);
- }
- };
- MDCLinearProgressFoundation.prototype.setBuffer = function (value) {
- if (this.isDeterminate_) {
- this.setScale_(this.adapter_.getBuffer(), value);
- }
- };
- MDCLinearProgressFoundation.prototype.setReverse = function (isReversed) {
- this.isReversed_ = isReversed;
- 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_;
- },
- 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"]:not(:disabled), input[type="radio"]:not(:disabled)',
- CHECKBOX_SELECTOR: 'input[type="checkbox"]:not(:disabled)',
- 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"]:not(:disabled)'
- };
- 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;
- },
- 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;
- };
- MDCListFoundation.prototype.setSelectedIndexOnAction_ = function (index, toggleCheckbox) {
- if (toggleCheckbox === void 0) {
- toggleCheckbox = true;
- }
- 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
- });
- /**
- * Removes the menu-surface from it's current location and appends it to the
- * body to overcome any overflow:hidden issues.
- */
- MDCMenuSurface.prototype.hoistMenuToBody = function () {
- document.body.appendChild(this.root_);
- this.setIsHoisted(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;
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts");
- exports.Corner = constants_1.Corner;
- exports.CornerBit = constants_1.CornerBit;
- __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.hoistMenuToBody = function () {
- this.menuSurface_.hoistMenuToBody();
- };
- 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
- this.initialSize_ = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
- 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 detectEdgePseudoVarBug(windowObj) {
- // Detect versions of Edge with buggy var() support
- // See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/11495448/
- var document = windowObj.document;
- var node = document.createElement('div');
- node.className = 'mdc-ripple-surface--test-edge-var-bug';
- // Append to head instead of body because this script might be invoked in the
- // head, in which case the body doesn't exist yet. The probe works either way.
- document.head.appendChild(node);
- // The bug exists if ::before style ends up propagating to the parent element.
- // Additionally, getComputedStyle returns null in iframes with display: "none" in Firefox,
- // but Firefox is known to support CSS custom properties correctly.
- // See: https://bugzilla.mozilla.org/show_bug.cgi?id=548397
- var computedStyle = windowObj.getComputedStyle(node);
- var hasPseudoVarBug = computedStyle !== null && computedStyle.borderTopStyle === 'solid';
- if (node.parentNode) {
- node.parentNode.removeChild(node);
- }
- return hasPseudoVarBug;
- }
- 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');
- if (explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus) {
- supportsCssVars = !detectEdgePseudoVarBug(windowObj);
- } else {
- supportsCssVars = false;
- }
- 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 VALIDATION_ATTR_WHITELIST = ['required', 'aria-required'];
- 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.isMenuOpen_ = false;
- this.nativeControl_ = this.root_.querySelector(constants_1.strings.NATIVE_CONTROL_SELECTOR);
- this.selectedText_ = this.root_.querySelector(constants_1.strings.SELECTED_TEXT_SELECTOR);
- var targetElement = this.nativeControl_ || this.selectedText_;
- if (!targetElement) {
- throw new Error('MDCSelect: Missing required element: Exactly one of the following selectors must be present: ' + ("'" + constants_1.strings.NATIVE_CONTROL_SELECTOR + "' or '" + constants_1.strings.SELECTED_TEXT_SELECTOR + "'"));
- }
- this.targetElement_ = targetElement;
- if (this.targetElement_.hasAttribute(constants_1.strings.ARIA_CONTROLS)) {
- var helperTextElement = document.getElementById(this.targetElement_.getAttribute(constants_1.strings.ARIA_CONTROLS));
- if (helperTextElement) {
- this.helperText_ = helperTextFactory(helperTextElement);
- }
- }
- if (this.selectedText_) {
- this.enhancedSelectSetup_(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.root_.classList.add(constants_1.cssClasses.WITH_LEADING_ICON);
- this.leadingIcon_ = iconFactory(leadingIcon);
- if (this.menuElement_) {
- this.menuElement_.classList.add(constants_1.cssClasses.WITH_LEADING_ICON);
- }
- }
- if (!this.root_.classList.contains(constants_1.cssClasses.OUTLINED)) {
- this.ripple = this.createRipple_();
- }
- // The required state needs to be sync'd before the mutation observer is added.
- this.initialSyncRequiredState_();
- this.addMutationObserverForRequired_();
- };
- /**
- * 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( /* didChange */true);
- };
- this.handleFocus_ = function () {
- return _this.foundation_.handleFocus();
- };
- this.handleBlur_ = function () {
- return _this.foundation_.handleBlur();
- };
- this.handleClick_ = function (evt) {
- if (_this.selectedText_) {
- _this.selectedText_.focus();
- }
- _this.foundation_.handleClick(_this.getNormalizedXCoordinate_(evt));
- };
- this.handleKeydown_ = function (evt) {
- return _this.foundation_.handleKeydown(evt);
- };
- this.handleMenuSelected_ = function (evtData) {
- return _this.selectedIndex = evtData.detail.index;
- };
- this.handleMenuOpened_ = function () {
- _this.foundation_.handleMenuOpened();
- if (_this.menu_.items.length === 0) {
- return;
- }
- // Menu should open to the last selected element, should open to first menu item otherwise.
- var focusItemIndex = _this.selectedIndex >= 0 ? _this.selectedIndex : 0;
- var focusItemEl = _this.menu_.items[focusItemIndex];
- focusItemEl.focus();
- };
- this.handleMenuClosed_ = function () {
- _this.foundation_.handleMenuClosed();
- // isMenuOpen_ is used to track the state of the menu opening or closing since the menu.open function
- // will return false if the menu is still closing and this method listens to the closed event which
- // occurs after the menu is already closed.
- _this.isMenuOpen_ = false;
- _this.selectedText_.removeAttribute('aria-expanded');
- if (document.activeElement !== _this.selectedText_) {
- _this.foundation_.handleBlur();
- }
- };
- this.targetElement_.addEventListener('change', this.handleChange_);
- this.targetElement_.addEventListener('focus', this.handleFocus_);
- this.targetElement_.addEventListener('blur', this.handleBlur_);
- this.targetElement_.addEventListener('click', this.handleClick_);
- if (this.menuElement_) {
- 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.handleMenuSelected_);
- if (this.hiddenInput_ && this.hiddenInput_.value) {
- // If the hidden input already has a value, use it to restore the select's value.
- // This can happen e.g. if the user goes back or (in some browsers) refreshes the page.
- var enhancedAdapterMethods = this.getEnhancedSelectAdapterMethods_();
- enhancedAdapterMethods.setValue(this.hiddenInput_.value);
- } else if (this.menuElement_.querySelector(constants_1.strings.SELECTED_ITEM_SELECTOR)) {
- // If an element is selected, the select should set the initial selected text.
- var enhancedAdapterMethods = this.getEnhancedSelectAdapterMethods_();
- enhancedAdapterMethods.setValue(enhancedAdapterMethods.getValue());
- }
- }
- // Initially sync floating label
- this.foundation_.handleChange( /* didChange */false);
- if (this.root_.classList.contains(constants_1.cssClasses.DISABLED) || this.nativeControl_ && this.nativeControl_.disabled) {
- this.disabled = true;
- }
- };
- MDCSelect.prototype.destroy = function () {
- this.targetElement_.removeEventListener('change', this.handleChange_);
- this.targetElement_.removeEventListener('focus', this.handleFocus_);
- this.targetElement_.removeEventListener('blur', this.handleBlur_);
- this.targetElement_.removeEventListener('keydown', this.handleKeydown_);
- this.targetElement_.removeEventListener('click', this.handleClick_);
- if (this.menu_) {
- 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.handleMenuSelected_);
- 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();
- }
- if (this.validationObserver_) {
- this.validationObserver_.disconnect();
- }
- _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() {
- var selectedIndex = -1;
- if (this.menuElement_ && this.menu_) {
- var selectedEl = this.menuElement_.querySelector(constants_1.strings.SELECTED_ITEM_SELECTOR);
- selectedIndex = this.menu_.items.indexOf(selectedEl);
- } else if (this.nativeControl_) {
- selectedIndex = this.nativeControl_.selectedIndex;
- }
- return selectedIndex;
- },
- set: function set(selectedIndex) {
- this.foundation_.setSelectedIndex(selectedIndex);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "disabled", {
- get: function get() {
- return this.root_.classList.contains(constants_1.cssClasses.DISABLED) || (this.nativeControl_ ? this.nativeControl_.disabled : false);
- },
- 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() {
- if (this.nativeControl_) {
- return this.nativeControl_.required;
- } else {
- return this.selectedText_.getAttribute('aria-required') === 'true';
- }
- },
- /**
- * Sets the control to the required state.
- */
- set: function set(isRequired) {
- if (this.nativeControl_) {
- this.nativeControl_.required = isRequired;
- } else {
- if (isRequired) {
- this.selectedText_.setAttribute('aria-required', isRequired.toString());
- } else {
- this.selectedText_.removeAttribute('aria-required');
- }
- }
- },
- 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.nativeControl_ ? this.getNativeSelectAdapterMethods_() : this.getEnhancedSelectAdapterMethods_(), this.getCommonAdapterMethods_(), this.getOutlineAdapterMethods_(), this.getLabelAdapterMethods_());
- return new foundation_2.MDCSelectFoundation(adapter, this.getFoundationMap_());
- };
- /**
- * Handles setup for the enhanced menu.
- */
- MDCSelect.prototype.enhancedSelectSetup_ = function (menuFactory) {
- var isDisabled = this.root_.classList.contains(constants_1.cssClasses.DISABLED);
- this.selectedText_.setAttribute('tabindex', isDisabled ? '-1' : '0');
- this.hiddenInput_ = this.root_.querySelector(constants_1.strings.HIDDEN_INPUT_SELECTOR);
- this.menuElement_ = this.root_.querySelector(constants_1.strings.MENU_SELECTOR);
- this.menu_ = menuFactory(this.menuElement_);
- this.menu_.hoistMenuToBody();
- this.menu_.setAnchorElement(this.root_);
- this.menu_.setAnchorCorner(menuSurfaceConstants.Corner.BOTTOM_START);
- this.menu_.wrapFocus = false;
- };
- 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(this), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return _this.targetElement_.addEventListener(evtType, handler);
- }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return _this.targetElement_.removeEventListener(evtType, handler);
- } });
- // tslint:enable:object-literal-sort-keys
- return new component_6.MDCRipple(this.root_, new foundation_1.MDCRippleFoundation(adapter));
- };
- MDCSelect.prototype.getNativeSelectAdapterMethods_ = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- getValue: function getValue() {
- return _this.nativeControl_.value;
- },
- setValue: function setValue(value) {
- _this.nativeControl_.value = value;
- },
- openMenu: function openMenu() {
- return undefined;
- },
- closeMenu: function closeMenu() {
- return undefined;
- },
- isMenuOpen: function isMenuOpen() {
- return false;
- },
- setSelectedIndex: function setSelectedIndex(index) {
- _this.nativeControl_.selectedIndex = index;
- },
- setDisabled: function setDisabled(isDisabled) {
- _this.nativeControl_.disabled = isDisabled;
- },
- setValid: function setValid(isValid) {
- if (isValid) {
- _this.root_.classList.remove(constants_1.cssClasses.INVALID);
- } else {
- _this.root_.classList.add(constants_1.cssClasses.INVALID);
- }
- },
- checkValidity: function checkValidity() {
- return _this.nativeControl_.checkValidity();
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- MDCSelect.prototype.getEnhancedSelectAdapterMethods_ = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- getValue: function getValue() {
- var listItem = _this.menuElement_.querySelector(constants_1.strings.SELECTED_ITEM_SELECTOR);
- if (listItem && listItem.hasAttribute(constants_1.strings.ENHANCED_VALUE_ATTR)) {
- return listItem.getAttribute(constants_1.strings.ENHANCED_VALUE_ATTR) || '';
- }
- return '';
- },
- setValue: function setValue(value) {
- var element = _this.menuElement_.querySelector("[" + constants_1.strings.ENHANCED_VALUE_ATTR + "=\"" + value + "\"]");
- _this.setEnhancedSelectedIndex_(element ? _this.menu_.items.indexOf(element) : -1);
- },
- openMenu: function openMenu() {
- if (_this.menu_ && !_this.menu_.open) {
- _this.menu_.open = true;
- _this.isMenuOpen_ = true;
- _this.selectedText_.setAttribute('aria-expanded', 'true');
- }
- },
- closeMenu: function closeMenu() {
- if (_this.menu_ && _this.menu_.open) {
- _this.menu_.open = false;
- }
- },
- isMenuOpen: function isMenuOpen() {
- return Boolean(_this.menu_) && _this.isMenuOpen_;
- },
- setSelectedIndex: function setSelectedIndex(index) {
- return _this.setEnhancedSelectedIndex_(index);
- },
- setDisabled: function setDisabled(isDisabled) {
- _this.selectedText_.setAttribute('tabindex', isDisabled ? '-1' : '0');
- _this.selectedText_.setAttribute('aria-disabled', isDisabled.toString());
- if (_this.hiddenInput_) {
- _this.hiddenInput_.disabled = isDisabled;
- }
- },
- checkValidity: function checkValidity() {
- var classList = _this.root_.classList;
- if (classList.contains(constants_1.cssClasses.REQUIRED) && !classList.contains(constants_1.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 !== -1 && (_this.selectedIndex !== 0 || Boolean(_this.value));
- } else {
- return true;
- }
- },
- setValid: function setValid(isValid) {
- _this.selectedText_.setAttribute('aria-invalid', (!isValid).toString());
- if (isValid) {
- _this.root_.classList.remove(constants_1.cssClasses.INVALID);
- } else {
- _this.root_.classList.add(constants_1.cssClasses.INVALID);
- }
- }
- };
- // 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;
- return {
- floatLabel: function floatLabel(shouldFloat) {
- return _this.label_ && _this.label_.float(shouldFloat);
- },
- getLabelWidth: function getLabelWidth() {
- return _this.label_ ? _this.label_.getWidth() : 0;
- }
- };
- };
- /**
- * 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
- };
- };
- MDCSelect.prototype.setEnhancedSelectedIndex_ = function (index) {
- var selectedItem = this.menu_.items[index];
- this.selectedText_.textContent = selectedItem ? selectedItem.textContent.trim() : '';
- var previouslySelected = this.menuElement_.querySelector(constants_1.strings.SELECTED_ITEM_SELECTOR);
- if (previouslySelected) {
- previouslySelected.classList.remove(constants_1.cssClasses.SELECTED_ITEM_CLASS);
- previouslySelected.removeAttribute(constants_1.strings.ARIA_SELECTED_ATTR);
- }
- if (selectedItem) {
- selectedItem.classList.add(constants_1.cssClasses.SELECTED_ITEM_CLASS);
- selectedItem.setAttribute(constants_1.strings.ARIA_SELECTED_ATTR, 'true');
- }
- // Synchronize hidden input's value with data-value attribute of selected item.
- // This code path is also followed when setting value directly, so this covers all cases.
- if (this.hiddenInput_) {
- this.hiddenInput_.value = selectedItem ? selectedItem.getAttribute(constants_1.strings.ENHANCED_VALUE_ATTR) || '' : '';
- }
- this.layout();
- };
- MDCSelect.prototype.initialSyncRequiredState_ = function () {
- var isRequired = this.targetElement_.required || this.targetElement_.getAttribute('aria-required') === 'true' || this.root_.classList.contains(constants_1.cssClasses.REQUIRED);
- if (isRequired) {
- if (this.nativeControl_) {
- this.nativeControl_.required = true;
- } else {
- this.selectedText_.setAttribute('aria-required', 'true');
- }
- this.root_.classList.add(constants_1.cssClasses.REQUIRED);
- }
- };
- MDCSelect.prototype.addMutationObserverForRequired_ = function () {
- var _this = this;
- var observerHandler = function observerHandler(attributesList) {
- attributesList.some(function (attributeName) {
- if (VALIDATION_ATTR_WHITELIST.indexOf(attributeName) === -1) {
- return false;
- }
- if (_this.selectedText_) {
- if (_this.selectedText_.getAttribute('aria-required') === 'true') {
- _this.root_.classList.add(constants_1.cssClasses.REQUIRED);
- } else {
- _this.root_.classList.remove(constants_1.cssClasses.REQUIRED);
- }
- } else {
- if (_this.nativeControl_.required) {
- _this.root_.classList.add(constants_1.cssClasses.REQUIRED);
- } else {
- _this.root_.classList.remove(constants_1.cssClasses.REQUIRED);
- }
- }
- return true;
- });
- };
- 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 observerHandler(getAttributesList(mutationsList));
- });
- observer.observe(this.targetElement_, { attributes: true });
- this.validationObserver_ = observer;
- };
- 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',
- ENHANCED_VALUE_ATTR: 'data-value',
- HIDDEN_INPUT_SELECTOR: 'input[type="hidden"]',
- LABEL_SELECTOR: '.mdc-floating-label',
- LEADING_ICON_SELECTOR: '.mdc-select__icon',
- LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
- MENU_SELECTOR: '.mdc-select__menu',
- NATIVE_CONTROL_SELECTOR: '.mdc-select__native-control',
- OUTLINE_SELECTOR: '.mdc-notched-outline',
- SELECTED_ITEM_SELECTOR: "." + cssClasses.SELECTED_ITEM_CLASS,
- SELECTED_TEXT_SELECTOR: '.mdc-select__selected-text'
- };
- exports.strings = strings;
- var numbers = {
- LABEL_SCALE: 0.75
- };
- 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__(/*! ./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;
- _this.leadingIcon_ = foundationMap.leadingIcon;
- _this.helperText_ = foundationMap.helperText;
- return _this;
- }
- Object.defineProperty(MDCSelectFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelectFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelectFoundation, "strings", {
- get: function get() {
- return constants_1.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;
- },
- setValue: function setValue() {
- return undefined;
- },
- getValue: function getValue() {
- return '';
- },
- 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;
- },
- openMenu: function openMenu() {
- return undefined;
- },
- closeMenu: function closeMenu() {
- return undefined;
- },
- isMenuOpen: function isMenuOpen() {
- return false;
- },
- setSelectedIndex: function setSelectedIndex() {
- return undefined;
- },
- setDisabled: function setDisabled() {
- return undefined;
- },
- setRippleCenter: function setRippleCenter() {
- return undefined;
- },
- notifyChange: function notifyChange() {
- return undefined;
- },
- checkValidity: function checkValidity() {
- return false;
- },
- setValid: function setValid() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCSelectFoundation.prototype.setSelectedIndex = function (index) {
- this.adapter_.setSelectedIndex(index);
- this.adapter_.closeMenu();
- var didChange = true;
- this.handleChange(didChange);
- };
- MDCSelectFoundation.prototype.setValue = function (value) {
- this.adapter_.setValue(value);
- var didChange = true;
- this.handleChange(didChange);
- };
- MDCSelectFoundation.prototype.getValue = function () {
- return this.adapter_.getValue();
- };
- MDCSelectFoundation.prototype.setDisabled = function (isDisabled) {
- if (isDisabled) {
- this.adapter_.addClass(constants_1.cssClasses.DISABLED);
- } else {
- this.adapter_.removeClass(constants_1.cssClasses.DISABLED);
- }
- this.adapter_.setDisabled(isDisabled);
- this.adapter_.closeMenu();
- if (this.leadingIcon_) {
- this.leadingIcon_.setDisabled(isDisabled);
- }
- };
- /**
- * @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 () {
- var openNotch = this.getValue().length > 0;
- this.notchOutline(openNotch);
- };
- MDCSelectFoundation.prototype.handleMenuOpened = function () {
- this.adapter_.addClass(constants_1.cssClasses.ACTIVATED);
- };
- MDCSelectFoundation.prototype.handleMenuClosed = function () {
- this.adapter_.removeClass(constants_1.cssClasses.ACTIVATED);
- };
- /**
- * Handles value changes, via change event or programmatic updates.
- */
- MDCSelectFoundation.prototype.handleChange = function (didChange) {
- if (didChange === void 0) {
- didChange = true;
- }
- var value = this.getValue();
- var optionHasValue = value.length > 0;
- var isRequired = this.adapter_.hasClass(constants_1.cssClasses.REQUIRED);
- this.notchOutline(optionHasValue);
- if (!this.adapter_.hasClass(constants_1.cssClasses.FOCUSED)) {
- this.adapter_.floatLabel(optionHasValue);
- }
- if (didChange) {
- this.adapter_.notifyChange(value);
- if (isRequired) {
- this.setValid(this.isValid());
- if (this.helperText_) {
- this.helperText_.setValidity(this.isValid());
- }
- }
- }
- };
- /**
- * Handles focus events from select element.
- */
- MDCSelectFoundation.prototype.handleFocus = function () {
- this.adapter_.addClass(constants_1.cssClasses.FOCUSED);
- this.adapter_.floatLabel(true);
- this.notchOutline(true);
- this.adapter_.activateBottomLine();
- if (this.helperText_) {
- this.helperText_.showToScreenReader();
- }
- };
- /**
- * Handles blur events from select element.
- */
- MDCSelectFoundation.prototype.handleBlur = function () {
- if (this.adapter_.isMenuOpen()) {
- return;
- }
- this.adapter_.removeClass(constants_1.cssClasses.FOCUSED);
- this.handleChange(false);
- this.adapter_.deactivateBottomLine();
- var isRequired = this.adapter_.hasClass(constants_1.cssClasses.REQUIRED);
- if (isRequired) {
- this.setValid(this.isValid());
- if (this.helperText_) {
- this.helperText_.setValidity(this.isValid());
- }
- }
- };
- MDCSelectFoundation.prototype.handleClick = function (normalizedX) {
- if (this.adapter_.isMenuOpen()) {
- return;
- }
- this.adapter_.setRippleCenter(normalizedX);
- this.adapter_.openMenu();
- };
- MDCSelectFoundation.prototype.handleKeydown = function (event) {
- if (this.adapter_.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_1.cssClasses.FOCUSED) && (isEnter || isSpace || arrowUp || arrowDown)) {
- this.adapter_.openMenu();
- event.preventDefault();
- }
- };
- /**
- * Opens/closes the notched outline.
- */
- MDCSelectFoundation.prototype.notchOutline = function (openNotch) {
- if (!this.adapter_.hasOutline()) {
- return;
- }
- var isFocused = this.adapter_.hasClass(constants_1.cssClasses.FOCUSED);
- if (openNotch) {
- var labelScale = constants_1.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_.setValid(isValid);
- };
- MDCSelectFoundation.prototype.isValid = function () {
- return this.adapter_.checkValidity();
- };
- 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();
- },
- appendTrackMarkers: function appendTrackMarkers(numMarkers) {
- var frag = document.createDocumentFragment();
- for (var i = 0; i < numMarkers; i++) {
- var marker = document.createElement('div');
- marker.classList.add('mdc-slider__track-marker');
- frag.appendChild(marker);
- }
- _this.trackMarkerContainer_.appendChild(frag);
- },
- removeTrackMarkers: function removeTrackMarkers() {
- while (_this.trackMarkerContainer_.firstChild) {
- _this.trackMarkerContainer_.removeChild(_this.trackMarkerContainer_.firstChild);
- }
- },
- setLastTrackMarkersStyleProperty: function setLastTrackMarkersStyleProperty(propertyName, value) {
- // We remove and append new nodes, thus, the last track marker must be dynamically found.
- var lastTrackMarker = _this.root_.querySelector(constants_1.strings.LAST_TRACK_MARKER_SELECTOR);
- lastTrackMarker.style.setProperty(propertyName, value);
- },
- 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',
- LAST_TRACK_MARKER_SELECTOR: '.mdc-slider__track-marker:last-child',
- 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;
- },
- appendTrackMarkers: function appendTrackMarkers() {
- return undefined;
- },
- removeTrackMarkers: function removeTrackMarkers() {
- return undefined;
- },
- setLastTrackMarkersStyleProperty: function setLastTrackMarkersStyleProperty() {
- 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) {
- var min = this.getMin();
- var max = this.getMax();
- var step = this.getStep();
- var numMarkers = (max - min) / step;
- // In case distance between max & min is indivisible to step,
- // we place the secondary to last marker proportionally at where thumb
- // could reach and place the last marker at max value
- var indivisible = Math.ceil(numMarkers) !== numMarkers;
- if (indivisible) {
- numMarkers = Math.ceil(numMarkers);
- }
- this.adapter_.removeTrackMarkers();
- this.adapter_.appendTrackMarkers(numMarkers);
- if (indivisible) {
- var lastStepRatio = (max - numMarkers * step) / step + 1;
- this.adapter_.setLastTrackMarkersStyleProperty('flex-grow', String(lastStepRatio));
- }
- }
- };
- 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 pageX of the event
- */
- MDCSliderFoundation.prototype.getPageX_ = function (evt) {
- if (evt.targetTouches && evt.targetTouches.length > 0) {
- return evt.targetTouches[0].pageX;
- }
- return evt.pageX;
- };
- /**
- * Sets the slider value from an event
- */
- MDCSliderFoundation.prototype.setValueFromEvt_ = function (evt) {
- var pageX = this.getPageX_(evt);
- var value = this.computeValueFromPageX_(pageX);
- this.setValue_(value, true);
- };
- /**
- * Computes the new value from the pageX position
- */
- MDCSliderFoundation.prototype.computeValueFromPageX_ = function (pageX) {
- var _a = this,
- max = _a.max_,
- min = _a.min_;
- var xPos = pageX - 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;
- }
- 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,
- 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 () {
- _this.handleAnimationTimerEnd_();
- _this.adapter_.notifyOpened();
- _this.autoDismissTimer_ = setTimeout(function () {
- _this.close(REASON_DISMISS);
- }, _this.getTimeoutMs());
- }, 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;
- if (timeoutMs <= maxValue && timeoutMs >= minValue) {
- this.autoDismissTimeoutMs_ = timeoutMs;
- } else {
- throw new Error("timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + ", 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;
- }
- };
- 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) {
- return 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 = {
- /** 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;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- /** Sets the checked state of the switch. */
- MDCSwitchFoundation.prototype.setChecked = function (checked) {
- this.adapter_.setNativeControlChecked(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.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);
- }
- };
- 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
- * @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;
- }
- if (this.isRTL_()) {
- return this.incrementScrollRTL_(scrollXIncrement);
- }
- this.incrementScroll_(scrollXIncrement);
- };
- /**
- * 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 increment scroll method
- * @param scrollX The new scroll position increment
- */
- MDCTabScrollerFoundation.prototype.incrementScroll_ = function (scrollX) {
- var currentScrollX = this.getScrollPosition();
- var targetScrollX = scrollX + currentScrollX;
- var safeScrollX = this.clampScrollValue_(targetScrollX);
- var scrollDelta = safeScrollX - currentScrollX;
- this.animate_({
- finalScrollPosition: safeScrollX,
- scrollDelta: scrollDelta
- });
- };
- /**
- * Internal increment scroll RTL method
- * @param scrollX The new scroll position RTL increment
- */
- MDCTabScrollerFoundation.prototype.incrementScrollRTL_ = function (scrollX) {
- var animation = this.getRTLScroller().incrementScrollRTL(scrollX);
- this.animate_(animation);
- };
- /**
- * 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;
- this.leadingIcon_ = null;
- this.trailingIcon_ = null;
- var iconElements = this.root_.querySelectorAll(constants_1.strings.ICON_SELECTOR);
- if (iconElements.length > 0) {
- if (iconElements.length > 1) {
- // Has both icons.
- this.leadingIcon_ = iconFactory(iconElements[0]);
- this.trailingIcon_ = iconFactory(iconElements[1]);
- } else {
- if (this.root_.classList.contains(constants_1.cssClasses.WITH_LEADING_ICON)) {
- this.leadingIcon_ = iconFactory(iconElements[0]);
- } else {
- this.trailingIcon_ = iconFactory(iconElements[0]);
- }
- }
- }
- 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',
- ICON_SELECTOR: '.mdc-text-field__icon',
- INPUT_SELECTOR: '.mdc-text-field__input',
- LABEL_SELECTOR: '.mdc-floating-label',
- LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
- OUTLINE_SELECTOR: '.mdc-notched-outline'
- };
- 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_ || Boolean(this.getValue()) || this.isBadInput_();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldShake", {
- get: function get() {
- return !this.isFocused_ && !this.isValid() && Boolean(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_;
- 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) {
- 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
|