12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598 |
- /**
- * @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 banner = __importStar(__webpack_require__(/*! @material/banner/index */ "./packages/mdc-banner/index.ts"));
- exports.banner = banner;
- 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 circularProgress = __importStar(__webpack_require__(/*! @material/circular-progress/index */ "./packages/mdc-circular-progress/index.ts"));
- exports.circularProgress = circularProgress;
- var dataTable = __importStar(__webpack_require__(/*! @material/data-table/index */ "./packages/mdc-data-table/index.ts"));
- exports.dataTable = dataTable;
- var dialog = __importStar(__webpack_require__(/*! @material/dialog/index */ "./packages/mdc-dialog/index.ts"));
- exports.dialog = dialog;
- var dom = __importStar(__webpack_require__(/*! @material/dom/index */ "./packages/mdc-dom/index.ts"));
- exports.dom = dom;
- var drawer = __importStar(__webpack_require__(/*! @material/drawer/index */ "./packages/mdc-drawer/index.ts"));
- exports.drawer = drawer;
- var floatingLabel = __importStar(__webpack_require__(/*! @material/floating-label/index */ "./packages/mdc-floating-label/index.ts"));
- exports.floatingLabel = floatingLabel;
- var formField = __importStar(__webpack_require__(/*! @material/form-field/index */ "./packages/mdc-form-field/index.ts"));
- exports.formField = formField;
- var iconButton = __importStar(__webpack_require__(/*! @material/icon-button/index */ "./packages/mdc-icon-button/index.ts"));
- exports.iconButton = iconButton;
- var lineRipple = __importStar(__webpack_require__(/*! @material/line-ripple/index */ "./packages/mdc-line-ripple/index.ts"));
- exports.lineRipple = lineRipple;
- var linearProgress = __importStar(__webpack_require__(/*! @material/linear-progress/index */ "./packages/mdc-linear-progress/index.ts"));
- exports.linearProgress = linearProgress;
- var list = __importStar(__webpack_require__(/*! @material/list/index */ "./packages/mdc-list/index.ts"));
- exports.list = list;
- var menuSurface = __importStar(__webpack_require__(/*! @material/menu-surface/index */ "./packages/mdc-menu-surface/index.ts"));
- exports.menuSurface = menuSurface;
- var menu = __importStar(__webpack_require__(/*! @material/menu/index */ "./packages/mdc-menu/index.ts"));
- exports.menu = menu;
- var notchedOutline = __importStar(__webpack_require__(/*! @material/notched-outline/index */ "./packages/mdc-notched-outline/index.ts"));
- exports.notchedOutline = notchedOutline;
- var radio = __importStar(__webpack_require__(/*! @material/radio/index */ "./packages/mdc-radio/index.ts"));
- exports.radio = radio;
- var ripple = __importStar(__webpack_require__(/*! @material/ripple/index */ "./packages/mdc-ripple/index.ts"));
- exports.ripple = ripple;
- var segmentedButton = __importStar(__webpack_require__(/*! @material/segmented-button/index */ "./packages/mdc-segmented-button/index.ts"));
- exports.segmentedButton = segmentedButton;
- 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 tooltip = __importStar(__webpack_require__(/*! @material/tooltip/index */ "./packages/mdc-tooltip/index.ts"));
- exports.tooltip = tooltip;
- 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('MDCBanner', banner.MDCBanner);
- 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('MDCCircularProgress', circularProgress.MDCCircularProgress);
- index_1.default.register('MDCDataTable', dataTable.MDCDataTable);
- index_1.default.register('MDCDialog', dialog.MDCDialog);
- index_1.default.register('MDCDrawer', drawer.MDCDrawer);
- index_1.default.register('MDCFloatingLabel', floatingLabel.MDCFloatingLabel);
- index_1.default.register('MDCFormField', formField.MDCFormField);
- index_1.default.register('MDCIconButtonToggle', iconButton.MDCIconButtonToggle);
- index_1.default.register('MDCLineRipple', lineRipple.MDCLineRipple);
- index_1.default.register('MDCLinearProgress', linearProgress.MDCLinearProgress);
- index_1.default.register('MDCList', list.MDCList);
- index_1.default.register('MDCMenu', menu.MDCMenu);
- index_1.default.register('MDCMenuSurface', menuSurface.MDCMenuSurface);
- index_1.default.register('MDCNotchedOutline', notchedOutline.MDCNotchedOutline);
- index_1.default.register('MDCRadio', radio.MDCRadio);
- index_1.default.register('MDCRipple', ripple.MDCRipple);
- index_1.default.register('MDCSegmentedButton', segmentedButton.MDCSegmentedButton);
- 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('MDCTooltip', tooltip.MDCTooltip);
- index_1.default.register('MDCTopAppBar', topAppBar.MDCTopAppBar);
- /***/ }),
- /***/ "./packages/mdc-animation/animationframe.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-animation/animationframe.ts ***!
- \**************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * AnimationFrame provides a user-friendly abstraction around requesting
- * and canceling animation frames.
- */
- var AnimationFrame = /** @class */function () {
- function AnimationFrame() {
- this.rafIDs = new Map();
- }
- /**
- * Requests an animation frame. Cancels any existing frame with the same key.
- * @param {string} key The key for this callback.
- * @param {FrameRequestCallback} callback The callback to be executed.
- */
- AnimationFrame.prototype.request = function (key, callback) {
- var _this = this;
- this.cancel(key);
- var frameID = requestAnimationFrame(function (frame) {
- _this.rafIDs.delete(key);
- // Callback must come *after* the key is deleted so that nested calls to
- // request with the same key are not deleted.
- callback(frame);
- });
- this.rafIDs.set(key, frameID);
- };
- /**
- * Cancels a queued callback with the given key.
- * @param {string} key The key for this callback.
- */
- AnimationFrame.prototype.cancel = function (key) {
- var rafID = this.rafIDs.get(key);
- if (rafID) {
- cancelAnimationFrame(rafID);
- this.rafIDs.delete(key);
- }
- };
- /**
- * Cancels all queued callback.
- */
- AnimationFrame.prototype.cancelAll = function () {
- var _this = this;
- // Need to use forEach because it's the only iteration method supported
- // by IE11. Suppress the underscore because we don't need it.
- // tslint:disable-next-line:enforce-name-casing
- this.rafIDs.forEach(function (_, key) {
- _this.cancel(key);
- });
- };
- /**
- * Returns the queue of unexecuted callback keys.
- */
- AnimationFrame.prototype.getQueue = function () {
- var queue = [];
- // Need to use forEach because it's the only iteration method supported
- // by IE11. Suppress the underscore because we don't need it.
- // tslint:disable-next-line:enforce-name-casing
- this.rafIDs.forEach(function (_, key) {
- queue.push(key);
- });
- return queue;
- };
- return AnimationFrame;
- }();
- exports.AnimationFrame = AnimationFrame;
- /***/ }),
- /***/ "./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 s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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];
- };
- /** @nocollapse */
- 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-banner/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-banner/component.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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-banner/constants.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-banner/foundation.ts");
- /** Vanilla JS implementation of banner component. */
- var MDCBanner = /** @class */function (_super) {
- __extends(MDCBanner, _super);
- function MDCBanner() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCBanner.attachTo = function (root) {
- return new MDCBanner(root);
- };
- MDCBanner.prototype.initialize = function () {
- var _this = this;
- this.contentEl = this.root.querySelector(constants_1.selectors.CONTENT);
- this.textEl = this.root.querySelector(constants_1.selectors.TEXT);
- this.primaryActionEl = this.root.querySelector(constants_1.selectors.PRIMARY_ACTION);
- this.secondaryActionEl = this.root.querySelector(constants_1.selectors.SECONDARY_ACTION);
- this.handleContentClick = function (evt) {
- var target = evt.target;
- if (ponyfill_1.closest(target, constants_1.selectors.PRIMARY_ACTION)) {
- _this.foundation.handlePrimaryActionClick();
- } else if (ponyfill_1.closest(target, constants_1.selectors.SECONDARY_ACTION)) {
- _this.foundation.handleSecondaryActionClick();
- }
- };
- };
- MDCBanner.prototype.initialSyncWithDOM = function () {
- this.registerContentClickHandler(this.handleContentClick);
- };
- MDCBanner.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.deregisterContentClickHandler(this.handleContentClick);
- };
- MDCBanner.prototype.layout = function () {
- this.foundation.layout();
- };
- /**
- * Opens the banner and fires events.OPENING to indicate the beginning of its
- * opening animation and then events.OPENED once the animation finishes.
- */
- MDCBanner.prototype.open = function () {
- this.foundation.open();
- };
- /**
- * Closes the banner and fires events.CLOSING to indicate the beginning of its
- * closing animation and then events.CLOSED once the animation finishes.
- * @param reason Why the banner was closed. Value will be passed to
- * events.CLOSING and events.CLOSED via the `event.detail.reason`
- * property. Standard values are CloseReason.PRIMARY and
- * CloseReason.SECONDARY, but CloseReason.UNSPECIFIED is provided for
- * custom handling of programmatic closing of the banner.
- */
- MDCBanner.prototype.close = function (reason) {
- this.foundation.close(reason);
- };
- MDCBanner.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) {
- _this.root.classList.add(className);
- },
- getContentHeight: function getContentHeight() {
- return _this.contentEl.offsetHeight;
- },
- notifyClosed: function notifyClosed(reason) {
- _this.emit(constants_1.events.CLOSED, { reason: reason });
- },
- notifyClosing: function notifyClosing(reason) {
- _this.emit(constants_1.events.CLOSING, { reason: reason });
- },
- notifyOpened: function notifyOpened() {
- _this.emit(constants_1.events.OPENED, {});
- },
- notifyOpening: function notifyOpening() {
- _this.emit(constants_1.events.OPENING, {});
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- setStyleProperty: function setStyleProperty(propertyName, value) {
- _this.root.style.setProperty(propertyName, value);
- }
- };
- return new foundation_1.MDCBannerFoundation(adapter);
- };
- Object.defineProperty(MDCBanner.prototype, "isOpen", {
- get: function get() {
- return this.foundation.isOpen();
- },
- enumerable: true,
- configurable: true
- });
- MDCBanner.prototype.getText = function () {
- return this.textEl.textContent || '';
- };
- MDCBanner.prototype.setText = function (text) {
- this.textEl.textContent = text;
- };
- MDCBanner.prototype.getPrimaryActionText = function () {
- return this.primaryActionEl.textContent || '';
- };
- MDCBanner.prototype.setPrimaryActionText = function (actionButtonText) {
- this.primaryActionEl.textContent = actionButtonText;
- };
- /** Returns null if the banner has no secondary action. */
- MDCBanner.prototype.getSecondaryActionText = function () {
- return this.secondaryActionEl ? this.secondaryActionEl.textContent || '' : null;
- };
- MDCBanner.prototype.setSecondaryActionText = function (actionButtonText) {
- if (this.secondaryActionEl) {
- this.secondaryActionEl.textContent = actionButtonText;
- }
- };
- MDCBanner.prototype.registerContentClickHandler = function (handler) {
- this.contentEl.addEventListener('click', handler);
- };
- MDCBanner.prototype.deregisterContentClickHandler = function (handler) {
- this.contentEl.removeEventListener('click', handler);
- };
- return MDCBanner;
- }(component_1.MDCComponent);
- exports.MDCBanner = MDCBanner;
- /***/ }),
- /***/ "./packages/mdc-banner/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-banner/constants.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /** Banner element classes. */
- exports.cssClasses = {
- CLOSING: 'mdc-banner--closing',
- OPEN: 'mdc-banner--open',
- OPENING: 'mdc-banner--opening'
- };
- /** Banner numbers. */
- exports.numbers = {
- BANNER_ANIMATION_CLOSE_TIME_MS: 250,
- BANNER_ANIMATION_OPEN_TIME_MS: 300
- };
- /** Banner events. */
- exports.events = {
- CLOSED: 'MDCBanner:closed',
- CLOSING: 'MDCBanner:closing',
- OPENED: 'MDCBanner:opened',
- OPENING: 'MDCBanner:opening'
- };
- /** Banner selectors. */
- exports.selectors = {
- CONTENT: '.mdc-banner__content',
- PRIMARY_ACTION: '.mdc-banner__primary-action',
- SECONDARY_ACTION: '.mdc-banner__secondary-action',
- TEXT: '.mdc-banner__text'
- };
- /** Reason as to why the banner was closed. */
- var CloseReason;
- (function (CloseReason) {
- // Indicates the banner was closed via primary action button.
- CloseReason[CloseReason["PRIMARY"] = 0] = "PRIMARY";
- // Indicates the banner was closed via secondary action button.
- CloseReason[CloseReason["SECONDARY"] = 1] = "SECONDARY";
- // Will never be used by the component. Provided for custom handling of
- // programmatic closing of the banner.
- CloseReason[CloseReason["UNSPECIFIED"] = 2] = "UNSPECIFIED";
- })(CloseReason = exports.CloseReason || (exports.CloseReason = {}));
- /***/ }),
- /***/ "./packages/mdc-banner/foundation.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-banner/foundation.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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-banner/constants.ts");
- var OPENING = constants_1.cssClasses.OPENING,
- OPEN = constants_1.cssClasses.OPEN,
- CLOSING = constants_1.cssClasses.CLOSING;
- /**
- * Foundation class for banner. Responsibilities include opening and closing the
- * banner.
- */
- var MDCBannerFoundation = /** @class */function (_super) {
- __extends(MDCBannerFoundation, _super);
- function MDCBannerFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCBannerFoundation.defaultAdapter), adapter)) || this;
- _this.isOpened = false;
- // Request id for open animation, used to cancel the refresh callback
- // request on close() and destroy().
- _this.animationFrame = 0;
- // Timer id for close and open animation, used to cancel the timer on
- // close() and destroy().
- _this.animationTimer = 0;
- return _this;
- }
- Object.defineProperty(MDCBannerFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- getContentHeight: function getContentHeight() {
- return 0;
- },
- 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;
- },
- setStyleProperty: function setStyleProperty() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCBannerFoundation.prototype.destroy = function () {
- cancelAnimationFrame(this.animationFrame);
- this.animationFrame = 0;
- clearTimeout(this.animationTimer);
- this.animationTimer = 0;
- };
- MDCBannerFoundation.prototype.open = function () {
- var _this = this;
- this.isOpened = true;
- this.adapter.notifyOpening();
- this.adapter.removeClass(CLOSING);
- this.adapter.addClass(OPENING);
- var contentHeight = this.adapter.getContentHeight();
- this.animationFrame = requestAnimationFrame(function () {
- _this.adapter.addClass(OPEN);
- _this.adapter.setStyleProperty('height', contentHeight + "px");
- _this.animationTimer = setTimeout(function () {
- _this.handleAnimationTimerEnd();
- _this.adapter.notifyOpened();
- }, constants_1.numbers.BANNER_ANIMATION_OPEN_TIME_MS);
- });
- };
- /**
- * @param reason Why the banner was closed. Value will be passed to
- * events.CLOSING and events.CLOSED via the `event.detail.reason`
- * property. Standard values are CloseReason.PRIMARY and
- * CloseReason.SECONDARY, but CloseReason.UNSPECIFIED is provided for
- * custom handling of programmatic closing of the banner.
- */
- MDCBannerFoundation.prototype.close = function (reason) {
- var _this = this;
- if (!this.isOpened) {
- // Avoid redundant close calls (and events), e.g. repeated interactions as
- // the banner is animating closed
- return;
- }
- cancelAnimationFrame(this.animationFrame);
- this.animationFrame = 0;
- this.isOpened = false;
- this.adapter.notifyClosing(reason);
- this.adapter.addClass(CLOSING);
- this.adapter.setStyleProperty('height', '0');
- this.adapter.removeClass(OPEN);
- this.adapter.removeClass(OPENING);
- clearTimeout(this.animationTimer);
- this.animationTimer = setTimeout(function () {
- _this.handleAnimationTimerEnd();
- _this.adapter.notifyClosed(reason);
- }, constants_1.numbers.BANNER_ANIMATION_CLOSE_TIME_MS);
- };
- MDCBannerFoundation.prototype.isOpen = function () {
- return this.isOpened;
- };
- MDCBannerFoundation.prototype.handlePrimaryActionClick = function () {
- this.close(constants_1.CloseReason.PRIMARY);
- };
- MDCBannerFoundation.prototype.handleSecondaryActionClick = function () {
- this.close(constants_1.CloseReason.SECONDARY);
- };
- MDCBannerFoundation.prototype.layout = function () {
- var contentHeight = this.adapter.getContentHeight();
- this.adapter.setStyleProperty('height', contentHeight + "px");
- };
- MDCBannerFoundation.prototype.handleAnimationTimerEnd = function () {
- this.animationTimer = 0;
- this.adapter.removeClass(OPENING);
- this.adapter.removeClass(CLOSING);
- };
- return MDCBannerFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCBannerFoundation = MDCBannerFoundation;
- /***/ }),
- /***/ "./packages/mdc-banner/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-banner/index.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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-banner/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-banner/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-banner/foundation.ts"));
- /***/ }),
- /***/ "./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 constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.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.initialize = function () {
- var DATA_INDETERMINATE_ATTR = constants_1.strings.DATA_INDETERMINATE_ATTR;
- this.nativeControl_.indeterminate = this.nativeControl_.getAttribute(DATA_INDETERMINATE_ATTR) === 'true';
- this.nativeControl_.removeAttribute(DATA_INDETERMINATE_ATTR);
- };
- 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) {
- _this.root.classList.remove(className);
- },
- removeNativeControlAttr: function removeNativeControlAttr(attr) {
- _this.nativeControl_.removeAttribute(attr);
- },
- setNativeControlAttr: function setNativeControlAttr(attr, value) {
- _this.nativeControl_.setAttribute(attr, value);
- },
- setNativeControlDisabled: function setNativeControlDisabled(disabled) {
- _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(__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 = constants_1.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',
- DATA_INDETERMINATE_ATTR: 'data-indeterminate',
- 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(__assign({}, MDCCheckboxFoundation.defaultAdapter), adapter)) || this;
- _this.currentCheckState_ = constants_1.strings.TRANSITION_STATE_INIT;
- _this.currentAnimationClass_ = '';
- _this.animEndLatchTimer_ = 0;
- _this.enableAnimationEndHandler_ = false;
- return _this;
- }
- Object.defineProperty(MDCCheckboxFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCheckboxFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCheckboxFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCheckboxFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- forceLayout: function forceLayout() {
- return undefined;
- },
- hasNativeControl: function hasNativeControl() {
- return false;
- },
- isAttachedToDOM: function isAttachedToDOM() {
- return false;
- },
- isChecked: function isChecked() {
- return false;
- },
- isIndeterminate: function isIndeterminate() {
- return false;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- removeNativeControlAttr: function removeNativeControlAttr() {
- return undefined;
- },
- setNativeControlAttr: function setNativeControlAttr() {
- return undefined;
- },
- setNativeControlDisabled: function setNativeControlDisabled() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCCheckboxFoundation.prototype.init = function () {
- this.currentCheckState_ = this.determineCheckState_();
- this.updateAriaChecked_();
- this.adapter.addClass(constants_1.cssClasses.UPGRADED);
- };
- MDCCheckboxFoundation.prototype.destroy = function () {
- clearTimeout(this.animEndLatchTimer_);
- };
- MDCCheckboxFoundation.prototype.setDisabled = function (disabled) {
- this.adapter.setNativeControlDisabled(disabled);
- if (disabled) {
- this.adapter.addClass(constants_1.cssClasses.DISABLED);
- } else {
- this.adapter.removeClass(constants_1.cssClasses.DISABLED);
- }
- };
- /**
- * Handles the animationend event for the checkbox
- */
- MDCCheckboxFoundation.prototype.handleAnimationEnd = function () {
- var _this = this;
- if (!this.enableAnimationEndHandler_) {
- return;
- }
- clearTimeout(this.animEndLatchTimer_);
- this.animEndLatchTimer_ = setTimeout(function () {
- _this.adapter.removeClass(_this.currentAnimationClass_);
- _this.enableAnimationEndHandler_ = false;
- }, constants_1.numbers.ANIM_END_LATCH_MS);
- };
- /**
- * Handles the change event for the checkbox
- */
- MDCCheckboxFoundation.prototype.handleChange = function () {
- this.transitionCheckState_();
- };
- MDCCheckboxFoundation.prototype.transitionCheckState_ = function () {
- if (!this.adapter.hasNativeControl()) {
- return;
- }
- var oldState = this.currentCheckState_;
- var newState = this.determineCheckState_();
- if (oldState === newState) {
- return;
- }
- this.updateAriaChecked_();
- var TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
- var SELECTED = constants_1.cssClasses.SELECTED;
- if (newState === TRANSITION_STATE_UNCHECKED) {
- this.adapter.removeClass(SELECTED);
- } else {
- this.adapter.addClass(SELECTED);
- }
- // Check to ensure that there isn't a previously existing animation class, in case for example
- // the user interacted with the checkbox before the animation was finished.
- if (this.currentAnimationClass_.length > 0) {
- clearTimeout(this.animEndLatchTimer_);
- this.adapter.forceLayout();
- this.adapter.removeClass(this.currentAnimationClass_);
- }
- this.currentAnimationClass_ = this.getTransitionAnimationClass_(oldState, newState);
- this.currentCheckState_ = newState;
- // Check for parentNode so that animations are only run when the element is attached
- // to the DOM.
- if (this.adapter.isAttachedToDOM() && this.currentAnimationClass_.length > 0) {
- this.adapter.addClass(this.currentAnimationClass_);
- this.enableAnimationEndHandler_ = true;
- }
- };
- MDCCheckboxFoundation.prototype.determineCheckState_ = function () {
- var TRANSITION_STATE_INDETERMINATE = constants_1.strings.TRANSITION_STATE_INDETERMINATE,
- TRANSITION_STATE_CHECKED = constants_1.strings.TRANSITION_STATE_CHECKED,
- TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
- if (this.adapter.isIndeterminate()) {
- return TRANSITION_STATE_INDETERMINATE;
- }
- return this.adapter.isChecked() ? TRANSITION_STATE_CHECKED : TRANSITION_STATE_UNCHECKED;
- };
- MDCCheckboxFoundation.prototype.getTransitionAnimationClass_ = function (oldState, newState) {
- var TRANSITION_STATE_INIT = constants_1.strings.TRANSITION_STATE_INIT,
- TRANSITION_STATE_CHECKED = constants_1.strings.TRANSITION_STATE_CHECKED,
- TRANSITION_STATE_UNCHECKED = constants_1.strings.TRANSITION_STATE_UNCHECKED;
- var _a = MDCCheckboxFoundation.cssClasses,
- ANIM_UNCHECKED_CHECKED = _a.ANIM_UNCHECKED_CHECKED,
- ANIM_UNCHECKED_INDETERMINATE = _a.ANIM_UNCHECKED_INDETERMINATE,
- ANIM_CHECKED_UNCHECKED = _a.ANIM_CHECKED_UNCHECKED,
- ANIM_CHECKED_INDETERMINATE = _a.ANIM_CHECKED_INDETERMINATE,
- ANIM_INDETERMINATE_CHECKED = _a.ANIM_INDETERMINATE_CHECKED,
- ANIM_INDETERMINATE_UNCHECKED = _a.ANIM_INDETERMINATE_UNCHECKED;
- switch (oldState) {
- case TRANSITION_STATE_INIT:
- if (newState === TRANSITION_STATE_UNCHECKED) {
- return '';
- }
- return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED;
- case TRANSITION_STATE_UNCHECKED:
- return newState === TRANSITION_STATE_CHECKED ? ANIM_UNCHECKED_CHECKED : ANIM_UNCHECKED_INDETERMINATE;
- case TRANSITION_STATE_CHECKED:
- return newState === TRANSITION_STATE_UNCHECKED ? ANIM_CHECKED_UNCHECKED : ANIM_CHECKED_INDETERMINATE;
- default:
- // TRANSITION_STATE_INDETERMINATE
- return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED;
- }
- };
- MDCCheckboxFoundation.prototype.updateAriaChecked_ = function () {
- // Ensure aria-checked is set to mixed if checkbox is in indeterminate state.
- if (this.adapter.isIndeterminate()) {
- this.adapter.setNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR, constants_1.strings.ARIA_CHECKED_INDETERMINATE_VALUE);
- } else {
- // The on/off state does not need to keep track of aria-checked, since
- // the screenreader uses the checked property on the checkbox element.
- this.adapter.removeNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR);
- }
- };
- return MDCCheckboxFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCCheckboxFoundation = MDCCheckboxFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCCheckboxFoundation;
- /***/ }),
- /***/ "./packages/mdc-checkbox/index.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-checkbox/index.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-checkbox/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-checkbox/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-checkbox/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-chips/chip-set/component.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-chips/chip-set/component.ts ***!
- \**************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var announce_1 = __webpack_require__(/*! @material/dom/announce */ "./packages/mdc-dom/announce.ts");
- var component_2 = __webpack_require__(/*! ../chip/component */ "./packages/mdc-chips/chip/component.ts");
- var foundation_1 = __webpack_require__(/*! ../chip/foundation */ "./packages/mdc-chips/chip/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip-set/foundation.ts");
- var _a = foundation_1.MDCChipFoundation.strings,
- INTERACTION_EVENT = _a.INTERACTION_EVENT,
- SELECTION_EVENT = _a.SELECTION_EVENT,
- REMOVAL_EVENT = _a.REMOVAL_EVENT,
- NAVIGATION_EVENT = _a.NAVIGATION_EVENT;
- var CHIP_SELECTOR = foundation_2.MDCChipSetFoundation.strings.CHIP_SELECTOR;
- var idCounter = 0;
- var MDCChipSet = /** @class */function (_super) {
- __extends(MDCChipSet, _super);
- function MDCChipSet() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCChipSet.attachTo = function (root) {
- return new MDCChipSet(root);
- };
- Object.defineProperty(MDCChipSet.prototype, "chips", {
- get: function get() {
- return this.chips_.slice();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipSet.prototype, "selectedChipIds", {
- /**
- * @return An array of the IDs of all selected chips.
- */
- get: function get() {
- return this.foundation.getSelectedChipIds();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param chipFactory A function which creates a new MDCChip.
- */
- MDCChipSet.prototype.initialize = function (chipFactory) {
- if (chipFactory === void 0) {
- chipFactory = function chipFactory(el) {
- return new component_2.MDCChip(el);
- };
- }
- this.chipFactory_ = chipFactory;
- this.chips_ = this.instantiateChips_(this.chipFactory_);
- };
- MDCChipSet.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.chips_.forEach(function (chip) {
- if (chip.id && chip.selected) {
- _this.foundation.select(chip.id);
- }
- });
- this.handleChipInteraction_ = function (evt) {
- return _this.foundation.handleChipInteraction(evt.detail);
- };
- this.handleChipSelection_ = function (evt) {
- return _this.foundation.handleChipSelection(evt.detail);
- };
- this.handleChipRemoval_ = function (evt) {
- return _this.foundation.handleChipRemoval(evt.detail);
- };
- this.handleChipNavigation_ = function (evt) {
- return _this.foundation.handleChipNavigation(evt.detail);
- };
- this.listen(INTERACTION_EVENT, this.handleChipInteraction_);
- this.listen(SELECTION_EVENT, this.handleChipSelection_);
- this.listen(REMOVAL_EVENT, this.handleChipRemoval_);
- this.listen(NAVIGATION_EVENT, this.handleChipNavigation_);
- };
- MDCChipSet.prototype.destroy = function () {
- this.chips_.forEach(function (chip) {
- chip.destroy();
- });
- this.unlisten(INTERACTION_EVENT, this.handleChipInteraction_);
- this.unlisten(SELECTION_EVENT, this.handleChipSelection_);
- this.unlisten(REMOVAL_EVENT, this.handleChipRemoval_);
- this.unlisten(NAVIGATION_EVENT, this.handleChipNavigation_);
- _super.prototype.destroy.call(this);
- };
- /**
- * Adds a new chip object to the chip set from the given chip element.
- */
- MDCChipSet.prototype.addChip = function (chipEl) {
- chipEl.id = chipEl.id || "mdc-chip-" + ++idCounter;
- this.chips_.push(this.chipFactory_(chipEl));
- };
- MDCChipSet.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- var adapter = {
- announceMessage: function announceMessage(message) {
- announce_1.announce(message);
- },
- focusChipPrimaryActionAtIndex: function focusChipPrimaryActionAtIndex(index) {
- _this.chips_[index].focusPrimaryAction();
- },
- focusChipTrailingActionAtIndex: function focusChipTrailingActionAtIndex(index) {
- _this.chips_[index].focusTrailingAction();
- },
- getChipListCount: function getChipListCount() {
- return _this.chips_.length;
- },
- getIndexOfChipById: function getIndexOfChipById(chipId) {
- return _this.findChipIndex_(chipId);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- isRTL: function isRTL() {
- return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
- },
- removeChipAtIndex: function removeChipAtIndex(index) {
- if (index >= 0 && index < _this.chips_.length) {
- _this.chips_[index].destroy();
- _this.chips_[index].remove();
- _this.chips_.splice(index, 1);
- }
- },
- removeFocusFromChipAtIndex: function removeFocusFromChipAtIndex(index) {
- _this.chips_[index].removeFocus();
- },
- selectChipAtIndex: function selectChipAtIndex(index, selected, shouldNotifyClients) {
- if (index >= 0 && index < _this.chips_.length) {
- _this.chips_[index].setSelectedFromChipSet(selected, shouldNotifyClients);
- }
- }
- };
- return new foundation_2.MDCChipSetFoundation(adapter);
- };
- /**
- * Instantiates chip components on all of the chip set's child chip elements.
- */
- MDCChipSet.prototype.instantiateChips_ = function (chipFactory) {
- var chipElements = [].slice.call(this.root.querySelectorAll(CHIP_SELECTOR));
- return chipElements.map(function (el) {
- el.id = el.id || "mdc-chip-" + ++idCounter;
- return chipFactory(el);
- });
- };
- /**
- * Returns the index of the chip with the given id, or -1 if the chip does not exist.
- */
- MDCChipSet.prototype.findChipIndex_ = function (chipId) {
- for (var i = 0; i < this.chips_.length; i++) {
- if (this.chips_[i].id === chipId) {
- return i;
- }
- }
- return -1;
- };
- return MDCChipSet;
- }(component_1.MDCComponent);
- exports.MDCChipSet = MDCChipSet;
- /***/ }),
- /***/ "./packages/mdc-chips/chip-set/constants.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-chips/chip-set/constants.ts ***!
- \**************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.strings = {
- CHIP_SELECTOR: '.mdc-chip'
- };
- exports.cssClasses = {
- CHOICE: 'mdc-chip-set--choice',
- FILTER: 'mdc-chip-set--filter'
- };
- /***/ }),
- /***/ "./packages/mdc-chips/chip-set/foundation.ts":
- /*!***************************************************!*\
- !*** ./packages/mdc-chips/chip-set/foundation.ts ***!
- \***************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2017 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ../chip/constants */ "./packages/mdc-chips/chip/constants.ts");
- var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip-set/constants.ts");
- var MDCChipSetFoundation = /** @class */function (_super) {
- __extends(MDCChipSetFoundation, _super);
- function MDCChipSetFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCChipSetFoundation.defaultAdapter), adapter)) || this;
- /**
- * The ids of the selected chips in the set. Only used for choice chip set or filter chip set.
- */
- _this.selectedChipIds_ = [];
- return _this;
- }
- Object.defineProperty(MDCChipSetFoundation, "strings", {
- get: function get() {
- return constants_2.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipSetFoundation, "cssClasses", {
- get: function get() {
- return constants_2.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipSetFoundation, "defaultAdapter", {
- get: function get() {
- return {
- announceMessage: function announceMessage() {
- return undefined;
- },
- focusChipPrimaryActionAtIndex: function focusChipPrimaryActionAtIndex() {
- return undefined;
- },
- focusChipTrailingActionAtIndex: function focusChipTrailingActionAtIndex() {
- return undefined;
- },
- getChipListCount: function getChipListCount() {
- return -1;
- },
- getIndexOfChipById: function getIndexOfChipById() {
- return -1;
- },
- hasClass: function hasClass() {
- return false;
- },
- isRTL: function isRTL() {
- return false;
- },
- removeChipAtIndex: function removeChipAtIndex() {
- return undefined;
- },
- removeFocusFromChipAtIndex: function removeFocusFromChipAtIndex() {
- return undefined;
- },
- selectChipAtIndex: function selectChipAtIndex() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Returns an array of the IDs of all selected chips.
- */
- MDCChipSetFoundation.prototype.getSelectedChipIds = function () {
- return this.selectedChipIds_.slice();
- };
- /**
- * Selects the chip with the given id. Deselects all other chips if the chip set is of the choice variant.
- * Does not notify clients of the updated selection state.
- */
- MDCChipSetFoundation.prototype.select = function (chipId) {
- this.select_(chipId, false);
- };
- /**
- * Handles a chip interaction event
- */
- MDCChipSetFoundation.prototype.handleChipInteraction = function (_a) {
- var chipId = _a.chipId;
- var index = this.adapter.getIndexOfChipById(chipId);
- this.removeFocusFromChipsExcept_(index);
- if (this.adapter.hasClass(constants_2.cssClasses.CHOICE) || this.adapter.hasClass(constants_2.cssClasses.FILTER)) {
- this.toggleSelect_(chipId);
- }
- };
- /**
- * Handles a chip selection event, used to handle discrepancy when selection state is set directly on the Chip.
- */
- MDCChipSetFoundation.prototype.handleChipSelection = function (_a) {
- var chipId = _a.chipId,
- selected = _a.selected,
- shouldIgnore = _a.shouldIgnore;
- // Early exit if we should ignore the event
- if (shouldIgnore) {
- return;
- }
- var chipIsSelected = this.selectedChipIds_.indexOf(chipId) >= 0;
- if (selected && !chipIsSelected) {
- this.select(chipId);
- } else if (!selected && chipIsSelected) {
- this.deselect_(chipId);
- }
- };
- /**
- * Handles the event when a chip is removed.
- */
- MDCChipSetFoundation.prototype.handleChipRemoval = function (_a) {
- var chipId = _a.chipId,
- removedAnnouncement = _a.removedAnnouncement;
- if (removedAnnouncement) {
- this.adapter.announceMessage(removedAnnouncement);
- }
- var index = this.adapter.getIndexOfChipById(chipId);
- this.deselectAndNotifyClients_(chipId);
- this.adapter.removeChipAtIndex(index);
- var maxIndex = this.adapter.getChipListCount() - 1;
- if (maxIndex < 0) {
- return;
- }
- var nextIndex = Math.min(index, maxIndex);
- this.removeFocusFromChipsExcept_(nextIndex);
- // After removing a chip, we should focus the trailing action for the next chip.
- this.adapter.focusChipTrailingActionAtIndex(nextIndex);
- };
- /**
- * Handles a chip navigation event.
- */
- MDCChipSetFoundation.prototype.handleChipNavigation = function (_a) {
- var chipId = _a.chipId,
- key = _a.key,
- source = _a.source;
- var maxIndex = this.adapter.getChipListCount() - 1;
- var index = this.adapter.getIndexOfChipById(chipId);
- // Early exit if the index is out of range or the key is unusable
- if (index === -1 || !constants_1.navigationKeys.has(key)) {
- return;
- }
- var isRTL = this.adapter.isRTL();
- var isLeftKey = key === constants_1.strings.ARROW_LEFT_KEY || key === constants_1.strings.IE_ARROW_LEFT_KEY;
- var isRightKey = key === constants_1.strings.ARROW_RIGHT_KEY || key === constants_1.strings.IE_ARROW_RIGHT_KEY;
- var isDownKey = key === constants_1.strings.ARROW_DOWN_KEY || key === constants_1.strings.IE_ARROW_DOWN_KEY;
- var shouldIncrement = !isRTL && isRightKey || isRTL && isLeftKey || isDownKey;
- var isHome = key === constants_1.strings.HOME_KEY;
- var isEnd = key === constants_1.strings.END_KEY;
- if (shouldIncrement) {
- index++;
- } else if (isHome) {
- index = 0;
- } else if (isEnd) {
- index = maxIndex;
- } else {
- index--;
- }
- // Early exit if the index is out of bounds
- if (index < 0 || index > maxIndex) {
- return;
- }
- this.removeFocusFromChipsExcept_(index);
- this.focusChipAction_(index, key, source);
- };
- MDCChipSetFoundation.prototype.focusChipAction_ = function (index, key, source) {
- var shouldJumpChips = constants_1.jumpChipKeys.has(key);
- if (shouldJumpChips && source === constants_1.EventSource.PRIMARY) {
- return this.adapter.focusChipPrimaryActionAtIndex(index);
- }
- if (shouldJumpChips && source === constants_1.EventSource.TRAILING) {
- return this.adapter.focusChipTrailingActionAtIndex(index);
- }
- var dir = this.getDirection_(key);
- if (dir === constants_1.Direction.LEFT) {
- return this.adapter.focusChipTrailingActionAtIndex(index);
- }
- if (dir === constants_1.Direction.RIGHT) {
- return this.adapter.focusChipPrimaryActionAtIndex(index);
- }
- };
- MDCChipSetFoundation.prototype.getDirection_ = function (key) {
- var isRTL = this.adapter.isRTL();
- var isLeftKey = key === constants_1.strings.ARROW_LEFT_KEY || key === constants_1.strings.IE_ARROW_LEFT_KEY;
- var isRightKey = key === constants_1.strings.ARROW_RIGHT_KEY || key === constants_1.strings.IE_ARROW_RIGHT_KEY;
- if (!isRTL && isLeftKey || isRTL && isRightKey) {
- return constants_1.Direction.LEFT;
- }
- return constants_1.Direction.RIGHT;
- };
- /**
- * Deselects the chip with the given id and optionally notifies clients.
- */
- MDCChipSetFoundation.prototype.deselect_ = function (chipId, shouldNotifyClients) {
- if (shouldNotifyClients === void 0) {
- shouldNotifyClients = false;
- }
- var index = this.selectedChipIds_.indexOf(chipId);
- if (index >= 0) {
- this.selectedChipIds_.splice(index, 1);
- var chipIndex = this.adapter.getIndexOfChipById(chipId);
- this.adapter.selectChipAtIndex(chipIndex, /** isSelected */false, shouldNotifyClients);
- }
- };
- /**
- * Deselects the chip with the given id and notifies clients.
- */
- MDCChipSetFoundation.prototype.deselectAndNotifyClients_ = function (chipId) {
- this.deselect_(chipId, true);
- };
- /**
- * Toggles selection of the chip with the given id.
- */
- MDCChipSetFoundation.prototype.toggleSelect_ = function (chipId) {
- if (this.selectedChipIds_.indexOf(chipId) >= 0) {
- this.deselectAndNotifyClients_(chipId);
- } else {
- this.selectAndNotifyClients_(chipId);
- }
- };
- MDCChipSetFoundation.prototype.removeFocusFromChipsExcept_ = function (index) {
- var chipCount = this.adapter.getChipListCount();
- for (var i = 0; i < chipCount; i++) {
- if (i !== index) {
- this.adapter.removeFocusFromChipAtIndex(i);
- }
- }
- };
- MDCChipSetFoundation.prototype.selectAndNotifyClients_ = function (chipId) {
- this.select_(chipId, true);
- };
- MDCChipSetFoundation.prototype.select_ = function (chipId, shouldNotifyClients) {
- if (this.selectedChipIds_.indexOf(chipId) >= 0) {
- return;
- }
- if (this.adapter.hasClass(constants_2.cssClasses.CHOICE) && this.selectedChipIds_.length > 0) {
- var previouslySelectedChip = this.selectedChipIds_[0];
- var previouslySelectedIndex = this.adapter.getIndexOfChipById(previouslySelectedChip);
- this.selectedChipIds_ = [];
- this.adapter.selectChipAtIndex(previouslySelectedIndex, /** isSelected */false, shouldNotifyClients);
- }
- this.selectedChipIds_.push(chipId);
- var index = this.adapter.getIndexOfChipById(chipId);
- this.adapter.selectChipAtIndex(index, /** isSelected */true, shouldNotifyClients);
- };
- return MDCChipSetFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCChipSetFoundation = MDCChipSetFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCChipSetFoundation;
- /***/ }),
- /***/ "./packages/mdc-chips/chip-set/index.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-chips/chip-set/index.ts ***!
- \**********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-chips/chip-set/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip-set/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip-set/constants.ts");
- exports.chipSetCssClasses = constants_1.cssClasses;
- exports.chipSetStrings = constants_1.strings;
- /***/ }),
- /***/ "./packages/mdc-chips/chip/component.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-chips/chip/component.ts ***!
- \**********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var component_3 = __webpack_require__(/*! ../trailingaction/component */ "./packages/mdc-chips/trailingaction/component.ts");
- var constants_1 = __webpack_require__(/*! ../trailingaction/constants */ "./packages/mdc-chips/trailingaction/constants.ts");
- var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip/constants.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/chip/foundation.ts");
- 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, "setShouldFocusPrimaryActionOnClick", {
- /**
- * Sets whether a clicking on the chip should focus the primary action.
- */
- set: function set(shouldFocus) {
- this.foundation.setShouldFocusPrimaryActionOnClick(shouldFocus);
- },
- 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, trailingActionFactory) {
- var _this = this;
- if (rippleFactory === void 0) {
- rippleFactory = function rippleFactory(el, foundation) {
- return new component_2.MDCRipple(el, foundation);
- };
- }
- if (trailingActionFactory === void 0) {
- trailingActionFactory = function trailingActionFactory(el) {
- return new component_3.MDCChipTrailingAction(el);
- };
- }
- this.leadingIcon_ = this.root.querySelector(constants_2.strings.LEADING_ICON_SELECTOR);
- this.checkmark_ = this.root.querySelector(constants_2.strings.CHECKMARK_SELECTOR);
- this.primaryAction_ = this.root.querySelector(constants_2.strings.PRIMARY_ACTION_SELECTOR);
- var trailingActionEl = this.root.querySelector(constants_2.strings.TRAILING_ACTION_SELECTOR);
- if (trailingActionEl) {
- this.trailingAction_ = trailingActionFactory(trailingActionEl);
- }
- // 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(__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;
- // Custom events
- this.handleTrailingActionInteraction_ = function () {
- _this.foundation.handleTrailingActionInteraction();
- };
- this.handleTrailingActionNavigation_ = function (evt) {
- _this.foundation.handleTrailingActionNavigation(evt);
- };
- // Native events
- this.handleClick_ = function () {
- _this.foundation.handleClick();
- };
- this.handleKeydown_ = function (evt) {
- _this.foundation.handleKeydown(evt);
- };
- this.handleTransitionEnd_ = function (evt) {
- _this.foundation.handleTransitionEnd(evt);
- };
- this.handleFocusIn_ = function (evt) {
- _this.foundation.handleFocusIn(evt);
- };
- this.handleFocusOut_ = function (evt) {
- _this.foundation.handleFocusOut(evt);
- };
- this.listen('transitionend', this.handleTransitionEnd_);
- this.listen('click', this.handleClick_);
- this.listen('keydown', this.handleKeydown_);
- this.listen('focusin', this.handleFocusIn_);
- this.listen('focusout', this.handleFocusOut_);
- if (this.trailingAction_) {
- this.listen(constants_1.strings.INTERACTION_EVENT, this.handleTrailingActionInteraction_);
- this.listen(constants_1.strings.NAVIGATION_EVENT, this.handleTrailingActionNavigation_);
- }
- };
- MDCChip.prototype.destroy = function () {
- this.ripple_.destroy();
- this.unlisten('transitionend', this.handleTransitionEnd_);
- this.unlisten('keydown', this.handleKeydown_);
- this.unlisten('click', this.handleClick_);
- this.unlisten('focusin', this.handleFocusIn_);
- this.unlisten('focusout', this.handleFocusOut_);
- if (this.trailingAction_) {
- this.unlisten(constants_1.strings.INTERACTION_EVENT, this.handleTrailingActionInteraction_);
- this.unlisten(constants_1.strings.NAVIGATION_EVENT, this.handleTrailingActionNavigation_);
- }
- _super.prototype.destroy.call(this);
- };
- /**
- * Begins the exit animation which leads to removal of the chip.
- */
- MDCChip.prototype.beginExit = function () {
- this.foundation.beginExit();
- };
- MDCChip.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- var adapter = {
- addClass: function addClass(className) {
- return _this.root.classList.add(className);
- },
- addClassToLeadingIcon: function addClassToLeadingIcon(className) {
- if (_this.leadingIcon_) {
- _this.leadingIcon_.classList.add(className);
- }
- },
- eventTargetHasClass: function eventTargetHasClass(target, className) {
- return target ? target.classList.contains(className) : false;
- },
- focusPrimaryAction: function focusPrimaryAction() {
- if (_this.primaryAction_) {
- _this.primaryAction_.focus();
- }
- },
- focusTrailingAction: function focusTrailingAction() {
- if (_this.trailingAction_) {
- _this.trailingAction_.focus();
- }
- },
- getAttribute: function getAttribute(attr) {
- return _this.root.getAttribute(attr);
- },
- getCheckmarkBoundingClientRect: function getCheckmarkBoundingClientRect() {
- return _this.checkmark_ ? _this.checkmark_.getBoundingClientRect() : null;
- },
- getComputedStyleValue: function getComputedStyleValue(propertyName) {
- return window.getComputedStyle(_this.root).getPropertyValue(propertyName);
- },
- getRootBoundingClientRect: function getRootBoundingClientRect() {
- return _this.root.getBoundingClientRect();
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- hasLeadingIcon: function hasLeadingIcon() {
- return !!_this.leadingIcon_;
- },
- isRTL: function isRTL() {
- return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
- },
- isTrailingActionNavigable: function isTrailingActionNavigable() {
- if (_this.trailingAction_) {
- return _this.trailingAction_.isNavigable();
- }
- return false;
- },
- notifyInteraction: function notifyInteraction() {
- return _this.emit(constants_2.strings.INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */);
- },
- notifyNavigation: function notifyNavigation(key, source) {
- return _this.emit(constants_2.strings.NAVIGATION_EVENT, { chipId: _this.id, key: key, source: source }, true /* shouldBubble */);
- },
- notifyRemoval: function notifyRemoval(removedAnnouncement) {
- _this.emit(constants_2.strings.REMOVAL_EVENT, { chipId: _this.id, removedAnnouncement: removedAnnouncement }, true /* shouldBubble */);
- },
- notifySelection: function notifySelection(selected, shouldIgnore) {
- return _this.emit(constants_2.strings.SELECTION_EVENT, { chipId: _this.id, selected: selected, shouldIgnore: shouldIgnore }, true /* shouldBubble */);
- },
- notifyTrailingIconInteraction: function notifyTrailingIconInteraction() {
- return _this.emit(constants_2.strings.TRAILING_ICON_INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */);
- },
- notifyEditStart: function notifyEditStart() {},
- notifyEditFinish: function notifyEditFinish() {},
- removeClass: function removeClass(className) {
- return _this.root.classList.remove(className);
- },
- removeClassFromLeadingIcon: function removeClassFromLeadingIcon(className) {
- if (_this.leadingIcon_) {
- _this.leadingIcon_.classList.remove(className);
- }
- },
- removeTrailingActionFocus: function removeTrailingActionFocus() {
- if (_this.trailingAction_) {
- _this.trailingAction_.removeFocus();
- }
- },
- setPrimaryActionAttr: function setPrimaryActionAttr(attr, value) {
- if (_this.primaryAction_) {
- _this.primaryAction_.setAttribute(attr, value);
- }
- },
- setStyleProperty: function setStyleProperty(propertyName, value) {
- return _this.root.style.setProperty(propertyName, value);
- }
- };
- return new foundation_2.MDCChipFoundation(adapter);
- };
- MDCChip.prototype.setSelectedFromChipSet = function (selected, shouldNotifyClients) {
- this.foundation.setSelectedFromChipSet(selected, shouldNotifyClients);
- };
- MDCChip.prototype.focusPrimaryAction = function () {
- this.foundation.focusPrimaryAction();
- };
- MDCChip.prototype.focusTrailingAction = function () {
- this.foundation.focusTrailingAction();
- };
- MDCChip.prototype.removeFocus = function () {
- this.foundation.removeFocus();
- };
- MDCChip.prototype.remove = function () {
- var parent = this.root.parentNode;
- if (parent !== null) {
- parent.removeChild(this.root);
- }
- };
- return MDCChip;
- }(component_1.MDCComponent);
- exports.MDCChip = MDCChip;
- /***/ }),
- /***/ "./packages/mdc-chips/chip/constants.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-chips/chip/constants.ts ***!
- \**********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var Direction;
- (function (Direction) {
- Direction["LEFT"] = "left";
- Direction["RIGHT"] = "right";
- })(Direction = exports.Direction || (exports.Direction = {}));
- var EventSource;
- (function (EventSource) {
- EventSource["PRIMARY"] = "primary";
- EventSource["TRAILING"] = "trailing";
- EventSource["NONE"] = "none";
- })(EventSource = exports.EventSource || (exports.EventSource = {}));
- exports.strings = {
- ADDED_ANNOUNCEMENT_ATTRIBUTE: 'data-mdc-chip-added-announcement',
- ARIA_CHECKED: 'aria-checked',
- ARROW_DOWN_KEY: 'ArrowDown',
- ARROW_LEFT_KEY: 'ArrowLeft',
- ARROW_RIGHT_KEY: 'ArrowRight',
- ARROW_UP_KEY: 'ArrowUp',
- BACKSPACE_KEY: 'Backspace',
- CHECKMARK_SELECTOR: '.mdc-chip__checkmark',
- DELETE_KEY: 'Delete',
- END_KEY: 'End',
- ENTER_KEY: 'Enter',
- ENTRY_ANIMATION_NAME: 'mdc-chip-entry',
- HOME_KEY: 'Home',
- IE_ARROW_DOWN_KEY: 'Down',
- IE_ARROW_LEFT_KEY: 'Left',
- IE_ARROW_RIGHT_KEY: 'Right',
- IE_ARROW_UP_KEY: 'Up',
- IE_DELETE_KEY: 'Del',
- INTERACTION_EVENT: 'MDCChip:interaction',
- LEADING_ICON_SELECTOR: '.mdc-chip__icon--leading',
- NAVIGATION_EVENT: 'MDCChip:navigation',
- PRIMARY_ACTION_SELECTOR: '.mdc-chip__primary-action',
- REMOVED_ANNOUNCEMENT_ATTRIBUTE: 'data-mdc-chip-removed-announcement',
- REMOVAL_EVENT: 'MDCChip:removal',
- SELECTION_EVENT: 'MDCChip:selection',
- SPACEBAR_KEY: ' ',
- TAB_INDEX: 'tabindex',
- TRAILING_ACTION_SELECTOR: '.mdc-chip-trailing-action',
- TRAILING_ICON_INTERACTION_EVENT: 'MDCChip:trailingIconInteraction',
- TRAILING_ICON_SELECTOR: '.mdc-chip__icon--trailing'
- };
- exports.cssClasses = {
- CHECKMARK: 'mdc-chip__checkmark',
- CHIP_EXIT: 'mdc-chip--exit',
- DELETABLE: 'mdc-chip--deletable',
- EDITABLE: 'mdc-chip--editable',
- EDITING: 'mdc-chip--editing',
- HIDDEN_LEADING_ICON: 'mdc-chip__icon--leading-hidden',
- LEADING_ICON: 'mdc-chip__icon--leading',
- PRIMARY_ACTION: 'mdc-chip__primary-action',
- PRIMARY_ACTION_FOCUSED: 'mdc-chip--primary-action-focused',
- SELECTED: 'mdc-chip--selected',
- TEXT: 'mdc-chip__text',
- TRAILING_ACTION: 'mdc-chip__trailing-action',
- TRAILING_ICON: 'mdc-chip__icon--trailing'
- };
- exports.navigationKeys = new Set();
- // IE11 has no support for new Set with iterable so we need to initialize this by hand
- exports.navigationKeys.add(exports.strings.ARROW_LEFT_KEY);
- exports.navigationKeys.add(exports.strings.ARROW_RIGHT_KEY);
- exports.navigationKeys.add(exports.strings.ARROW_DOWN_KEY);
- exports.navigationKeys.add(exports.strings.ARROW_UP_KEY);
- exports.navigationKeys.add(exports.strings.END_KEY);
- exports.navigationKeys.add(exports.strings.HOME_KEY);
- exports.navigationKeys.add(exports.strings.IE_ARROW_LEFT_KEY);
- exports.navigationKeys.add(exports.strings.IE_ARROW_RIGHT_KEY);
- exports.navigationKeys.add(exports.strings.IE_ARROW_DOWN_KEY);
- exports.navigationKeys.add(exports.strings.IE_ARROW_UP_KEY);
- exports.jumpChipKeys = new Set();
- // IE11 has no support for new Set with iterable so we need to initialize this by hand
- exports.jumpChipKeys.add(exports.strings.ARROW_UP_KEY);
- exports.jumpChipKeys.add(exports.strings.ARROW_DOWN_KEY);
- exports.jumpChipKeys.add(exports.strings.HOME_KEY);
- exports.jumpChipKeys.add(exports.strings.END_KEY);
- exports.jumpChipKeys.add(exports.strings.IE_ARROW_UP_KEY);
- exports.jumpChipKeys.add(exports.strings.IE_ARROW_DOWN_KEY);
- /***/ }),
- /***/ "./packages/mdc-chips/chip/foundation.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-chips/chip/foundation.ts ***!
- \***********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/chip/constants.ts");
- var emptyClientRect = {
- bottom: 0,
- height: 0,
- left: 0,
- right: 0,
- top: 0,
- width: 0
- };
- var FocusBehavior;
- (function (FocusBehavior) {
- FocusBehavior[FocusBehavior["SHOULD_FOCUS"] = 0] = "SHOULD_FOCUS";
- FocusBehavior[FocusBehavior["SHOULD_NOT_FOCUS"] = 1] = "SHOULD_NOT_FOCUS";
- })(FocusBehavior || (FocusBehavior = {}));
- var MDCChipFoundation = /** @class */function (_super) {
- __extends(MDCChipFoundation, _super);
- function MDCChipFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCChipFoundation.defaultAdapter), adapter)) || this;
- /** Whether a trailing icon click should immediately trigger exit/removal of the chip. */
- _this.shouldRemoveOnTrailingIconClick_ = true;
- /**
- * Whether the primary action should receive focus on click. Should only be
- * set to true for clients who programmatically give focus to a different
- * element on the page when a chip is clicked (like a menu).
- */
- _this.shouldFocusPrimaryActionOnClick_ = true;
- return _this;
- }
- Object.defineProperty(MDCChipFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- addClassToLeadingIcon: function addClassToLeadingIcon() {
- return undefined;
- },
- eventTargetHasClass: function eventTargetHasClass() {
- return false;
- },
- focusPrimaryAction: function focusPrimaryAction() {
- return undefined;
- },
- focusTrailingAction: function focusTrailingAction() {
- return undefined;
- },
- getAttribute: function getAttribute() {
- return null;
- },
- getCheckmarkBoundingClientRect: function getCheckmarkBoundingClientRect() {
- return emptyClientRect;
- },
- getComputedStyleValue: function getComputedStyleValue() {
- return '';
- },
- getRootBoundingClientRect: function getRootBoundingClientRect() {
- return emptyClientRect;
- },
- hasClass: function hasClass() {
- return false;
- },
- hasLeadingIcon: function hasLeadingIcon() {
- return false;
- },
- isRTL: function isRTL() {
- return false;
- },
- isTrailingActionNavigable: function isTrailingActionNavigable() {
- return false;
- },
- notifyEditFinish: function notifyEditFinish() {
- return undefined;
- },
- notifyEditStart: function notifyEditStart() {
- return undefined;
- },
- notifyInteraction: function notifyInteraction() {
- return undefined;
- },
- notifyNavigation: function notifyNavigation() {
- return undefined;
- },
- notifyRemoval: function notifyRemoval() {
- return undefined;
- },
- notifySelection: function notifySelection() {
- return undefined;
- },
- notifyTrailingIconInteraction: function notifyTrailingIconInteraction() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- removeClassFromLeadingIcon: function removeClassFromLeadingIcon() {
- return undefined;
- },
- removeTrailingActionFocus: function removeTrailingActionFocus() {
- return undefined;
- },
- setPrimaryActionAttr: function setPrimaryActionAttr() {
- 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.isEditable = function () {
- return this.adapter.hasClass(constants_1.cssClasses.EDITABLE);
- };
- MDCChipFoundation.prototype.isEditing = function () {
- return this.adapter.hasClass(constants_1.cssClasses.EDITING);
- };
- MDCChipFoundation.prototype.setSelected = function (selected) {
- this.setSelected_(selected);
- this.notifySelection_(selected);
- };
- MDCChipFoundation.prototype.setSelectedFromChipSet = function (selected, shouldNotifyClients) {
- this.setSelected_(selected);
- if (shouldNotifyClients) {
- this.notifyIgnoredSelection_(selected);
- }
- };
- MDCChipFoundation.prototype.getShouldRemoveOnTrailingIconClick = function () {
- return this.shouldRemoveOnTrailingIconClick_;
- };
- MDCChipFoundation.prototype.setShouldRemoveOnTrailingIconClick = function (shouldRemove) {
- this.shouldRemoveOnTrailingIconClick_ = shouldRemove;
- };
- MDCChipFoundation.prototype.setShouldFocusPrimaryActionOnClick = function (shouldFocus) {
- this.shouldFocusPrimaryActionOnClick_ = shouldFocus;
- };
- 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);
- };
- MDCChipFoundation.prototype.handleClick = function () {
- this.adapter.notifyInteraction();
- this.setPrimaryActionFocusable_(this.getFocusBehavior_());
- };
- MDCChipFoundation.prototype.handleDoubleClick = function () {
- if (this.isEditable()) {
- this.startEditing();
- }
- };
- /**
- * Handles a transition end event on the root element.
- */
- MDCChipFoundation.prototype.handleTransitionEnd = function (evt) {
- var _this = this;
- // Handle transition end event on the chip when it is about to be removed.
- var shouldHandle = this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.CHIP_EXIT);
- var widthIsAnimating = evt.propertyName === 'width';
- var opacityIsAnimating = evt.propertyName === 'opacity';
- if (shouldHandle && opacityIsAnimating) {
- // See: https://css-tricks.com/using-css-transitions-auto-dimensions/#article-header-id-5
- var chipWidth_1 = this.adapter.getComputedStyleValue('width');
- // On the next frame (once we get the computed width), explicitly set the chip's width
- // to its current pixel width, so we aren't transitioning out of 'auto'.
- requestAnimationFrame(function () {
- _this.adapter.setStyleProperty('width', chipWidth_1);
- // To mitigate jitter, start transitioning padding and margin before width.
- _this.adapter.setStyleProperty('padding', '0');
- _this.adapter.setStyleProperty('margin', '0');
- // On the next frame (once width is explicitly set), transition width to 0.
- requestAnimationFrame(function () {
- _this.adapter.setStyleProperty('width', '0');
- });
- });
- return;
- }
- if (shouldHandle && widthIsAnimating) {
- this.removeFocus();
- var removedAnnouncement = this.adapter.getAttribute(constants_1.strings.REMOVED_ANNOUNCEMENT_ATTRIBUTE);
- this.adapter.notifyRemoval(removedAnnouncement);
- }
- // Handle a transition end event on the leading icon or checkmark, since the transition end event bubbles.
- if (!opacityIsAnimating) {
- return;
- }
- var shouldHideLeadingIcon = this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.LEADING_ICON) && this.adapter.hasClass(constants_1.cssClasses.SELECTED);
- var shouldShowLeadingIcon = this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.CHECKMARK) && !this.adapter.hasClass(constants_1.cssClasses.SELECTED);
- if (shouldHideLeadingIcon) {
- this.adapter.addClassToLeadingIcon(constants_1.cssClasses.HIDDEN_LEADING_ICON);
- return;
- }
- if (shouldShowLeadingIcon) {
- this.adapter.removeClassFromLeadingIcon(constants_1.cssClasses.HIDDEN_LEADING_ICON);
- return;
- }
- };
- MDCChipFoundation.prototype.handleFocusIn = function (evt) {
- // Early exit if the event doesn't come from the primary action
- if (!this.eventFromPrimaryAction_(evt)) {
- return;
- }
- this.adapter.addClass(constants_1.cssClasses.PRIMARY_ACTION_FOCUSED);
- };
- MDCChipFoundation.prototype.handleFocusOut = function (evt) {
- // Early exit if the event doesn't come from the primary action
- if (!this.eventFromPrimaryAction_(evt)) {
- return;
- }
- if (this.isEditing()) {
- this.finishEditing();
- }
- this.adapter.removeClass(constants_1.cssClasses.PRIMARY_ACTION_FOCUSED);
- };
- /**
- * 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.handleTrailingActionInteraction = function () {
- this.adapter.notifyTrailingIconInteraction();
- this.removeChip_();
- };
- /**
- * Handles a keydown event from the root element.
- */
- MDCChipFoundation.prototype.handleKeydown = function (evt) {
- if (this.isEditing()) {
- if (this.shouldFinishEditing(evt)) {
- evt.preventDefault();
- this.finishEditing();
- }
- // When editing, the foundation should only handle key events that finish
- // the editing process.
- return;
- }
- if (this.isEditable()) {
- if (this.shouldStartEditing(evt)) {
- evt.preventDefault();
- this.startEditing();
- }
- }
- if (this.shouldNotifyInteraction_(evt)) {
- this.adapter.notifyInteraction();
- this.setPrimaryActionFocusable_(this.getFocusBehavior_());
- return;
- }
- if (this.isDeleteAction_(evt)) {
- evt.preventDefault();
- this.removeChip_();
- return;
- }
- // Early exit if the key is not usable
- if (!constants_1.navigationKeys.has(evt.key)) {
- return;
- }
- // Prevent default behavior for movement keys which could include scrolling
- evt.preventDefault();
- this.focusNextAction_(evt.key, constants_1.EventSource.PRIMARY);
- };
- MDCChipFoundation.prototype.handleTrailingActionNavigation = function (evt) {
- return this.focusNextAction_(evt.detail.key, constants_1.EventSource.TRAILING);
- };
- /**
- * Called by the chip set to remove focus from the chip actions.
- */
- MDCChipFoundation.prototype.removeFocus = function () {
- this.adapter.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '-1');
- this.adapter.removeTrailingActionFocus();
- };
- /**
- * Called by the chip set to focus the primary action.
- *
- */
- MDCChipFoundation.prototype.focusPrimaryAction = function () {
- this.setPrimaryActionFocusable_(FocusBehavior.SHOULD_FOCUS);
- };
- /**
- * Called by the chip set to focus the trailing action (if present), otherwise
- * gives focus to the trailing action.
- */
- MDCChipFoundation.prototype.focusTrailingAction = function () {
- var trailingActionIsNavigable = this.adapter.isTrailingActionNavigable();
- if (trailingActionIsNavigable) {
- this.adapter.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '-1');
- this.adapter.focusTrailingAction();
- return;
- }
- this.focusPrimaryAction();
- };
- MDCChipFoundation.prototype.setPrimaryActionFocusable_ = function (focusBehavior) {
- this.adapter.setPrimaryActionAttr(constants_1.strings.TAB_INDEX, '0');
- if (focusBehavior === FocusBehavior.SHOULD_FOCUS) {
- this.adapter.focusPrimaryAction();
- }
- this.adapter.removeTrailingActionFocus();
- };
- MDCChipFoundation.prototype.getFocusBehavior_ = function () {
- if (this.shouldFocusPrimaryActionOnClick_) {
- return FocusBehavior.SHOULD_FOCUS;
- }
- return FocusBehavior.SHOULD_NOT_FOCUS;
- };
- MDCChipFoundation.prototype.focusNextAction_ = function (key, source) {
- var isTrailingActionNavigable = this.adapter.isTrailingActionNavigable();
- var dir = this.getDirection_(key);
- // Early exit if the key should jump chips
- if (constants_1.jumpChipKeys.has(key) || !isTrailingActionNavigable) {
- return this.adapter.notifyNavigation(key, source);
- }
- if (source === constants_1.EventSource.PRIMARY && dir === constants_1.Direction.RIGHT) {
- return this.focusTrailingAction();
- }
- if (source === constants_1.EventSource.TRAILING && dir === constants_1.Direction.LEFT) {
- return this.focusPrimaryAction();
- }
- this.adapter.notifyNavigation(key, constants_1.EventSource.NONE);
- };
- MDCChipFoundation.prototype.getDirection_ = function (key) {
- var isRTL = this.adapter.isRTL();
- var isLeftKey = key === constants_1.strings.ARROW_LEFT_KEY || key === constants_1.strings.IE_ARROW_LEFT_KEY;
- var isRightKey = key === constants_1.strings.ARROW_RIGHT_KEY || key === constants_1.strings.IE_ARROW_RIGHT_KEY;
- if (!isRTL && isLeftKey || isRTL && isRightKey) {
- return constants_1.Direction.LEFT;
- }
- return constants_1.Direction.RIGHT;
- };
- MDCChipFoundation.prototype.removeChip_ = function () {
- if (this.shouldRemoveOnTrailingIconClick_) {
- this.beginExit();
- }
- };
- MDCChipFoundation.prototype.shouldStartEditing = function (evt) {
- return this.eventFromPrimaryAction_(evt) && evt.key === constants_1.strings.ENTER_KEY;
- };
- MDCChipFoundation.prototype.shouldFinishEditing = function (evt) {
- return evt.key === constants_1.strings.ENTER_KEY;
- };
- MDCChipFoundation.prototype.shouldNotifyInteraction_ = function (evt) {
- return evt.key === constants_1.strings.ENTER_KEY || evt.key === constants_1.strings.SPACEBAR_KEY;
- };
- MDCChipFoundation.prototype.isDeleteAction_ = function (evt) {
- var isDeletable = this.adapter.hasClass(constants_1.cssClasses.DELETABLE);
- return isDeletable && (evt.key === constants_1.strings.BACKSPACE_KEY || evt.key === constants_1.strings.DELETE_KEY || evt.key === constants_1.strings.IE_DELETE_KEY);
- };
- MDCChipFoundation.prototype.setSelected_ = function (selected) {
- if (selected) {
- this.adapter.addClass(constants_1.cssClasses.SELECTED);
- this.adapter.setPrimaryActionAttr(constants_1.strings.ARIA_CHECKED, 'true');
- } else {
- this.adapter.removeClass(constants_1.cssClasses.SELECTED);
- this.adapter.setPrimaryActionAttr(constants_1.strings.ARIA_CHECKED, 'false');
- }
- };
- MDCChipFoundation.prototype.notifySelection_ = function (selected) {
- this.adapter.notifySelection(selected, false);
- };
- MDCChipFoundation.prototype.notifyIgnoredSelection_ = function (selected) {
- this.adapter.notifySelection(selected, true);
- };
- MDCChipFoundation.prototype.eventFromPrimaryAction_ = function (evt) {
- return this.adapter.eventTargetHasClass(evt.target, constants_1.cssClasses.PRIMARY_ACTION);
- };
- MDCChipFoundation.prototype.startEditing = function () {
- this.adapter.addClass(constants_1.cssClasses.EDITING);
- this.adapter.notifyEditStart();
- };
- MDCChipFoundation.prototype.finishEditing = function () {
- this.adapter.removeClass(constants_1.cssClasses.EDITING);
- this.adapter.notifyEditFinish();
- };
- 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__(/*! ./trailingaction/index */ "./packages/mdc-chips/trailingaction/index.ts"));
- __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-chips/trailingaction/component.ts":
- /*!********************************************************!*\
- !*** ./packages/mdc-chips/trailingaction/component.ts ***!
- \********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/trailingaction/constants.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-chips/trailingaction/foundation.ts");
- var MDCChipTrailingAction = /** @class */function (_super) {
- __extends(MDCChipTrailingAction, _super);
- function MDCChipTrailingAction() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- Object.defineProperty(MDCChipTrailingAction.prototype, "ripple", {
- get: function get() {
- return this.ripple_;
- },
- enumerable: true,
- configurable: true
- });
- MDCChipTrailingAction.attachTo = function (root) {
- return new MDCChipTrailingAction(root);
- };
- MDCChipTrailingAction.prototype.initialize = function (rippleFactory) {
- if (rippleFactory === void 0) {
- rippleFactory = function rippleFactory(el, foundation) {
- return new component_2.MDCRipple(el, foundation);
- };
- }
- // 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 = component_2.MDCRipple.createAdapter(this);
- this.ripple_ = rippleFactory(this.root, new foundation_1.MDCRippleFoundation(rippleAdapter));
- };
- MDCChipTrailingAction.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleClick_ = function (evt) {
- _this.foundation.handleClick(evt);
- };
- this.handleKeydown_ = function (evt) {
- _this.foundation.handleKeydown(evt);
- };
- this.listen('click', this.handleClick_);
- this.listen('keydown', this.handleKeydown_);
- };
- MDCChipTrailingAction.prototype.destroy = function () {
- this.ripple_.destroy();
- this.unlisten('click', this.handleClick_);
- this.unlisten('keydown', this.handleKeydown_);
- _super.prototype.destroy.call(this);
- };
- MDCChipTrailingAction.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 = {
- focus: function focus() {
- // TODO(b/157231863): Migate MDCComponent#root to HTMLElement
- _this.root.focus();
- },
- getAttribute: function getAttribute(attr) {
- return _this.root.getAttribute(attr);
- },
- notifyInteraction: function notifyInteraction(trigger) {
- return _this.emit(constants_1.strings.INTERACTION_EVENT, { trigger: trigger }, true /* shouldBubble */);
- },
- notifyNavigation: function notifyNavigation(key) {
- _this.emit(constants_1.strings.NAVIGATION_EVENT, { key: key }, true /* shouldBubble */);
- },
- setAttribute: function setAttribute(attr, value) {
- _this.root.setAttribute(attr, value);
- }
- };
- return new foundation_2.MDCChipTrailingActionFoundation(adapter);
- };
- MDCChipTrailingAction.prototype.isNavigable = function () {
- return this.foundation.isNavigable();
- };
- MDCChipTrailingAction.prototype.focus = function () {
- this.foundation.focus();
- };
- MDCChipTrailingAction.prototype.removeFocus = function () {
- this.foundation.removeFocus();
- };
- return MDCChipTrailingAction;
- }(component_1.MDCComponent);
- exports.MDCChipTrailingAction = MDCChipTrailingAction;
- /***/ }),
- /***/ "./packages/mdc-chips/trailingaction/constants.ts":
- /*!********************************************************!*\
- !*** ./packages/mdc-chips/trailingaction/constants.ts ***!
- \********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var InteractionTrigger;
- (function (InteractionTrigger) {
- InteractionTrigger[InteractionTrigger["UNSPECIFIED"] = 0] = "UNSPECIFIED";
- InteractionTrigger[InteractionTrigger["CLICK"] = 1] = "CLICK";
- InteractionTrigger[InteractionTrigger["BACKSPACE_KEY"] = 2] = "BACKSPACE_KEY";
- InteractionTrigger[InteractionTrigger["DELETE_KEY"] = 3] = "DELETE_KEY";
- InteractionTrigger[InteractionTrigger["SPACEBAR_KEY"] = 4] = "SPACEBAR_KEY";
- InteractionTrigger[InteractionTrigger["ENTER_KEY"] = 5] = "ENTER_KEY";
- })(InteractionTrigger = exports.InteractionTrigger || (exports.InteractionTrigger = {}));
- exports.strings = {
- ARIA_HIDDEN: 'aria-hidden',
- INTERACTION_EVENT: 'MDCChipTrailingAction:interaction',
- NAVIGATION_EVENT: 'MDCChipTrailingAction:navigation',
- TAB_INDEX: 'tabindex'
- };
- /***/ }),
- /***/ "./packages/mdc-chips/trailingaction/foundation.ts":
- /*!*********************************************************!*\
- !*** ./packages/mdc-chips/trailingaction/foundation.ts ***!
- \*********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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 keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/trailingaction/constants.ts");
- var MDCChipTrailingActionFoundation = /** @class */function (_super) {
- __extends(MDCChipTrailingActionFoundation, _super);
- function MDCChipTrailingActionFoundation(adapter) {
- return _super.call(this, __assign(__assign({}, MDCChipTrailingActionFoundation.defaultAdapter), adapter)) || this;
- }
- Object.defineProperty(MDCChipTrailingActionFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCChipTrailingActionFoundation, "defaultAdapter", {
- get: function get() {
- return {
- focus: function focus() {
- return undefined;
- },
- getAttribute: function getAttribute() {
- return null;
- },
- setAttribute: function setAttribute() {
- return undefined;
- },
- notifyInteraction: function notifyInteraction() {
- return undefined;
- },
- notifyNavigation: function notifyNavigation() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCChipTrailingActionFoundation.prototype.handleClick = function (evt) {
- evt.stopPropagation();
- this.adapter.notifyInteraction(constants_1.InteractionTrigger.CLICK);
- };
- MDCChipTrailingActionFoundation.prototype.handleKeydown = function (evt) {
- evt.stopPropagation();
- var key = keyboard_1.normalizeKey(evt);
- if (this.shouldNotifyInteractionFromKey_(key)) {
- var trigger = this.getTriggerFromKey_(key);
- this.adapter.notifyInteraction(trigger);
- return;
- }
- if (keyboard_1.isNavigationEvent(evt)) {
- this.adapter.notifyNavigation(key);
- return;
- }
- };
- MDCChipTrailingActionFoundation.prototype.removeFocus = function () {
- this.adapter.setAttribute(constants_1.strings.TAB_INDEX, '-1');
- };
- MDCChipTrailingActionFoundation.prototype.focus = function () {
- this.adapter.setAttribute(constants_1.strings.TAB_INDEX, '0');
- this.adapter.focus();
- };
- MDCChipTrailingActionFoundation.prototype.isNavigable = function () {
- return this.adapter.getAttribute(constants_1.strings.ARIA_HIDDEN) !== 'true';
- };
- MDCChipTrailingActionFoundation.prototype.shouldNotifyInteractionFromKey_ = function (key) {
- var isFromActionKey = key === keyboard_1.KEY.ENTER || key === keyboard_1.KEY.SPACEBAR;
- var isFromDeleteKey = key === keyboard_1.KEY.BACKSPACE || key === keyboard_1.KEY.DELETE;
- return isFromActionKey || isFromDeleteKey;
- };
- MDCChipTrailingActionFoundation.prototype.getTriggerFromKey_ = function (key) {
- if (key === keyboard_1.KEY.SPACEBAR) {
- return constants_1.InteractionTrigger.SPACEBAR_KEY;
- }
- if (key === keyboard_1.KEY.ENTER) {
- return constants_1.InteractionTrigger.ENTER_KEY;
- }
- if (key === keyboard_1.KEY.DELETE) {
- return constants_1.InteractionTrigger.DELETE_KEY;
- }
- if (key === keyboard_1.KEY.BACKSPACE) {
- return constants_1.InteractionTrigger.BACKSPACE_KEY;
- }
- // Default case, should never be returned
- return constants_1.InteractionTrigger.UNSPECIFIED;
- };
- return MDCChipTrailingActionFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCChipTrailingActionFoundation = MDCChipTrailingActionFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCChipTrailingActionFoundation;
- /***/ }),
- /***/ "./packages/mdc-chips/trailingaction/index.ts":
- /*!****************************************************!*\
- !*** ./packages/mdc-chips/trailingaction/index.ts ***!
- \****************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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/trailingaction/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-chips/trailingaction/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-chips/trailingaction/constants.ts");
- exports.trailingActionStrings = constants_1.strings;
- /***/ }),
- /***/ "./packages/mdc-circular-progress/component.ts":
- /*!*****************************************************!*\
- !*** ./packages/mdc-circular-progress/component.ts ***!
- \*****************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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-circular-progress/foundation.ts");
- var MDCCircularProgress = /** @class */function (_super) {
- __extends(MDCCircularProgress, _super);
- function MDCCircularProgress() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCCircularProgress.prototype.initialize = function () {
- this.determinateCircle_ = this.root.querySelector(foundation_1.MDCCircularProgressFoundation.strings.DETERMINATE_CIRCLE_SELECTOR);
- };
- MDCCircularProgress.attachTo = function (root) {
- return new MDCCircularProgress(root);
- };
- Object.defineProperty(MDCCircularProgress.prototype, "determinate", {
- /**
- * Sets whether the progress indicator is in determinate mode.
- * @param isDeterminate Whether the indicator should be determinate.
- */
- set: function set(value) {
- this.foundation.setDeterminate(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCircularProgress.prototype, "progress", {
- /**
- * Sets the current progress value. In indeterminate mode, this has no
- * visual effect but will be reflected if the indicator is switched to
- * determinate mode.
- * @param value The current progress value, which must be between 0 and 1.
- */
- set: function set(value) {
- this.foundation.setProgress(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCircularProgress.prototype, "isClosed", {
- /**
- * Whether the progress indicator is hidden.
- */
- get: function get() {
- return this.foundation.isClosed();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Shows the progress indicator.
- */
- MDCCircularProgress.prototype.open = function () {
- this.foundation.open();
- };
- /**
- * Hides the progress indicator.
- */
- MDCCircularProgress.prototype.close = function () {
- this.foundation.close();
- };
- MDCCircularProgress.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);
- },
- getDeterminateCircleAttribute: function getDeterminateCircleAttribute(attributeName) {
- return _this.determinateCircle_.getAttribute(attributeName);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- removeClass: function removeClass(className) {
- return _this.root.classList.remove(className);
- },
- removeAttribute: function removeAttribute(attributeName) {
- return _this.root.removeAttribute(attributeName);
- },
- setAttribute: function setAttribute(attributeName, value) {
- return _this.root.setAttribute(attributeName, value);
- },
- setDeterminateCircleAttribute: function setDeterminateCircleAttribute(attributeName, value) {
- return _this.determinateCircle_.setAttribute(attributeName, value);
- }
- };
- return new foundation_1.MDCCircularProgressFoundation(adapter);
- };
- return MDCCircularProgress;
- }(component_1.MDCComponent);
- exports.MDCCircularProgress = MDCCircularProgress;
- /***/ }),
- /***/ "./packages/mdc-circular-progress/constants.ts":
- /*!*****************************************************!*\
- !*** ./packages/mdc-circular-progress/constants.ts ***!
- \*****************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * CSS class names used in component.
- */
- exports.cssClasses = {
- INDETERMINATE_CLASS: 'mdc-circular-progress--indeterminate',
- CLOSED_CLASS: 'mdc-circular-progress--closed'
- };
- /**
- * Attributes and selectors used in component.
- */
- exports.strings = {
- DETERMINATE_CIRCLE_SELECTOR: '.mdc-circular-progress__determinate-circle',
- ARIA_VALUENOW: 'aria-valuenow',
- RADIUS: 'r',
- STROKE_DASHOFFSET: 'stroke-dashoffset'
- };
- /***/ }),
- /***/ "./packages/mdc-circular-progress/foundation.ts":
- /*!******************************************************!*\
- !*** ./packages/mdc-circular-progress/foundation.ts ***!
- \******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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-circular-progress/constants.ts");
- var MDCCircularProgressFoundation = /** @class */function (_super) {
- __extends(MDCCircularProgressFoundation, _super);
- function MDCCircularProgressFoundation(adapter) {
- return _super.call(this, __assign(__assign({}, MDCCircularProgressFoundation.defaultAdapter), adapter)) || this;
- }
- Object.defineProperty(MDCCircularProgressFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCircularProgressFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCCircularProgressFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- getDeterminateCircleAttribute: function getDeterminateCircleAttribute() {
- return null;
- },
- hasClass: function hasClass() {
- return false;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- removeAttribute: function removeAttribute() {
- return undefined;
- },
- setAttribute: function setAttribute() {
- return undefined;
- },
- setDeterminateCircleAttribute: function setDeterminateCircleAttribute() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCCircularProgressFoundation.prototype.init = function () {
- this.isClosed_ = this.adapter.hasClass(constants_1.cssClasses.CLOSED_CLASS);
- this.isDeterminate_ = !this.adapter.hasClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.progress_ = 0;
- if (this.isDeterminate_) {
- this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress_.toString());
- }
- this.radius_ = Number(this.adapter.getDeterminateCircleAttribute(constants_1.strings.RADIUS));
- };
- MDCCircularProgressFoundation.prototype.isDeterminate = function () {
- return this.isDeterminate_;
- };
- MDCCircularProgressFoundation.prototype.getProgress = function () {
- return this.progress_;
- };
- /**
- * @return Returns whether the progress indicator is hidden.
- */
- MDCCircularProgressFoundation.prototype.isClosed = function () {
- return this.isClosed_;
- };
- /**
- * Sets whether the progress indicator is in determinate mode.
- * @param isDeterminate Whether the indicator should be determinate.
- */
- MDCCircularProgressFoundation.prototype.setDeterminate = function (isDeterminate) {
- this.isDeterminate_ = isDeterminate;
- if (this.isDeterminate_) {
- this.adapter.removeClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.setProgress(this.progress_);
- } else {
- this.adapter.addClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.adapter.removeAttribute(constants_1.strings.ARIA_VALUENOW);
- }
- };
- /**
- * Sets the current progress value. In indeterminate mode, this has no
- * visual effect but will be reflected if the indicator is switched to
- * determinate mode.
- * @param value The current progress value, which must be between 0 and 1.
- */
- MDCCircularProgressFoundation.prototype.setProgress = function (value) {
- this.progress_ = value;
- if (this.isDeterminate_) {
- var unfilledArcLength = (1 - this.progress_) * (2 * Math.PI * this.radius_);
- this.adapter.setDeterminateCircleAttribute(constants_1.strings.STROKE_DASHOFFSET, "" + unfilledArcLength);
- this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress_.toString());
- }
- };
- /**
- * Shows the progress indicator.
- */
- MDCCircularProgressFoundation.prototype.open = function () {
- this.isClosed_ = false;
- this.adapter.removeClass(constants_1.cssClasses.CLOSED_CLASS);
- };
- /**
- * Hides the progress indicator
- */
- MDCCircularProgressFoundation.prototype.close = function () {
- this.isClosed_ = true;
- this.adapter.addClass(constants_1.cssClasses.CLOSED_CLASS);
- };
- return MDCCircularProgressFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCCircularProgressFoundation = MDCCircularProgressFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCCircularProgressFoundation;
- /***/ }),
- /***/ "./packages/mdc-circular-progress/index.ts":
- /*!*************************************************!*\
- !*** ./packages/mdc-circular-progress/index.ts ***!
- \*************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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-circular-progress/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-circular-progress/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-circular-progress/foundation.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 __());
- };
- }();
- var __values = this && this.__values || function (o) {
- var s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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 component_3 = __webpack_require__(/*! @material/linear-progress/component */ "./packages/mdc-linear-progress/component.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");
- /**
- * Implementation of `MDCDataTableFoundation`
- */
- 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 () {
- _this.foundation.handleHeaderRowCheckboxChange();
- };
- this.headerRow.addEventListener('change', this.handleHeaderRowCheckboxChange);
- this.headerRowClickListener = function (event) {
- _this.handleHeaderRowClick(event);
- };
- this.headerRow.addEventListener('click', this.headerRowClickListener);
- this.content = this.root.querySelector("." + constants_1.cssClasses.CONTENT);
- this.handleRowCheckboxChange = function (event) {
- _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 header row cell elements.
- */
- MDCDataTable.prototype.getHeaderCells = function () {
- return [].slice.call(this.root.querySelectorAll(constants_1.selectors.HEADER_CELL));
- };
- /**
- * @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);
- };
- /**
- * Shows progress indicator when data table is in loading state.
- */
- MDCDataTable.prototype.showProgress = function () {
- this.getLinearProgress().open();
- this.foundation.showProgress();
- };
- /**
- * Hides progress indicator after data table is finished loading.
- */
- MDCDataTable.prototype.hideProgress = function () {
- this.foundation.hideProgress();
- this.getLinearProgress().close();
- };
- MDCDataTable.prototype.destroy = function () {
- var e_1, _a;
- if (this.handleHeaderRowCheckboxChange) {
- this.headerRow.removeEventListener('change', this.handleHeaderRowCheckboxChange);
- }
- if (this.headerRowClickListener) {
- this.headerRow.removeEventListener('click', this.headerRowClickListener);
- }
- if (this.handleRowCheckboxChange) {
- this.content.removeEventListener('change', this.handleRowCheckboxChange);
- }
- if (this.headerRowCheckbox) {
- this.headerRowCheckbox.destroy();
- }
- if (this.rowCheckboxList) {
- try {
- for (var _b = __values(this.rowCheckboxList), _c = _b.next(); !_c.done; _c = _b.next()) {
- var checkbox = _c.value;
- checkbox.destroy();
- }
- } 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;
- }
- }
- }
- };
- 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 = {
- addClass: function addClass(className) {
- _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- getHeaderCellElements: function getHeaderCellElements() {
- return _this.getHeaderCells();
- },
- getHeaderCellCount: function getHeaderCellCount() {
- return _this.getHeaderCells().length;
- },
- getAttributeByHeaderCellIndex: function getAttributeByHeaderCellIndex(index, attribute) {
- return _this.getHeaderCells()[index].getAttribute(attribute);
- },
- setAttributeByHeaderCellIndex: function setAttributeByHeaderCellIndex(index, attribute, value) {
- _this.getHeaderCells()[index].setAttribute(attribute, value);
- },
- setClassNameByHeaderCellIndex: function setClassNameByHeaderCellIndex(index, className) {
- _this.getHeaderCells()[index].classList.add(className);
- },
- removeClassNameByHeaderCellIndex: function removeClassNameByHeaderCellIndex(index, className) {
- _this.getHeaderCells()[index].classList.remove(className);
- },
- notifySortAction: function notifySortAction(data) {
- _this.emit(constants_1.events.SORTED, data, /** shouldBubble */true);
- },
- getTableContainerHeight: function getTableContainerHeight() {
- var tableContainer = _this.root.querySelector("." + constants_1.cssClasses.TABLE_CONTAINER);
- if (!tableContainer) {
- throw new Error('MDCDataTable: Table container element not found.');
- }
- return tableContainer.getBoundingClientRect().height;
- },
- getTableHeaderHeight: function getTableHeaderHeight() {
- var tableHeader = _this.root.querySelector(constants_1.selectors.HEADER_ROW);
- if (!tableHeader) {
- throw new Error('MDCDataTable: Table header element not found.');
- }
- return tableHeader.getBoundingClientRect().height;
- },
- setProgressIndicatorStyles: function setProgressIndicatorStyles(styles) {
- var progressIndicator = _this.root.querySelector(constants_1.selectors.PROGRESS_INDICATOR);
- if (!progressIndicator) {
- throw new Error('MDCDataTable: Progress indicator element not found.');
- }
- progressIndicator.style.setProperty('height', styles.height);
- progressIndicator.style.setProperty('top', styles.top);
- },
- addClassAtRowIndex: function addClassAtRowIndex(rowIndex, className) {
- _this.getRows()[rowIndex].classList.add(className);
- },
- getRowCount: function getRowCount() {
- return _this.getRows().length;
- },
- getRowElements: function getRowElements() {
- return [].slice.call(_this.root.querySelectorAll(constants_1.selectors.ROW));
- },
- getRowIdAtIndex: function getRowIdAtIndex(rowIndex) {
- return _this.getRows()[rowIndex].getAttribute(constants_1.dataAttributes.ROW_ID);
- },
- getRowIndexByChildElement: function getRowIndexByChildElement(el) {
- return _this.getRows().indexOf(ponyfill_1.closest(el, constants_1.selectors.ROW));
- },
- getSelectedRowCount: function getSelectedRowCount() {
- return _this.root.querySelectorAll(constants_1.selectors.ROW_SELECTED).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.selectors.ROW_CHECKBOX) || !!_this.root.querySelector(constants_1.selectors.HEADER_ROW_CHECKBOX);
- },
- 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() {
- _this.emit(constants_1.events.SELECTED_ALL, {}, /** shouldBubble */true);
- },
- notifyUnselectedAll: function notifyUnselectedAll() {
- _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.selectors.HEADER_ROW_CHECKBOX);
- _this.headerRowCheckbox = _this.checkboxFactory(checkboxEl);
- },
- registerRowCheckboxes: function registerRowCheckboxes() {
- if (_this.rowCheckboxList) {
- _this.rowCheckboxList.forEach(function (checkbox) {
- checkbox.destroy();
- });
- }
- _this.rowCheckboxList = [];
- _this.getRows().forEach(function (rowEl) {
- var checkbox = _this.checkboxFactory(rowEl.querySelector(constants_1.selectors.ROW_CHECKBOX));
- _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;
- },
- setSortStatusLabelByHeaderCellIndex: function setSortStatusLabelByHeaderCellIndex(columnIndex, sortValue) {
- var headerCell = _this.getHeaderCells()[columnIndex];
- var sortStatusLabel = headerCell.querySelector(constants_1.selectors.SORT_STATUS_LABEL);
- if (!sortStatusLabel) return;
- sortStatusLabel.textContent = _this.getSortStatusMessageBySortValue(sortValue);
- }
- };
- 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.dataAttributes.ROW_ID);
- };
- MDCDataTable.prototype.handleHeaderRowClick = function (event) {
- var headerCell = ponyfill_1.closest(event.target, constants_1.selectors.HEADER_CELL_WITH_SORT);
- if (!headerCell) {
- return;
- }
- var columnId = headerCell.getAttribute(constants_1.dataAttributes.COLUMN_ID);
- var columnIndex = this.getHeaderCells().indexOf(headerCell);
- if (columnIndex === -1) {
- return;
- }
- this.foundation.handleSortAction({ columnId: columnId, columnIndex: columnIndex, headerCell: headerCell });
- };
- MDCDataTable.prototype.getSortStatusMessageBySortValue = function (sortValue) {
- switch (sortValue) {
- case constants_1.SortValue.ASCENDING:
- return constants_1.messages.SORTED_IN_ASCENDING;
- case constants_1.SortValue.DESCENDING:
- return constants_1.messages.SORTED_IN_DESCENDING;
- default:
- return '';
- }
- };
- MDCDataTable.prototype.getLinearProgressElement = function () {
- var el = this.root.querySelector("." + constants_1.cssClasses.LINEAR_PROGRESS);
- if (!el) {
- throw new Error('MDCDataTable: linear progress element is not found.');
- }
- return el;
- };
- MDCDataTable.prototype.getLinearProgress = function () {
- if (!this.linearProgress) {
- var el = this.getLinearProgressElement();
- this.linearProgress = new component_3.MDCLinearProgress(el);
- }
- return this.linearProgress;
- };
- 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 });
- /**
- * CSS class names used in component.
- */
- exports.cssClasses = {
- CELL: 'mdc-data-table__cell',
- CELL_NUMERIC: 'mdc-data-table__cell--numeric',
- CONTENT: 'mdc-data-table__content',
- HEADER_CELL: 'mdc-data-table__header-cell',
- HEADER_CELL_LABEL: 'mdc-data-table__header-cell-label',
- HEADER_CELL_SORTED: 'mdc-data-table__header-cell--sorted',
- HEADER_CELL_SORTED_DESCENDING: 'mdc-data-table__header-cell--sorted-descending',
- HEADER_CELL_WITH_SORT: 'mdc-data-table__header-cell--with-sort',
- HEADER_CELL_WRAPPER: 'mdc-data-table__header-cell-wrapper',
- HEADER_ROW: 'mdc-data-table__header-row',
- HEADER_ROW_CHECKBOX: 'mdc-data-table__header-row-checkbox',
- IN_PROGRESS: 'mdc-data-table--in-progress',
- LINEAR_PROGRESS: 'mdc-data-table__linear-progress',
- PAGINATION_ROWS_PER_PAGE_LABEL: 'mdc-data-table__pagination-rows-per-page-label',
- PAGINATION_ROWS_PER_PAGE_SELECT: 'mdc-data-table__pagination-rows-per-page-select',
- PROGRESS_INDICATOR: 'mdc-data-table__progress-indicator',
- ROOT: 'mdc-data-table',
- ROW: 'mdc-data-table__row',
- ROW_CHECKBOX: 'mdc-data-table__row-checkbox',
- ROW_SELECTED: 'mdc-data-table__row--selected',
- SORT_ICON_BUTTON: 'mdc-data-table__sort-icon-button',
- SORT_STATUS_LABEL: 'mdc-data-table__sort-status-label',
- TABLE_CONTAINER: 'mdc-data-table__table-container'
- };
- /**
- * DOM attributes used in component.
- */
- exports.attributes = {
- ARIA_SELECTED: 'aria-selected',
- ARIA_SORT: 'aria-sort'
- };
- /**
- * List of data attributes used in component.
- */
- exports.dataAttributes = {
- COLUMN_ID: 'data-column-id',
- ROW_ID: 'data-row-id'
- };
- /**
- * CSS selectors used in component.
- */
- exports.selectors = {
- CONTENT: "." + exports.cssClasses.CONTENT,
- HEADER_CELL: "." + exports.cssClasses.HEADER_CELL,
- HEADER_CELL_WITH_SORT: "." + exports.cssClasses.HEADER_CELL_WITH_SORT,
- HEADER_ROW: "." + exports.cssClasses.HEADER_ROW,
- HEADER_ROW_CHECKBOX: "." + exports.cssClasses.HEADER_ROW_CHECKBOX,
- PROGRESS_INDICATOR: "." + exports.cssClasses.PROGRESS_INDICATOR,
- ROW: "." + exports.cssClasses.ROW,
- ROW_CHECKBOX: "." + exports.cssClasses.ROW_CHECKBOX,
- ROW_SELECTED: "." + exports.cssClasses.ROW_SELECTED,
- SORT_ICON_BUTTON: "." + exports.cssClasses.SORT_ICON_BUTTON,
- SORT_STATUS_LABEL: "." + exports.cssClasses.SORT_STATUS_LABEL
- };
- /**
- * Messages used in component.
- */
- exports.messages = {
- SORTED_IN_DESCENDING: 'Sorted in descending order',
- SORTED_IN_ASCENDING: 'Sorted in ascending order'
- };
- /**
- * Attributes and selectors used in component.
- * @deprecated Use `attributes`, `dataAttributes` and `selectors` instead.
- */
- exports.strings = {
- ARIA_SELECTED: exports.attributes.ARIA_SELECTED,
- ARIA_SORT: exports.attributes.ARIA_SORT,
- DATA_ROW_ID_ATTR: exports.dataAttributes.ROW_ID,
- HEADER_ROW_CHECKBOX_SELECTOR: exports.selectors.HEADER_ROW_CHECKBOX,
- ROW_CHECKBOX_SELECTOR: exports.selectors.ROW_CHECKBOX,
- ROW_SELECTED_SELECTOR: exports.selectors.ROW_SELECTED,
- ROW_SELECTOR: exports.selectors.ROW
- };
- /**
- * Sort values defined by ARIA.
- * See https://www.w3.org/WAI/PF/aria/states_and_properties#aria-sort
- */
- var SortValue;
- (function (SortValue) {
- // Items are sorted in ascending order by this column.
- SortValue["ASCENDING"] = "ascending";
- // Items are sorted in descending order by this column.
- SortValue["DESCENDING"] = "descending";
- // There is no defined sort applied to the column.
- SortValue["NONE"] = "none";
- // A sort algorithm other than ascending or descending has been applied.
- SortValue["OTHER"] = "other";
- })(SortValue = exports.SortValue || (exports.SortValue = {}));
- /**
- * Event names used in component.
- */
- exports.events = {
- ROW_SELECTION_CHANGED: 'MDCDataTable:rowSelectionChanged',
- SELECTED_ALL: 'MDCDataTable:selectedAll',
- UNSELECTED_ALL: 'MDCDataTable:unselectedAll',
- SORTED: 'MDCDataTable:sorted'
- };
- /***/ }),
- /***/ "./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) {
- function adopt(value) {
- return value instanceof P ? value : new P(function (resolve) {
- resolve(value);
- });
- }
- 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) : adopt(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");
- /**
- * The Foundation of data table component containing pure business logic, any
- * logic requiring DOM manipulation are delegated to adapter methods.
- */
- var MDCDataTableFoundation = /** @class */function (_super) {
- __extends(MDCDataTableFoundation, _super);
- function MDCDataTableFoundation(adapter) {
- return _super.call(this, __assign(__assign({}, MDCDataTableFoundation.defaultAdapter), adapter)) || this;
- }
- Object.defineProperty(MDCDataTableFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- addClassAtRowIndex: function addClassAtRowIndex() {
- return undefined;
- },
- getAttributeByHeaderCellIndex: function getAttributeByHeaderCellIndex() {
- return '';
- },
- getHeaderCellCount: function getHeaderCellCount() {
- return 0;
- },
- getHeaderCellElements: function getHeaderCellElements() {
- return [];
- },
- getRowCount: function getRowCount() {
- return 0;
- },
- getRowElements: function getRowElements() {
- return [];
- },
- getRowIdAtIndex: function getRowIdAtIndex() {
- return '';
- },
- getRowIndexByChildElement: function getRowIndexByChildElement() {
- return 0;
- },
- getSelectedRowCount: function getSelectedRowCount() {
- return 0;
- },
- getTableContainerHeight: function getTableContainerHeight() {
- return 0;
- },
- getTableHeaderHeight: function getTableHeaderHeight() {
- 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;
- },
- notifySortAction: function notifySortAction() {
- return undefined;
- },
- notifyUnselectedAll: function notifyUnselectedAll() {
- return undefined;
- },
- registerHeaderRowCheckbox: function registerHeaderRowCheckbox() {
- return undefined;
- },
- registerRowCheckboxes: function registerRowCheckboxes() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- removeClassAtRowIndex: function removeClassAtRowIndex() {
- return undefined;
- },
- removeClassNameByHeaderCellIndex: function removeClassNameByHeaderCellIndex() {
- return undefined;
- },
- setAttributeAtRowIndex: function setAttributeAtRowIndex() {
- return undefined;
- },
- setAttributeByHeaderCellIndex: function setAttributeByHeaderCellIndex() {
- return undefined;
- },
- setClassNameByHeaderCellIndex: function setClassNameByHeaderCellIndex() {
- return undefined;
- },
- setHeaderRowCheckboxChecked: function setHeaderRowCheckboxChecked() {
- return undefined;
- },
- setHeaderRowCheckboxIndeterminate: function setHeaderRowCheckboxIndeterminate() {
- return undefined;
- },
- setProgressIndicatorStyles: function setProgressIndicatorStyles() {
- return undefined;
- },
- setRowCheckboxCheckedAtIndex: function setRowCheckboxCheckedAtIndex() {
- return undefined;
- },
- setSortStatusLabelByHeaderCellIndex: function setSortStatusLabelByHeaderCellIndex() {
- 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();
- };
- /**
- * @return Array of header cell elements.
- */
- MDCDataTableFoundation.prototype.getHeaderCells = function () {
- return this.adapter.getHeaderCellElements();
- };
- /**
- * 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 all row ids.
- */
- MDCDataTableFoundation.prototype.getRowIds = function () {
- var rowIds = [];
- for (var rowIndex = 0; rowIndex < this.adapter.getRowCount(); rowIndex++) {
- rowIds.push(this.adapter.getRowIdAtIndex(rowIndex));
- }
- return rowIds;
- };
- /**
- * @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 });
- };
- /**
- * Handles sort action on sortable header cell.
- */
- MDCDataTableFoundation.prototype.handleSortAction = function (eventData) {
- var columnId = eventData.columnId,
- columnIndex = eventData.columnIndex,
- headerCell = eventData.headerCell;
- // Reset sort attributes / classes on other header cells.
- for (var index = 0; index < this.adapter.getHeaderCellCount(); index++) {
- if (index === columnIndex) {
- continue;
- }
- this.adapter.removeClassNameByHeaderCellIndex(index, constants_1.cssClasses.HEADER_CELL_SORTED);
- this.adapter.removeClassNameByHeaderCellIndex(index, constants_1.cssClasses.HEADER_CELL_SORTED_DESCENDING);
- this.adapter.setAttributeByHeaderCellIndex(index, constants_1.strings.ARIA_SORT, constants_1.SortValue.NONE);
- this.adapter.setSortStatusLabelByHeaderCellIndex(index, constants_1.SortValue.NONE);
- }
- // Set appropriate sort attributes / classes on target header cell.
- this.adapter.setClassNameByHeaderCellIndex(columnIndex, constants_1.cssClasses.HEADER_CELL_SORTED);
- var currentSortValue = this.adapter.getAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT);
- var sortValue = constants_1.SortValue.NONE;
- // Set to descending if sorted on ascending order.
- if (currentSortValue === constants_1.SortValue.ASCENDING) {
- this.adapter.setClassNameByHeaderCellIndex(columnIndex, constants_1.cssClasses.HEADER_CELL_SORTED_DESCENDING);
- this.adapter.setAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT, constants_1.SortValue.DESCENDING);
- sortValue = constants_1.SortValue.DESCENDING;
- // Set to ascending if sorted on descending order.
- } else if (currentSortValue === constants_1.SortValue.DESCENDING) {
- this.adapter.removeClassNameByHeaderCellIndex(columnIndex, constants_1.cssClasses.HEADER_CELL_SORTED_DESCENDING);
- this.adapter.setAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT, constants_1.SortValue.ASCENDING);
- sortValue = constants_1.SortValue.ASCENDING;
- } else {
- // Set to ascending by default when not sorted.
- this.adapter.setAttributeByHeaderCellIndex(columnIndex, constants_1.strings.ARIA_SORT, constants_1.SortValue.ASCENDING);
- sortValue = constants_1.SortValue.ASCENDING;
- }
- this.adapter.setSortStatusLabelByHeaderCellIndex(columnIndex, sortValue);
- this.adapter.notifySortAction({
- columnId: columnId,
- columnIndex: columnIndex,
- headerCell: headerCell,
- sortValue: sortValue
- });
- };
- /**
- * Shows progress indicator blocking only the table body content when in
- * loading state.
- */
- MDCDataTableFoundation.prototype.showProgress = function () {
- var tableHeaderHeight = this.adapter.getTableHeaderHeight();
- // Calculate the height of table content (Not scroll content) excluding
- // header row height.
- var height = this.adapter.getTableContainerHeight() - tableHeaderHeight;
- var top = tableHeaderHeight;
- this.adapter.setProgressIndicatorStyles({
- height: height + "px",
- top: top + "px"
- });
- this.adapter.addClass(constants_1.cssClasses.IN_PROGRESS);
- };
- /**
- * Hides progress indicator when data table is finished loading.
- */
- MDCDataTableFoundation.prototype.hideProgress = function () {
- this.adapter.removeClass(constants_1.cssClasses.IN_PROGRESS);
- };
- /**
- * Updates header row checkbox state based on number of rows selected.
- */
- MDCDataTableFoundation.prototype.setHeaderRowCheckboxState = function () {
- if (this.adapter.getSelectedRowCount() === 0) {
- this.adapter.setHeaderRowCheckboxChecked(false);
- this.adapter.setHeaderRowCheckboxIndeterminate(false);
- } else if (this.adapter.getSelectedRowCount() === this.adapter.getRowCount()) {
- this.adapter.setHeaderRowCheckboxChecked(true);
- this.adapter.setHeaderRowCheckboxIndeterminate(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 s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts");
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
- var strings = foundation_1.MDCDialogFoundation.strings;
- var MDCDialog = /** @class */function (_super) {
- __extends(MDCDialog, _super);
- function MDCDialog() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- Object.defineProperty(MDCDialog.prototype, "isOpen", {
- get: function get() {
- return this.foundation.isOpen();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDialog.prototype, "escapeKeyAction", {
- get: function get() {
- return this.foundation.getEscapeKeyAction();
- },
- set: function set(action) {
- this.foundation.setEscapeKeyAction(action);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDialog.prototype, "scrimClickAction", {
- get: function get() {
- return this.foundation.getScrimClickAction();
- },
- set: function set(action) {
- this.foundation.setScrimClickAction(action);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDialog.prototype, "autoStackButtons", {
- get: function get() {
- return this.foundation.getAutoStackButtons();
- },
- set: function set(autoStack) {
- this.foundation.setAutoStackButtons(autoStack);
- },
- enumerable: true,
- configurable: true
- });
- MDCDialog.attachTo = function (root) {
- return new MDCDialog(root);
- };
- MDCDialog.prototype.initialize = function (focusTrapFactory) {
- var e_1, _a;
- if (focusTrapFactory === void 0) {
- focusTrapFactory = function focusTrapFactory(el, focusOptions) {
- return new focus_trap_1.FocusTrap(el, focusOptions);
- };
- }
- var container = this.root.querySelector(strings.CONTAINER_SELECTOR);
- if (!container) {
- throw new Error("Dialog component requires a " + strings.CONTAINER_SELECTOR + " container element");
- }
- this.container_ = container;
- this.content_ = this.root.querySelector(strings.CONTENT_SELECTOR);
- this.buttons_ = [].slice.call(this.root.querySelectorAll(strings.BUTTON_SELECTOR));
- this.defaultButton_ = this.root.querySelector("[" + strings.BUTTON_DEFAULT_ATTRIBUTE + "]");
- this.focusTrapFactory_ = focusTrapFactory;
- this.buttonRipples_ = [];
- try {
- for (var _b = __values(this.buttons_), _c = _b.next(); !_c.done; _c = _b.next()) {
- var buttonEl = _c.value;
- this.buttonRipples_.push(new component_2.MDCRipple(buttonEl));
- }
- } catch (e_1_1) {
- e_1 = { error: e_1_1 };
- } finally {
- try {
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
- } finally {
- if (e_1) throw e_1.error;
- }
- }
- };
- MDCDialog.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.focusTrap_ = util.createFocusTrapInstance(this.container_, this.focusTrapFactory_, this.getInitialFocusEl_() || undefined);
- this.handleClick_ = this.foundation.handleClick.bind(this.foundation);
- this.handleKeydown_ = this.foundation.handleKeydown.bind(this.foundation);
- this.handleDocumentKeydown_ = this.foundation.handleDocumentKeydown.bind(this.foundation);
- this.handleLayout_ = this.layout.bind(this);
- var LAYOUT_EVENTS = ['resize', 'orientationchange'];
- this.handleOpening_ = function () {
- LAYOUT_EVENTS.forEach(function (evtType) {
- return window.addEventListener(evtType, _this.handleLayout_);
- });
- document.addEventListener('keydown', _this.handleDocumentKeydown_);
- };
- this.handleClosing_ = function () {
- LAYOUT_EVENTS.forEach(function (evtType) {
- return window.removeEventListener(evtType, _this.handleLayout_);
- });
- document.removeEventListener('keydown', _this.handleDocumentKeydown_);
- };
- this.listen('click', this.handleClick_);
- this.listen('keydown', this.handleKeydown_);
- this.listen(strings.OPENING_EVENT, this.handleOpening_);
- this.listen(strings.CLOSING_EVENT, this.handleClosing_);
- };
- MDCDialog.prototype.destroy = function () {
- this.unlisten('click', this.handleClick_);
- this.unlisten('keydown', this.handleKeydown_);
- this.unlisten(strings.OPENING_EVENT, this.handleOpening_);
- this.unlisten(strings.CLOSING_EVENT, this.handleClosing_);
- this.handleClosing_();
- this.buttonRipples_.forEach(function (ripple) {
- return ripple.destroy();
- });
- _super.prototype.destroy.call(this);
- };
- MDCDialog.prototype.layout = function () {
- this.foundation.layout();
- };
- MDCDialog.prototype.open = function () {
- this.foundation.open();
- };
- MDCDialog.prototype.close = function (action) {
- if (action === void 0) {
- action = '';
- }
- this.foundation.close(action);
- };
- MDCDialog.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- var adapter = {
- addBodyClass: function addBodyClass(className) {
- return document.body.classList.add(className);
- },
- addClass: function addClass(className) {
- return _this.root.classList.add(className);
- },
- areButtonsStacked: function areButtonsStacked() {
- return util.areTopsMisaligned(_this.buttons_);
- },
- clickDefaultButton: function clickDefaultButton() {
- return _this.defaultButton_ && _this.defaultButton_.click();
- },
- eventTargetMatches: function eventTargetMatches(target, selector) {
- return target ? ponyfill_1.matches(target, selector) : false;
- },
- getActionFromEvent: function getActionFromEvent(evt) {
- if (!evt.target) {
- return '';
- }
- var element = ponyfill_1.closest(evt.target, "[" + strings.ACTION_ATTRIBUTE + "]");
- return element && element.getAttribute(strings.ACTION_ATTRIBUTE);
- },
- getInitialFocusEl: function getInitialFocusEl() {
- return _this.getInitialFocusEl_();
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- isContentScrollable: function isContentScrollable() {
- return util.isScrollable(_this.content_);
- },
- notifyClosed: function notifyClosed(action) {
- return _this.emit(strings.CLOSED_EVENT, action ? { action: action } : {});
- },
- notifyClosing: function notifyClosing(action) {
- return _this.emit(strings.CLOSING_EVENT, action ? { action: action } : {});
- },
- notifyOpened: function notifyOpened() {
- return _this.emit(strings.OPENED_EVENT, {});
- },
- notifyOpening: function notifyOpening() {
- return _this.emit(strings.OPENING_EVENT, {});
- },
- releaseFocus: function releaseFocus() {
- return _this.focusTrap_.releaseFocus();
- },
- removeBodyClass: function removeBodyClass(className) {
- return document.body.classList.remove(className);
- },
- removeClass: function removeClass(className) {
- return _this.root.classList.remove(className);
- },
- reverseButtons: function reverseButtons() {
- _this.buttons_.reverse();
- _this.buttons_.forEach(function (button) {
- button.parentElement.appendChild(button);
- });
- },
- trapFocus: function trapFocus() {
- return _this.focusTrap_.trapFocus();
- }
- };
- return new foundation_1.MDCDialogFoundation(adapter);
- };
- MDCDialog.prototype.getInitialFocusEl_ = function () {
- return this.root.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(__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;
- _this.suppressDefaultPressSelector = constants_1.strings.SUPPRESS_DEFAULT_PRESS_SELECTOR;
- 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.getSuppressDefaultPressSelector = function () {
- return this.suppressDefaultPressSelector;
- };
- MDCDialogFoundation.prototype.setSuppressDefaultPressSelector = function (selector) {
- this.suppressDefaultPressSelector = selector;
- };
- 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;
- }
- // `composedPath` is used here, when available, to account for use cases
- // where a target meant to suppress the default press behaviour
- // may exist in a shadow root.
- // For example, a textarea inside a web component:
- // <mwc-dialog>
- // <horizontal-layout>
- // #shadow-root (open)
- // <mwc-textarea>
- // #shadow-root (open)
- // <textarea></textarea>
- // </mwc-textarea>
- // </horizontal-layout>
- // </mwc-dialog>
- var target = evt.composedPath ? evt.composedPath()[0] : evt.target;
- var isDefault = this.suppressDefaultPressSelector ? !this.adapter.eventTargetMatches(target, this.suppressDefaultPressSelector) : true;
- if (isEnter && isDefault) {
- this.adapter.clickDefaultButton();
- }
- };
- /** Handles keydown on the document. */
- MDCDialogFoundation.prototype.handleDocumentKeydown = function (evt) {
- var isEscape = evt.key === 'Escape' || evt.keyCode === 27;
- if (isEscape && this.escapeKeyAction_ !== '') {
- this.close(this.escapeKeyAction_);
- }
- };
- MDCDialogFoundation.prototype.layoutInternal_ = function () {
- if (this.autoStackButtons_) {
- this.detectStackedButtons_();
- }
- this.detectScrollableContent_();
- };
- MDCDialogFoundation.prototype.handleAnimationTimerEnd_ = function () {
- this.animationTimer_ = 0;
- this.adapter.removeClass(constants_1.cssClasses.OPENING);
- this.adapter.removeClass(constants_1.cssClasses.CLOSING);
- };
- /**
- * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
- */
- MDCDialogFoundation.prototype.runNextAnimationFrame_ = function (callback) {
- var _this = this;
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = requestAnimationFrame(function () {
- _this.animationFrame_ = 0;
- clearTimeout(_this.animationTimer_);
- _this.animationTimer_ = setTimeout(callback, 0);
- });
- };
- MDCDialogFoundation.prototype.detectStackedButtons_ = function () {
- // Remove the class first to let us measure the buttons' natural positions.
- this.adapter.removeClass(constants_1.cssClasses.STACKED);
- var areButtonsStacked = this.adapter.areButtonsStacked();
- if (areButtonsStacked) {
- this.adapter.addClass(constants_1.cssClasses.STACKED);
- }
- if (areButtonsStacked !== this.areButtonsStacked_) {
- this.adapter.reverseButtons();
- this.areButtonsStacked_ = areButtonsStacked;
- }
- };
- MDCDialogFoundation.prototype.detectScrollableContent_ = function () {
- // Remove the class first to let us measure the natural height of the content.
- this.adapter.removeClass(constants_1.cssClasses.SCROLLABLE);
- if (this.adapter.isContentScrollable()) {
- this.adapter.addClass(constants_1.cssClasses.SCROLLABLE);
- }
- };
- return MDCDialogFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCDialogFoundation = MDCDialogFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCDialogFoundation;
- /***/ }),
- /***/ "./packages/mdc-dialog/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-dialog/index.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-dialog/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-dialog/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-dialog/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-dialog/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-dialog/util.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-dialog/util.ts ***!
- \*************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- function createFocusTrapInstance(surfaceEl, focusTrapFactory, initialFocusEl) {
- return focusTrapFactory(surfaceEl, { initialFocusEl: initialFocusEl });
- }
- exports.createFocusTrapInstance = createFocusTrapInstance;
- function isScrollable(el) {
- return el ? el.scrollHeight > el.offsetHeight : false;
- }
- exports.isScrollable = isScrollable;
- function areTopsMisaligned(els) {
- var tops = new Set();
- [].forEach.call(els, function (el) {
- return tops.add(el.offsetTop);
- });
- return tops.size > 1;
- }
- exports.areTopsMisaligned = areTopsMisaligned;
- /***/ }),
- /***/ "./packages/mdc-dom/announce.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-dom/announce.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * Priorities for the announce function
- */
- var AnnouncerPriority;
- (function (AnnouncerPriority) {
- AnnouncerPriority["POLITE"] = "polite";
- AnnouncerPriority["ASSERTIVE"] = "assertive";
- })(AnnouncerPriority = exports.AnnouncerPriority || (exports.AnnouncerPriority = {}));
- /**
- * Data attribute added to live region element.
- */
- exports.DATA_MDC_DOM_ANNOUNCE = 'data-mdc-dom-announce';
- /**
- * Announces the given message with optional priority, defaulting to "polite"
- */
- function announce(message, priority) {
- Announcer.getInstance().say(message, priority);
- }
- exports.announce = announce;
- var Announcer = /** @class */function () {
- // Constructor made private to ensure only the singleton is used
- function Announcer() {
- this.liveRegions = new Map();
- }
- Announcer.getInstance = function () {
- if (!Announcer.instance) {
- Announcer.instance = new Announcer();
- }
- return Announcer.instance;
- };
- Announcer.prototype.say = function (message, priority) {
- if (priority === void 0) {
- priority = AnnouncerPriority.POLITE;
- }
- var liveRegion = this.getLiveRegion(priority);
- // Reset the region to pick up the message, even if the message is the
- // exact same as before.
- liveRegion.textContent = '';
- // Timeout is necessary for screen readers like NVDA and VoiceOver.
- setTimeout(function () {
- liveRegion.textContent = message;
- document.addEventListener('click', clearLiveRegion);
- }, 1);
- function clearLiveRegion() {
- liveRegion.textContent = '';
- document.removeEventListener('click', clearLiveRegion);
- }
- };
- Announcer.prototype.getLiveRegion = function (priority) {
- var existingLiveRegion = this.liveRegions.get(priority);
- if (existingLiveRegion && document.body.contains(existingLiveRegion)) {
- return existingLiveRegion;
- }
- var liveRegion = this.createLiveRegion(priority);
- this.liveRegions.set(priority, liveRegion);
- return liveRegion;
- };
- Announcer.prototype.createLiveRegion = function (priority) {
- var el = document.createElement('div');
- el.style.position = 'absolute';
- el.style.top = '-9999px';
- el.style.left = '-9999px';
- el.style.height = '1px';
- el.style.overflow = 'hidden';
- el.setAttribute('aria-atomic', 'true');
- el.setAttribute('aria-live', priority);
- el.setAttribute(exports.DATA_MDC_DOM_ANNOUNCE, 'true');
- document.body.appendChild(el);
- return el;
- };
- return Announcer;
- }();
- /***/ }),
- /***/ "./packages/mdc-dom/events.ts":
- /*!************************************!*\
- !*** ./packages/mdc-dom/events.ts ***!
- \************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * Determine whether the current browser supports passive event listeners, and
- * if so, use them.
- */
- function applyPassive(globalObj) {
- if (globalObj === void 0) {
- globalObj = window;
- }
- return supportsPassiveOption(globalObj) ? { passive: true } : false;
- }
- exports.applyPassive = applyPassive;
- function supportsPassiveOption(globalObj) {
- if (globalObj === void 0) {
- globalObj = window;
- }
- // See
- // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener
- var passiveSupported = false;
- try {
- var options = {
- // This function will be called when the browser
- // attempts to access the passive property.
- get passive() {
- passiveSupported = true;
- return false;
- }
- };
- var handler = function handler() {};
- globalObj.document.addEventListener('test', handler, options);
- globalObj.document.removeEventListener('test', handler, options);
- } catch (err) {
- passiveSupported = false;
- }
- return passiveSupported;
- }
- /***/ }),
- /***/ "./packages/mdc-dom/focus-trap.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-dom/focus-trap.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var FOCUS_SENTINEL_CLASS = 'mdc-dom-focus-sentinel';
- /**
- * Utility to trap focus in a given root element, e.g. for modal components such
- * as dialogs. The root should have at least one focusable child element,
- * for setting initial focus when trapping focus.
- * Also tracks the previously focused element, and restores focus to that
- * element when releasing focus.
- */
- var FocusTrap = /** @class */function () {
- function FocusTrap(root, options) {
- if (options === void 0) {
- options = {};
- }
- this.root = root;
- this.options = options;
- // Previously focused element before trapping focus.
- this.elFocusedBeforeTrapFocus = null;
- }
- /**
- * Traps focus in `root`. Also focuses on either `initialFocusEl` if set;
- * otherwises sets initial focus to the first focusable child element.
- */
- FocusTrap.prototype.trapFocus = function () {
- var focusableEls = this.getFocusableElements(this.root);
- if (focusableEls.length === 0) {
- throw new Error('FocusTrap: Element must have at least one focusable child.');
- }
- this.elFocusedBeforeTrapFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
- this.wrapTabFocus(this.root, focusableEls);
- if (!this.options.skipInitialFocus) {
- this.focusInitialElement(focusableEls, this.options.initialFocusEl);
- }
- };
- /**
- * Releases focus from `root`. Also restores focus to the previously focused
- * element.
- */
- FocusTrap.prototype.releaseFocus = function () {
- [].slice.call(this.root.querySelectorAll("." + FOCUS_SENTINEL_CLASS)).forEach(function (sentinelEl) {
- sentinelEl.parentElement.removeChild(sentinelEl);
- });
- if (this.elFocusedBeforeTrapFocus) {
- this.elFocusedBeforeTrapFocus.focus();
- }
- };
- /**
- * Wraps tab focus within `el` by adding two hidden sentinel divs which are
- * used to mark the beginning and the end of the tabbable region. When
- * focused, these sentinel elements redirect focus to the first/last
- * children elements of the tabbable region, ensuring that focus is trapped
- * within that region.
- */
- FocusTrap.prototype.wrapTabFocus = function (el, focusableEls) {
- var sentinelStart = this.createSentinel();
- var sentinelEnd = this.createSentinel();
- sentinelStart.addEventListener('focus', function () {
- if (focusableEls.length > 0) {
- focusableEls[focusableEls.length - 1].focus();
- }
- });
- sentinelEnd.addEventListener('focus', function () {
- if (focusableEls.length > 0) {
- focusableEls[0].focus();
- }
- });
- el.insertBefore(sentinelStart, el.children[0]);
- el.appendChild(sentinelEnd);
- };
- /**
- * Focuses on `initialFocusEl` if defined and a child of the root element.
- * Otherwise, focuses on the first focusable child element of the root.
- */
- FocusTrap.prototype.focusInitialElement = function (focusableEls, initialFocusEl) {
- var focusIndex = 0;
- if (initialFocusEl) {
- focusIndex = Math.max(focusableEls.indexOf(initialFocusEl), 0);
- }
- focusableEls[focusIndex].focus();
- };
- FocusTrap.prototype.getFocusableElements = function (root) {
- var focusableEls = [].slice.call(root.querySelectorAll('[autofocus], [tabindex], a, input, textarea, select, button'));
- return focusableEls.filter(function (el) {
- var isDisabledOrHidden = el.getAttribute('aria-disabled') === 'true' || el.getAttribute('disabled') != null || el.getAttribute('hidden') != null || el.getAttribute('aria-hidden') === 'true';
- var isTabbableAndVisible = el.tabIndex >= 0 && el.getBoundingClientRect().width > 0 && !el.classList.contains(FOCUS_SENTINEL_CLASS) && !isDisabledOrHidden;
- var isProgrammaticallyHidden = false;
- if (isTabbableAndVisible) {
- var style = getComputedStyle(el);
- isProgrammaticallyHidden = style.display === 'none' || style.visibility === 'hidden';
- }
- return isTabbableAndVisible && !isProgrammaticallyHidden;
- });
- };
- FocusTrap.prototype.createSentinel = function () {
- var sentinel = document.createElement('div');
- sentinel.setAttribute('tabindex', '0');
- // Don't announce in screen readers.
- sentinel.setAttribute('aria-hidden', 'true');
- sentinel.classList.add(FOCUS_SENTINEL_CLASS);
- return sentinel;
- };
- return FocusTrap;
- }();
- exports.FocusTrap = FocusTrap;
- /***/ }),
- /***/ "./packages/mdc-dom/index.ts":
- /*!***********************************!*\
- !*** ./packages/mdc-dom/index.ts ***!
- \***********************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var events = __importStar(__webpack_require__(/*! ./events */ "./packages/mdc-dom/events.ts"));
- exports.events = events;
- var focusTrap = __importStar(__webpack_require__(/*! ./focus-trap */ "./packages/mdc-dom/focus-trap.ts"));
- exports.focusTrap = focusTrap;
- var keyboard = __importStar(__webpack_require__(/*! ./keyboard */ "./packages/mdc-dom/keyboard.ts"));
- exports.keyboard = keyboard;
- var ponyfill = __importStar(__webpack_require__(/*! ./ponyfill */ "./packages/mdc-dom/ponyfill.ts"));
- exports.ponyfill = ponyfill;
- /***/ }),
- /***/ "./packages/mdc-dom/keyboard.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-dom/keyboard.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * KEY provides normalized string values for keys.
- */
- exports.KEY = {
- UNKNOWN: 'Unknown',
- BACKSPACE: 'Backspace',
- ENTER: 'Enter',
- SPACEBAR: 'Spacebar',
- PAGE_UP: 'PageUp',
- PAGE_DOWN: 'PageDown',
- END: 'End',
- HOME: 'Home',
- ARROW_LEFT: 'ArrowLeft',
- ARROW_UP: 'ArrowUp',
- ARROW_RIGHT: 'ArrowRight',
- ARROW_DOWN: 'ArrowDown',
- DELETE: 'Delete',
- ESCAPE: 'Escape'
- };
- var normalizedKeys = new Set();
- // IE11 has no support for new Map with iterable so we need to initialize this
- // by hand.
- normalizedKeys.add(exports.KEY.BACKSPACE);
- normalizedKeys.add(exports.KEY.ENTER);
- normalizedKeys.add(exports.KEY.SPACEBAR);
- normalizedKeys.add(exports.KEY.PAGE_UP);
- normalizedKeys.add(exports.KEY.PAGE_DOWN);
- normalizedKeys.add(exports.KEY.END);
- normalizedKeys.add(exports.KEY.HOME);
- normalizedKeys.add(exports.KEY.ARROW_LEFT);
- normalizedKeys.add(exports.KEY.ARROW_UP);
- normalizedKeys.add(exports.KEY.ARROW_RIGHT);
- normalizedKeys.add(exports.KEY.ARROW_DOWN);
- normalizedKeys.add(exports.KEY.DELETE);
- normalizedKeys.add(exports.KEY.ESCAPE);
- var KEY_CODE = {
- BACKSPACE: 8,
- ENTER: 13,
- SPACEBAR: 32,
- PAGE_UP: 33,
- PAGE_DOWN: 34,
- END: 35,
- HOME: 36,
- ARROW_LEFT: 37,
- ARROW_UP: 38,
- ARROW_RIGHT: 39,
- ARROW_DOWN: 40,
- DELETE: 46,
- ESCAPE: 27
- };
- var mappedKeyCodes = new Map();
- // IE11 has no support for new Map with iterable so we need to initialize this
- // by hand.
- mappedKeyCodes.set(KEY_CODE.BACKSPACE, exports.KEY.BACKSPACE);
- mappedKeyCodes.set(KEY_CODE.ENTER, exports.KEY.ENTER);
- mappedKeyCodes.set(KEY_CODE.SPACEBAR, exports.KEY.SPACEBAR);
- mappedKeyCodes.set(KEY_CODE.PAGE_UP, exports.KEY.PAGE_UP);
- mappedKeyCodes.set(KEY_CODE.PAGE_DOWN, exports.KEY.PAGE_DOWN);
- mappedKeyCodes.set(KEY_CODE.END, exports.KEY.END);
- mappedKeyCodes.set(KEY_CODE.HOME, exports.KEY.HOME);
- mappedKeyCodes.set(KEY_CODE.ARROW_LEFT, exports.KEY.ARROW_LEFT);
- mappedKeyCodes.set(KEY_CODE.ARROW_UP, exports.KEY.ARROW_UP);
- mappedKeyCodes.set(KEY_CODE.ARROW_RIGHT, exports.KEY.ARROW_RIGHT);
- mappedKeyCodes.set(KEY_CODE.ARROW_DOWN, exports.KEY.ARROW_DOWN);
- mappedKeyCodes.set(KEY_CODE.DELETE, exports.KEY.DELETE);
- mappedKeyCodes.set(KEY_CODE.ESCAPE, exports.KEY.ESCAPE);
- var navigationKeys = new Set();
- // IE11 has no support for new Set with iterable so we need to initialize this
- // by hand.
- navigationKeys.add(exports.KEY.PAGE_UP);
- navigationKeys.add(exports.KEY.PAGE_DOWN);
- navigationKeys.add(exports.KEY.END);
- navigationKeys.add(exports.KEY.HOME);
- navigationKeys.add(exports.KEY.ARROW_LEFT);
- navigationKeys.add(exports.KEY.ARROW_UP);
- navigationKeys.add(exports.KEY.ARROW_RIGHT);
- navigationKeys.add(exports.KEY.ARROW_DOWN);
- /**
- * normalizeKey returns the normalized string for a navigational action.
- */
- function normalizeKey(evt) {
- var key = evt.key;
- // If the event already has a normalized key, return it
- if (normalizedKeys.has(key)) {
- return key;
- }
- // tslint:disable-next-line:deprecation
- var mappedKey = mappedKeyCodes.get(evt.keyCode);
- if (mappedKey) {
- return mappedKey;
- }
- return exports.KEY.UNKNOWN;
- }
- exports.normalizeKey = normalizeKey;
- /**
- * isNavigationEvent returns whether the event is a navigation event
- */
- function isNavigationEvent(evt) {
- return navigationKeys.has(normalizeKey(evt));
- }
- exports.isNavigationEvent = isNavigationEvent;
- /***/ }),
- /***/ "./packages/mdc-dom/ponyfill.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-dom/ponyfill.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
- * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
- */
- function closest(element, selector) {
- if (element.closest) {
- return element.closest(selector);
- }
- var el = element;
- while (el) {
- if (matches(el, selector)) {
- return el;
- }
- el = el.parentElement;
- }
- return null;
- }
- exports.closest = closest;
- function matches(element, selector) {
- var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
- return nativeMatches.call(element, selector);
- }
- exports.matches = matches;
- /**
- * Used to compute the estimated scroll width of elements. When an element is
- * hidden due to display: none; being applied to a parent element, the width is
- * returned as 0. However, the element will have a true width once no longer
- * inside a display: none context. This method computes an estimated width when
- * the element is hidden or returns the true width when the element is visble.
- * @param {Element} element the element whose width to estimate
- */
- function estimateScrollWidth(element) {
- // Check the offsetParent. If the element inherits display: none from any
- // parent, the offsetParent property will be null (see
- // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
- // This check ensures we only clone the node when necessary.
- var htmlEl = element;
- if (htmlEl.offsetParent !== null) {
- return htmlEl.scrollWidth;
- }
- var clone = htmlEl.cloneNode(true);
- clone.style.setProperty('position', 'absolute');
- clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
- document.documentElement.appendChild(clone);
- var scrollWidth = clone.scrollWidth;
- document.documentElement.removeChild(clone);
- return scrollWidth;
- }
- exports.estimateScrollWidth = estimateScrollWidth;
- /***/ }),
- /***/ "./packages/mdc-drawer/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-drawer/component.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var focus_trap_1 = __webpack_require__(/*! @material/dom/focus-trap */ "./packages/mdc-dom/focus-trap.ts");
- var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/list/foundation */ "./packages/mdc-list/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
- var foundation_3 = __webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts");
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
- var cssClasses = foundation_2.MDCDismissibleDrawerFoundation.cssClasses,
- strings = foundation_2.MDCDismissibleDrawerFoundation.strings;
- /**
- * @events `MDCDrawer:closed {}` Emits when the navigation drawer has closed.
- * @events `MDCDrawer:opened {}` Emits when the navigation drawer has opened.
- */
- var MDCDrawer = /** @class */function (_super) {
- __extends(MDCDrawer, _super);
- function MDCDrawer() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCDrawer.attachTo = function (root) {
- return new MDCDrawer(root);
- };
- Object.defineProperty(MDCDrawer.prototype, "open", {
- /**
- * @return boolean Proxies to the foundation's `open`/`close` methods.
- * Also returns true if drawer is in the open position.
- */
- get: function get() {
- return this.foundation.isOpen();
- },
- /**
- * Toggles the drawer open and closed.
- */
- set: function set(isOpen) {
- if (isOpen) {
- this.foundation.open();
- } else {
- this.foundation.close();
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDrawer.prototype, "list", {
- get: function get() {
- return this.list_;
- },
- enumerable: true,
- configurable: true
- });
- MDCDrawer.prototype.initialize = function (focusTrapFactory, listFactory) {
- if (focusTrapFactory === void 0) {
- focusTrapFactory = function focusTrapFactory(el) {
- return new focus_trap_1.FocusTrap(el);
- };
- }
- if (listFactory === void 0) {
- listFactory = function listFactory(el) {
- return new component_2.MDCList(el);
- };
- }
- var listEl = this.root.querySelector("." + foundation_1.MDCListFoundation.cssClasses.ROOT);
- if (listEl) {
- this.list_ = listFactory(listEl);
- this.list_.wrapFocus = true;
- }
- this.focusTrapFactory_ = focusTrapFactory;
- };
- MDCDrawer.prototype.initialSyncWithDOM = function () {
- var _this = this;
- var MODAL = cssClasses.MODAL;
- var SCRIM_SELECTOR = strings.SCRIM_SELECTOR;
- this.scrim_ = this.root.parentNode.querySelector(SCRIM_SELECTOR);
- if (this.scrim_ && this.root.classList.contains(MODAL)) {
- this.handleScrimClick_ = function () {
- return _this.foundation.handleScrimClick();
- };
- this.scrim_.addEventListener('click', this.handleScrimClick_);
- this.focusTrap_ = util.createFocusTrapInstance(this.root, this.focusTrapFactory_);
- }
- this.handleKeydown_ = function (evt) {
- return _this.foundation.handleKeydown(evt);
- };
- this.handleTransitionEnd_ = function (evt) {
- return _this.foundation.handleTransitionEnd(evt);
- };
- this.listen('keydown', this.handleKeydown_);
- this.listen('transitionend', this.handleTransitionEnd_);
- };
- MDCDrawer.prototype.destroy = function () {
- this.unlisten('keydown', this.handleKeydown_);
- this.unlisten('transitionend', this.handleTransitionEnd_);
- if (this.list_) {
- this.list_.destroy();
- }
- var MODAL = cssClasses.MODAL;
- if (this.scrim_ && this.handleScrimClick_ && this.root.classList.contains(MODAL)) {
- this.scrim_.removeEventListener('click', this.handleScrimClick_);
- // Ensure drawer is closed to hide scrim and release focus
- this.open = false;
- }
- };
- MDCDrawer.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- addClass: function addClass(className) {
- return _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- elementHasClass: function elementHasClass(element, className) {
- return element.classList.contains(className);
- },
- saveFocus: function saveFocus() {
- return _this.previousFocus_ = document.activeElement;
- },
- restoreFocus: function restoreFocus() {
- var previousFocus = _this.previousFocus_;
- if (previousFocus && previousFocus.focus && _this.root.contains(document.activeElement)) {
- previousFocus.focus();
- }
- },
- focusActiveNavigationItem: function focusActiveNavigationItem() {
- var activeNavItemEl = _this.root.querySelector("." + foundation_1.MDCListFoundation.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
- if (activeNavItemEl) {
- activeNavItemEl.focus();
- }
- },
- notifyClose: function notifyClose() {
- return _this.emit(strings.CLOSE_EVENT, {}, true /* shouldBubble */);
- },
- notifyOpen: function notifyOpen() {
- return _this.emit(strings.OPEN_EVENT, {}, true /* shouldBubble */);
- },
- trapFocus: function trapFocus() {
- return _this.focusTrap_.trapFocus();
- },
- releaseFocus: function releaseFocus() {
- return _this.focusTrap_.releaseFocus();
- }
- };
- // tslint:enable:object-literal-sort-keys
- var DISMISSIBLE = cssClasses.DISMISSIBLE,
- MODAL = cssClasses.MODAL;
- if (this.root.classList.contains(DISMISSIBLE)) {
- return new foundation_2.MDCDismissibleDrawerFoundation(adapter);
- } else if (this.root.classList.contains(MODAL)) {
- return new foundation_3.MDCModalDrawerFoundation(adapter);
- } else {
- throw new Error("MDCDrawer: Failed to instantiate component. Supported variants are " + DISMISSIBLE + " and " + MODAL + ".");
- }
- };
- return MDCDrawer;
- }(component_1.MDCComponent);
- exports.MDCDrawer = MDCDrawer;
- /***/ }),
- /***/ "./packages/mdc-drawer/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-drawer/constants.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var cssClasses = {
- ANIMATE: 'mdc-drawer--animate',
- CLOSING: 'mdc-drawer--closing',
- DISMISSIBLE: 'mdc-drawer--dismissible',
- MODAL: 'mdc-drawer--modal',
- OPEN: 'mdc-drawer--open',
- OPENING: 'mdc-drawer--opening',
- ROOT: 'mdc-drawer'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- APP_CONTENT_SELECTOR: '.mdc-drawer-app-content',
- CLOSE_EVENT: 'MDCDrawer:closed',
- OPEN_EVENT: 'MDCDrawer:opened',
- SCRIM_SELECTOR: '.mdc-drawer-scrim'
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-drawer/dismissible/foundation.ts":
- /*!*******************************************************!*\
- !*** ./packages/mdc-drawer/dismissible/foundation.ts ***!
- \*******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ../constants */ "./packages/mdc-drawer/constants.ts");
- var MDCDismissibleDrawerFoundation = /** @class */function (_super) {
- __extends(MDCDismissibleDrawerFoundation, _super);
- function MDCDismissibleDrawerFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCDismissibleDrawerFoundation.defaultAdapter), adapter)) || this;
- _this.animationFrame_ = 0;
- _this.animationTimer_ = 0;
- return _this;
- }
- Object.defineProperty(MDCDismissibleDrawerFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDismissibleDrawerFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCDismissibleDrawerFoundation, "defaultAdapter", {
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return false;
- },
- elementHasClass: function elementHasClass() {
- return false;
- },
- notifyClose: function notifyClose() {
- return undefined;
- },
- notifyOpen: function notifyOpen() {
- return undefined;
- },
- saveFocus: function saveFocus() {
- return undefined;
- },
- restoreFocus: function restoreFocus() {
- return undefined;
- },
- focusActiveNavigationItem: function focusActiveNavigationItem() {
- return undefined;
- },
- trapFocus: function trapFocus() {
- return undefined;
- },
- releaseFocus: function releaseFocus() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCDismissibleDrawerFoundation.prototype.destroy = function () {
- if (this.animationFrame_) {
- cancelAnimationFrame(this.animationFrame_);
- }
- if (this.animationTimer_) {
- clearTimeout(this.animationTimer_);
- }
- };
- /**
- * Opens the drawer from the closed state.
- */
- MDCDismissibleDrawerFoundation.prototype.open = function () {
- var _this = this;
- if (this.isOpen() || this.isOpening() || this.isClosing()) {
- return;
- }
- this.adapter.addClass(constants_1.cssClasses.OPEN);
- this.adapter.addClass(constants_1.cssClasses.ANIMATE);
- // Wait a frame once display is no longer "none", to establish basis for animation
- this.runNextAnimationFrame_(function () {
- _this.adapter.addClass(constants_1.cssClasses.OPENING);
- });
- this.adapter.saveFocus();
- };
- /**
- * Closes the drawer from the open state.
- */
- MDCDismissibleDrawerFoundation.prototype.close = function () {
- if (!this.isOpen() || this.isOpening() || this.isClosing()) {
- return;
- }
- this.adapter.addClass(constants_1.cssClasses.CLOSING);
- };
- /**
- * Returns true if the drawer is in the open position.
- * @return true if drawer is in open state.
- */
- MDCDismissibleDrawerFoundation.prototype.isOpen = function () {
- return this.adapter.hasClass(constants_1.cssClasses.OPEN);
- };
- /**
- * Returns true if the drawer is animating open.
- * @return true if drawer is animating open.
- */
- MDCDismissibleDrawerFoundation.prototype.isOpening = function () {
- return this.adapter.hasClass(constants_1.cssClasses.OPENING) || this.adapter.hasClass(constants_1.cssClasses.ANIMATE);
- };
- /**
- * Returns true if the drawer is animating closed.
- * @return true if drawer is animating closed.
- */
- MDCDismissibleDrawerFoundation.prototype.isClosing = function () {
- return this.adapter.hasClass(constants_1.cssClasses.CLOSING);
- };
- /**
- * Keydown handler to close drawer when key is escape.
- */
- MDCDismissibleDrawerFoundation.prototype.handleKeydown = function (evt) {
- var keyCode = evt.keyCode,
- key = evt.key;
- var isEscape = key === 'Escape' || keyCode === 27;
- if (isEscape) {
- this.close();
- }
- };
- /**
- * Handles the `transitionend` event when the drawer finishes opening/closing.
- */
- MDCDismissibleDrawerFoundation.prototype.handleTransitionEnd = function (evt) {
- var OPENING = constants_1.cssClasses.OPENING,
- CLOSING = constants_1.cssClasses.CLOSING,
- OPEN = constants_1.cssClasses.OPEN,
- ANIMATE = constants_1.cssClasses.ANIMATE,
- ROOT = constants_1.cssClasses.ROOT;
- // In Edge, transitionend on ripple pseudo-elements yields a target without classList, so check for Element first.
- var isRootElement = this.isElement_(evt.target) && this.adapter.elementHasClass(evt.target, ROOT);
- if (!isRootElement) {
- return;
- }
- if (this.isClosing()) {
- this.adapter.removeClass(OPEN);
- this.closed_();
- this.adapter.restoreFocus();
- this.adapter.notifyClose();
- } else {
- this.adapter.focusActiveNavigationItem();
- this.opened_();
- this.adapter.notifyOpen();
- }
- this.adapter.removeClass(ANIMATE);
- this.adapter.removeClass(OPENING);
- this.adapter.removeClass(CLOSING);
- };
- /**
- * Extension point for when drawer finishes open animation.
- */
- MDCDismissibleDrawerFoundation.prototype.opened_ = function () {}; // tslint:disable-line:no-empty
- /**
- * Extension point for when drawer finishes close animation.
- */
- MDCDismissibleDrawerFoundation.prototype.closed_ = function () {}; // tslint:disable-line:no-empty
- /**
- * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
- */
- MDCDismissibleDrawerFoundation.prototype.runNextAnimationFrame_ = function (callback) {
- var _this = this;
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = requestAnimationFrame(function () {
- _this.animationFrame_ = 0;
- clearTimeout(_this.animationTimer_);
- _this.animationTimer_ = setTimeout(callback, 0);
- });
- };
- MDCDismissibleDrawerFoundation.prototype.isElement_ = function (element) {
- // In Edge, transitionend on ripple pseudo-elements yields a target without classList.
- return Boolean(element.classList);
- };
- return MDCDismissibleDrawerFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCDismissibleDrawerFoundation = MDCDismissibleDrawerFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCDismissibleDrawerFoundation;
- /***/ }),
- /***/ "./packages/mdc-drawer/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-drawer/index.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-drawer/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-drawer/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-drawer/constants.ts"));
- __export(__webpack_require__(/*! ./dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts"));
- __export(__webpack_require__(/*! ./modal/foundation */ "./packages/mdc-drawer/modal/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-drawer/modal/foundation.ts":
- /*!*************************************************!*\
- !*** ./packages/mdc-drawer/modal/foundation.ts ***!
- \*************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! ../dismissible/foundation */ "./packages/mdc-drawer/dismissible/foundation.ts");
- /* istanbul ignore next: subclass is not a branch statement */
- var MDCModalDrawerFoundation = /** @class */function (_super) {
- __extends(MDCModalDrawerFoundation, _super);
- function MDCModalDrawerFoundation() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * Handles click event on scrim.
- */
- MDCModalDrawerFoundation.prototype.handleScrimClick = function () {
- this.close();
- };
- /**
- * Called when drawer finishes open animation.
- */
- MDCModalDrawerFoundation.prototype.opened_ = function () {
- this.adapter.trapFocus();
- };
- /**
- * Called when drawer finishes close animation.
- */
- MDCModalDrawerFoundation.prototype.closed_ = function () {
- this.adapter.releaseFocus();
- };
- return MDCModalDrawerFoundation;
- }(foundation_1.MDCDismissibleDrawerFoundation);
- exports.MDCModalDrawerFoundation = MDCModalDrawerFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCModalDrawerFoundation;
- /***/ }),
- /***/ "./packages/mdc-drawer/util.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-drawer/util.ts ***!
- \*************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- function createFocusTrapInstance(surfaceEl, focusTrapFactory) {
- return focusTrapFactory(surfaceEl, {
- // Component handles focusing on active nav item.
- skipInitialFocus: true
- });
- }
- exports.createFocusTrapInstance = createFocusTrapInstance;
- /***/ }),
- /***/ "./packages/mdc-floating-label/component.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-floating-label/component.ts ***!
- \**************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts");
- var MDCFloatingLabel = /** @class */function (_super) {
- __extends(MDCFloatingLabel, _super);
- function MDCFloatingLabel() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCFloatingLabel.attachTo = function (root) {
- return new MDCFloatingLabel(root);
- };
- /**
- * Styles the label to produce the label shake for errors.
- * @param shouldShake If true, shakes the label by adding a CSS class; otherwise, stops shaking by removing the class.
- */
- MDCFloatingLabel.prototype.shake = function (shouldShake) {
- this.foundation.shake(shouldShake);
- };
- /**
- * Styles the label to float/dock.
- * @param shouldFloat If true, floats the label by adding a CSS class; otherwise, docks it by removing the class.
- */
- MDCFloatingLabel.prototype.float = function (shouldFloat) {
- this.foundation.float(shouldFloat);
- };
- /**
- * Styles the label as required.
- * @param isRequired If true, adds an asterisk to the label, indicating that it is required.
- */
- MDCFloatingLabel.prototype.setRequired = function (isRequired) {
- this.foundation.setRequired(isRequired);
- };
- MDCFloatingLabel.prototype.getWidth = function () {
- return this.foundation.getWidth();
- };
- MDCFloatingLabel.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- addClass: function addClass(className) {
- return _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root.classList.remove(className);
- },
- getWidth: function getWidth() {
- return ponyfill_1.estimateScrollWidth(_this.root);
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- return _this.listen(evtType, handler);
- },
- deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- return _this.unlisten(evtType, handler);
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCFloatingLabelFoundation(adapter);
- };
- return MDCFloatingLabel;
- }(component_1.MDCComponent);
- exports.MDCFloatingLabel = MDCFloatingLabel;
- /***/ }),
- /***/ "./packages/mdc-floating-label/constants.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-floating-label/constants.ts ***!
- \**************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.cssClasses = {
- LABEL_FLOAT_ABOVE: 'mdc-floating-label--float-above',
- LABEL_REQUIRED: 'mdc-floating-label--required',
- 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(__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);
- }
- };
- /**
- * Styles the label as required.
- * @param isRequired If true, adds an asterisk to the label, indicating that it is required.
- */
- MDCFloatingLabelFoundation.prototype.setRequired = function (isRequired) {
- var LABEL_REQUIRED = MDCFloatingLabelFoundation.cssClasses.LABEL_REQUIRED;
- if (isRequired) {
- this.adapter.addClass(LABEL_REQUIRED);
- } else {
- this.adapter.removeClass(LABEL_REQUIRED);
- }
- };
- MDCFloatingLabelFoundation.prototype.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);
- };
- MDCFormField.prototype.labelEl = function () {
- var LABEL_SELECTOR = foundation_1.MDCFormFieldFoundation.strings.LABEL_SELECTOR;
- return this.root.querySelector(LABEL_SELECTOR);
- };
- 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) {
- var labelEl = _this.labelEl();
- if (labelEl) {
- labelEl.removeEventListener(evtType, handler);
- }
- },
- registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- var labelEl = _this.labelEl();
- if (labelEl) {
- labelEl.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(__assign({}, MDCFormFieldFoundation.defaultAdapter), adapter)) || this;
- _this.click = function () {
- _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.click);
- };
- MDCFormFieldFoundation.prototype.destroy = function () {
- this.adapter.deregisterInteractionHandler('click', this.click);
- };
- MDCFormFieldFoundation.prototype.handleClick = function () {
- var _this = this;
- this.adapter.activateInputRipple();
- requestAnimationFrame(function () {
- _this.adapter.deactivateInputRipple();
- });
- };
- return MDCFormFieldFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCFormFieldFoundation = MDCFormFieldFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCFormFieldFoundation;
- /***/ }),
- /***/ "./packages/mdc-form-field/index.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-form-field/index.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-form-field/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-form-field/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-form-field/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-icon-button/component.ts":
- /*!***********************************************!*\
- !*** ./packages/mdc-icon-button/component.ts ***!
- \***********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-icon-button/foundation.ts");
- var strings = foundation_1.MDCIconButtonToggleFoundation.strings;
- var MDCIconButtonToggle = /** @class */function (_super) {
- __extends(MDCIconButtonToggle, _super);
- function MDCIconButtonToggle() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.rippleComponent = _this.createRipple();
- return _this;
- }
- MDCIconButtonToggle.attachTo = function (root) {
- return new MDCIconButtonToggle(root);
- };
- MDCIconButtonToggle.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleClick = function () {
- _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) {
- _this.emit(strings.CHANGE_EVENT, evtData);
- },
- removeClass: function removeClass(className) {
- return _this.root.classList.remove(className);
- },
- getAttr: function getAttr(attrName) {
- return _this.root.getAttribute(attrName);
- },
- 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.rippleComponent;
- },
- 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_LABEL: 'aria-label',
- ARIA_PRESSED: 'aria-pressed',
- DATA_ARIA_LABEL_OFF: 'data-aria-label-off',
- DATA_ARIA_LABEL_ON: 'data-aria-label-on',
- 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) {
- var _this = _super.call(this, __assign(__assign({}, MDCIconButtonToggleFoundation.defaultAdapter), adapter)) || this;
- /**
- * Whether the icon button has an aria label that changes depending on
- * toggled state.
- */
- _this.hasToggledAriaLabel = false;
- return _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;
- },
- getAttr: function getAttr() {
- return null;
- },
- setAttr: function setAttr() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCIconButtonToggleFoundation.prototype.init = function () {
- var ariaLabelOn = this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_ON);
- var ariaLabelOff = this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_OFF);
- if (ariaLabelOn && ariaLabelOff) {
- if (this.adapter.getAttr(constants_1.strings.ARIA_PRESSED) !== null) {
- throw new Error('MDCIconButtonToggleFoundation: Button should not set ' + '`aria-pressed` if it has a toggled aria label.');
- }
- this.hasToggledAriaLabel = true;
- } else {
- this.adapter.setAttr(constants_1.strings.ARIA_PRESSED, String(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();
- }
- // Toggle UI based on state.
- if (isOn) {
- this.adapter.addClass(constants_1.cssClasses.ICON_BUTTON_ON);
- } else {
- this.adapter.removeClass(constants_1.cssClasses.ICON_BUTTON_ON);
- }
- // Toggle aria attributes based on state.
- if (this.hasToggledAriaLabel) {
- var ariaLabel = isOn ? this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_ON) : this.adapter.getAttr(constants_1.strings.DATA_ARIA_LABEL_OFF);
- this.adapter.setAttr(constants_1.strings.ARIA_LABEL, ariaLabel || '');
- } else {
- 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(__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.initialSyncWithDOM = function () {
- var _this = this;
- this.root.addEventListener('transitionend', function () {
- _this.foundation.handleTransitionEnd();
- });
- };
- 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) {
- _this.root.classList.add(className);
- },
- forceLayout: function forceLayout() {
- _this.root.getBoundingClientRect();
- },
- setBufferBarStyle: function setBufferBarStyle(styleProperty, value) {
- var bufferBar = _this.root.querySelector(foundation_1.MDCLinearProgressFoundation.strings.BUFFER_BAR_SELECTOR);
- if (bufferBar) {
- bufferBar.style.setProperty(styleProperty, value);
- }
- },
- setPrimaryBarStyle: function setPrimaryBarStyle(styleProperty, value) {
- var primaryBar = _this.root.querySelector(foundation_1.MDCLinearProgressFoundation.strings.PRIMARY_BAR_SELECTOR);
- if (primaryBar) {
- primaryBar.style.setProperty(styleProperty, value);
- }
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- removeAttribute: function removeAttribute(attributeName) {
- _this.root.removeAttribute(attributeName);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- setAttribute: function setAttribute(attributeName, value) {
- _this.root.setAttribute(attributeName, value);
- },
- setStyle: function setStyle(name, value) {
- _this.root.style.setProperty(name, value);
- },
- attachResizeObserver: function attachResizeObserver(callback) {
- if (window.ResizeObserver) {
- var ro = new ResizeObserver(callback);
- ro.observe(_this.root);
- return ro;
- }
- return null;
- },
- getWidth: function getWidth() {
- return _this.root.offsetWidth;
- }
- };
- 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',
- CLOSED_ANIMATION_OFF_CLASS: 'mdc-linear-progress--closed-animation-off',
- INDETERMINATE_CLASS: 'mdc-linear-progress--indeterminate',
- REVERSED_CLASS: 'mdc-linear-progress--reversed',
- ANIMATION_READY_CLASS: 'mdc-linear-progress--animation-ready'
- };
- exports.strings = {
- ARIA_VALUEMAX: 'aria-valuemax',
- ARIA_VALUEMIN: 'aria-valuemin',
- ARIA_VALUENOW: 'aria-valuenow',
- BUFFER_BAR_SELECTOR: '.mdc-linear-progress__buffer-bar',
- FLEX_BASIS: 'flex-basis',
- PRIMARY_BAR_SELECTOR: '.mdc-linear-progress__primary-bar'
- };
- // these are percentages pulled from keyframes.scss
- exports.animationDimensionPercentages = {
- PRIMARY_HALF: .8367142,
- PRIMARY_FULL: 2.00611057,
- SECONDARY_QUARTER: .37651913,
- SECONDARY_HALF: .84386165,
- SECONDARY_FULL: 1.60277782
- };
- /***/ }),
- /***/ "./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);
- };
- var __values = this && this.__values || function (o) {
- var s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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) {
- var _this = _super.call(this, __assign(__assign({}, MDCLinearProgressFoundation.defaultAdapter), adapter)) || this;
- _this.observer = null;
- return _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;
- },
- attachResizeObserver: function attachResizeObserver() {
- return null;
- },
- forceLayout: function forceLayout() {
- return undefined;
- },
- getWidth: function getWidth() {
- return 0;
- },
- hasClass: function hasClass() {
- return false;
- },
- setBufferBarStyle: function setBufferBarStyle() {
- return null;
- },
- setPrimaryBarStyle: function setPrimaryBarStyle() {
- return null;
- },
- setStyle: function setStyle() {
- return undefined;
- },
- removeAttribute: function removeAttribute() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- setAttribute: function setAttribute() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCLinearProgressFoundation.prototype.init = function () {
- var _this = this;
- this.isDeterminate = !this.adapter.hasClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.adapter.addClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
- this.isReversed = this.adapter.hasClass(constants_1.cssClasses.REVERSED_CLASS);
- this.progress = 0;
- this.buffer = 1;
- this.observer = this.adapter.attachResizeObserver(function (entries) {
- var e_1, _a;
- if (_this.isDeterminate) {
- return;
- }
- try {
- for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
- var entry = entries_1_1.value;
- if (entry.contentRect) {
- _this.calculateAndSetDimensions(entry.contentRect.width);
- }
- }
- } catch (e_1_1) {
- e_1 = { error: e_1_1 };
- } finally {
- try {
- if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
- } finally {
- if (e_1) throw e_1.error;
- }
- }
- });
- if (!this.isDeterminate && this.observer) {
- this.calculateAndSetDimensions(this.adapter.getWidth());
- }
- };
- MDCLinearProgressFoundation.prototype.setDeterminate = function (isDeterminate) {
- this.isDeterminate = isDeterminate;
- if (this.isDeterminate) {
- this.adapter.removeClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, this.progress.toString());
- this.adapter.setAttribute(constants_1.strings.ARIA_VALUEMAX, '1');
- this.adapter.setAttribute(constants_1.strings.ARIA_VALUEMIN, '0');
- this.setPrimaryBarProgress(this.progress);
- this.setBufferBarProgress(this.buffer);
- return;
- }
- if (this.isReversed) {
- // Adding/removing REVERSED_CLASS starts a translate animation, while
- // adding INDETERMINATE_CLASS starts a scale animation. Here, we reset
- // the translate animation in order to keep it in sync with the new
- // scale animation that will start from adding INDETERMINATE_CLASS
- // below.
- this.adapter.removeClass(constants_1.cssClasses.REVERSED_CLASS);
- this.adapter.forceLayout();
- this.adapter.addClass(constants_1.cssClasses.REVERSED_CLASS);
- }
- if (this.observer) {
- this.calculateAndSetDimensions(this.adapter.getWidth());
- }
- this.adapter.addClass(constants_1.cssClasses.INDETERMINATE_CLASS);
- this.adapter.removeAttribute(constants_1.strings.ARIA_VALUENOW);
- this.adapter.removeAttribute(constants_1.strings.ARIA_VALUEMAX);
- this.adapter.removeAttribute(constants_1.strings.ARIA_VALUEMIN);
- this.setPrimaryBarProgress(1);
- this.setBufferBarProgress(1);
- };
- MDCLinearProgressFoundation.prototype.getDeterminate = function () {
- return this.isDeterminate;
- };
- MDCLinearProgressFoundation.prototype.setProgress = function (value) {
- this.progress = value;
- if (this.isDeterminate) {
- this.setPrimaryBarProgress(value);
- this.adapter.setAttribute(constants_1.strings.ARIA_VALUENOW, value.toString());
- }
- };
- MDCLinearProgressFoundation.prototype.getProgress = function () {
- return this.progress;
- };
- MDCLinearProgressFoundation.prototype.setBuffer = function (value) {
- this.buffer = value;
- if (this.isDeterminate) {
- this.setBufferBarProgress(value);
- }
- };
- MDCLinearProgressFoundation.prototype.setReverse = function (isReversed) {
- this.isReversed = isReversed;
- if (!this.isDeterminate) {
- // Adding ANIMATION_READY_CLASS starts a scale animation, while
- // adding/removing REVERSED_CLASS starts a translate animation. Here, we
- // reset the scale animation in order to keep it in sync with the new
- // translate animation that will start from adding/removing REVERSED_CLASS
- // below.
- this.restartAnimation();
- }
- if (this.isReversed) {
- this.adapter.addClass(constants_1.cssClasses.REVERSED_CLASS);
- return;
- }
- this.adapter.removeClass(constants_1.cssClasses.REVERSED_CLASS);
- };
- MDCLinearProgressFoundation.prototype.open = function () {
- this.adapter.removeClass(constants_1.cssClasses.CLOSED_CLASS);
- this.adapter.removeClass(constants_1.cssClasses.CLOSED_ANIMATION_OFF_CLASS);
- };
- MDCLinearProgressFoundation.prototype.close = function () {
- this.adapter.addClass(constants_1.cssClasses.CLOSED_CLASS);
- };
- /**
- * Handles the transitionend event emitted after `close()` is called and the
- * opacity fades out. This is so that animations are removed only after the
- * progress indicator is completely hidden.
- */
- MDCLinearProgressFoundation.prototype.handleTransitionEnd = function () {
- if (this.adapter.hasClass(constants_1.cssClasses.CLOSED_CLASS)) {
- this.adapter.addClass(constants_1.cssClasses.CLOSED_ANIMATION_OFF_CLASS);
- }
- };
- MDCLinearProgressFoundation.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- if (this.observer) {
- this.observer.disconnect();
- }
- };
- MDCLinearProgressFoundation.prototype.setPrimaryBarProgress = function (progressValue) {
- var value = "scaleX(" + progressValue + ")";
- // Accessing `window` without a `typeof` check will throw on Node
- // environments.
- var transformProp = typeof window !== 'undefined' ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
- this.adapter.setPrimaryBarStyle(transformProp, value);
- };
- MDCLinearProgressFoundation.prototype.setBufferBarProgress = function (progressValue) {
- var value = progressValue * 100 + "%";
- this.adapter.setBufferBarStyle(constants_1.strings.FLEX_BASIS, value);
- };
- MDCLinearProgressFoundation.prototype.restartAnimation = function () {
- this.adapter.removeClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
- this.adapter.forceLayout();
- this.adapter.addClass(constants_1.cssClasses.ANIMATION_READY_CLASS);
- };
- MDCLinearProgressFoundation.prototype.calculateAndSetDimensions = function (width) {
- var primaryHalf = width * constants_1.animationDimensionPercentages.PRIMARY_HALF;
- var primaryFull = width * constants_1.animationDimensionPercentages.PRIMARY_FULL;
- var secondaryQuarter = width * constants_1.animationDimensionPercentages.SECONDARY_QUARTER;
- var secondaryHalf = width * constants_1.animationDimensionPercentages.SECONDARY_HALF;
- var secondaryFull = width * constants_1.animationDimensionPercentages.SECONDARY_FULL;
- this.adapter.setStyle('--mdc-linear-progress-primary-half', primaryHalf + "px");
- this.adapter.setStyle('--mdc-linear-progress-primary-half-neg', -primaryHalf + "px");
- this.adapter.setStyle('--mdc-linear-progress-primary-full', primaryFull + "px");
- this.adapter.setStyle('--mdc-linear-progress-primary-full-neg', -primaryFull + "px");
- this.adapter.setStyle('--mdc-linear-progress-secondary-quarter', secondaryQuarter + "px");
- this.adapter.setStyle('--mdc-linear-progress-secondary-quarter-neg', -secondaryQuarter + "px");
- this.adapter.setStyle('--mdc-linear-progress-secondary-half', secondaryHalf + "px");
- this.adapter.setStyle('--mdc-linear-progress-secondary-half-neg', -secondaryHalf + "px");
- this.adapter.setStyle('--mdc-linear-progress-secondary-full', secondaryFull + "px");
- this.adapter.setStyle('--mdc-linear-progress-secondary-full-neg', -secondaryFull + "px");
- // need to restart animation for custom props to apply to keyframes
- this.restartAnimation();
- };
- 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 Array.from(this.root.querySelectorAll("." + this.classNameMap[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, "typeaheadInProgress", {
- /**
- * @return Whether typeahead is currently matching a user-specified prefix.
- */
- get: function get() {
- return this.foundation.isTypeaheadInProgress();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCList.prototype, "hasTypeahead", {
- /**
- * Sets whether typeahead functionality is enabled on the list.
- * @param hasTypeahead Whether typeahead is enabled.
- */
- set: function set(hasTypeahead) {
- this.foundation.setHasTypeahead(hasTypeahead);
- },
- enumerable: 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.isEvolutionEnabled = constants_1.evolutionAttribute in this.root.dataset;
- this.classNameMap = this.isEvolutionEnabled ? constants_1.evolutionClassNameMap : Object.values(constants_1.cssClasses).reduce(function (obj, className) {
- obj[className] = className;
- return obj;
- }, {});
- this.handleClick = this.handleClickEvent.bind(this);
- this.handleKeydown = this.handleKeydownEvent.bind(this);
- this.focusInEventListener = this.handleFocusInEvent.bind(this);
- this.focusOutEventListener = this.handleFocusOutEvent.bind(this);
- this.listen('keydown', this.handleKeydown);
- this.listen('click', this.handleClick);
- this.listen('focusin', this.focusInEventListener);
- this.listen('focusout', this.focusOutEventListener);
- this.layout();
- this.initializeListType();
- this.ensureFocusable();
- };
- MDCList.prototype.destroy = function () {
- this.unlisten('keydown', this.handleKeydown);
- this.unlisten('click', this.handleClick);
- this.unlisten('focusin', this.focusInEventListener);
- this.unlisten('focusout', this.focusOutEventListener);
- };
- MDCList.prototype.layout = function () {
- var direction = this.root.getAttribute(constants_1.strings.ARIA_ORIENTATION);
- this.vertical = direction !== constants_1.strings.ARIA_ORIENTATION_HORIZONTAL;
- var itemSelector = "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not([tabindex])";
- var childSelector = "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + " " + constants_1.strings.FOCUSABLE_CHILD_ELEMENTS;
- // List items need to have at least tabindex=-1 to be focusable.
- Array.prototype.forEach.call(this.root.querySelectorAll(itemSelector), function (el) {
- el.setAttribute('tabindex', '-1');
- });
- // Child button/a elements are not tabbable until the list item is focused.
- Array.prototype.forEach.call(this.root.querySelectorAll(childSelector), function (el) {
- el.setAttribute('tabindex', '-1');
- });
- if (this.isEvolutionEnabled) {
- this.foundation.setUseSelectedAttribute(true);
- }
- this.foundation.layout();
- };
- /**
- * Extracts the primary text from a list item.
- * @param item The list item element.
- * @return The primary text in the element.
- */
- MDCList.prototype.getPrimaryText = function (item) {
- var _a;
- var primaryText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS]);
- if (this.isEvolutionEnabled || primaryText) {
- return (_a = primaryText === null || primaryText === void 0 ? void 0 : primaryText.textContent) !== null && _a !== void 0 ? _a : '';
- }
- var singleLineText = item.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_TEXT_CLASS]);
- return singleLineText && singleLineText.textContent || '';
- };
- /**
- * Initialize selectedIndex value based on pre-selected list items.
- */
- MDCList.prototype.initializeListType = function () {
- var _this = this;
- this.isInteractive = ponyfill_1.matches(this.root, constants_1.strings.ARIA_INTERACTIVE_ROLES_SELECTOR);
- if (this.isEvolutionEnabled && this.isInteractive) {
- var selection = Array.from(this.root.querySelectorAll(constants_1.strings.SELECTED_ITEM_SELECTOR), function (listItem) {
- return _this.listElements.indexOf(listItem);
- });
- if (ponyfill_1.matches(this.root, constants_1.strings.ARIA_MULTI_SELECTABLE_SELECTOR)) {
- this.selectedIndex = selection;
- } else if (selection.length > 0) {
- this.selectedIndex = selection[0];
- }
- return;
- }
- var checkboxListItems = this.root.querySelectorAll(constants_1.strings.ARIA_ROLE_CHECKBOX_SELECTOR);
- var radioSelectedListItem = this.root.querySelector(constants_1.strings.ARIA_CHECKED_RADIO_SELECTOR);
- if (checkboxListItems.length) {
- var preselectedItems = this.root.querySelectorAll(constants_1.strings.ARIA_CHECKED_CHECKBOX_SELECTOR);
- this.selectedIndex = Array.from(preselectedItems, function (listItem) {
- return _this.listElements.indexOf(listItem);
- });
- } else if (radioSelectedListItem) {
- this.selectedIndex = this.listElements.indexOf(radioSelectedListItem);
- }
- };
- /**
- * Updates the list item at itemIndex to the desired isEnabled state.
- * @param itemIndex Index of the list item
- * @param isEnabled Sets the list item to enabled or disabled.
- */
- MDCList.prototype.setEnabled = function (itemIndex, isEnabled) {
- this.foundation.setEnabled(itemIndex, isEnabled);
- };
- /**
- * Given the next desired character from the user, adds it to the typeahead
- * buffer. Then, attempts to find the next option matching the buffer. Wraps
- * around if at the end of options.
- *
- * @param nextChar The next character to add to the prefix buffer.
- * @param startingIndex The index from which to start matching. Defaults to
- * the currently focused index.
- * @return The index of the matched item.
- */
- MDCList.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
- return this.foundation.typeaheadMatchItem(nextChar, startingIndex, /** skipFocus */true);
- };
- MDCList.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take
- // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any
- // methods, we need a separate, strongly typed adapter variable.
- var adapter = {
- addClassForElementIndex: function addClassForElementIndex(index, className) {
- var element = _this.listElements[index];
- if (element) {
- element.classList.add(_this.classNameMap[className]);
- }
- },
- focusItemAtIndex: function focusItemAtIndex(index) {
- var 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;
- },
- getPrimaryTextAtIndex: function getPrimaryTextAtIndex(index) {
- return _this.getPrimaryText(_this.listElements[index]);
- },
- hasCheckboxAtIndex: function hasCheckboxAtIndex(index) {
- var listItem = _this.listElements[index];
- return !!listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
- },
- hasRadioAtIndex: function hasRadioAtIndex(index) {
- var listItem = _this.listElements[index];
- return !!listItem.querySelector(constants_1.strings.RADIO_SELECTOR);
- },
- isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex(index) {
- var listItem = _this.listElements[index];
- var toggleEl = listItem.querySelector(constants_1.strings.CHECKBOX_SELECTOR);
- return toggleEl.checked;
- },
- isFocusInsideList: function isFocusInsideList() {
- return _this.root !== document.activeElement && _this.root.contains(document.activeElement);
- },
- isRootFocused: function isRootFocused() {
- return document.activeElement === _this.root;
- },
- listItemAtIndexHasClass: function listItemAtIndexHasClass(index, className) {
- return _this.listElements[index].classList.contains(_this.classNameMap[className]);
- },
- notifyAction: function notifyAction(index) {
- _this.emit(constants_1.strings.ACTION_EVENT, { index: index }, /** shouldBubble */true);
- },
- removeClassForElementIndex: function removeClassForElementIndex(index, className) {
- var element = _this.listElements[index];
- if (element) {
- element.classList.remove(_this.classNameMap[className]);
- }
- },
- setAttributeForElementIndex: function setAttributeForElementIndex(index, attr, value) {
- var element = _this.listElements[index];
- if (element) {
- 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 selector = "." + _this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + " " + constants_1.strings.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX;
- Array.prototype.forEach.call(element.querySelectorAll(selector), function (el) {
- el.setAttribute('tabindex', tabIndexValue);
- });
- }
- };
- return new foundation_1.MDCListFoundation(adapter);
- };
- /**
- * Ensures that at least one item is focusable if the list is interactive and
- * doesn't specify a suitable tabindex.
- */
- MDCList.prototype.ensureFocusable = function () {
- if (this.isEvolutionEnabled && this.isInteractive) {
- if (!this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + "[tabindex=\"0\"]")) {
- var index = this.initialFocusIndex();
- if (index !== -1) {
- this.listElements[index].tabIndex = 0;
- }
- }
- }
- };
- MDCList.prototype.initialFocusIndex = function () {
- if (this.selectedIndex instanceof Array && this.selectedIndex.length > 0) {
- return this.selectedIndex[0];
- }
- if (typeof this.selectedIndex === 'number' && this.selectedIndex !== constants_1.numbers.UNSET_INDEX) {
- return this.selectedIndex;
- }
- var el = this.root.querySelector("." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ":not(." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS] + ")");
- if (el === null) {
- return -1;
- }
- return this.getListItemIndex(el);
- };
- /**
- * Used to figure out which list item this event is targetting. Or returns -1
- * if there is no list item
- */
- MDCList.prototype.getListItemIndex = function (el) {
- var nearestParent = ponyfill_1.closest(el, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS] + ", ." + this.classNameMap[constants_1.cssClasses.ROOT]);
- // Get the index of the element if it is a list item.
- if (nearestParent && ponyfill_1.matches(nearestParent, "." + this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS])) {
- return this.listElements.indexOf(nearestParent);
- }
- return -1;
- };
- /**
- * Used to figure out which element was clicked before sending the event to
- * the foundation.
- */
- MDCList.prototype.handleFocusInEvent = function (evt) {
- var index = this.getListItemIndex(evt.target);
- this.foundation.handleFocusIn(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.target);
- 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.target);
- var target = evt.target;
- this.foundation.handleKeydown(evt, target.classList.contains(this.classNameMap[constants_1.cssClasses.LIST_ITEM_CLASS]), index);
- };
- /**
- * Used to figure out which element was clicked before sending the event to
- * the foundation.
- */
- MDCList.prototype.handleClickEvent = function (evt) {
- var index = this.getListItemIndex(evt.target);
- var target = evt.target;
- // 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.
- */
- var _a;
- 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',
- LIST_ITEM_TEXT_CLASS: 'mdc-list-item__text',
- LIST_ITEM_PRIMARY_TEXT_CLASS: 'mdc-list-item__primary-text',
- ROOT: 'mdc-list'
- };
- exports.cssClasses = cssClasses;
- var 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',
- ARIA_INTERACTIVE_ROLES_SELECTOR: '[role="listbox"], [role="menu"]',
- ARIA_MULTI_SELECTABLE_SELECTOR: '[aria-multiselectable="true"]',
- CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"], input[type="radio"]',
- CHECKBOX_SELECTOR: 'input[type="checkbox"]',
- CHILD_ELEMENTS_TO_TOGGLE_TABINDEX: 'button:not(:disabled), a',
- FOCUSABLE_CHILD_ELEMENTS: 'button:not(:disabled), a, input[type="radio"]:not(:disabled), input[type="checkbox"]:not(:disabled)',
- RADIO_SELECTOR: 'input[type="radio"]',
- SELECTED_ITEM_SELECTOR: '[aria-selected="true"], [aria-current="true"]'
- };
- exports.strings = strings;
- var numbers = {
- UNSET_INDEX: -1,
- TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS: 300
- };
- exports.numbers = numbers;
- var evolutionClassNameMap = (_a = {}, _a["" + cssClasses.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-evolution-list-item--activated', _a["" + cssClasses.LIST_ITEM_CLASS] = 'mdc-evolution-list-item', _a["" + cssClasses.LIST_ITEM_DISABLED_CLASS] = 'mdc-evolution-list-item--disabled', _a["" + cssClasses.LIST_ITEM_SELECTED_CLASS] = 'mdc-evolution-list-item--selected', _a["" + cssClasses.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-evolution-list-item__primary-text', _a["" + cssClasses.ROOT] = 'mdc-evolution-list', _a);
- exports.evolutionClassNameMap = evolutionClassNameMap;
- var evolutionAttribute = 'evolution';
- exports.evolutionAttribute = evolutionAttribute;
- /***/ }),
- /***/ "./packages/mdc-list/events.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-list/events.ts ***!
- \*************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select'];
- /**
- * Ensures that preventDefault is only called if the containing element
- * doesn't consume the event, and it will cause an unintended scroll.
- *
- * @param evt keyboard event to be prevented.
- */
- exports.preventDefaultEvent = function (evt) {
- var target = evt.target;
- if (!target) {
- return;
- }
- var tagName = ("" + target.tagName).toLowerCase();
- if (ELEMENTS_KEY_ALLOWED_IN.indexOf(tagName) === -1) {
- evt.preventDefault();
- }
- };
- /***/ }),
- /***/ "./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);
- };
- 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 });
- // TODO(b/152410470): Remove trailing underscores from private properties
- // tslint:disable:strip-private-property-underscore
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
- var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
- var typeahead = __importStar(__webpack_require__(/*! ./typeahead */ "./packages/mdc-list/typeahead.ts"));
- function isNumberArray(selectedIndex) {
- return selectedIndex instanceof Array;
- }
- var MDCListFoundation = /** @class */function (_super) {
- __extends(MDCListFoundation, _super);
- function MDCListFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCListFoundation.defaultAdapter), adapter)) || this;
- _this.wrapFocus_ = false;
- _this.isVertical_ = true;
- _this.isSingleSelectionList_ = false;
- _this.selectedIndex_ = constants_1.numbers.UNSET_INDEX;
- _this.focusedItemIndex = constants_1.numbers.UNSET_INDEX;
- _this.useActivatedClass_ = false;
- _this.useSelectedAttr_ = false;
- _this.ariaCurrentAttrValue_ = null;
- _this.isCheckboxList_ = false;
- _this.isRadioList_ = false;
- _this.hasTypeahead = false;
- // Transiently holds current typeahead prefix from user.
- _this.typeaheadState = typeahead.initState();
- _this.sortedIndexByFirstChar = new Map();
- return _this;
- }
- Object.defineProperty(MDCListFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCListFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCListFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCListFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClassForElementIndex: function addClassForElementIndex() {
- return undefined;
- },
- focusItemAtIndex: function focusItemAtIndex() {
- return undefined;
- },
- getAttributeForElementIndex: function getAttributeForElementIndex() {
- return null;
- },
- getFocusedElementIndex: function getFocusedElementIndex() {
- return 0;
- },
- getListItemCount: function getListItemCount() {
- return 0;
- },
- hasCheckboxAtIndex: function hasCheckboxAtIndex() {
- return false;
- },
- hasRadioAtIndex: function hasRadioAtIndex() {
- return false;
- },
- isCheckboxCheckedAtIndex: function isCheckboxCheckedAtIndex() {
- return false;
- },
- isFocusInsideList: function isFocusInsideList() {
- return false;
- },
- isRootFocused: function isRootFocused() {
- return false;
- },
- listItemAtIndexHasClass: function listItemAtIndexHasClass() {
- return false;
- },
- notifyAction: function notifyAction() {
- return undefined;
- },
- removeClassForElementIndex: function removeClassForElementIndex() {
- return undefined;
- },
- setAttributeForElementIndex: function setAttributeForElementIndex() {
- return undefined;
- },
- setCheckedCheckboxOrRadioAtIndex: function setCheckedCheckboxOrRadioAtIndex() {
- return undefined;
- },
- setTabIndexForListItemChildren: function setTabIndexForListItemChildren() {
- return undefined;
- },
- getPrimaryTextAtIndex: function getPrimaryTextAtIndex() {
- return '';
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCListFoundation.prototype.layout = function () {
- if (this.adapter.getListItemCount() === 0) {
- return;
- }
- // TODO(b/172274142): consider all items when determining the list's type.
- if (this.adapter.hasCheckboxAtIndex(0)) {
- this.isCheckboxList_ = true;
- } else if (this.adapter.hasRadioAtIndex(0)) {
- this.isRadioList_ = true;
- } else {
- this.maybeInitializeSingleSelection();
- }
- if (this.hasTypeahead) {
- this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
- }
- };
- /**
- * 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;
- if (value) {
- this.maybeInitializeSingleSelection();
- }
- };
- /**
- * Automatically determines whether the list is single selection list. If so,
- * initializes the internal state to match the selected item.
- */
- MDCListFoundation.prototype.maybeInitializeSingleSelection = function () {
- var listItemsCount = this.adapter.getListItemCount();
- for (var i = 0; i < listItemsCount; i++) {
- var hasSelectedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_SELECTED_CLASS);
- var hasActivatedClass = this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_ACTIVATED_CLASS);
- if (!(hasSelectedClass || hasActivatedClass)) {
- continue;
- }
- if (hasActivatedClass) {
- this.setUseActivatedClass(true);
- }
- this.isSingleSelectionList_ = true;
- this.selectedIndex_ = i;
- return;
- }
- };
- /**
- * Sets whether typeahead is enabled on the list.
- * @param hasTypeahead Whether typeahead is enabled.
- */
- MDCListFoundation.prototype.setHasTypeahead = function (hasTypeahead) {
- this.hasTypeahead = hasTypeahead;
- if (hasTypeahead) {
- this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex();
- }
- };
- /**
- * @return Whether typeahead is currently matching a user-specified prefix.
- */
- MDCListFoundation.prototype.isTypeaheadInProgress = function () {
- return this.hasTypeahead && typeahead.isTypingInProgress(this.typeaheadState);
- };
- /**
- * Sets the useActivatedClass_ private variable.
- */
- MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) {
- this.useActivatedClass_ = useActivated;
- };
- /**
- * Sets the useSelectedAttr_ private variable.
- */
- MDCListFoundation.prototype.setUseSelectedAttribute = function (useSelected) {
- this.useSelectedAttr_ = useSelected;
- };
- 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.focusedItemIndex = listItemIndex;
- this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '0');
- this.adapter.setTabIndexForListItemChildren(listItemIndex, '0');
- }
- };
- /**
- * Focus out handler for the list items.
- */
- MDCListFoundation.prototype.handleFocusOut = function (_, listItemIndex) {
- var _this = this;
- if (listItemIndex >= 0) {
- this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '-1');
- this.adapter.setTabIndexForListItemChildren(listItemIndex, '-1');
- }
- /**
- * Between Focusout & Focusin some browsers do not have focus on any
- * element. Setting a delay to wait till the focus is moved to next element.
- */
- setTimeout(function () {
- if (!_this.adapter.isFocusInsideList()) {
- _this.setTabindexToFirstSelectedOrFocusedItem();
- }
- }, 0);
- };
- /**
- * Key handler for the list.
- */
- MDCListFoundation.prototype.handleKeydown = function (event, isRootListItem, listItemIndex) {
- var _this = this;
- var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
- var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
- var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
- var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
- var isHome = keyboard_1.normalizeKey(event) === 'Home';
- var isEnd = keyboard_1.normalizeKey(event) === 'End';
- var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
- var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
- // Have to check both upper and lower case, because having caps lock on affects the value.
- var isLetterA = event.key === 'A' || event.key === 'a';
- if (this.adapter.isRootFocused()) {
- if (isArrowUp || isEnd) {
- event.preventDefault();
- this.focusLastElement();
- } else if (isArrowDown || isHome) {
- event.preventDefault();
- this.focusFirstElement();
- }
- if (this.hasTypeahead) {
- var handleKeydownOpts = {
- event: event,
- focusItemAtIndex: function focusItemAtIndex(index) {
- _this.focusItemAtIndex(index);
- },
- focusedItemIndex: -1,
- isTargetListItem: isRootListItem,
- sortedIndexByFirstChar: this.sortedIndexByFirstChar,
- isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
- return _this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
- }
- };
- typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
- }
- return;
- }
- var currentIndex = this.adapter.getFocusedElementIndex();
- if (currentIndex === -1) {
- currentIndex = listItemIndex;
- if (currentIndex < 0) {
- // If this event doesn't have a mdc-list-item ancestor from the
- // current list (not from a sublist), return early.
- return;
- }
- }
- if (this.isVertical_ && isArrowDown || !this.isVertical_ && isArrowRight) {
- events_1.preventDefaultEvent(event);
- this.focusNextElement(currentIndex);
- } else if (this.isVertical_ && isArrowUp || !this.isVertical_ && isArrowLeft) {
- events_1.preventDefaultEvent(event);
- this.focusPrevElement(currentIndex);
- } else if (isHome) {
- events_1.preventDefaultEvent(event);
- this.focusFirstElement();
- } else if (isEnd) {
- events_1.preventDefaultEvent(event);
- this.focusLastElement();
- } else if (isLetterA && event.ctrlKey && this.isCheckboxList_) {
- event.preventDefault();
- this.toggleAll(this.selectedIndex_ === constants_1.numbers.UNSET_INDEX ? [] : this.selectedIndex_);
- } else if (isEnter || isSpace) {
- if (isRootListItem) {
- // Return early if enter key is pressed on anchor element which triggers
- // synthetic MouseEvent event.
- var target = event.target;
- if (target && target.tagName === 'A' && isEnter) {
- return;
- }
- events_1.preventDefaultEvent(event);
- if (this.adapter.listItemAtIndexHasClass(currentIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS)) {
- return;
- }
- if (!this.isTypeaheadInProgress()) {
- if (this.isSelectableList_()) {
- this.setSelectedIndexOnAction_(currentIndex);
- }
- this.adapter.notifyAction(currentIndex);
- }
- }
- }
- if (this.hasTypeahead) {
- var handleKeydownOpts = {
- event: event,
- focusItemAtIndex: function focusItemAtIndex(index) {
- _this.focusItemAtIndex(index);
- },
- focusedItemIndex: this.focusedItemIndex,
- isTargetListItem: isRootListItem,
- sortedIndexByFirstChar: this.sortedIndexByFirstChar,
- isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
- return _this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
- }
- };
- typeahead.handleKeydown(handleKeydownOpts, this.typeaheadState);
- }
- };
- /**
- * Click handler for the list.
- */
- MDCListFoundation.prototype.handleClick = function (index, toggleCheckbox) {
- if (index === constants_1.numbers.UNSET_INDEX) {
- return;
- }
- if (this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS)) {
- return;
- }
- if (this.isSelectableList_()) {
- this.setSelectedIndexOnAction_(index, toggleCheckbox);
- }
- this.adapter.notifyAction(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.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.focusItemAtIndex(prevIndex);
- return prevIndex;
- };
- MDCListFoundation.prototype.focusFirstElement = function () {
- this.focusItemAtIndex(0);
- return 0;
- };
- MDCListFoundation.prototype.focusLastElement = function () {
- var lastIndex = this.adapter.getListItemCount() - 1;
- this.focusItemAtIndex(lastIndex);
- return lastIndex;
- };
- MDCListFoundation.prototype.focusInitialElement = function () {
- var initialIndex = this.getFirstSelectedOrFocusedItemIndex();
- this.focusItemAtIndex(initialIndex);
- return initialIndex;
- };
- /**
- * @param itemIndex Index of the list item
- * @param isEnabled Sets the list item to enabled or disabled.
- */
- MDCListFoundation.prototype.setEnabled = function (itemIndex, isEnabled) {
- if (!this.isIndexValid_(itemIndex)) {
- return;
- }
- if (isEnabled) {
- this.adapter.removeClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
- this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'false');
- } else {
- this.adapter.addClassForElementIndex(itemIndex, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
- this.adapter.setAttributeForElementIndex(itemIndex, constants_1.strings.ARIA_DISABLED, 'true');
- }
- };
- MDCListFoundation.prototype.setSingleSelectionAtIndex_ = function (index) {
- 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.setAriaForSingleSelectionAtIndex_(index);
- this.setTabindexAtIndex(index);
- if (index !== constants_1.numbers.UNSET_INDEX) {
- this.adapter.addClassForElementIndex(index, selectedClassName);
- }
- 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');
- }
- if (index !== constants_1.numbers.UNSET_INDEX) {
- var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue_ : 'true';
- this.adapter.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue);
- }
- };
- /**
- * Returns the attribute to use for indicating selection status.
- */
- MDCListFoundation.prototype.getSelectionAttribute = function () {
- return this.useSelectedAttr_ ? constants_1.strings.ARIA_SELECTED : constants_1.strings.ARIA_CHECKED;
- };
- /**
- * Toggles radio at give index. Radio doesn't change the checked state if it
- * is already checked.
- */
- MDCListFoundation.prototype.setRadioAtIndex_ = function (index) {
- var selectionAttribute = this.getSelectionAttribute();
- this.adapter.setCheckedCheckboxOrRadioAtIndex(index, true);
- if (this.selectedIndex_ !== constants_1.numbers.UNSET_INDEX) {
- this.adapter.setAttributeForElementIndex(this.selectedIndex_, selectionAttribute, 'false');
- }
- this.adapter.setAttributeForElementIndex(index, selectionAttribute, 'true');
- this.selectedIndex_ = index;
- };
- MDCListFoundation.prototype.setCheckboxAtIndex_ = function (index) {
- var selectionAttribute = this.getSelectionAttribute();
- 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, selectionAttribute, isChecked ? 'true' : 'false');
- }
- this.selectedIndex_ = index;
- };
- MDCListFoundation.prototype.setTabindexAtIndex = function (index) {
- if (this.focusedItemIndex === constants_1.numbers.UNSET_INDEX && index !== 0) {
- // If some list item was selected set first list item's tabindex to -1.
- // Generally, tabindex is set to 0 on first list item of list that has no
- // preselected items.
- this.adapter.setAttributeForElementIndex(0, 'tabindex', '-1');
- } else if (this.focusedItemIndex >= 0 && this.focusedItemIndex !== index) {
- this.adapter.setAttributeForElementIndex(this.focusedItemIndex, 'tabindex', '-1');
- }
- // Set the previous selection's tabindex to -1. We need this because
- // in selection menus that are not visible, programmatically setting an
- // option will not change focus but will change where tabindex should be 0.
- if (!(this.selectedIndex_ instanceof Array) && this.selectedIndex_ !== index) {
- this.adapter.setAttributeForElementIndex(this.selectedIndex_, 'tabindex', '-1');
- }
- if (index !== constants_1.numbers.UNSET_INDEX) {
- this.adapter.setAttributeForElementIndex(index, 'tabindex', '0');
- }
- };
- /**
- * @return Return true if it is single selectin list, checkbox list or radio
- * list.
- */
- MDCListFoundation.prototype.isSelectableList_ = function () {
- return this.isSingleSelectionList_ || this.isCheckboxList_ || this.isRadioList_;
- };
- MDCListFoundation.prototype.setTabindexToFirstSelectedOrFocusedItem = function () {
- var targetIndex = this.getFirstSelectedOrFocusedItemIndex();
- this.setTabindexAtIndex(targetIndex);
- };
- MDCListFoundation.prototype.getFirstSelectedOrFocusedItemIndex = function () {
- var targetIndex = this.focusedItemIndex >= 0 ? this.focusedItemIndex : 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);
- });
- }
- }
- return 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) || this.isSingleSelectionList_ && index === constants_1.numbers.UNSET_INDEX;
- } else {
- return false;
- }
- };
- MDCListFoundation.prototype.isIndexInRange_ = function (index) {
- var listSize = this.adapter.getListItemCount();
- return index >= 0 && index < listSize;
- };
- /**
- * Sets selected index on user action, toggles checkbox / radio based on
- * toggleCheckbox value. User interaction should not toggle list item(s) when
- * disabled.
- */
- MDCListFoundation.prototype.setSelectedIndexOnAction_ = function (index, toggleCheckbox) {
- if (toggleCheckbox === void 0) {
- toggleCheckbox = true;
- }
- if (this.isCheckboxList_) {
- this.toggleCheckboxAtIndex_(index, toggleCheckbox);
- } else {
- this.setSelectedIndex(index);
- }
- };
- MDCListFoundation.prototype.toggleCheckboxAtIndex_ = function (index, toggleCheckbox) {
- var selectionAttribute = this.getSelectionAttribute();
- var isChecked = this.adapter.isCheckboxCheckedAtIndex(index);
- if (toggleCheckbox) {
- isChecked = !isChecked;
- this.adapter.setCheckedCheckboxOrRadioAtIndex(index, isChecked);
- }
- this.adapter.setAttributeForElementIndex(index, selectionAttribute, 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;
- };
- MDCListFoundation.prototype.focusItemAtIndex = function (index) {
- this.adapter.focusItemAtIndex(index);
- this.focusedItemIndex = index;
- };
- MDCListFoundation.prototype.toggleAll = function (currentlySelectedIndexes) {
- var count = this.adapter.getListItemCount();
- // If all items are selected, deselect everything.
- if (currentlySelectedIndexes.length === count) {
- this.setCheckboxAtIndex_([]);
- } else {
- // Otherwise select all enabled options.
- var allIndexes = [];
- for (var i = 0; i < count; i++) {
- if (!this.adapter.listItemAtIndexHasClass(i, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS) || currentlySelectedIndexes.indexOf(i) > -1) {
- allIndexes.push(i);
- }
- }
- this.setCheckboxAtIndex_(allIndexes);
- }
- };
- /**
- * Given the next desired character from the user, adds it to the typeahead
- * buffer. Then, attempts to find the next option matching the buffer. Wraps
- * around if at the end of options.
- *
- * @param nextChar The next character to add to the prefix buffer.
- * @param startingIndex The index from which to start matching. Only relevant
- * when starting a new match sequence. To start a new match sequence,
- * clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
- * to clear after a set interval defined in list foundation. Defaults to
- * the currently focused index.
- * @return The index of the matched item, or -1 if no match.
- */
- MDCListFoundation.prototype.typeaheadMatchItem = function (nextChar, startingIndex, skipFocus) {
- var _this = this;
- if (skipFocus === void 0) {
- skipFocus = false;
- }
- var opts = {
- focusItemAtIndex: function focusItemAtIndex(index) {
- _this.focusItemAtIndex(index);
- },
- focusedItemIndex: startingIndex ? startingIndex : this.focusedItemIndex,
- nextChar: nextChar,
- sortedIndexByFirstChar: this.sortedIndexByFirstChar,
- skipFocus: skipFocus,
- isItemAtIndexDisabled: function isItemAtIndexDisabled(index) {
- return _this.adapter.listItemAtIndexHasClass(index, constants_1.cssClasses.LIST_ITEM_DISABLED_CLASS);
- }
- };
- return typeahead.matchItem(opts, this.typeaheadState);
- };
- /**
- * Initializes the MDCListTextAndIndex data structure by indexing the current
- * list items by primary text.
- *
- * @return The primary texts of all the list items sorted by first character.
- */
- MDCListFoundation.prototype.typeaheadInitSortedIndex = function () {
- return typeahead.initSortedIndex(this.adapter.getListItemCount(), this.adapter.getPrimaryTextAtIndex);
- };
- /**
- * Clears the typeahead buffer.
- */
- MDCListFoundation.prototype.clearTypeaheadBuffer = function () {
- typeahead.clearBuffer(this.typeaheadState);
- };
- return MDCListFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCListFoundation = MDCListFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCListFoundation;
- /***/ }),
- /***/ "./packages/mdc-list/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-list/typeahead.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-list/typeahead.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-list/constants.ts");
- var events_1 = __webpack_require__(/*! ./events */ "./packages/mdc-list/events.ts");
- /**
- * Initializes a state object for typeahead. Use the same reference for calls to
- * typeahead functions.
- *
- * @return The current state of the typeahead process. Each state reference
- * represents a typeahead instance as the reference is typically mutated
- * in-place.
- */
- function initState() {
- var state = {
- bufferClearTimeout: 0,
- currentFirstChar: '',
- sortedIndexCursor: 0,
- typeaheadBuffer: ''
- };
- return state;
- }
- exports.initState = initState;
- /**
- * Initializes typeahead state by indexing the current list items by primary
- * text into the sortedIndexByFirstChar data structure.
- *
- * @param listItemCount numer of items in the list
- * @param getPrimaryTextByItemIndex function that returns the primary text at a
- * given index
- *
- * @return Map that maps the first character of the primary text to the full
- * list text and it's index
- */
- function initSortedIndex(listItemCount, getPrimaryTextByItemIndex) {
- var sortedIndexByFirstChar = new Map();
- // Aggregate item text to index mapping
- for (var i = 0; i < listItemCount; i++) {
- var primaryText = getPrimaryTextByItemIndex(i).trim();
- if (!primaryText) {
- continue;
- }
- var firstChar = primaryText[0].toLowerCase();
- if (!sortedIndexByFirstChar.has(firstChar)) {
- sortedIndexByFirstChar.set(firstChar, []);
- }
- sortedIndexByFirstChar.get(firstChar).push({ text: primaryText.toLowerCase(), index: i });
- }
- // Sort the mapping
- // TODO(b/157162694): Investigate replacing forEach with Map.values()
- sortedIndexByFirstChar.forEach(function (values) {
- values.sort(function (first, second) {
- return first.index - second.index;
- });
- });
- return sortedIndexByFirstChar;
- }
- exports.initSortedIndex = initSortedIndex;
- /**
- * Given the next desired character from the user, it attempts to find the next
- * list option matching the buffer. Wraps around if at the end of options.
- *
- * @param opts Options and accessors
- * - nextChar - the next character to match against items
- * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
- * - focusedItemIndex - the index of the currently focused item
- * - focusItemAtIndex - function that focuses a list item at given index
- * - skipFocus - whether or not to focus the matched item
- * - isItemAtIndexDisabled - function that determines whether an item at a
- * given index is disabled
- * @param state The typeahead state instance. See `initState`.
- *
- * @return The index of the matched item, or -1 if no match.
- */
- function matchItem(opts, state) {
- var nextChar = opts.nextChar,
- focusItemAtIndex = opts.focusItemAtIndex,
- sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
- focusedItemIndex = opts.focusedItemIndex,
- skipFocus = opts.skipFocus,
- isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
- clearTimeout(state.bufferClearTimeout);
- state.bufferClearTimeout = setTimeout(function () {
- clearBuffer(state);
- }, constants_1.numbers.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS);
- state.typeaheadBuffer = state.typeaheadBuffer + nextChar;
- var index;
- if (state.typeaheadBuffer.length === 1) {
- index = matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state);
- } else {
- index = matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state);
- }
- if (index !== -1 && !skipFocus) {
- focusItemAtIndex(index);
- }
- return index;
- }
- exports.matchItem = matchItem;
- /**
- * Matches the user's single input character in the buffer to the
- * next option that begins with such character. Wraps around if at
- * end of options. Returns -1 if no match is found.
- */
- function matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state) {
- var firstChar = state.typeaheadBuffer[0];
- var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
- if (!itemsMatchingFirstChar) {
- return -1;
- }
- // Has the same firstChar been recently matched?
- // Also, did starting index remain the same between key presses?
- // If both hold true, simply increment index.
- if (firstChar === state.currentFirstChar && itemsMatchingFirstChar[state.sortedIndexCursor].index === focusedItemIndex) {
- state.sortedIndexCursor = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
- var newIndex = itemsMatchingFirstChar[state.sortedIndexCursor].index;
- if (!isItemAtIndexDisabled(newIndex)) {
- return newIndex;
- }
- }
- // If we're here, it means one of the following happened:
- // - either firstChar or startingIndex has changed, invalidating the
- // cursor.
- // - The next item of typeahead is disabled, so we have to look further.
- state.currentFirstChar = firstChar;
- var newCursorPosition = -1;
- var cursorPosition;
- // Find the first non-disabled item as a fallback.
- for (cursorPosition = 0; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
- if (!isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
- newCursorPosition = cursorPosition;
- break;
- }
- }
- // Advance cursor to first item matching the firstChar that is positioned
- // after starting item. Cursor is unchanged from fallback if there's no
- // such item.
- for (; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) {
- if (itemsMatchingFirstChar[cursorPosition].index > focusedItemIndex && !isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) {
- newCursorPosition = cursorPosition;
- break;
- }
- }
- if (newCursorPosition !== -1) {
- state.sortedIndexCursor = newCursorPosition;
- return itemsMatchingFirstChar[state.sortedIndexCursor].index;
- }
- return -1;
- }
- /**
- * Attempts to find the next item that matches all of the typeahead buffer.
- * Wraps around if at end of options. Returns -1 if no match is found.
- */
- function matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state) {
- var firstChar = state.typeaheadBuffer[0];
- var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar);
- if (!itemsMatchingFirstChar) {
- return -1;
- }
- // Do nothing if text already matches
- var startingItem = itemsMatchingFirstChar[state.sortedIndexCursor];
- if (startingItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0 && !isItemAtIndexDisabled(startingItem.index)) {
- return startingItem.index;
- }
- // Find next item that matches completely; if no match, we'll eventually
- // loop around to same position
- var cursorPosition = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length;
- var nextCursorPosition = -1;
- while (cursorPosition !== state.sortedIndexCursor) {
- var currentItem = itemsMatchingFirstChar[cursorPosition];
- var matches = currentItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0;
- var isEnabled = !isItemAtIndexDisabled(currentItem.index);
- if (matches && isEnabled) {
- nextCursorPosition = cursorPosition;
- break;
- }
- cursorPosition = (cursorPosition + 1) % itemsMatchingFirstChar.length;
- }
- if (nextCursorPosition !== -1) {
- state.sortedIndexCursor = nextCursorPosition;
- return itemsMatchingFirstChar[state.sortedIndexCursor].index;
- }
- return -1;
- }
- /**
- * Whether or not the given typeahead instaance state is currently typing.
- *
- * @param state The typeahead state instance. See `initState`.
- */
- function isTypingInProgress(state) {
- return state.typeaheadBuffer.length > 0;
- }
- exports.isTypingInProgress = isTypingInProgress;
- /**
- * Clears the typeahaed buffer so that it resets item matching to the first
- * character.
- *
- * @param state The typeahead state instance. See `initState`.
- */
- function clearBuffer(state) {
- state.typeaheadBuffer = '';
- }
- exports.clearBuffer = clearBuffer;
- /**
- * Given a keydown event, it calculates whether or not to automatically focus a
- * list item depending on what was typed mimicing the typeahead functionality of
- * a standard <select> element that is open.
- *
- * @param opts Options and accessors
- * - event - the KeyboardEvent to handle and parse
- * - sortedIndexByFirstChar - output of `initSortedIndex(...)`
- * - focusedItemIndex - the index of the currently focused item
- * - focusItemAtIndex - function that focuses a list item at given index
- * - isItemAtFocusedIndexDisabled - whether or not the currently focused item
- * is disabled
- * - isTargetListItem - whether or not the event target is a list item
- * @param state The typeahead state instance. See `initState`.
- *
- * @returns index of the item matched by the keydown. -1 if not matched.
- */
- function handleKeydown(opts, state) {
- var event = opts.event,
- isTargetListItem = opts.isTargetListItem,
- focusedItemIndex = opts.focusedItemIndex,
- focusItemAtIndex = opts.focusItemAtIndex,
- sortedIndexByFirstChar = opts.sortedIndexByFirstChar,
- isItemAtIndexDisabled = opts.isItemAtIndexDisabled;
- var isArrowLeft = keyboard_1.normalizeKey(event) === 'ArrowLeft';
- var isArrowUp = keyboard_1.normalizeKey(event) === 'ArrowUp';
- var isArrowRight = keyboard_1.normalizeKey(event) === 'ArrowRight';
- var isArrowDown = keyboard_1.normalizeKey(event) === 'ArrowDown';
- var isHome = keyboard_1.normalizeKey(event) === 'Home';
- var isEnd = keyboard_1.normalizeKey(event) === 'End';
- var isEnter = keyboard_1.normalizeKey(event) === 'Enter';
- var isSpace = keyboard_1.normalizeKey(event) === 'Spacebar';
- if (isArrowLeft || isArrowUp || isArrowRight || isArrowDown || isHome || isEnd || isEnter) {
- return -1;
- }
- var isCharacterKey = !isSpace && event.key.length === 1;
- if (isCharacterKey) {
- events_1.preventDefaultEvent(event);
- var matchItemOpts = {
- focusItemAtIndex: focusItemAtIndex,
- focusedItemIndex: focusedItemIndex,
- nextChar: event.key.toLowerCase(),
- sortedIndexByFirstChar: sortedIndexByFirstChar,
- skipFocus: false,
- isItemAtIndexDisabled: isItemAtIndexDisabled
- };
- return matchItem(matchItemOpts, state);
- }
- if (!isSpace) {
- return -1;
- }
- if (isTargetListItem) {
- events_1.preventDefaultEvent(event);
- }
- var typeaheadOnListItem = isTargetListItem && isTypingInProgress(state);
- if (typeaheadOnListItem) {
- var matchItemOpts = {
- focusItemAtIndex: focusItemAtIndex,
- focusedItemIndex: focusedItemIndex,
- nextChar: ' ',
- sortedIndexByFirstChar: sortedIndexByFirstChar,
- skipFocus: false,
- isItemAtIndexDisabled: isItemAtIndexDisabled
- };
- // space participates in typeahead matching if in rapid typing mode
- return matchItem(matchItemOpts, state);
- }
- return -1;
- }
- exports.handleKeydown = handleKeydown;
- /***/ }),
- /***/ "./packages/mdc-menu-surface/component.ts":
- /*!************************************************!*\
- !*** ./packages/mdc-menu-surface/component.ts ***!
- \************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (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 (event) {
- _this.foundation.handleKeydown(event);
- };
- this.handleBodyClick = function (event) {
- _this.foundation.handleBodyClick(event);
- };
- // capture so that no race between handleBodyClick and quickOpen when
- // menusurface opened on button click which registers this listener
- this.registerBodyClickListener = function () {
- document.body.addEventListener('click', _this.handleBodyClick, { capture: true });
- };
- this.deregisterBodyClickListener = function () {
- document.body.removeEventListener('click', _this.handleBodyClick, { capture: true });
- };
- this.listen('keydown', this.handleKeydown);
- this.listen(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
- this.listen(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
- };
- MDCMenuSurface.prototype.destroy = function () {
- this.unlisten('keydown', this.handleKeydown);
- this.unlisten(constants_1.strings.OPENED_EVENT, this.registerBodyClickListener);
- this.unlisten(constants_1.strings.CLOSED_EVENT, this.deregisterBodyClickListener);
- _super.prototype.destroy.call(this);
- };
- MDCMenuSurface.prototype.isOpen = function () {
- return this.foundation.isOpen();
- };
- MDCMenuSurface.prototype.open = function () {
- this.foundation.open();
- };
- MDCMenuSurface.prototype.close = function (skipRestoreFocus) {
- if (skipRestoreFocus === void 0) {
- skipRestoreFocus = false;
- }
- this.foundation.close(skipRestoreFocus);
- };
- Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", {
- set: function set(quickOpen) {
- this.foundation.setQuickOpen(quickOpen);
- },
- enumerable: true,
- configurable: true
- });
- /** Sets the foundation to use page offsets for an positioning when the menu is hoisted to the body. */
- MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) {
- this.foundation.setIsHoisted(isHoisted);
- };
- /** Sets the element that the menu-surface is anchored to. */
- MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) {
- this.anchorElement = element;
- };
- /** Sets the menu-surface to position: fixed. */
- MDCMenuSurface.prototype.setFixedPosition = function (isFixed) {
- if (isFixed) {
- this.root.classList.add(constants_1.cssClasses.FIXED);
- } else {
- this.root.classList.remove(constants_1.cssClasses.FIXED);
- }
- this.foundation.setFixedPosition(isFixed);
- };
- /** Sets the absolute x/y position to position based on. Requires the menu to be hoisted. */
- MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) {
- this.foundation.setAbsolutePosition(x, y);
- this.setIsHoisted(true);
- };
- /**
- * @param corner Default anchor corner alignment of top-left surface corner.
- */
- MDCMenuSurface.prototype.setAnchorCorner = function (corner) {
- this.foundation.setAnchorCorner(corner);
- };
- MDCMenuSurface.prototype.setAnchorMargin = function (margin) {
- this.foundation.setAnchorMargin(margin);
- };
- MDCMenuSurface.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- addClass: function addClass(className) {
- return _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- hasAnchor: function hasAnchor() {
- return !!_this.anchorElement;
- },
- notifyClose: function notifyClose() {
- return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {});
- },
- notifyOpen: function notifyOpen() {
- return _this.emit(foundation_1.MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {});
- },
- isElementInContainer: function isElementInContainer(el) {
- return _this.root.contains(el);
- },
- isRtl: function isRtl() {
- return getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
- },
- setTransformOrigin: function setTransformOrigin(origin) {
- var propertyName = util.getTransformPropertyName(window) + "-origin";
- _this.root.style.setProperty(propertyName, origin);
- },
- isFocused: function isFocused() {
- return document.activeElement === _this.root;
- },
- saveFocus: function saveFocus() {
- _this.previousFocus = document.activeElement;
- },
- restoreFocus: function restoreFocus() {
- if (_this.root.contains(document.activeElement)) {
- if (_this.previousFocus && _this.previousFocus.focus) {
- _this.previousFocus.focus();
- }
- }
- },
- getInnerDimensions: function getInnerDimensions() {
- return {
- width: _this.root.offsetWidth,
- height: _this.root.offsetHeight
- };
- },
- getAnchorDimensions: function getAnchorDimensions() {
- return _this.anchorElement ? _this.anchorElement.getBoundingClientRect() : null;
- },
- getWindowDimensions: function getWindowDimensions() {
- return { width: window.innerWidth, height: window.innerHeight };
- },
- getBodyDimensions: function getBodyDimensions() {
- return { width: document.body.clientWidth, height: document.body.clientHeight };
- },
- getWindowScroll: function getWindowScroll() {
- return { x: window.pageXOffset, y: window.pageYOffset };
- },
- setPosition: function setPosition(position) {
- var rootHTML = _this.root;
- rootHTML.style.left = 'left' in position ? position.left + "px" : '';
- rootHTML.style.right = 'right' in position ? position.right + "px" : '';
- rootHTML.style.top = 'top' in position ? position.top + "px" : '';
- rootHTML.style.bottom = 'bottom' in position ? position.bottom + "px" : '';
- },
- setMaxHeight: function setMaxHeight(height) {
- _this.root.style.maxHeight = height;
- }
- };
- // 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',
- IS_OPEN_BELOW: 'mdc-menu-surface--is-open-below',
- OPEN: 'mdc-menu-surface--open',
- ROOT: 'mdc-menu-surface'
- };
- exports.cssClasses = cssClasses;
- // tslint:disable:object-literal-sort-keys
- var strings = {
- CLOSED_EVENT: 'MDCMenuSurface:closed',
- 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. Also used as a viewport margin. */
- MARGIN_TO_EDGE: 32,
- /** Ratio of anchor width to menu-surface width for switching from corner positioning to center positioning. */
- ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67
- };
- 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 s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- 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(__assign({}, MDCMenuSurfaceFoundation.defaultAdapter), adapter)) || this;
- _this.isSurfaceOpen = 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;
- /**
- * Corner of the menu surface to which menu surface is attached to anchor.
- *
- * Anchor corner --->+----------+
- * | ANCHOR |
- * +----------+
- * Origin corner --->+--------------+
- * | |
- * | |
- * | MENU SURFACE |
- * | |
- * | |
- * +--------------+
- */
- _this.originCorner = constants_1.Corner.TOP_START;
- _this.anchorMargin = { top: 0, right: 0, bottom: 0, left: 0 };
- _this.position = { x: 0, y: 0 };
- return _this;
- }
- Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: 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.isSurfaceOpen = 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;
- };
- /**
- * Flip menu corner horizontally.
- */
- MDCMenuSurfaceFoundation.prototype.flipCornerHorizontally = function () {
- this.originCorner = this.originCorner ^ constants_1.CornerBit.RIGHT;
- };
- /**
- * @param margin Set of margin values from anchor.
- */
- MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) {
- this.anchorMargin.top = margin.top || 0;
- this.anchorMargin.right = margin.right || 0;
- this.anchorMargin.bottom = margin.bottom || 0;
- this.anchorMargin.left = margin.left || 0;
- };
- /** Used to indicate if the menu-surface is hoisted to the body. */
- MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) {
- this.isHoistedElement = isHoisted;
- };
- /** Used to set the menu-surface calculations based on a fixed position menu. */
- MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) {
- this.isFixedPosition = isFixedPosition;
- };
- /** 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.isSurfaceOpen;
- };
- /**
- * Open the menu surface.
- */
- MDCMenuSurfaceFoundation.prototype.open = function () {
- var _this = this;
- if (this.isSurfaceOpen) {
- return;
- }
- this.adapter.saveFocus();
- if (this.isQuickOpen) {
- this.isSurfaceOpen = true;
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
- this.dimensions = this.adapter.getInnerDimensions();
- this.autoposition();
- this.adapter.notifyOpen();
- } else {
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
- this.animationRequestId = requestAnimationFrame(function () {
- _this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
- _this.dimensions = _this.adapter.getInnerDimensions();
- _this.autoposition();
- _this.openAnimationEndTimerId = setTimeout(function () {
- _this.openAnimationEndTimerId = 0;
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN);
- _this.adapter.notifyOpen();
- }, constants_1.numbers.TRANSITION_OPEN_DURATION);
- });
- this.isSurfaceOpen = true;
- }
- };
- /**
- * Closes the menu surface.
- */
- MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) {
- var _this = this;
- if (skipRestoreFocus === void 0) {
- skipRestoreFocus = false;
- }
- if (!this.isSurfaceOpen) {
- return;
- }
- if (this.isQuickOpen) {
- this.isSurfaceOpen = false;
- if (!skipRestoreFocus) {
- this.maybeRestoreFocus();
- }
- this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
- this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
- this.adapter.notifyClose();
- } else {
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
- requestAnimationFrame(function () {
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN);
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
- _this.closeAnimationEndTimerId = setTimeout(function () {
- _this.closeAnimationEndTimerId = 0;
- _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED);
- _this.adapter.notifyClose();
- }, constants_1.numbers.TRANSITION_CLOSE_DURATION);
- });
- this.isSurfaceOpen = false;
- if (!skipRestoreFocus) {
- this.maybeRestoreFocus();
- }
- }
- };
- /** Handle clicks and close if not within menu-surface element. */
- MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) {
- var el = evt.target;
- if (this.adapter.isElementInContainer(el)) {
- return;
- }
- this.close();
- };
- /** Handle keys that close the surface. */
- MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) {
- var keyCode = evt.keyCode,
- key = evt.key;
- var isEscape = key === 'Escape' || keyCode === 27;
- if (isEscape) {
- this.close();
- }
- };
- MDCMenuSurfaceFoundation.prototype.autoposition = function () {
- var _a;
- // Compute measurements for autoposition methods reuse.
- this.measurements = this.getAutoLayoutmeasurements();
- var corner = this.getoriginCorner();
- var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight(corner);
- var verticalAlignment = this.hasBit(corner, constants_1.CornerBit.BOTTOM) ? 'bottom' : 'top';
- var horizontalAlignment = this.hasBit(corner, constants_1.CornerBit.RIGHT) ? 'right' : 'left';
- var horizontalOffset = this.getHorizontalOriginOffset(corner);
- var verticalOffset = this.getVerticalOriginOffset(corner);
- var _b = this.measurements,
- anchorSize = _b.anchorSize,
- surfaceSize = _b.surfaceSize;
- var position = (_a = {}, _a[horizontalAlignment] = horizontalOffset, _a[verticalAlignment] = verticalOffset, _a);
- // Center align when anchor width is comparable or greater than menu surface, otherwise keep corner.
- if (anchorSize.width / surfaceSize.width > constants_1.numbers.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) {
- horizontalAlignment = 'center';
- }
- // If the menu-surface has been hoisted to the body, it's no longer relative to the anchor element
- if (this.isHoistedElement || this.isFixedPosition) {
- this.adjustPositionForHoistedElement(position);
- }
- this.adapter.setTransformOrigin(horizontalAlignment + " " + verticalAlignment);
- this.adapter.setPosition(position);
- this.adapter.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : '');
- // If it is opened from the top then add is-open-below class
- if (!this.hasBit(corner, constants_1.CornerBit.BOTTOM)) {
- this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW);
- }
- };
- /**
- * @return Measurements used to position menu surface popup.
- */
- MDCMenuSurfaceFoundation.prototype.getAutoLayoutmeasurements = function () {
- var anchorRect = this.adapter.getAnchorDimensions();
- var bodySize = this.adapter.getBodyDimensions();
- var viewportSize = this.adapter.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.
- *
- * Only LEFT or RIGHT bit is used to position the menu surface ignoring RTL
- * context. E.g., menu surface will be positioned from right side on TOP_END.
- */
- MDCMenuSurfaceFoundation.prototype.getoriginCorner = function () {
- var corner = this.originCorner;
- var _a = this.measurements,
- viewportDistance = _a.viewportDistance,
- anchorSize = _a.anchorSize,
- surfaceSize = _a.surfaceSize;
- var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE;
- var isAnchoredToBottom = this.hasBit(this.anchorCorner, constants_1.CornerBit.BOTTOM);
- var availableTop;
- var availableBottom;
- if (isAnchoredToBottom) {
- availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.bottom;
- availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE - this.anchorMargin.bottom;
- } else {
- availableTop = viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.top;
- availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE + anchorSize.height - this.anchorMargin.top;
- }
- var isAvailableBottom = availableBottom - surfaceSize.height > 0;
- if (!isAvailableBottom && availableTop > availableBottom) {
- // Attach bottom side of surface to the anchor.
- corner = this.setBit(corner, constants_1.CornerBit.BOTTOM);
- }
- var isRtl = this.adapter.isRtl();
- var isFlipRtl = this.hasBit(this.anchorCorner, constants_1.CornerBit.FLIP_RTL);
- var hasRightBit = this.hasBit(this.anchorCorner, constants_1.CornerBit.RIGHT) || this.hasBit(corner, constants_1.CornerBit.RIGHT);
- // Whether surface attached to right side of anchor element.
- var isAnchoredToRight = false;
- // Anchored to start
- if (isRtl && isFlipRtl) {
- isAnchoredToRight = !hasRightBit;
- } else {
- // Anchored to right
- isAnchoredToRight = hasRightBit;
- }
- var availableLeft;
- var availableRight;
- if (isAnchoredToRight) {
- availableLeft = viewportDistance.left + anchorSize.width + this.anchorMargin.right;
- availableRight = viewportDistance.right - this.anchorMargin.right;
- } else {
- availableLeft = viewportDistance.left + this.anchorMargin.left;
- availableRight = viewportDistance.right + anchorSize.width - this.anchorMargin.left;
- }
- var isAvailableLeft = availableLeft - surfaceSize.width > 0;
- var isAvailableRight = availableRight - surfaceSize.width > 0;
- var isOriginCornerAlignedToEnd = this.hasBit(corner, constants_1.CornerBit.FLIP_RTL) && this.hasBit(corner, constants_1.CornerBit.RIGHT);
- if (isAvailableRight && isOriginCornerAlignedToEnd && isRtl || !isAvailableLeft && isOriginCornerAlignedToEnd) {
- // Attach left side of surface to the anchor.
- corner = this.unsetBit(corner, constants_1.CornerBit.RIGHT);
- } else if (isAvailableLeft && isAnchoredToRight && isRtl || isAvailableLeft && !isAnchoredToRight && hasRightBit || !isAvailableRight && availableLeft >= availableRight) {
- // Attach right side of surface to the anchor.
- corner = this.setBit(corner, constants_1.CornerBit.RIGHT);
- }
- return corner;
- };
- /**
- * @param corner Origin corner of the menu surface.
- * @return Maximum height of the menu surface, based on available space. 0 indicates should not be set.
- */
- MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) {
- 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
- };
- MDCMenuSurfaceFoundation.prototype.unsetBit = function (corner, bit) {
- return corner ^ bit;
- };
- /**
- * isFinite that doesn't force conversion to number type.
- * Equivalent to Number.isFinite in ES2015, which is not supported in IE.
- */
- MDCMenuSurfaceFoundation.prototype.isFinite = function (num) {
- return typeof num === 'number' && isFinite(num);
- };
- return MDCMenuSurfaceFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCMenuSurfaceFoundation = MDCMenuSurfaceFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCMenuSurfaceFoundation;
- /***/ }),
- /***/ "./packages/mdc-menu-surface/index.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-menu-surface/index.ts ***!
- \********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-menu-surface/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-menu-surface/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-menu-surface/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-menu-surface/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-menu-surface/util.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-menu-surface/util.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var cachedCssTransformPropertyName_;
- /**
- * Returns the name of the correct transform property to use on the current browser.
- */
- function getTransformPropertyName(globalObj, forceRefresh) {
- if (forceRefresh === void 0) {
- forceRefresh = false;
- }
- if (cachedCssTransformPropertyName_ === undefined || forceRefresh) {
- var el = globalObj.document.createElement('div');
- cachedCssTransformPropertyName_ = 'transform' in el.style ? 'transform' : 'webkitTransform';
- }
- return cachedCssTransformPropertyName_;
- }
- exports.getTransformPropertyName = getTransformPropertyName;
- /***/ }),
- /***/ "./packages/mdc-menu/component.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-menu/component.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- // TODO(b/152410470): Remove trailing underscores from private properties
- // tslint:disable:strip-private-property-underscore
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var component_2 = __webpack_require__(/*! @material/list/component */ "./packages/mdc-list/component.ts");
- var constants_1 = __webpack_require__(/*! @material/list/constants */ "./packages/mdc-list/constants.ts");
- var foundation_1 = __webpack_require__(/*! @material/list/foundation */ "./packages/mdc-list/foundation.ts");
- var component_3 = __webpack_require__(/*! @material/menu-surface/component */ "./packages/mdc-menu-surface/component.ts");
- var foundation_2 = __webpack_require__(/*! @material/menu-surface/foundation */ "./packages/mdc-menu-surface/foundation.ts");
- var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-menu/constants.ts");
- var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-menu/foundation.ts");
- var MDCMenu = /** @class */function (_super) {
- __extends(MDCMenu, _super);
- function MDCMenu() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCMenu.attachTo = function (root) {
- return new MDCMenu(root);
- };
- MDCMenu.prototype.initialize = function (menuSurfaceFactory, listFactory) {
- if (menuSurfaceFactory === void 0) {
- menuSurfaceFactory = function menuSurfaceFactory(el) {
- return new component_3.MDCMenuSurface(el);
- };
- }
- if (listFactory === void 0) {
- listFactory = function listFactory(el) {
- return new component_2.MDCList(el);
- };
- }
- this.menuSurfaceFactory_ = menuSurfaceFactory;
- this.listFactory_ = listFactory;
- };
- MDCMenu.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.menuSurface_ = this.menuSurfaceFactory_(this.root);
- var list = this.root.querySelector(constants_2.strings.LIST_SELECTOR);
- if (list) {
- this.list_ = this.listFactory_(list);
- this.list_.wrapFocus = true;
- } else {
- this.list_ = null;
- }
- this.handleKeydown_ = function (evt) {
- 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, "hasTypeahead", {
- /**
- * Sets whether the menu has typeahead functionality.
- * @param value Whether typeahead is enabled.
- */
- set: function set(value) {
- if (this.list_) {
- this.list_.hasTypeahead = value;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCMenu.prototype, "typeaheadInProgress", {
- /**
- * @return Whether typeahead logic is currently matching some user prefix.
- */
- get: function get() {
- return this.list_ ? this.list_.typeaheadInProgress : false;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Given the next desired character from the user, adds it to the typeahead
- * buffer. Then, attempts to find the next option matching the buffer. Wraps
- * around if at the end of options.
- *
- * @param nextChar The next character to add to the prefix buffer.
- * @param startingIndex The index from which to start matching. Only relevant
- * when starting a new match sequence. To start a new match sequence,
- * clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer
- * to clear after a set interval defined in list foundation. Defaults to
- * the currently focused index.
- * @return The index of the matched item, or -1 if no match.
- */
- MDCMenu.prototype.typeaheadMatchItem = function (nextChar, startingIndex) {
- if (this.list_) {
- return this.list_.typeaheadMatchItem(nextChar, startingIndex);
- }
- return -1;
- };
- /**
- * Layout the underlying list element in the case of any dynamic updates
- * to its structure.
- */
- MDCMenu.prototype.layout = function () {
- if (this.list_) {
- this.list_.layout();
- }
- };
- Object.defineProperty(MDCMenu.prototype, "items", {
- /**
- * Return the items within the menu. Note that this only contains the set of elements within
- * the items container that are proper list items, and not supplemental / presentational DOM
- * elements.
- */
- get: function get() {
- return this.list_ ? this.list_.listElements : [];
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCMenu.prototype, "singleSelection", {
- /**
- * Turns on/off the underlying list's single selection mode. Used mainly
- * by select menu.
- *
- * @param singleSelection Whether to enable single selection mode.
- */
- set: function set(singleSelection) {
- if (this.list_) {
- this.list_.singleSelection = singleSelection;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCMenu.prototype, "selectedIndex", {
- /**
- * Retrieves the selected index. Only applicable to select menus.
- * @return The selected index, which is a number for single selection and
- * radio lists, and an array of numbers for checkbox lists.
- */
- get: function get() {
- return this.list_ ? this.list_.selectedIndex : constants_1.numbers.UNSET_INDEX;
- },
- /**
- * Sets the selected index of the list. Only applicable to select menus.
- * @param index The selected index, which is a number for single selection and
- * radio lists, and an array of numbers for checkbox lists.
- */
- set: function set(index) {
- if (this.list_) {
- this.list_.selectedIndex = index;
- }
- },
- enumerable: 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;
- }
- };
- /**
- * @param index A menu item's index.
- * @return The primary text within the menu at the index specified.
- */
- MDCMenu.prototype.getPrimaryTextAtIndex = function (index) {
- var item = this.getOptionByIndex(index);
- if (item && this.list_) {
- return this.list_.getPrimaryText(item) || '';
- }
- return '';
- };
- MDCMenu.prototype.setFixedPosition = function (isFixed) {
- this.menuSurface_.setFixedPosition(isFixed);
- };
- MDCMenu.prototype.setIsHoisted = function (isHoisted) {
- this.menuSurface_.setIsHoisted(isHoisted);
- };
- MDCMenu.prototype.setAbsolutePosition = function (x, y) {
- this.menuSurface_.setAbsolutePosition(x, y);
- };
- /**
- * Sets the element that the menu-surface is anchored to.
- */
- MDCMenu.prototype.setAnchorElement = function (element) {
- this.menuSurface_.anchorElement = element;
- };
- MDCMenu.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- addClassToElementAtIndex: function addClassToElementAtIndex(index, className) {
- var list = _this.items;
- list[index].classList.add(className);
- },
- removeClassFromElementAtIndex: function removeClassFromElementAtIndex(index, className) {
- var list = _this.items;
- list[index].classList.remove(className);
- },
- addAttributeToElementAtIndex: function addAttributeToElementAtIndex(index, attr, value) {
- var list = _this.items;
- 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_2.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_2.strings.LIST_SELECTOR).focus();
- },
- isSelectableItemAtIndex: function isSelectableItemAtIndex(index) {
- return !!ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
- },
- getSelectedSiblingOfItemAtIndex: function getSelectedSiblingOfItemAtIndex(index) {
- var selectionGroupEl = ponyfill_1.closest(_this.items[index], "." + constants_2.cssClasses.MENU_SELECTION_GROUP);
- var selectedItemEl = selectionGroupEl.querySelector("." + constants_2.cssClasses.MENU_SELECTED_LIST_ITEM);
- return selectedItemEl ? _this.items.indexOf(selectedItemEl) : -1;
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_3.MDCMenuFoundation(adapter);
- };
- return MDCMenu;
- }(component_1.MDCComponent);
- exports.MDCMenu = MDCMenu;
- /***/ }),
- /***/ "./packages/mdc-menu/constants.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-menu/constants.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- 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(__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 (recomputedIndex >= 0 && _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(__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(__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(__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(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this;
- _this.activationAnimationHasEnded_ = false;
- _this.activationTimer_ = 0;
- _this.fgDeactivationRemovalTimer_ = 0;
- _this.fgScale_ = '0';
- _this.frame_ = { width: 0, height: 0 };
- _this.initialSize_ = 0;
- _this.layoutFrame_ = 0;
- _this.maxRadius_ = 0;
- _this.unboundedCoords_ = { left: 0, top: 0 };
- _this.activationState_ = _this.defaultActivationState_();
- _this.activationTimerCallback_ = function () {
- _this.activationAnimationHasEnded_ = true;
- _this.runDeactivationUXLogicIfReady_();
- };
- _this.activateHandler_ = function (e) {
- return _this.activate_(e);
- };
- _this.deactivateHandler_ = function () {
- return _this.deactivate_();
- };
- _this.focusHandler_ = function () {
- return _this.handleFocus();
- };
- _this.blurHandler_ = function () {
- return _this.handleBlur();
- };
- _this.resizeHandler_ = function () {
- return _this.layout();
- };
- return _this;
- }
- Object.defineProperty(MDCRippleFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCRippleFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- browserSupportsCssVars: function browserSupportsCssVars() {
- return true;
- },
- computeBoundingRect: function computeBoundingRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- containsEventTarget: function containsEventTarget() {
- return true;
- },
- deregisterDocumentInteractionHandler: function deregisterDocumentInteractionHandler() {
- return undefined;
- },
- deregisterInteractionHandler: function deregisterInteractionHandler() {
- return undefined;
- },
- deregisterResizeHandler: function deregisterResizeHandler() {
- return undefined;
- },
- getWindowPageOffset: function getWindowPageOffset() {
- return { x: 0, y: 0 };
- },
- isSurfaceActive: function isSurfaceActive() {
- return true;
- },
- isSurfaceDisabled: function isSurfaceDisabled() {
- return true;
- },
- isUnbounded: function isUnbounded() {
- return true;
- },
- registerDocumentInteractionHandler: function registerDocumentInteractionHandler() {
- return undefined;
- },
- registerInteractionHandler: function registerInteractionHandler() {
- return undefined;
- },
- registerResizeHandler: function registerResizeHandler() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- updateCssVariable: function updateCssVariable() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCRippleFoundation.prototype.init = function () {
- var _this = this;
- var supportsPressRipple = this.supportsPressRipple_();
- this.registerRootHandlers_(supportsPressRipple);
- if (supportsPressRipple) {
- var _a = MDCRippleFoundation.cssClasses,
- ROOT_1 = _a.ROOT,
- UNBOUNDED_1 = _a.UNBOUNDED;
- requestAnimationFrame(function () {
- _this.adapter.addClass(ROOT_1);
- if (_this.adapter.isUnbounded()) {
- _this.adapter.addClass(UNBOUNDED_1);
- // Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple
- _this.layoutInternal_();
- }
- });
- }
- };
- MDCRippleFoundation.prototype.destroy = function () {
- var _this = this;
- if (this.supportsPressRipple_()) {
- if (this.activationTimer_) {
- clearTimeout(this.activationTimer_);
- this.activationTimer_ = 0;
- this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION);
- }
- if (this.fgDeactivationRemovalTimer_) {
- clearTimeout(this.fgDeactivationRemovalTimer_);
- this.fgDeactivationRemovalTimer_ = 0;
- this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION);
- }
- var _a = MDCRippleFoundation.cssClasses,
- ROOT_2 = _a.ROOT,
- UNBOUNDED_2 = _a.UNBOUNDED;
- requestAnimationFrame(function () {
- _this.adapter.removeClass(ROOT_2);
- _this.adapter.removeClass(UNBOUNDED_2);
- _this.removeCssVars_();
- });
- }
- this.deregisterRootHandlers_();
- this.deregisterDeactivationHandlers_();
- };
- /**
- * @param evt Optional event containing position information.
- */
- MDCRippleFoundation.prototype.activate = function (evt) {
- this.activate_(evt);
- };
- MDCRippleFoundation.prototype.deactivate = function () {
- this.deactivate_();
- };
- MDCRippleFoundation.prototype.layout = function () {
- var _this = this;
- if (this.layoutFrame_) {
- cancelAnimationFrame(this.layoutFrame_);
- }
- this.layoutFrame_ = requestAnimationFrame(function () {
- _this.layoutInternal_();
- _this.layoutFrame_ = 0;
- });
- };
- MDCRippleFoundation.prototype.setUnbounded = function (unbounded) {
- var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED;
- if (unbounded) {
- this.adapter.addClass(UNBOUNDED);
- } else {
- this.adapter.removeClass(UNBOUNDED);
- }
- };
- MDCRippleFoundation.prototype.handleFocus = function () {
- var _this = this;
- requestAnimationFrame(function () {
- return _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
- });
- };
- MDCRippleFoundation.prototype.handleBlur = function () {
- var _this = this;
- requestAnimationFrame(function () {
- return _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED);
- });
- };
- /**
- * We compute this property so that we are not querying information about the client
- * until the point in time where the foundation requests it. This prevents scenarios where
- * client-side feature-detection may happen too early, such as when components are rendered on the server
- * and then initialized at mount time on the client.
- */
- MDCRippleFoundation.prototype.supportsPressRipple_ = function () {
- return this.adapter.browserSupportsCssVars();
- };
- MDCRippleFoundation.prototype.defaultActivationState_ = function () {
- return {
- activationEvent: undefined,
- hasDeactivationUXRun: false,
- isActivated: false,
- isProgrammatic: false,
- wasActivatedByPointer: false,
- wasElementMadeActive: false
- };
- };
- /**
- * supportsPressRipple Passed from init to save a redundant function call
- */
- MDCRippleFoundation.prototype.registerRootHandlers_ = function (supportsPressRipple) {
- var _this = this;
- if (supportsPressRipple) {
- ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter.registerInteractionHandler(evtType, _this.activateHandler_);
- });
- if (this.adapter.isUnbounded()) {
- this.adapter.registerResizeHandler(this.resizeHandler_);
- }
- }
- this.adapter.registerInteractionHandler('focus', this.focusHandler_);
- this.adapter.registerInteractionHandler('blur', this.blurHandler_);
- };
- MDCRippleFoundation.prototype.registerDeactivationHandlers_ = function (evt) {
- var _this = this;
- if (evt.type === 'keydown') {
- this.adapter.registerInteractionHandler('keyup', this.deactivateHandler_);
- } else {
- POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter.registerDocumentInteractionHandler(evtType, _this.deactivateHandler_);
- });
- }
- };
- MDCRippleFoundation.prototype.deregisterRootHandlers_ = function () {
- var _this = this;
- ACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter.deregisterInteractionHandler(evtType, _this.activateHandler_);
- });
- this.adapter.deregisterInteractionHandler('focus', this.focusHandler_);
- this.adapter.deregisterInteractionHandler('blur', this.blurHandler_);
- if (this.adapter.isUnbounded()) {
- this.adapter.deregisterResizeHandler(this.resizeHandler_);
- }
- };
- MDCRippleFoundation.prototype.deregisterDeactivationHandlers_ = function () {
- var _this = this;
- this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler_);
- POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) {
- _this.adapter.deregisterDocumentInteractionHandler(evtType, _this.deactivateHandler_);
- });
- };
- MDCRippleFoundation.prototype.removeCssVars_ = function () {
- var _this = this;
- var rippleStrings = MDCRippleFoundation.strings;
- var keys = Object.keys(rippleStrings);
- keys.forEach(function (key) {
- if (key.indexOf('VAR_') === 0) {
- _this.adapter.updateCssVariable(rippleStrings[key], null);
- }
- });
- };
- MDCRippleFoundation.prototype.activate_ = function (evt) {
- var _this = this;
- if (this.adapter.isSurfaceDisabled()) {
- return;
- }
- var activationState = this.activationState_;
- if (activationState.isActivated) {
- return;
- }
- // Avoid reacting to follow-on events fired by touch device after an already-processed user interaction
- var previousActivationEvent = this.previousActivationEvent_;
- var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type;
- if (isSameInteraction) {
- return;
- }
- activationState.isActivated = true;
- activationState.isProgrammatic = evt === undefined;
- activationState.activationEvent = evt;
- activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown');
- var hasActivatedChild = evt !== undefined && activatedTargets.length > 0 && activatedTargets.some(function (target) {
- return _this.adapter.containsEventTarget(target);
- });
- if (hasActivatedChild) {
- // Immediately reset activation state, while preserving logic that prevents touch follow-on events
- this.resetActivationState_();
- return;
- }
- if (evt !== undefined) {
- activatedTargets.push(evt.target);
- this.registerDeactivationHandlers_(evt);
- }
- activationState.wasElementMadeActive = this.checkElementMadeActive_(evt);
- if (activationState.wasElementMadeActive) {
- this.animateActivation_();
- }
- requestAnimationFrame(function () {
- // Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples
- activatedTargets = [];
- if (!activationState.wasElementMadeActive && evt !== undefined && (evt.key === ' ' || evt.keyCode === 32)) {
- // If space was pressed, try again within an rAF call to detect :active, because different UAs report
- // active states inconsistently when they're called within event handling code:
- // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971
- // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741
- // We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS
- // variable is set within a rAF callback for a submit button interaction (#2241).
- activationState.wasElementMadeActive = _this.checkElementMadeActive_(evt);
- if (activationState.wasElementMadeActive) {
- _this.animateActivation_();
- }
- }
- if (!activationState.wasElementMadeActive) {
- // Reset activation state immediately if element was not made active.
- _this.activationState_ = _this.defaultActivationState_();
- }
- });
- };
- MDCRippleFoundation.prototype.checkElementMadeActive_ = function (evt) {
- return evt !== undefined && evt.type === 'keydown' ? this.adapter.isSurfaceActive() : true;
- };
- MDCRippleFoundation.prototype.animateActivation_ = function () {
- var _this = this;
- var _a = MDCRippleFoundation.strings,
- VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START,
- VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END;
- var _b = MDCRippleFoundation.cssClasses,
- FG_DEACTIVATION = _b.FG_DEACTIVATION,
- FG_ACTIVATION = _b.FG_ACTIVATION;
- var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS;
- this.layoutInternal_();
- var translateStart = '';
- var translateEnd = '';
- if (!this.adapter.isUnbounded()) {
- var _c = this.getFgTranslationCoordinates_(),
- startPoint = _c.startPoint,
- endPoint = _c.endPoint;
- translateStart = startPoint.x + "px, " + startPoint.y + "px";
- translateEnd = endPoint.x + "px, " + endPoint.y + "px";
- }
- this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart);
- this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd);
- // Cancel any ongoing activation/deactivation animations
- clearTimeout(this.activationTimer_);
- clearTimeout(this.fgDeactivationRemovalTimer_);
- this.rmBoundedActivationClasses_();
- this.adapter.removeClass(FG_DEACTIVATION);
- // Force layout in order to re-trigger the animation.
- this.adapter.computeBoundingRect();
- this.adapter.addClass(FG_ACTIVATION);
- this.activationTimer_ = setTimeout(function () {
- return _this.activationTimerCallback_();
- }, DEACTIVATION_TIMEOUT_MS);
- };
- MDCRippleFoundation.prototype.getFgTranslationCoordinates_ = function () {
- var _a = this.activationState_,
- activationEvent = _a.activationEvent,
- wasActivatedByPointer = _a.wasActivatedByPointer;
- var startPoint;
- if (wasActivatedByPointer) {
- startPoint = util_1.getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect());
- } else {
- startPoint = {
- x: this.frame_.width / 2,
- y: this.frame_.height / 2
- };
- }
- // Center the element around the start point.
- startPoint = {
- x: startPoint.x - this.initialSize_ / 2,
- y: startPoint.y - this.initialSize_ / 2
- };
- var endPoint = {
- x: this.frame_.width / 2 - this.initialSize_ / 2,
- y: this.frame_.height / 2 - this.initialSize_ / 2
- };
- return { startPoint: startPoint, endPoint: endPoint };
- };
- MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady_ = function () {
- var _this = this;
- // This method is called both when a pointing device is released, and when the activation animation ends.
- // The deactivation animation should only run after both of those occur.
- var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION;
- var _a = this.activationState_,
- hasDeactivationUXRun = _a.hasDeactivationUXRun,
- isActivated = _a.isActivated;
- var activationHasEnded = hasDeactivationUXRun || !isActivated;
- if (activationHasEnded && this.activationAnimationHasEnded_) {
- this.rmBoundedActivationClasses_();
- this.adapter.addClass(FG_DEACTIVATION);
- this.fgDeactivationRemovalTimer_ = setTimeout(function () {
- _this.adapter.removeClass(FG_DEACTIVATION);
- }, constants_1.numbers.FG_DEACTIVATION_MS);
- }
- };
- MDCRippleFoundation.prototype.rmBoundedActivationClasses_ = function () {
- var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION;
- this.adapter.removeClass(FG_ACTIVATION);
- this.activationAnimationHasEnded_ = false;
- this.adapter.computeBoundingRect();
- };
- MDCRippleFoundation.prototype.resetActivationState_ = function () {
- var _this = this;
- this.previousActivationEvent_ = this.activationState_.activationEvent;
- this.activationState_ = this.defaultActivationState_();
- // Touch devices may fire additional events for the same interaction within a short time.
- // Store the previous event until it's safe to assume that subsequent events are for new interactions.
- setTimeout(function () {
- return _this.previousActivationEvent_ = undefined;
- }, MDCRippleFoundation.numbers.TAP_DELAY_MS);
- };
- MDCRippleFoundation.prototype.deactivate_ = function () {
- var _this = this;
- var activationState = this.activationState_;
- // This can happen in scenarios such as when you have a keyup event that blurs the element.
- if (!activationState.isActivated) {
- return;
- }
- var state = __assign({}, activationState);
- if (activationState.isProgrammatic) {
- requestAnimationFrame(function () {
- return _this.animateDeactivation_(state);
- });
- this.resetActivationState_();
- } else {
- this.deregisterDeactivationHandlers_();
- requestAnimationFrame(function () {
- _this.activationState_.hasDeactivationUXRun = true;
- _this.animateDeactivation_(state);
- _this.resetActivationState_();
- });
- }
- };
- MDCRippleFoundation.prototype.animateDeactivation_ = function (_a) {
- var wasActivatedByPointer = _a.wasActivatedByPointer,
- wasElementMadeActive = _a.wasElementMadeActive;
- if (wasActivatedByPointer || wasElementMadeActive) {
- this.runDeactivationUXLogicIfReady_();
- }
- };
- MDCRippleFoundation.prototype.layoutInternal_ = function () {
- var _this = this;
- this.frame_ = this.adapter.computeBoundingRect();
- var maxDim = Math.max(this.frame_.height, this.frame_.width);
- // Surface diameter is treated differently for unbounded vs. bounded ripples.
- // Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately
- // to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically
- // square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter
- // (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via
- // `overflow: hidden`.
- var getBoundedRadius = function getBoundedRadius() {
- var hypotenuse = Math.sqrt(Math.pow(_this.frame_.width, 2) + Math.pow(_this.frame_.height, 2));
- return hypotenuse + MDCRippleFoundation.numbers.PADDING;
- };
- this.maxRadius_ = this.adapter.isUnbounded() ? maxDim : getBoundedRadius();
- // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform
- var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE);
- // Unbounded ripple size should always be even number to equally center align.
- if (this.adapter.isUnbounded() && initialSize % 2 !== 0) {
- this.initialSize_ = initialSize - 1;
- } else {
- this.initialSize_ = initialSize;
- }
- this.fgScale_ = "" + this.maxRadius_ / this.initialSize_;
- this.updateLayoutCssVars_();
- };
- MDCRippleFoundation.prototype.updateLayoutCssVars_ = function () {
- var _a = MDCRippleFoundation.strings,
- VAR_FG_SIZE = _a.VAR_FG_SIZE,
- VAR_LEFT = _a.VAR_LEFT,
- VAR_TOP = _a.VAR_TOP,
- VAR_FG_SCALE = _a.VAR_FG_SCALE;
- this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize_ + "px");
- this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale_);
- if (this.adapter.isUnbounded()) {
- this.unboundedCoords_ = {
- left: Math.round(this.frame_.width / 2 - this.initialSize_ / 2),
- top: Math.round(this.frame_.height / 2 - this.initialSize_ / 2)
- };
- this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords_.left + "px");
- this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords_.top + "px");
- }
- };
- return MDCRippleFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCRippleFoundation = MDCRippleFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCRippleFoundation;
- /***/ }),
- /***/ "./packages/mdc-ripple/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-ripple/index.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-ripple/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-ripple/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-ripple/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-ripple/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-ripple/util.ts":
- /*!*************************************!*\
- !*** ./packages/mdc-ripple/util.ts ***!
- \*************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * Stores result from supportsCssVariables to avoid redundant processing to
- * detect CSS custom variable support.
- */
- var supportsCssVariables_;
- function supportsCssVariables(windowObj, forceRefresh) {
- if (forceRefresh === void 0) {
- forceRefresh = false;
- }
- var CSS = windowObj.CSS;
- var supportsCssVars = supportsCssVariables_;
- if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) {
- return supportsCssVariables_;
- }
- var supportsFunctionPresent = CSS && typeof CSS.supports === 'function';
- if (!supportsFunctionPresent) {
- return false;
- }
- var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes');
- // See: https://bugs.webkit.org/show_bug.cgi?id=154669
- // See: README section on Safari
- var weAreFeatureDetectingSafari10plus = CSS.supports('(--css-vars: yes)') && CSS.supports('color', '#00000000');
- supportsCssVars = explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus;
- if (!forceRefresh) {
- supportsCssVariables_ = supportsCssVars;
- }
- return supportsCssVars;
- }
- exports.supportsCssVariables = supportsCssVariables;
- function getNormalizedEventCoords(evt, pageOffset, clientRect) {
- if (!evt) {
- return { x: 0, y: 0 };
- }
- var x = pageOffset.x,
- y = pageOffset.y;
- var documentX = x + clientRect.left;
- var documentY = y + clientRect.top;
- var normalizedX;
- var normalizedY;
- // Determine touch point relative to the ripple container.
- if (evt.type === 'touchstart') {
- var touchEvent = evt;
- normalizedX = touchEvent.changedTouches[0].pageX - documentX;
- normalizedY = touchEvent.changedTouches[0].pageY - documentY;
- } else {
- var mouseEvent = evt;
- normalizedX = mouseEvent.pageX - documentX;
- normalizedY = mouseEvent.pageY - documentY;
- }
- return { x: normalizedX, y: normalizedY };
- }
- exports.getNormalizedEventCoords = getNormalizedEventCoords;
- /***/ }),
- /***/ "./packages/mdc-segmented-button/index.ts":
- /*!************************************************!*\
- !*** ./packages/mdc-segmented-button/index.ts ***!
- \************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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__(/*! ./segmented-button/index */ "./packages/mdc-segmented-button/segmented-button/index.ts"));
- __export(__webpack_require__(/*! ./segment/index */ "./packages/mdc-segmented-button/segment/index.ts"));
- /***/ }),
- /***/ "./packages/mdc-segmented-button/segment/component.ts":
- /*!************************************************************!*\
- !*** ./packages/mdc-segmented-button/segment/component.ts ***!
- \************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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-segmented-button/segment/constants.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segment/foundation.ts");
- /**
- * Implementation of MDCSegmentedButtonSegmentFoundation
- */
- var MDCSegmentedButtonSegment = /** @class */function (_super) {
- __extends(MDCSegmentedButtonSegment, _super);
- function MDCSegmentedButtonSegment() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- Object.defineProperty(MDCSegmentedButtonSegment.prototype, "ripple", {
- get: function get() {
- return this.rippleComponent;
- },
- enumerable: true,
- configurable: true
- });
- MDCSegmentedButtonSegment.attachTo = function (root) {
- return new MDCSegmentedButtonSegment(root);
- };
- MDCSegmentedButtonSegment.prototype.initialize = function (rippleFactory) {
- var _this = this;
- if (rippleFactory === void 0) {
- rippleFactory = function rippleFactory(el, foundation) {
- return new component_2.MDCRipple(el, foundation);
- };
- }
- var rippleAdapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { computeBoundingRect: function computeBoundingRect() {
- return _this.foundation.getDimensions();
- } });
- this.rippleComponent = rippleFactory(this.root, new foundation_1.MDCRippleFoundation(rippleAdapter));
- };
- MDCSegmentedButtonSegment.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleClick = function () {
- _this.foundation.handleClick();
- };
- this.listen(constants_1.events.CLICK, this.handleClick);
- };
- MDCSegmentedButtonSegment.prototype.destroy = function () {
- this.ripple.destroy();
- this.unlisten(constants_1.events.CLICK, this.handleClick);
- _super.prototype.destroy.call(this);
- };
- MDCSegmentedButtonSegment.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 = {
- isSingleSelect: function isSingleSelect() {
- return _this.isSingleSelect;
- },
- getAttr: function getAttr(attrName) {
- return _this.root.getAttribute(attrName);
- },
- setAttr: function setAttr(attrName, value) {
- _this.root.setAttribute(attrName, value);
- },
- addClass: function addClass(className) {
- _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- notifySelectedChange: function notifySelectedChange(selected) {
- _this.emit(constants_1.events.SELECTED, {
- index: _this.index,
- selected: selected,
- segmentId: _this.getSegmentId()
- }, true /* shouldBubble */);
- },
- getRootBoundingClientRect: function getRootBoundingClientRect() {
- return _this.root.getBoundingClientRect();
- }
- };
- return new foundation_2.MDCSegmentedButtonSegmentFoundation(adapter);
- };
- /**
- * Sets segment's index value
- *
- * @param index Segment's index within wrapping segmented button
- */
- MDCSegmentedButtonSegment.prototype.setIndex = function (index) {
- this.index = index;
- };
- /**
- * Sets segment's isSingleSelect value
- *
- * @param isSingleSelect True if wrapping segmented button is single select
- */
- MDCSegmentedButtonSegment.prototype.setIsSingleSelect = function (isSingleSelect) {
- this.isSingleSelect = isSingleSelect;
- };
- /**
- * @return Returns true if segment is currently selected, otherwise returns
- * false
- */
- MDCSegmentedButtonSegment.prototype.isSelected = function () {
- return this.foundation.isSelected();
- };
- /**
- * Sets segment to be selected
- */
- MDCSegmentedButtonSegment.prototype.setSelected = function () {
- this.foundation.setSelected();
- };
- /**
- * Sets segment to be not selected
- */
- MDCSegmentedButtonSegment.prototype.setUnselected = function () {
- this.foundation.setUnselected();
- };
- /**
- * @return Returns segment's segmentId if it was set by client
- */
- MDCSegmentedButtonSegment.prototype.getSegmentId = function () {
- return this.foundation.getSegmentId();
- };
- return MDCSegmentedButtonSegment;
- }(component_1.MDCComponent);
- exports.MDCSegmentedButtonSegment = MDCSegmentedButtonSegment;
- /***/ }),
- /***/ "./packages/mdc-segmented-button/segment/constants.ts":
- /*!************************************************************!*\
- !*** ./packages/mdc-segmented-button/segment/constants.ts ***!
- \************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * Boolean strings for segment
- */
- exports.booleans = {
- TRUE: 'true',
- FALSE: 'false'
- };
- /**
- * Attributes referenced by segment
- */
- exports.attributes = {
- ARIA_CHECKED: 'aria-checked',
- ARIA_PRESSED: 'aria-pressed',
- DATA_SEGMENT_ID: 'data-segment-id'
- };
- /**
- * Events received or emitted by segment
- */
- exports.events = {
- CLICK: 'click',
- SELECTED: 'selected'
- };
- /**
- * Style classes for segment
- */
- exports.cssClasses = {
- SELECTED: 'mdc-segmented-button__segment--selected'
- };
- /***/ }),
- /***/ "./packages/mdc-segmented-button/segment/foundation.ts":
- /*!*************************************************************!*\
- !*** ./packages/mdc-segmented-button/segment/foundation.ts ***!
- \*************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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-segmented-button/segment/constants.ts");
- var emptyClientRect = {
- bottom: 0,
- height: 0,
- left: 0,
- right: 0,
- top: 0,
- width: 0
- };
- var MDCSegmentedButtonSegmentFoundation = /** @class */function (_super) {
- __extends(MDCSegmentedButtonSegmentFoundation, _super);
- function MDCSegmentedButtonSegmentFoundation(adapter) {
- return _super.call(this, __assign(__assign({}, MDCSegmentedButtonSegmentFoundation.defaultAdapter), adapter)) || this;
- }
- Object.defineProperty(MDCSegmentedButtonSegmentFoundation, "defaultAdapter", {
- get: function get() {
- return {
- isSingleSelect: function isSingleSelect() {
- return false;
- }, getAttr: function getAttr() {
- return '';
- }, setAttr: function setAttr() {
- return undefined;
- },
- addClass: function addClass() {
- return undefined;
- }, removeClass: function removeClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return false;
- },
- notifySelectedChange: function notifySelectedChange() {
- return undefined;
- },
- getRootBoundingClientRect: function getRootBoundingClientRect() {
- return emptyClientRect;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return Returns true if segment is currently selected, otherwise returns
- * false
- */
- MDCSegmentedButtonSegmentFoundation.prototype.isSelected = function () {
- return this.adapter.hasClass(constants_1.cssClasses.SELECTED);
- };
- /**
- * Sets segment to be selected
- */
- MDCSegmentedButtonSegmentFoundation.prototype.setSelected = function () {
- this.adapter.addClass(constants_1.cssClasses.SELECTED);
- this.setAriaAttr(constants_1.booleans.TRUE);
- };
- /**
- * Sets segment to be not selected
- */
- MDCSegmentedButtonSegmentFoundation.prototype.setUnselected = function () {
- this.adapter.removeClass(constants_1.cssClasses.SELECTED);
- this.setAriaAttr(constants_1.booleans.FALSE);
- };
- /**
- * @return Returns segment's segmentId if it was set by client
- */
- MDCSegmentedButtonSegmentFoundation.prototype.getSegmentId = function () {
- var _a;
- return (_a = this.adapter.getAttr(constants_1.attributes.DATA_SEGMENT_ID)) !== null && _a !== void 0 ? _a : undefined;
- };
- /**
- * Called when segment is clicked. If the wrapping segmented button is single
- * select, doesn't allow segment to be set to not selected. Otherwise, toggles
- * segment's selected status. Finally, emits event to wrapping segmented
- * button.
- *
- * @event selected With detail - SegmentDetail
- */
- MDCSegmentedButtonSegmentFoundation.prototype.handleClick = function () {
- if (this.adapter.isSingleSelect()) {
- this.setSelected();
- } else {
- this.toggleSelection();
- }
- this.adapter.notifySelectedChange(this.isSelected());
- };
- /**
- * @return Returns bounding rectangle for ripple effect
- */
- MDCSegmentedButtonSegmentFoundation.prototype.getDimensions = function () {
- return this.adapter.getRootBoundingClientRect();
- };
- /**
- * Sets segment from not selected to selected, or selected to not selected
- */
- MDCSegmentedButtonSegmentFoundation.prototype.toggleSelection = function () {
- if (this.isSelected()) {
- this.setUnselected();
- } else {
- this.setSelected();
- }
- };
- /**
- * Sets appropriate aria attribute, based on wrapping segmented button's
- * single selected value, to new value
- *
- * @param value Value that represents selected status
- */
- MDCSegmentedButtonSegmentFoundation.prototype.setAriaAttr = function (value) {
- if (this.adapter.isSingleSelect()) {
- this.adapter.setAttr(constants_1.attributes.ARIA_CHECKED, value);
- } else {
- this.adapter.setAttr(constants_1.attributes.ARIA_PRESSED, value);
- }
- };
- return MDCSegmentedButtonSegmentFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSegmentedButtonSegmentFoundation = MDCSegmentedButtonSegmentFoundation;
- /***/ }),
- /***/ "./packages/mdc-segmented-button/segment/index.ts":
- /*!********************************************************!*\
- !*** ./packages/mdc-segmented-button/segment/index.ts ***!
- \********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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__(/*! ./foundation */ "./packages/mdc-segmented-button/segment/foundation.ts"));
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-segmented-button/segment/component.ts"));
- /***/ }),
- /***/ "./packages/mdc-segmented-button/segmented-button/component.ts":
- /*!*********************************************************************!*\
- !*** ./packages/mdc-segmented-button/segmented-button/component.ts ***!
- \*********************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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__(/*! ../segment/component */ "./packages/mdc-segmented-button/segment/component.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segmented-button/constants.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-segmented-button/segmented-button/foundation.ts");
- // TODO(b/152410470): Remove trailing underscores from private properties
- // tslint:disable:strip-private-property-underscore
- var MDCSegmentedButton = /** @class */function (_super) {
- __extends(MDCSegmentedButton, _super);
- function MDCSegmentedButton() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCSegmentedButton.attachTo = function (root) {
- return new MDCSegmentedButton(root);
- };
- Object.defineProperty(MDCSegmentedButton.prototype, "segments", {
- get: function get() {
- return this.segments_.slice();
- },
- enumerable: true,
- configurable: true
- });
- // initialSyncWithDOM
- MDCSegmentedButton.prototype.initialize = function (segmentFactory) {
- if (segmentFactory === void 0) {
- segmentFactory = function segmentFactory(el) {
- return new component_2.MDCSegmentedButtonSegment(el);
- };
- }
- this.segmentFactory = segmentFactory;
- this.segments_ = this.instantiateSegments(this.segmentFactory);
- };
- /**
- * @param segmentFactory Factory to create new child segments
- * @return Returns list of child segments found in DOM
- */
- MDCSegmentedButton.prototype.instantiateSegments = function (segmentFactory) {
- var segmentElements = [].slice.call(this.root.querySelectorAll(constants_1.selectors.SEGMENT));
- return segmentElements.map(function (el) {
- return segmentFactory(el);
- });
- };
- MDCSegmentedButton.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleSelected = function (event) {
- _this.foundation.handleSelected(event.detail);
- };
- this.listen(constants_1.events.SELECTED, this.handleSelected);
- var isSingleSelect = this.foundation.isSingleSelect();
- this.segments_.forEach(function (segment, index) {
- segment.setIndex(index);
- segment.setIsSingleSelect(isSingleSelect);
- });
- var selectedSegments = this.segments_.filter(function (segment) {
- return segment.isSelected();
- });
- if (isSingleSelect && selectedSegments.length == 0 && this.segments_.length > 0) {
- throw new Error('No segment selected in singleSelect mdc-segmented-button');
- } else if (isSingleSelect && selectedSegments.length > 1) {
- throw new Error('Multiple segments selected in singleSelect mdc-segmented-button');
- }
- };
- MDCSegmentedButton.prototype.destroy = function () {
- this.segments_.forEach(function (segment) {
- segment.destroy();
- });
- this.unlisten(constants_1.events.SELECTED, this.handleSelected);
- _super.prototype.destroy.call(this);
- };
- MDCSegmentedButton.prototype.getDefaultFoundation = function () {
- var _this = this;
- var adapter = {
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- getSegments: function getSegments() {
- return _this.mappedSegments();
- },
- selectSegment: function selectSegment(indexOrSegmentId) {
- var segmentDetail = _this.mappedSegments().find(function (_segmentDetail) {
- return _segmentDetail.index === indexOrSegmentId || _segmentDetail.segmentId === indexOrSegmentId;
- });
- if (segmentDetail) {
- _this.segments_[segmentDetail.index].setSelected();
- }
- },
- unselectSegment: function unselectSegment(indexOrSegmentId) {
- var segmentDetail = _this.mappedSegments().find(function (_segmentDetail) {
- return _segmentDetail.index === indexOrSegmentId || _segmentDetail.segmentId === indexOrSegmentId;
- });
- if (segmentDetail) {
- _this.segments_[segmentDetail.index].setUnselected();
- }
- },
- notifySelectedChange: function notifySelectedChange(detail) {
- _this.emit(constants_1.events.CHANGE, detail, true /* shouldBubble */);
- }
- };
- return new foundation_1.MDCSegmentedButtonFoundation(adapter);
- };
- /**
- * @return Returns readonly list of selected child segments as SegmentDetails
- */
- MDCSegmentedButton.prototype.getSelectedSegments = function () {
- return this.foundation.getSelectedSegments();
- };
- /**
- * Sets identified segment to be selected
- *
- * @param indexOrSegmentId Number index or string segmentId that identifies
- * child segment
- */
- MDCSegmentedButton.prototype.selectSegment = function (indexOrSegmentId) {
- this.foundation.selectSegment(indexOrSegmentId);
- };
- /**
- * Sets identified segment to be not selected
- *
- * @param indexOrSegmentId Number index or string segmentId that identifies
- * child segment
- */
- MDCSegmentedButton.prototype.unselectSegment = function (indexOrSegmentId) {
- this.foundation.unselectSegment(indexOrSegmentId);
- };
- /**
- * @param indexOrSegmentId Number index or string segmentId that identifies
- * child segment
- * @return Returns true if identified child segment is currently selected,
- * otherwise returns false
- */
- MDCSegmentedButton.prototype.isSegmentSelected = function (indexOrSegmentId) {
- return this.foundation.isSegmentSelected(indexOrSegmentId);
- };
- /**
- * @return Returns child segments mapped to readonly SegmentDetail list
- */
- MDCSegmentedButton.prototype.mappedSegments = function () {
- return this.segments_.map(function (segment, index) {
- return {
- index: index,
- selected: segment.isSelected(),
- segmentId: segment.getSegmentId()
- };
- });
- };
- return MDCSegmentedButton;
- }(component_1.MDCComponent);
- exports.MDCSegmentedButton = MDCSegmentedButton;
- /***/ }),
- /***/ "./packages/mdc-segmented-button/segmented-button/constants.ts":
- /*!*********************************************************************!*\
- !*** ./packages/mdc-segmented-button/segmented-button/constants.ts ***!
- \*********************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * Selectors used by segmented-button
- */
- exports.selectors = {
- SEGMENT: '.mdc-segmented-button__segment'
- };
- /**
- * Events received or emitted by segmented-button
- */
- exports.events = {
- SELECTED: 'selected',
- CHANGE: 'change'
- };
- /**
- * Style classes for segmented-button
- */
- exports.cssClasses = {
- SINGLE_SELECT: 'mdc-segmented-button--single-select'
- };
- /***/ }),
- /***/ "./packages/mdc-segmented-button/segmented-button/foundation.ts":
- /*!**********************************************************************!*\
- !*** ./packages/mdc-segmented-button/segmented-button/foundation.ts ***!
- \**********************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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 s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-segmented-button/segmented-button/constants.ts");
- var MDCSegmentedButtonFoundation = /** @class */function (_super) {
- __extends(MDCSegmentedButtonFoundation, _super);
- function MDCSegmentedButtonFoundation(adapter) {
- return _super.call(this, __assign(__assign({}, MDCSegmentedButtonFoundation.defaultAdapter), adapter)) || this;
- }
- Object.defineProperty(MDCSegmentedButtonFoundation, "defaultAdapter", {
- get: function get() {
- return {
- hasClass: function hasClass() {
- return false;
- }, getSegments: function getSegments() {
- return [];
- },
- selectSegment: function selectSegment() {
- return undefined;
- },
- unselectSegment: function unselectSegment() {
- return undefined;
- },
- notifySelectedChange: function notifySelectedChange() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Sets identified child segment to be selected
- *
- * @param indexOrSegmentId Number index or string segmentId that identifies
- * child segment
- */
- MDCSegmentedButtonFoundation.prototype.selectSegment = function (indexOrSegmentId) {
- this.adapter.selectSegment(indexOrSegmentId);
- };
- /**
- * Sets identified child segment to be not selected
- *
- * @param indexOrSegmentId Number index or string segmentId that identifies
- * child segment
- */
- MDCSegmentedButtonFoundation.prototype.unselectSegment = function (indexOrSegmentId) {
- this.adapter.unselectSegment(indexOrSegmentId);
- };
- /**
- * @return Returns currently selected child segments as readonly list of
- * SegmentDetails
- */
- MDCSegmentedButtonFoundation.prototype.getSelectedSegments = function () {
- return this.adapter.getSegments().filter(function (segmentDetail) {
- return segmentDetail.selected;
- });
- };
- /**
- * @param indexOrSegmentId Number index or string segmentId that identifies
- * child segment
- * @return Returns true if identified child segment is currently selected,
- * otherwise returns false
- */
- MDCSegmentedButtonFoundation.prototype.isSegmentSelected = function (indexOrSegmentId) {
- return this.adapter.getSegments().some(function (segmentDetail) {
- return (segmentDetail.index === indexOrSegmentId || segmentDetail.segmentId === indexOrSegmentId) && segmentDetail.selected;
- });
- };
- /**
- * @return Returns true if segmented button is single select, otherwise
- * returns false
- */
- MDCSegmentedButtonFoundation.prototype.isSingleSelect = function () {
- return this.adapter.hasClass(constants_1.cssClasses.SINGLE_SELECT);
- };
- /**
- * Called when child segment's selected status may have changed. If segmented
- * button is single select, unselects all child segments other than identified
- * child segment. Finally, emits event to client.
- *
- * @param detail Child segment affected represented as SegmentDetail
- * @event change With detail - SegmentDetail
- */
- MDCSegmentedButtonFoundation.prototype.handleSelected = function (detail) {
- if (this.isSingleSelect()) {
- this.unselectPrevSelected(detail.index);
- }
- this.adapter.notifySelectedChange(detail);
- };
- /**
- * Sets all child segments to be not selected except for child segment
- * identified by index
- *
- * @param index Index of child segment to not unselect
- */
- MDCSegmentedButtonFoundation.prototype.unselectPrevSelected = function (index) {
- var e_1, _a;
- try {
- for (var _b = __values(this.getSelectedSegments()), _c = _b.next(); !_c.done; _c = _b.next()) {
- var selectedSegment = _c.value;
- if (selectedSegment.index !== index) {
- this.unselectSegment(selectedSegment.index);
- }
- }
- } 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;
- }
- }
- };
- return MDCSegmentedButtonFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSegmentedButtonFoundation = MDCSegmentedButtonFoundation;
- /***/ }),
- /***/ "./packages/mdc-segmented-button/segmented-button/index.ts":
- /*!*****************************************************************!*\
- !*** ./packages/mdc-segmented-button/segmented-button/index.ts ***!
- \*****************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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__(/*! ./foundation */ "./packages/mdc-segmented-button/segmented-button/foundation.ts"));
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-segmented-button/segmented-button/component.ts"));
- /***/ }),
- /***/ "./packages/mdc-select/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-select/component.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/floating-label/component */ "./packages/mdc-floating-label/component.ts");
- var component_3 = __webpack_require__(/*! @material/line-ripple/component */ "./packages/mdc-line-ripple/component.ts");
- var menuSurfaceConstants = __importStar(__webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts"));
- var component_4 = __webpack_require__(/*! @material/menu/component */ "./packages/mdc-menu/component.ts");
- var menuConstants = __importStar(__webpack_require__(/*! @material/menu/constants */ "./packages/mdc-menu/constants.ts"));
- var component_5 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
- var component_6 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-select/foundation.ts");
- var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-select/helper-text/component.ts");
- var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-select/icon/component.ts");
- var MDCSelect = /** @class */function (_super) {
- __extends(MDCSelect, _super);
- function MDCSelect() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCSelect.attachTo = function (root) {
- return new MDCSelect(root);
- };
- MDCSelect.prototype.initialize = function (labelFactory, lineRippleFactory, outlineFactory, menuFactory, iconFactory, helperTextFactory) {
- if (labelFactory === void 0) {
- labelFactory = function labelFactory(el) {
- return new component_2.MDCFloatingLabel(el);
- };
- }
- if (lineRippleFactory === void 0) {
- lineRippleFactory = function lineRippleFactory(el) {
- return new component_3.MDCLineRipple(el);
- };
- }
- if (outlineFactory === void 0) {
- outlineFactory = function outlineFactory(el) {
- return new component_5.MDCNotchedOutline(el);
- };
- }
- if (menuFactory === void 0) {
- menuFactory = function menuFactory(el) {
- return new component_4.MDCMenu(el);
- };
- }
- if (iconFactory === void 0) {
- iconFactory = function iconFactory(el) {
- return new component_8.MDCSelectIcon(el);
- };
- }
- if (helperTextFactory === void 0) {
- helperTextFactory = function helperTextFactory(el) {
- return new component_7.MDCSelectHelperText(el);
- };
- }
- this.selectAnchor = this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
- this.selectedText = this.root.querySelector(constants_1.strings.SELECTED_TEXT_SELECTOR);
- this.hiddenInput = this.root.querySelector(constants_1.strings.HIDDEN_INPUT_SELECTOR);
- if (!this.selectedText) {
- throw new Error('MDCSelect: Missing required element: The following selector must be present: ' + ("'" + constants_1.strings.SELECTED_TEXT_SELECTOR + "'"));
- }
- if (this.selectAnchor.hasAttribute(constants_1.strings.ARIA_CONTROLS)) {
- var helperTextElement = document.getElementById(this.selectAnchor.getAttribute(constants_1.strings.ARIA_CONTROLS));
- if (helperTextElement) {
- this.helperText = helperTextFactory(helperTextElement);
- }
- }
- this.menuSetup(menuFactory);
- var labelElement = this.root.querySelector(constants_1.strings.LABEL_SELECTOR);
- this.label = labelElement ? labelFactory(labelElement) : null;
- var lineRippleElement = this.root.querySelector(constants_1.strings.LINE_RIPPLE_SELECTOR);
- this.lineRipple = lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
- var outlineElement = this.root.querySelector(constants_1.strings.OUTLINE_SELECTOR);
- this.outline = outlineElement ? outlineFactory(outlineElement) : null;
- var leadingIcon = this.root.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
- if (leadingIcon) {
- this.leadingIcon = iconFactory(leadingIcon);
- }
- if (!this.root.classList.contains(constants_1.cssClasses.OUTLINED)) {
- this.ripple = this.createRipple();
- }
- };
- /**
- * Initializes the select's event listeners and internal state based
- * on the environment's state.
- */
- MDCSelect.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleFocus = function () {
- _this.foundation.handleFocus();
- };
- this.handleBlur = function () {
- _this.foundation.handleBlur();
- };
- this.handleClick = function (evt) {
- _this.selectAnchor.focus();
- _this.foundation.handleClick(_this.getNormalizedXCoordinate(evt));
- };
- this.handleKeydown = function (evt) {
- _this.foundation.handleKeydown(evt);
- };
- this.handleMenuItemAction = function (evt) {
- _this.foundation.handleMenuItemAction(evt.detail.index);
- };
- this.handleMenuOpened = function () {
- _this.foundation.handleMenuOpened();
- };
- this.handleMenuClosed = function () {
- _this.foundation.handleMenuClosed();
- };
- this.selectAnchor.addEventListener('focus', this.handleFocus);
- this.selectAnchor.addEventListener('blur', this.handleBlur);
- this.selectAnchor.addEventListener('click', this.handleClick);
- this.selectAnchor.addEventListener('keydown', this.handleKeydown);
- this.menu.listen(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
- this.menu.listen(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
- this.menu.listen(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
- if (this.hiddenInput) {
- if (this.hiddenInput.value) {
- // If the hidden input already has a value, use it to restore the
- // select's value. This can happen e.g. if the user goes back or (in
- // some browsers) refreshes the page.
- this.foundation.setValue(this.hiddenInput.value, /** skipNotify */true);
- this.foundation.layout();
- return;
- }
- this.hiddenInput.value = this.value;
- }
- };
- MDCSelect.prototype.destroy = function () {
- this.selectAnchor.removeEventListener('focus', this.handleFocus);
- this.selectAnchor.removeEventListener('blur', this.handleBlur);
- this.selectAnchor.removeEventListener('keydown', this.handleKeydown);
- this.selectAnchor.removeEventListener('click', this.handleClick);
- this.menu.unlisten(menuSurfaceConstants.strings.CLOSED_EVENT, this.handleMenuClosed);
- this.menu.unlisten(menuSurfaceConstants.strings.OPENED_EVENT, this.handleMenuOpened);
- this.menu.unlisten(menuConstants.strings.SELECTED_EVENT, this.handleMenuItemAction);
- this.menu.destroy();
- if (this.ripple) {
- this.ripple.destroy();
- }
- if (this.outline) {
- this.outline.destroy();
- }
- if (this.leadingIcon) {
- this.leadingIcon.destroy();
- }
- if (this.helperText) {
- this.helperText.destroy();
- }
- _super.prototype.destroy.call(this);
- };
- Object.defineProperty(MDCSelect.prototype, "value", {
- get: function get() {
- return this.foundation.getValue();
- },
- set: function set(value) {
- this.foundation.setValue(value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "selectedIndex", {
- get: function get() {
- return this.foundation.getSelectedIndex();
- },
- set: function set(selectedIndex) {
- this.foundation.setSelectedIndex(selectedIndex, /** closeMenu */true);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "disabled", {
- get: function get() {
- return this.foundation.getDisabled();
- },
- set: function set(disabled) {
- this.foundation.setDisabled(disabled);
- if (this.hiddenInput) {
- this.hiddenInput.disabled = 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, "useDefaultValidation", {
- /**
- * Enables or disables the default validation scheme where a required select
- * must be non-empty. Set to false for custom validation.
- * @param useDefaultValidation Set this to false to ignore default
- * validation scheme.
- */
- set: function set(useDefaultValidation) {
- this.foundation.setUseDefaultValidation(useDefaultValidation);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "valid", {
- /**
- * Checks if the select is in a valid state.
- */
- get: function get() {
- return this.foundation.isValid();
- },
- /**
- * Sets the current invalid state of the select.
- */
- set: function set(isValid) {
- this.foundation.setValid(isValid);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelect.prototype, "required", {
- /**
- * Returns whether the select is required.
- */
- get: function get() {
- return this.foundation.getRequired();
- },
- /**
- * Sets the control to the required state.
- */
- set: function set(isRequired) {
- this.foundation.setRequired(isRequired);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Re-calculates if the notched outline should be notched and if the label
- * should float.
- */
- MDCSelect.prototype.layout = function () {
- this.foundation.layout();
- };
- /**
- * Synchronizes the list of options with the state of the foundation. Call
- * this whenever menu options are dynamically updated.
- */
- MDCSelect.prototype.layoutOptions = function () {
- this.foundation.layoutOptions();
- this.menu.layout();
- // Update cached menuItemValues for adapter.
- this.menuItemValues = this.menu.items.map(function (el) {
- return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
- });
- if (this.hiddenInput) {
- this.hiddenInput.value = this.value;
- }
- };
- MDCSelect.prototype.getDefaultFoundation = function () {
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- var adapter = __assign(__assign(__assign(__assign({}, this.getSelectAdapterMethods()), this.getCommonAdapterMethods()), this.getOutlineAdapterMethods()), this.getLabelAdapterMethods());
- return new foundation_2.MDCSelectFoundation(adapter, this.getFoundationMap());
- };
- /**
- * Handles setup for the menu.
- */
- MDCSelect.prototype.menuSetup = function (menuFactory) {
- this.menuElement = this.root.querySelector(constants_1.strings.MENU_SELECTOR);
- this.menu = menuFactory(this.menuElement);
- this.menu.hasTypeahead = true;
- this.menu.singleSelection = true;
- this.menuItemValues = this.menu.items.map(function (el) {
- return el.getAttribute(constants_1.strings.VALUE_ATTR) || '';
- });
- };
- MDCSelect.prototype.createRipple = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = __assign(__assign({}, component_6.MDCRipple.createAdapter({ root: this.selectAnchor })), { registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- _this.selectAnchor.addEventListener(evtType, handler);
- }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- _this.selectAnchor.removeEventListener(evtType, handler);
- } });
- // tslint:enable:object-literal-sort-keys
- return new component_6.MDCRipple(this.selectAnchor, new foundation_1.MDCRippleFoundation(adapter));
- };
- MDCSelect.prototype.getSelectAdapterMethods = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- getMenuItemAttr: function getMenuItemAttr(menuItem, attr) {
- return menuItem.getAttribute(attr);
- },
- setSelectedText: function setSelectedText(text) {
- _this.selectedText.textContent = text;
- },
- isSelectAnchorFocused: function isSelectAnchorFocused() {
- return document.activeElement === _this.selectAnchor;
- },
- getSelectAnchorAttr: function getSelectAnchorAttr(attr) {
- return _this.selectAnchor.getAttribute(attr);
- },
- setSelectAnchorAttr: function setSelectAnchorAttr(attr, value) {
- _this.selectAnchor.setAttribute(attr, value);
- },
- removeSelectAnchorAttr: function removeSelectAnchorAttr(attr) {
- _this.selectAnchor.removeAttribute(attr);
- },
- addMenuClass: function addMenuClass(className) {
- _this.menuElement.classList.add(className);
- },
- removeMenuClass: function removeMenuClass(className) {
- _this.menuElement.classList.remove(className);
- },
- openMenu: function openMenu() {
- _this.menu.open = true;
- },
- closeMenu: function closeMenu() {
- _this.menu.open = false;
- },
- getAnchorElement: function getAnchorElement() {
- return _this.root.querySelector(constants_1.strings.SELECT_ANCHOR_SELECTOR);
- },
- setMenuAnchorElement: function setMenuAnchorElement(anchorEl) {
- _this.menu.setAnchorElement(anchorEl);
- },
- setMenuAnchorCorner: function setMenuAnchorCorner(anchorCorner) {
- _this.menu.setAnchorCorner(anchorCorner);
- },
- setMenuWrapFocus: function setMenuWrapFocus(wrapFocus) {
- _this.menu.wrapFocus = wrapFocus;
- },
- getSelectedIndex: function getSelectedIndex() {
- var index = _this.menu.selectedIndex;
- return index instanceof Array ? index[0] : index;
- },
- setSelectedIndex: function setSelectedIndex(index) {
- _this.menu.selectedIndex = index;
- },
- focusMenuItemAtIndex: function focusMenuItemAtIndex(index) {
- _this.menu.items[index].focus();
- },
- getMenuItemCount: function getMenuItemCount() {
- return _this.menu.items.length;
- },
- // Cache menu item values. layoutOptions() updates this cache.
- getMenuItemValues: function getMenuItemValues() {
- return _this.menuItemValues;
- },
- getMenuItemTextAtIndex: function getMenuItemTextAtIndex(index) {
- return _this.menu.getPrimaryTextAtIndex(index);
- },
- isTypeaheadInProgress: function isTypeaheadInProgress() {
- return _this.menu.typeaheadInProgress;
- },
- typeaheadMatchItem: function typeaheadMatchItem(nextChar, startingIndex) {
- return _this.menu.typeaheadMatchItem(nextChar, startingIndex);
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- MDCSelect.prototype.getCommonAdapterMethods = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass(className) {
- _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- setRippleCenter: function setRippleCenter(normalizedX) {
- _this.lineRipple && _this.lineRipple.setRippleCenter(normalizedX);
- },
- activateBottomLine: function activateBottomLine() {
- _this.lineRipple && _this.lineRipple.activate();
- },
- deactivateBottomLine: function deactivateBottomLine() {
- _this.lineRipple && _this.lineRipple.deactivate();
- },
- notifyChange: function notifyChange(value) {
- var index = _this.selectedIndex;
- _this.emit(constants_1.strings.CHANGE_EVENT, { value: value, index: index }, true /* shouldBubble */);
- if (_this.hiddenInput) {
- _this.hiddenInput.value = value;
- }
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- MDCSelect.prototype.getOutlineAdapterMethods = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- hasOutline: function hasOutline() {
- return Boolean(_this.outline);
- },
- notchOutline: function notchOutline(labelWidth) {
- _this.outline && _this.outline.notch(labelWidth);
- },
- closeOutline: function closeOutline() {
- _this.outline && _this.outline.closeNotch();
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- MDCSelect.prototype.getLabelAdapterMethods = function () {
- var _this = this;
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- hasLabel: function hasLabel() {
- return !!_this.label;
- },
- floatLabel: function floatLabel(shouldFloat) {
- _this.label && _this.label.float(shouldFloat);
- },
- getLabelWidth: function getLabelWidth() {
- return _this.label ? _this.label.getWidth() : 0;
- },
- setLabelRequired: function setLabelRequired(isRequired) {
- _this.label && _this.label.setRequired(isRequired);
- }
- };
- // tslint:enable:object-literal-sort-keys
- };
- /**
- * Calculates where the line ripple should start based on the x coordinate within the component.
- */
- MDCSelect.prototype.getNormalizedXCoordinate = function (evt) {
- var targetClientRect = evt.target.getBoundingClientRect();
- var xCoordinate = this.isTouchEvent(evt) ? evt.touches[0].clientX : evt.clientX;
- return xCoordinate - targetClientRect.left;
- };
- MDCSelect.prototype.isTouchEvent = function (evt) {
- return Boolean(evt.touches);
- };
- /**
- * Returns a map of all subcomponents to subfoundations.
- */
- MDCSelect.prototype.getFoundationMap = function () {
- return {
- helperText: this.helperText ? this.helperText.foundationForSelect : undefined,
- leadingIcon: this.leadingIcon ? this.leadingIcon.foundationForSelect : undefined
- };
- };
- return MDCSelect;
- }(component_1.MDCComponent);
- exports.MDCSelect = MDCSelect;
- /***/ }),
- /***/ "./packages/mdc-select/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-select/constants.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var cssClasses = {
- ACTIVATED: 'mdc-select--activated',
- DISABLED: 'mdc-select--disabled',
- FOCUSED: 'mdc-select--focused',
- INVALID: 'mdc-select--invalid',
- MENU_INVALID: 'mdc-select__menu--invalid',
- OUTLINED: 'mdc-select--outlined',
- REQUIRED: 'mdc-select--required',
- ROOT: 'mdc-select',
- WITH_LEADING_ICON: 'mdc-select--with-leading-icon'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ARIA_CONTROLS: 'aria-controls',
- ARIA_DESCRIBEDBY: 'aria-describedby',
- ARIA_SELECTED_ATTR: 'aria-selected',
- CHANGE_EVENT: 'MDCSelect:change',
- HIDDEN_INPUT_SELECTOR: 'input[type="hidden"]',
- LABEL_SELECTOR: '.mdc-floating-label',
- LEADING_ICON_SELECTOR: '.mdc-select__icon',
- LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
- MENU_SELECTOR: '.mdc-select__menu',
- OUTLINE_SELECTOR: '.mdc-notched-outline',
- SELECTED_TEXT_SELECTOR: '.mdc-select__selected-text',
- SELECT_ANCHOR_SELECTOR: '.mdc-select__anchor',
- VALUE_ATTR: 'data-value'
- };
- exports.strings = strings;
- var numbers = {
- LABEL_SCALE: 0.75,
- UNSET_INDEX: -1,
- CLICK_DEBOUNCE_TIMEOUT_MS: 330
- };
- exports.numbers = numbers;
- /***/ }),
- /***/ "./packages/mdc-select/foundation.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-select/foundation.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (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 keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
- var constants_1 = __webpack_require__(/*! @material/menu-surface/constants */ "./packages/mdc-menu-surface/constants.ts");
- var constants_2 = __webpack_require__(/*! ./constants */ "./packages/mdc-select/constants.ts");
- 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(__assign({}, MDCSelectFoundation.defaultAdapter), adapter)) || this;
- // Disabled state
- _this.disabled = false;
- // isMenuOpen is used to track the state of the menu by listening to the
- // MDCMenuSurface:closed event For reference, menu.open will return false if
- // the menu is still closing, but isMenuOpen returns false only after the menu
- // has closed
- _this.isMenuOpen = false;
- // By default, select is invalid if it is required but no value is selected.
- _this.useDefaultValidation = true;
- _this.customValidity = true;
- _this.lastSelectedIndex = constants_2.numbers.UNSET_INDEX;
- _this.clickDebounceTimeout = 0;
- _this.recentlyClicked = false;
- _this.leadingIcon = foundationMap.leadingIcon;
- _this.helperText = foundationMap.helperText;
- return _this;
- }
- Object.defineProperty(MDCSelectFoundation, "cssClasses", {
- get: function get() {
- return constants_2.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelectFoundation, "numbers", {
- get: function get() {
- return constants_2.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelectFoundation, "strings", {
- get: function get() {
- return constants_2.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSelectFoundation, "defaultAdapter", {
- /**
- * See {@link MDCSelectAdapter} for typing information on parameters and return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return false;
- },
- activateBottomLine: function activateBottomLine() {
- return undefined;
- },
- deactivateBottomLine: function deactivateBottomLine() {
- return undefined;
- },
- getSelectedIndex: function getSelectedIndex() {
- return -1;
- },
- setSelectedIndex: function setSelectedIndex() {
- return undefined;
- },
- hasLabel: function hasLabel() {
- return false;
- },
- floatLabel: function floatLabel() {
- return undefined;
- },
- getLabelWidth: function getLabelWidth() {
- return 0;
- },
- setLabelRequired: function setLabelRequired() {
- return undefined;
- },
- hasOutline: function hasOutline() {
- return false;
- },
- notchOutline: function notchOutline() {
- return undefined;
- },
- closeOutline: function closeOutline() {
- return undefined;
- },
- setRippleCenter: function setRippleCenter() {
- return undefined;
- },
- notifyChange: function notifyChange() {
- return undefined;
- },
- setSelectedText: function setSelectedText() {
- return undefined;
- },
- isSelectAnchorFocused: function isSelectAnchorFocused() {
- return false;
- },
- getSelectAnchorAttr: function getSelectAnchorAttr() {
- return '';
- },
- setSelectAnchorAttr: function setSelectAnchorAttr() {
- return undefined;
- },
- removeSelectAnchorAttr: function removeSelectAnchorAttr() {
- return undefined;
- },
- addMenuClass: function addMenuClass() {
- return undefined;
- },
- removeMenuClass: function removeMenuClass() {
- return undefined;
- },
- openMenu: function openMenu() {
- return undefined;
- },
- closeMenu: function closeMenu() {
- return undefined;
- },
- getAnchorElement: function getAnchorElement() {
- return null;
- },
- setMenuAnchorElement: function setMenuAnchorElement() {
- return undefined;
- },
- setMenuAnchorCorner: function setMenuAnchorCorner() {
- return undefined;
- },
- setMenuWrapFocus: function setMenuWrapFocus() {
- return undefined;
- },
- focusMenuItemAtIndex: function focusMenuItemAtIndex() {
- return undefined;
- },
- getMenuItemCount: function getMenuItemCount() {
- return 0;
- },
- getMenuItemValues: function getMenuItemValues() {
- return [];
- },
- getMenuItemTextAtIndex: function getMenuItemTextAtIndex() {
- return '';
- },
- isTypeaheadInProgress: function isTypeaheadInProgress() {
- return false;
- },
- typeaheadMatchItem: function typeaheadMatchItem() {
- return -1;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- /** Returns the index of the currently selected menu item, or -1 if none. */
- MDCSelectFoundation.prototype.getSelectedIndex = function () {
- return this.adapter.getSelectedIndex();
- };
- MDCSelectFoundation.prototype.setSelectedIndex = function (index, closeMenu, skipNotify) {
- if (closeMenu === void 0) {
- closeMenu = false;
- }
- if (skipNotify === void 0) {
- skipNotify = false;
- }
- if (index >= this.adapter.getMenuItemCount()) {
- return;
- }
- if (index === constants_2.numbers.UNSET_INDEX) {
- this.adapter.setSelectedText('');
- } else {
- this.adapter.setSelectedText(this.adapter.getMenuItemTextAtIndex(index).trim());
- }
- this.adapter.setSelectedIndex(index);
- if (closeMenu) {
- this.adapter.closeMenu();
- }
- if (!skipNotify && this.lastSelectedIndex !== index) {
- this.handleChange();
- }
- this.lastSelectedIndex = index;
- };
- MDCSelectFoundation.prototype.setValue = function (value, skipNotify) {
- if (skipNotify === void 0) {
- skipNotify = false;
- }
- var index = this.adapter.getMenuItemValues().indexOf(value);
- this.setSelectedIndex(index, /** closeMenu */false, skipNotify);
- };
- MDCSelectFoundation.prototype.getValue = function () {
- var index = this.adapter.getSelectedIndex();
- var menuItemValues = this.adapter.getMenuItemValues();
- return index !== constants_2.numbers.UNSET_INDEX ? menuItemValues[index] : '';
- };
- MDCSelectFoundation.prototype.getDisabled = function () {
- return this.disabled;
- };
- MDCSelectFoundation.prototype.setDisabled = function (isDisabled) {
- this.disabled = isDisabled;
- if (this.disabled) {
- this.adapter.addClass(constants_2.cssClasses.DISABLED);
- this.adapter.closeMenu();
- } else {
- this.adapter.removeClass(constants_2.cssClasses.DISABLED);
- }
- if (this.leadingIcon) {
- this.leadingIcon.setDisabled(this.disabled);
- }
- if (this.disabled) {
- // Prevent click events from focusing select. Simply pointer-events: none
- // is not enough since screenreader clicks may bypass this.
- this.adapter.removeSelectAnchorAttr('tabindex');
- } else {
- this.adapter.setSelectAnchorAttr('tabindex', '0');
- }
- this.adapter.setSelectAnchorAttr('aria-disabled', this.disabled.toString());
- };
- /** Opens the menu. */
- MDCSelectFoundation.prototype.openMenu = function () {
- this.adapter.addClass(constants_2.cssClasses.ACTIVATED);
- this.adapter.openMenu();
- this.isMenuOpen = true;
- this.adapter.setSelectAnchorAttr('aria-expanded', 'true');
- };
- /**
- * @param content Sets the content of the helper text.
- */
- MDCSelectFoundation.prototype.setHelperTextContent = function (content) {
- if (this.helperText) {
- this.helperText.setContent(content);
- }
- };
- /**
- * Re-calculates if the notched outline should be notched and if the label
- * should float.
- */
- MDCSelectFoundation.prototype.layout = function () {
- if (this.adapter.hasLabel()) {
- var optionHasValue = this.getValue().length > 0;
- var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
- var shouldFloatAndNotch = optionHasValue || isFocused;
- var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
- this.notchOutline(shouldFloatAndNotch);
- this.adapter.floatLabel(shouldFloatAndNotch);
- this.adapter.setLabelRequired(isRequired);
- }
- };
- /**
- * Synchronizes the list of options with the state of the foundation. Call
- * this whenever menu options are dynamically updated.
- */
- MDCSelectFoundation.prototype.layoutOptions = function () {
- var menuItemValues = this.adapter.getMenuItemValues();
- var selectedIndex = menuItemValues.indexOf(this.getValue());
- this.setSelectedIndex(selectedIndex, /** closeMenu */false, /** skipNotify */true);
- };
- MDCSelectFoundation.prototype.handleMenuOpened = function () {
- if (this.adapter.getMenuItemValues().length === 0) {
- return;
- }
- // Menu should open to the last selected element, should open to first menu item otherwise.
- var selectedIndex = this.getSelectedIndex();
- var focusItemIndex = selectedIndex >= 0 ? selectedIndex : 0;
- this.adapter.focusMenuItemAtIndex(focusItemIndex);
- };
- MDCSelectFoundation.prototype.handleMenuClosed = function () {
- this.adapter.removeClass(constants_2.cssClasses.ACTIVATED);
- this.isMenuOpen = false;
- this.adapter.setSelectAnchorAttr('aria-expanded', 'false');
- // Unfocus the select if menu is closed without a selection
- if (!this.adapter.isSelectAnchorFocused()) {
- this.blur();
- }
- };
- /**
- * Handles value changes, via change event or programmatic updates.
- */
- MDCSelectFoundation.prototype.handleChange = function () {
- this.layout();
- this.adapter.notifyChange(this.getValue());
- var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
- if (isRequired && this.useDefaultValidation) {
- this.setValid(this.isValid());
- }
- };
- MDCSelectFoundation.prototype.handleMenuItemAction = function (index) {
- this.setSelectedIndex(index, /** closeMenu */true);
- };
- /**
- * Handles focus events from select element.
- */
- MDCSelectFoundation.prototype.handleFocus = function () {
- this.adapter.addClass(constants_2.cssClasses.FOCUSED);
- this.layout();
- this.adapter.activateBottomLine();
- };
- /**
- * Handles blur events from select element.
- */
- MDCSelectFoundation.prototype.handleBlur = function () {
- if (this.isMenuOpen) {
- return;
- }
- this.blur();
- };
- MDCSelectFoundation.prototype.handleClick = function (normalizedX) {
- if (this.disabled || this.recentlyClicked) {
- return;
- }
- this.setClickDebounceTimeout();
- if (this.isMenuOpen) {
- this.adapter.closeMenu();
- return;
- }
- this.adapter.setRippleCenter(normalizedX);
- this.openMenu();
- };
- /**
- * Handles keydown events on select element. Depending on the type of
- * character typed, does typeahead matching or opens menu.
- */
- MDCSelectFoundation.prototype.handleKeydown = function (event) {
- if (this.isMenuOpen || !this.adapter.hasClass(constants_2.cssClasses.FOCUSED)) {
- return;
- }
- var isEnter = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ENTER;
- var isSpace = keyboard_1.normalizeKey(event) === keyboard_1.KEY.SPACEBAR;
- var arrowUp = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_UP;
- var arrowDown = keyboard_1.normalizeKey(event) === keyboard_1.KEY.ARROW_DOWN;
- // Typeahead
- if (!isSpace && event.key && event.key.length === 1 || isSpace && this.adapter.isTypeaheadInProgress()) {
- var key = isSpace ? ' ' : event.key;
- var typeaheadNextIndex = this.adapter.typeaheadMatchItem(key, this.getSelectedIndex());
- if (typeaheadNextIndex >= 0) {
- this.setSelectedIndex(typeaheadNextIndex);
- }
- event.preventDefault();
- return;
- }
- if (!isEnter && !isSpace && !arrowUp && !arrowDown) {
- return;
- }
- // Increment/decrement index as necessary and open menu.
- if (arrowUp && this.getSelectedIndex() > 0) {
- this.setSelectedIndex(this.getSelectedIndex() - 1);
- } else if (arrowDown && this.getSelectedIndex() < this.adapter.getMenuItemCount() - 1) {
- this.setSelectedIndex(this.getSelectedIndex() + 1);
- }
- this.openMenu();
- event.preventDefault();
- };
- /**
- * Opens/closes the notched outline.
- */
- MDCSelectFoundation.prototype.notchOutline = function (openNotch) {
- if (!this.adapter.hasOutline()) {
- return;
- }
- var isFocused = this.adapter.hasClass(constants_2.cssClasses.FOCUSED);
- if (openNotch) {
- var labelScale = constants_2.numbers.LABEL_SCALE;
- var labelWidth = this.adapter.getLabelWidth() * labelScale;
- this.adapter.notchOutline(labelWidth);
- } else if (!isFocused) {
- this.adapter.closeOutline();
- }
- };
- /**
- * Sets the aria label of the leading icon.
- */
- MDCSelectFoundation.prototype.setLeadingIconAriaLabel = function (label) {
- if (this.leadingIcon) {
- this.leadingIcon.setAriaLabel(label);
- }
- };
- /**
- * Sets the text content of the leading icon.
- */
- MDCSelectFoundation.prototype.setLeadingIconContent = function (content) {
- if (this.leadingIcon) {
- this.leadingIcon.setContent(content);
- }
- };
- MDCSelectFoundation.prototype.setUseDefaultValidation = function (useDefaultValidation) {
- this.useDefaultValidation = useDefaultValidation;
- };
- MDCSelectFoundation.prototype.setValid = function (isValid) {
- if (!this.useDefaultValidation) {
- this.customValidity = isValid;
- }
- this.adapter.setSelectAnchorAttr('aria-invalid', (!isValid).toString());
- if (isValid) {
- this.adapter.removeClass(constants_2.cssClasses.INVALID);
- this.adapter.removeMenuClass(constants_2.cssClasses.MENU_INVALID);
- } else {
- this.adapter.addClass(constants_2.cssClasses.INVALID);
- this.adapter.addMenuClass(constants_2.cssClasses.MENU_INVALID);
- }
- this.syncHelperTextValidity(isValid);
- };
- MDCSelectFoundation.prototype.isValid = function () {
- if (this.useDefaultValidation && this.adapter.hasClass(constants_2.cssClasses.REQUIRED) && !this.adapter.hasClass(constants_2.cssClasses.DISABLED)) {
- // See notes for required attribute under https://www.w3.org/TR/html52/sec-forms.html#the-select-element
- // TL;DR: Invalid if no index is selected, or if the first index is selected and has an empty value.
- return this.getSelectedIndex() !== constants_2.numbers.UNSET_INDEX && (this.getSelectedIndex() !== 0 || Boolean(this.getValue()));
- }
- return this.customValidity;
- };
- MDCSelectFoundation.prototype.setRequired = function (isRequired) {
- if (isRequired) {
- this.adapter.addClass(constants_2.cssClasses.REQUIRED);
- } else {
- this.adapter.removeClass(constants_2.cssClasses.REQUIRED);
- }
- this.adapter.setSelectAnchorAttr('aria-required', isRequired.toString());
- this.adapter.setLabelRequired(isRequired);
- };
- MDCSelectFoundation.prototype.getRequired = function () {
- return this.adapter.getSelectAnchorAttr('aria-required') === 'true';
- };
- MDCSelectFoundation.prototype.init = function () {
- var anchorEl = this.adapter.getAnchorElement();
- if (anchorEl) {
- this.adapter.setMenuAnchorElement(anchorEl);
- this.adapter.setMenuAnchorCorner(constants_1.Corner.BOTTOM_START);
- }
- this.adapter.setMenuWrapFocus(false);
- this.setDisabled(this.adapter.hasClass(constants_2.cssClasses.DISABLED));
- this.syncHelperTextValidity(!this.adapter.hasClass(constants_2.cssClasses.INVALID));
- this.layout();
- this.layoutOptions();
- };
- /**
- * Unfocuses the select component.
- */
- MDCSelectFoundation.prototype.blur = function () {
- this.adapter.removeClass(constants_2.cssClasses.FOCUSED);
- this.layout();
- this.adapter.deactivateBottomLine();
- var isRequired = this.adapter.hasClass(constants_2.cssClasses.REQUIRED);
- if (isRequired && this.useDefaultValidation) {
- this.setValid(this.isValid());
- }
- };
- MDCSelectFoundation.prototype.syncHelperTextValidity = function (isValid) {
- if (!this.helperText) {
- return;
- }
- this.helperText.setValidity(isValid);
- var helperTextVisible = this.helperText.isVisible();
- var helperTextId = this.helperText.getId();
- if (helperTextVisible && helperTextId) {
- this.adapter.setSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY, helperTextId);
- } else {
- // Needed because screenreaders will read labels pointed to by
- // `aria-describedby` even if they are `aria-hidden`.
- this.adapter.removeSelectAnchorAttr(constants_2.strings.ARIA_DESCRIBEDBY);
- }
- };
- MDCSelectFoundation.prototype.setClickDebounceTimeout = function () {
- var _this = this;
- clearTimeout(this.clickDebounceTimeout);
- this.clickDebounceTimeout = setTimeout(function () {
- _this.recentlyClicked = false;
- }, constants_2.numbers.CLICK_DEBOUNCE_TIMEOUT_MS);
- this.recentlyClicked = true;
- };
- return MDCSelectFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSelectFoundation = MDCSelectFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCSelectFoundation;
- /***/ }),
- /***/ "./packages/mdc-select/helper-text/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, "foundationForSelect", {
- // Provided for access by MDCSelect component
- 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);
- },
- 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;
- }
- };
- // 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_VALIDATION_MSG: 'mdc-select-helper-text--validation-msg',
- HELPER_TEXT_VALIDATION_MSG_PERSISTENT: 'mdc-select-helper-text--validation-msg-persistent'
- };
- exports.cssClasses = cssClasses;
- /***/ }),
- /***/ "./packages/mdc-select/helper-text/foundation.ts":
- /*!*******************************************************!*\
- !*** ./packages/mdc-select/helper-text/foundation.ts ***!
- \*******************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (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(__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;
- },
- getAttr: function getAttr() {
- return null;
- },
- removeAttr: function removeAttr() {
- return undefined;
- },
- setContent: function setContent() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return The ID of the helper text, or null if none is set.
- */
- MDCSelectHelperTextFoundation.prototype.getId = function () {
- return this.adapter.getAttr('id');
- };
- /**
- * @return Whether the helper text is currently visible.
- */
- MDCSelectHelperTextFoundation.prototype.isVisible = function () {
- return this.adapter.getAttr(constants_1.strings.ARIA_HIDDEN) !== 'true';
- };
- /**
- * Sets the content of the helper text field.
- */
- MDCSelectHelperTextFoundation.prototype.setContent = function (content) {
- this.adapter.setContent(content);
- };
- /**
- * Sets the helper text to act as a validation message.
- * By default, validation messages are hidden when the select is valid and
- * visible when the select is invalid.
- *
- * @param isValidation True to make the helper text act as an error validation
- * message.
- */
- MDCSelectHelperTextFoundation.prototype.setValidation = function (isValidation) {
- if (isValidation) {
- this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
- } else {
- this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
- }
- };
- /**
- * Sets the persistency of the validation helper text.
- * This keeps the validation message visible even if the select is valid,
- * though it will be displayed in the normal (grey) color.
- */
- MDCSelectHelperTextFoundation.prototype.setValidationMsgPersistent = function (isPersistent) {
- if (isPersistent) {
- this.adapter.addClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
- } else {
- this.adapter.removeClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
- }
- };
- /**
- * When acting as a validation message, shows/hides the helper text and
- * triggers alerts as necessary based on the select's validity.
- */
- MDCSelectHelperTextFoundation.prototype.setValidity = function (selectIsValid) {
- var isValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
- if (!isValidationMsg) {
- // Non-validating helper-text is always displayed and does not participate
- // in validation logic.
- return;
- }
- var isPersistentValidationMsg = this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG_PERSISTENT);
- // Validating helper text is displayed if select is invalid, unless it is
- // set as persistent, in which case it always displays.
- var msgShouldDisplay = !selectIsValid || isPersistentValidationMsg;
- if (msgShouldDisplay) {
- this.showToScreenReader();
- // In addition to displaying, also trigger an alert if the select
- // has become invalid.
- if (!selectIsValid) {
- this.adapter.setAttr(constants_1.strings.ROLE, 'alert');
- } else {
- this.adapter.removeAttr(constants_1.strings.ROLE);
- }
- return;
- }
- // Hide everything.
- this.adapter.removeAttr(constants_1.strings.ROLE);
- this.hide();
- };
- /**
- * Makes the helper text visible to screen readers.
- */
- MDCSelectHelperTextFoundation.prototype.showToScreenReader = function () {
- this.adapter.removeAttr(constants_1.strings.ARIA_HIDDEN);
- };
- /**
- * Hides the help text from screen readers.
- */
- MDCSelectHelperTextFoundation.prototype.hide = function () {
- this.adapter.setAttr(constants_1.strings.ARIA_HIDDEN, 'true');
- };
- return MDCSelectHelperTextFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSelectHelperTextFoundation = MDCSelectHelperTextFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCSelectHelperTextFoundation;
- /***/ }),
- /***/ "./packages/mdc-select/helper-text/index.ts":
- /*!**************************************************!*\
- !*** ./packages/mdc-select/helper-text/index.ts ***!
- \**************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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, "foundationForSelect", {
- // Provided for access by MDCSelect component
- 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(__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 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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 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 constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-slider/constants.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-slider/foundation.ts");
- var types_1 = __webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts");
- /** Vanilla JS implementation of slider component. */
- var MDCSlider = /** @class */function (_super) {
- __extends(MDCSlider, _super);
- function MDCSlider() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.skipInitialUIUpdate = false;
- // Function that maps a slider value to the value of the `aria-valuetext`
- // attribute on the thumb element.
- _this.valueToAriaValueTextFn = null;
- return _this;
- }
- MDCSlider.attachTo = function (root, options) {
- if (options === void 0) {
- options = {};
- }
- return new MDCSlider(root, undefined, options);
- };
- MDCSlider.prototype.getDefaultFoundation = function () {
- var _this = this;
- // 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) {
- _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- addThumbClass: function addThumbClass(className, thumb) {
- _this.getThumbEl(thumb).classList.add(className);
- },
- removeThumbClass: function removeThumbClass(className, thumb) {
- _this.getThumbEl(thumb).classList.remove(className);
- },
- getAttribute: function getAttribute(attribute) {
- return _this.root.getAttribute(attribute);
- },
- getInputValue: function getInputValue(thumb) {
- return _this.getInput(thumb).value;
- },
- setInputValue: function setInputValue(value, thumb) {
- _this.getInput(thumb).value = value;
- },
- getInputAttribute: function getInputAttribute(attribute, thumb) {
- return _this.getInput(thumb).getAttribute(attribute);
- },
- setInputAttribute: function setInputAttribute(attribute, value, thumb) {
- _this.getInput(thumb).setAttribute(attribute, value);
- },
- removeInputAttribute: function removeInputAttribute(attribute, thumb) {
- _this.getInput(thumb).removeAttribute(attribute);
- },
- focusInput: function focusInput(thumb) {
- _this.getInput(thumb).focus();
- },
- isInputFocused: function isInputFocused(thumb) {
- return _this.getInput(thumb) === document.activeElement;
- },
- getThumbKnobWidth: function getThumbKnobWidth(thumb) {
- return _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.THUMB_KNOB).getBoundingClientRect().width;
- },
- getThumbBoundingClientRect: function getThumbBoundingClientRect(thumb) {
- return _this.getThumbEl(thumb).getBoundingClientRect();
- },
- getBoundingClientRect: function getBoundingClientRect() {
- return _this.root.getBoundingClientRect();
- },
- isRTL: function isRTL() {
- return getComputedStyle(_this.root).direction === 'rtl';
- },
- setThumbStyleProperty: function setThumbStyleProperty(propertyName, value, thumb) {
- _this.getThumbEl(thumb).style.setProperty(propertyName, value);
- },
- removeThumbStyleProperty: function removeThumbStyleProperty(propertyName, thumb) {
- _this.getThumbEl(thumb).style.removeProperty(propertyName);
- },
- setTrackActiveStyleProperty: function setTrackActiveStyleProperty(propertyName, value) {
- _this.trackActive.style.setProperty(propertyName, value);
- },
- removeTrackActiveStyleProperty: function removeTrackActiveStyleProperty(propertyName) {
- _this.trackActive.style.removeProperty(propertyName);
- },
- setValueIndicatorText: function setValueIndicatorText(value, thumb) {
- var valueIndicatorEl = _this.getThumbEl(thumb).querySelector("." + constants_1.cssClasses.VALUE_INDICATOR_TEXT);
- valueIndicatorEl.textContent = String(value);
- },
- getValueToAriaValueTextFn: function getValueToAriaValueTextFn() {
- return _this.valueToAriaValueTextFn;
- },
- updateTickMarks: function updateTickMarks(tickMarks) {
- var tickMarksContainer = _this.root.querySelector("." + constants_1.cssClasses.TICK_MARKS_CONTAINER);
- if (!tickMarksContainer) {
- tickMarksContainer = document.createElement('div');
- tickMarksContainer.classList.add(constants_1.cssClasses.TICK_MARKS_CONTAINER);
- var track = _this.root.querySelector("." + constants_1.cssClasses.TRACK);
- track.appendChild(tickMarksContainer);
- }
- if (tickMarks.length !== tickMarksContainer.children.length) {
- tickMarksContainer.innerHTML = '';
- _this.addTickMarks(tickMarksContainer, tickMarks);
- } else {
- _this.updateTickMarks(tickMarksContainer, tickMarks);
- }
- },
- setPointerCapture: function setPointerCapture(pointerId) {
- _this.root.setPointerCapture(pointerId);
- },
- emitChangeEvent: function emitChangeEvent(value, thumb) {
- _this.emit(constants_1.events.CHANGE, { value: value, thumb: thumb });
- },
- emitInputEvent: function emitInputEvent(value, thumb) {
- _this.emit(constants_1.events.INPUT, { value: value, thumb: thumb });
- },
- emitDragStartEvent: function emitDragStartEvent(_, thumb) {
- // Emitting event is not yet implemented. See issue:
- // https://github.com/material-components/material-components-web/issues/6448
- _this.getRipple(thumb).activate();
- },
- emitDragEndEvent: function emitDragEndEvent(_, thumb) {
- // Emitting event is not yet implemented. See issue:
- // https://github.com/material-components/material-components-web/issues/6448
- _this.getRipple(thumb).deactivate();
- },
- registerEventHandler: function registerEventHandler(evtType, handler) {
- _this.listen(evtType, handler);
- },
- deregisterEventHandler: function deregisterEventHandler(evtType, handler) {
- _this.unlisten(evtType, handler);
- },
- registerThumbEventHandler: function registerThumbEventHandler(thumb, evtType, handler) {
- _this.getThumbEl(thumb).addEventListener(evtType, handler);
- },
- deregisterThumbEventHandler: function deregisterThumbEventHandler(thumb, evtType, handler) {
- _this.getThumbEl(thumb).removeEventListener(evtType, handler);
- },
- registerInputEventHandler: function registerInputEventHandler(thumb, evtType, handler) {
- _this.getInput(thumb).addEventListener(evtType, handler);
- },
- deregisterInputEventHandler: function deregisterInputEventHandler(thumb, evtType, handler) {
- _this.getInput(thumb).removeEventListener(evtType, handler);
- },
- registerBodyEventHandler: function registerBodyEventHandler(evtType, handler) {
- document.body.addEventListener(evtType, handler);
- },
- deregisterBodyEventHandler: function deregisterBodyEventHandler(evtType, handler) {
- document.body.removeEventListener(evtType, handler);
- },
- registerWindowEventHandler: function registerWindowEventHandler(evtType, handler) {
- window.addEventListener(evtType, handler);
- },
- deregisterWindowEventHandler: function deregisterWindowEventHandler(evtType, handler) {
- window.removeEventListener(evtType, handler);
- }
- };
- return new foundation_2.MDCSliderFoundation(adapter);
- };
- /**
- * Initializes component, with the following options:
- * - `skipInitialUIUpdate`: Whether to skip updating the UI when initially
- * syncing with the DOM. This should be enabled when the slider position
- * is set before component initialization.
- */
- MDCSlider.prototype.initialize = function (_a) {
- var skipInitialUIUpdate = (_a === void 0 ? {} : _a).skipInitialUIUpdate;
- this.inputs = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.INPUT));
- this.thumbs = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.THUMB));
- this.trackActive = this.root.querySelector("." + constants_1.cssClasses.TRACK_ACTIVE);
- this.ripples = this.createRipples();
- if (skipInitialUIUpdate) {
- this.skipInitialUIUpdate = true;
- }
- };
- MDCSlider.prototype.initialSyncWithDOM = function () {
- this.foundation.layout({ skipUpdateUI: this.skipInitialUIUpdate });
- };
- /** Redraws UI based on DOM (e.g. element dimensions, RTL). */
- MDCSlider.prototype.layout = function () {
- this.foundation.layout();
- };
- MDCSlider.prototype.getValueStart = function () {
- return this.foundation.getValueStart();
- };
- MDCSlider.prototype.setValueStart = function (valueStart) {
- this.foundation.setValueStart(valueStart);
- };
- MDCSlider.prototype.getValue = function () {
- return this.foundation.getValue();
- };
- MDCSlider.prototype.setValue = function (value) {
- this.foundation.setValue(value);
- };
- /** @return Slider disabled state. */
- MDCSlider.prototype.getDisabled = function () {
- return this.foundation.getDisabled();
- };
- /** Sets slider disabled state. */
- MDCSlider.prototype.setDisabled = function (disabled) {
- this.foundation.setDisabled(disabled);
- };
- /**
- * Sets a function that maps the slider value to the value of the
- * `aria-valuetext` attribute on the thumb element.
- */
- MDCSlider.prototype.setValueToAriaValueTextFn = function (mapFn) {
- this.valueToAriaValueTextFn = mapFn;
- };
- MDCSlider.prototype.getThumbEl = function (thumb) {
- return thumb === types_1.Thumb.END ? this.thumbs[this.thumbs.length - 1] : this.thumbs[0];
- };
- MDCSlider.prototype.getInput = function (thumb) {
- return thumb === types_1.Thumb.END ? this.inputs[this.inputs.length - 1] : this.inputs[0];
- };
- MDCSlider.prototype.getRipple = function (thumb) {
- return thumb === types_1.Thumb.END ? this.ripples[this.ripples.length - 1] : this.ripples[0];
- };
- /** Adds tick mark elements to the given container. */
- MDCSlider.prototype.addTickMarks = function (tickMarkContainer, tickMarks) {
- var fragment = document.createDocumentFragment();
- for (var i = 0; i < tickMarks.length; i++) {
- var div = document.createElement('div');
- var tickMarkClass = tickMarks[i] === types_1.TickMark.ACTIVE ? constants_1.cssClasses.TICK_MARK_ACTIVE : constants_1.cssClasses.TICK_MARK_INACTIVE;
- div.classList.add(tickMarkClass);
- fragment.appendChild(div);
- }
- tickMarkContainer.appendChild(fragment);
- };
- /** Updates tick mark elements' classes in the given container. */
- MDCSlider.prototype.updateTickMarks = function (tickMarkContainer, tickMarks) {
- var tickMarkEls = Array.from(tickMarkContainer.children);
- for (var i = 0; i < tickMarkEls.length; i++) {
- if (tickMarks[i] === types_1.TickMark.ACTIVE) {
- tickMarkEls[i].classList.add(constants_1.cssClasses.TICK_MARK_ACTIVE);
- tickMarkEls[i].classList.remove(constants_1.cssClasses.TICK_MARK_INACTIVE);
- } else {
- tickMarkEls[i].classList.add(constants_1.cssClasses.TICK_MARK_INACTIVE);
- tickMarkEls[i].classList.remove(constants_1.cssClasses.TICK_MARK_ACTIVE);
- }
- }
- };
- /** Initializes thumb ripples. */
- MDCSlider.prototype.createRipples = function () {
- var ripples = [];
- var rippleSurfaces = [].slice.call(this.root.querySelectorAll("." + constants_1.cssClasses.THUMB));
- var _loop_1 = function _loop_1(i) {
- var rippleSurface = rippleSurfaces[i];
- // Use the corresponding input as the focus source for the ripple (i.e.
- // when the input is focused, the ripple is in the focused state).
- var input = this_1.inputs[i];
- var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this_1)), { addClass: function addClass(className) {
- rippleSurface.classList.add(className);
- }, computeBoundingRect: function computeBoundingRect() {
- return rippleSurface.getBoundingClientRect();
- }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- input.removeEventListener(evtType, handler);
- }, isSurfaceActive: function isSurfaceActive() {
- return ponyfill_1.matches(input, ':active');
- }, isUnbounded: function isUnbounded() {
- return true;
- }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- input.addEventListener(evtType, handler, events_1.applyPassive());
- }, removeClass: function removeClass(className) {
- rippleSurface.classList.remove(className);
- }, updateCssVariable: function updateCssVariable(varName, value) {
- rippleSurface.style.setProperty(varName, value);
- } });
- var ripple = new component_2.MDCRipple(rippleSurface, new foundation_1.MDCRippleFoundation(adapter));
- ripple.unbounded = true;
- ripples.push(ripple);
- };
- var this_1 = this;
- for (var i = 0; i < rippleSurfaces.length; i++) {
- _loop_1(i);
- }
- return ripples;
- };
- 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 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /** Slider element classes. */
- exports.cssClasses = {
- DISABLED: 'mdc-slider--disabled',
- DISCRETE: 'mdc-slider--discrete',
- INPUT: 'mdc-slider__input',
- RANGE: 'mdc-slider--range',
- THUMB: 'mdc-slider__thumb',
- THUMB_KNOB: 'mdc-slider__thumb-knob',
- // Class added to the top thumb (for overlapping thumbs in range slider).
- THUMB_TOP: 'mdc-slider__thumb--top',
- THUMB_WITH_INDICATOR: 'mdc-slider__thumb--with-indicator',
- TICK_MARKS: 'mdc-slider--tick-marks',
- TICK_MARKS_CONTAINER: 'mdc-slider__tick-marks',
- TICK_MARK_ACTIVE: 'mdc-slider__tick-mark--active',
- TICK_MARK_INACTIVE: 'mdc-slider__tick-mark--inactive',
- TRACK: 'mdc-slider__track',
- // The active track fill element that will be scaled as the value changes.
- TRACK_ACTIVE: 'mdc-slider__track--active_fill',
- VALUE_INDICATOR_TEXT: 'mdc-slider__value-indicator-text'
- };
- /** Slider numbers. */
- exports.numbers = {
- // Default step size.
- STEP_SIZE: 1,
- // Minimum absolute difference between clientX of move event / down event
- // for which to update thumb, in the case of overlapping thumbs.
- // This is needed to reduce chances of choosing the thumb based on
- // pointer jitter.
- THUMB_UPDATE_MIN_PX: 5
- };
- /** Slider attributes. */
- exports.attributes = {
- ARIA_DISABLED: 'aria-disabled',
- ARIA_VALUEMAX: 'aria-valuemax',
- ARIA_VALUEMIN: 'aria-valuemin',
- ARIA_VALUENOW: 'aria-valuenow',
- ARIA_VALUETEXT: 'aria-valuetext',
- INPUT_DISABLED: 'disabled',
- INPUT_MIN: 'min',
- INPUT_MAX: 'max',
- INPUT_VALUE: 'value',
- INPUT_STEP: 'step'
- };
- /** Slider events. */
- exports.events = {
- CHANGE: 'MDCSlider:change',
- INPUT: 'MDCSlider:input'
- };
- /***/ }),
- /***/ "./packages/mdc-slider/foundation.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-slider/foundation.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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 types_1 = __webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts");
- // Accessing `window` without a `typeof` check will throw on Node environments.
- var HAS_WINDOW = typeof window !== 'undefined';
- /**
- * Foundation class for slider. Responsibilities include:
- * - Updating slider values (internal state and DOM updates) based on client
- * 'x' position.
- * - Updating DOM after slider property updates (e.g. min, max).
- */
- var MDCSliderFoundation = /** @class */function (_super) {
- __extends(MDCSliderFoundation, _super);
- function MDCSliderFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCSliderFoundation.defaultAdapter), adapter)) || this;
- // Whether the initial styles (to position the thumb, before component
- // initialization) have been removed.
- _this.initialStylesRemoved = false;
- _this.isDisabled = false;
- _this.isDiscrete = false;
- _this.step = constants_1.numbers.STEP_SIZE;
- _this.hasTickMarks = false;
- // The following properties are only set for range sliders.
- _this.isRange = false;
- // Tracks the thumb being moved across a slider pointer interaction (down,
- // move event).
- _this.thumb = null;
- // `clientX` from the most recent down event. Used in subsequent move
- // events to determine which thumb to move (in the case of
- // overlapping thumbs).
- _this.downEventClientX = null;
- // Width of the start thumb knob.
- _this.startThumbKnobWidth = 0;
- // Width of the end thumb knob.
- _this.endThumbKnobWidth = 0;
- return _this;
- }
- 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;
- },
- addThumbClass: function addThumbClass() {
- return undefined;
- },
- removeThumbClass: function removeThumbClass() {
- return undefined;
- },
- getAttribute: function getAttribute() {
- return null;
- },
- getInputValue: function getInputValue() {
- return '';
- },
- setInputValue: function setInputValue() {
- return undefined;
- },
- getInputAttribute: function getInputAttribute() {
- return null;
- },
- setInputAttribute: function setInputAttribute() {
- return null;
- },
- removeInputAttribute: function removeInputAttribute() {
- return null;
- },
- focusInput: function focusInput() {
- return undefined;
- },
- isInputFocused: function isInputFocused() {
- return false;
- },
- getThumbKnobWidth: function getThumbKnobWidth() {
- return 0;
- },
- getThumbBoundingClientRect: function getThumbBoundingClientRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- getBoundingClientRect: function getBoundingClientRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- isRTL: function isRTL() {
- return false;
- },
- setThumbStyleProperty: function setThumbStyleProperty() {
- return undefined;
- },
- removeThumbStyleProperty: function removeThumbStyleProperty() {
- return undefined;
- },
- setTrackActiveStyleProperty: function setTrackActiveStyleProperty() {
- return undefined;
- },
- removeTrackActiveStyleProperty: function removeTrackActiveStyleProperty() {
- return undefined;
- },
- setValueIndicatorText: function setValueIndicatorText() {
- return undefined;
- },
- getValueToAriaValueTextFn: function getValueToAriaValueTextFn() {
- return null;
- },
- updateTickMarks: function updateTickMarks() {
- return undefined;
- },
- setPointerCapture: function setPointerCapture() {
- return undefined;
- },
- emitChangeEvent: function emitChangeEvent() {
- return undefined;
- },
- emitInputEvent: function emitInputEvent() {
- return undefined;
- },
- emitDragStartEvent: function emitDragStartEvent() {
- return undefined;
- },
- emitDragEndEvent: function emitDragEndEvent() {
- return undefined;
- },
- registerEventHandler: function registerEventHandler() {
- return undefined;
- },
- deregisterEventHandler: function deregisterEventHandler() {
- return undefined;
- },
- registerThumbEventHandler: function registerThumbEventHandler() {
- return undefined;
- },
- deregisterThumbEventHandler: function deregisterThumbEventHandler() {
- return undefined;
- },
- registerInputEventHandler: function registerInputEventHandler() {
- return undefined;
- },
- deregisterInputEventHandler: function deregisterInputEventHandler() {
- return undefined;
- },
- registerBodyEventHandler: function registerBodyEventHandler() {
- return undefined;
- },
- deregisterBodyEventHandler: function deregisterBodyEventHandler() {
- return undefined;
- },
- registerWindowEventHandler: function registerWindowEventHandler() {
- return undefined;
- },
- deregisterWindowEventHandler: function deregisterWindowEventHandler() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCSliderFoundation.prototype.init = function () {
- var _this = this;
- this.isDisabled = this.adapter.hasClass(constants_1.cssClasses.DISABLED);
- this.isDiscrete = this.adapter.hasClass(constants_1.cssClasses.DISCRETE);
- this.hasTickMarks = this.adapter.hasClass(constants_1.cssClasses.TICK_MARKS);
- this.isRange = this.adapter.hasClass(constants_1.cssClasses.RANGE);
- var min = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_MIN, this.isRange ? types_1.Thumb.START : types_1.Thumb.END), constants_1.attributes.INPUT_MIN);
- var max = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_MAX, types_1.Thumb.END), constants_1.attributes.INPUT_MAX);
- var value = this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_VALUE, types_1.Thumb.END), constants_1.attributes.INPUT_VALUE);
- var valueStart = this.isRange ? this.convertAttributeValueToNumber(this.adapter.getInputAttribute(constants_1.attributes.INPUT_VALUE, types_1.Thumb.START), constants_1.attributes.INPUT_VALUE) : min;
- this.validateProperties({ min: min, max: max, value: value, valueStart: valueStart });
- this.min = min;
- this.max = max;
- this.value = value;
- this.valueStart = valueStart;
- this.valueBeforeDownEvent = value;
- this.valueStartBeforeDownEvent = valueStart;
- var stepAttr = this.adapter.getInputAttribute(constants_1.attributes.INPUT_STEP, types_1.Thumb.END);
- if (stepAttr) {
- this.step = this.convertAttributeValueToNumber(stepAttr, constants_1.attributes.INPUT_STEP);
- }
- if (this.step <= 0) {
- throw new Error("MDCSliderFoundation: step must be a positive number. " + ("Current step: " + this.step));
- }
- this.mousedownOrTouchstartListener = this.handleMousedownOrTouchstart.bind(this);
- this.moveListener = this.handleMove.bind(this);
- this.pointerdownListener = this.handlePointerdown.bind(this);
- this.pointerupListener = this.handlePointerup.bind(this);
- this.thumbMouseenterListener = this.handleThumbMouseenter.bind(this);
- this.thumbMouseleaveListener = this.handleThumbMouseleave.bind(this);
- this.inputStartChangeListener = function () {
- _this.handleInputChange(types_1.Thumb.START);
- };
- this.inputEndChangeListener = function () {
- _this.handleInputChange(types_1.Thumb.END);
- };
- this.inputStartFocusListener = function () {
- _this.handleInputFocus(types_1.Thumb.START);
- };
- this.inputEndFocusListener = function () {
- _this.handleInputFocus(types_1.Thumb.END);
- };
- this.inputStartBlurListener = function () {
- _this.handleInputBlur(types_1.Thumb.START);
- };
- this.inputEndBlurListener = function () {
- _this.handleInputBlur(types_1.Thumb.END);
- };
- this.resizeListener = this.handleResize.bind(this);
- this.registerEventHandlers();
- };
- MDCSliderFoundation.prototype.destroy = function () {
- this.deregisterEventHandlers();
- };
- MDCSliderFoundation.prototype.getMin = function () {
- return this.min;
- };
- MDCSliderFoundation.prototype.getMax = function () {
- return this.max;
- };
- /**
- * - For single point sliders, returns the thumb value.
- * - For range (two-thumb) sliders, returns the end thumb's value.
- */
- MDCSliderFoundation.prototype.getValue = function () {
- return this.value;
- };
- /**
- * - For single point sliders, sets the thumb value.
- * - For range (two-thumb) sliders, sets the end thumb's value.
- */
- MDCSliderFoundation.prototype.setValue = function (value) {
- if (this.isRange && value < this.valueStart) {
- throw new Error("end thumb value (" + value + ") must be >= start thumb " + ("value (" + this.valueStart + ")"));
- }
- this.updateValue(value, types_1.Thumb.END);
- };
- /**
- * Only applicable for range sliders.
- * @return The start thumb's value.
- */
- MDCSliderFoundation.prototype.getValueStart = function () {
- if (!this.isRange) {
- throw new Error('`valueStart` is only applicable for range sliders.');
- }
- return this.valueStart;
- };
- /**
- * Only applicable for range sliders. Sets the start thumb's value.
- */
- MDCSliderFoundation.prototype.setValueStart = function (valueStart) {
- if (!this.isRange) {
- throw new Error('`valueStart` is only applicable for range sliders.');
- }
- if (this.isRange && valueStart > this.value) {
- throw new Error("start thumb value (" + valueStart + ") must be <= end thumb " + ("value (" + this.value + ")"));
- }
- this.updateValue(valueStart, types_1.Thumb.START);
- };
- MDCSliderFoundation.prototype.getStep = function () {
- return this.step;
- };
- MDCSliderFoundation.prototype.getDisabled = function () {
- return this.isDisabled;
- };
- /**
- * Sets disabled state, including updating styles and thumb tabindex.
- */
- MDCSliderFoundation.prototype.setDisabled = function (disabled) {
- this.isDisabled = disabled;
- if (disabled) {
- this.adapter.addClass(constants_1.cssClasses.DISABLED);
- if (this.isRange) {
- this.adapter.setInputAttribute(constants_1.attributes.INPUT_DISABLED, '', types_1.Thumb.START);
- }
- this.adapter.setInputAttribute(constants_1.attributes.INPUT_DISABLED, '', types_1.Thumb.END);
- } else {
- this.adapter.removeClass(constants_1.cssClasses.DISABLED);
- if (this.isRange) {
- this.adapter.removeInputAttribute(constants_1.attributes.INPUT_DISABLED, types_1.Thumb.START);
- }
- this.adapter.removeInputAttribute(constants_1.attributes.INPUT_DISABLED, types_1.Thumb.END);
- }
- };
- /** @return Whether the slider is a range slider. */
- MDCSliderFoundation.prototype.getIsRange = function () {
- return this.isRange;
- };
- /**
- * - Syncs slider boundingClientRect with the current DOM.
- * - Updates UI based on internal state.
- */
- MDCSliderFoundation.prototype.layout = function (_a) {
- var skipUpdateUI = (_a === void 0 ? {} : _a).skipUpdateUI;
- this.rect = this.adapter.getBoundingClientRect();
- if (this.isRange) {
- this.startThumbKnobWidth = this.adapter.getThumbKnobWidth(types_1.Thumb.START);
- this.endThumbKnobWidth = this.adapter.getThumbKnobWidth(types_1.Thumb.END);
- }
- if (!skipUpdateUI) {
- this.updateUI();
- }
- };
- /** Handles resize events on the window. */
- MDCSliderFoundation.prototype.handleResize = function () {
- this.layout();
- };
- /**
- * Handles pointer down events on the slider root element.
- */
- MDCSliderFoundation.prototype.handleDown = function (event) {
- if (this.isDisabled) return;
- this.valueStartBeforeDownEvent = this.valueStart;
- this.valueBeforeDownEvent = this.value;
- var clientX = event.clientX != null ? event.clientX : event.targetTouches[0].clientX;
- this.downEventClientX = clientX;
- var value = this.mapClientXOnSliderScale(clientX);
- this.thumb = this.getThumbFromDownEvent(clientX, value);
- if (this.thumb === null) return;
- this.handleDragStart(event, value, this.thumb);
- // Presses within the range do not invoke slider updates.
- var newValueInCurrentRange = this.isRange && value >= this.valueStart && value <= this.value;
- if (newValueInCurrentRange) return;
- this.updateValue(value, this.thumb, { emitInputEvent: true });
- };
- /**
- * Handles pointer move events on the slider root element.
- */
- MDCSliderFoundation.prototype.handleMove = function (event) {
- if (this.isDisabled) return;
- // Prevent scrolling.
- event.preventDefault();
- var clientX = event.clientX != null ? event.clientX : event.targetTouches[0].clientX;
- var dragAlreadyStarted = this.thumb != null;
- this.thumb = this.getThumbFromMoveEvent(clientX);
- if (this.thumb === null) return;
- var value = this.mapClientXOnSliderScale(clientX);
- if (!dragAlreadyStarted) {
- this.handleDragStart(event, value, this.thumb);
- this.adapter.emitDragStartEvent(value, this.thumb);
- }
- this.updateValue(value, this.thumb, { emitInputEvent: true });
- };
- /**
- * Handles pointer up events on the slider root element.
- */
- MDCSliderFoundation.prototype.handleUp = function () {
- if (this.isDisabled || this.thumb === null) return;
- var oldValue = this.thumb === types_1.Thumb.START ? this.valueStartBeforeDownEvent : this.valueBeforeDownEvent;
- var newValue = this.thumb === types_1.Thumb.START ? this.valueStart : this.value;
- if (oldValue !== newValue) {
- this.adapter.emitChangeEvent(newValue, this.thumb);
- }
- this.adapter.emitDragEndEvent(newValue, this.thumb);
- this.thumb = null;
- };
- /**
- * For range, discrete slider, shows the value indicator on both thumbs.
- */
- MDCSliderFoundation.prototype.handleThumbMouseenter = function () {
- if (!this.isDiscrete || !this.isRange) return;
- this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.START);
- this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.END);
- };
- /**
- * For range, discrete slider, hides the value indicator on both thumbs.
- */
- MDCSliderFoundation.prototype.handleThumbMouseleave = function () {
- if (!this.isDiscrete || !this.isRange) return;
- if (this.adapter.isInputFocused(types_1.Thumb.START) || this.adapter.isInputFocused(types_1.Thumb.END)) {
- // Leave value indicator shown if either input is focused.
- return;
- }
- this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.START);
- this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, types_1.Thumb.END);
- };
- MDCSliderFoundation.prototype.handleMousedownOrTouchstart = function (event) {
- var _this = this;
- var moveEventType = event.type === 'mousedown' ? 'mousemove' : 'touchmove';
- // After a down event on the slider root, listen for move events on
- // body (so the slider value is updated for events outside of the
- // slider root).
- this.adapter.registerBodyEventHandler(moveEventType, this.moveListener);
- var upHandler = function upHandler() {
- _this.handleUp();
- // Once the drag is finished (up event on body), remove the move
- // handler.
- _this.adapter.deregisterBodyEventHandler(moveEventType, _this.moveListener);
- // Also stop listening for subsequent up events.
- _this.adapter.deregisterEventHandler('mouseup', upHandler);
- _this.adapter.deregisterEventHandler('touchend', upHandler);
- };
- this.adapter.registerBodyEventHandler('mouseup', upHandler);
- this.adapter.registerBodyEventHandler('touchend', upHandler);
- this.handleDown(event);
- };
- MDCSliderFoundation.prototype.handlePointerdown = function (event) {
- this.adapter.setPointerCapture(event.pointerId);
- this.adapter.registerEventHandler('pointermove', this.moveListener);
- this.handleDown(event);
- };
- /**
- * Handles input `change` event by setting internal slider value to match
- * input's new value.
- */
- MDCSliderFoundation.prototype.handleInputChange = function (thumb) {
- var value = Number(this.adapter.getInputValue(thumb));
- if (thumb === types_1.Thumb.START) {
- this.setValueStart(value);
- } else {
- this.setValue(value);
- }
- };
- /** Shows value indicator on thumb(s). */
- MDCSliderFoundation.prototype.handleInputFocus = function (thumb) {
- if (!this.isDiscrete) return;
- this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, thumb);
- if (this.isRange) {
- var otherThumb = thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START;
- this.adapter.addThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, otherThumb);
- }
- };
- /** Removes value indicator from thumb(s). */
- MDCSliderFoundation.prototype.handleInputBlur = function (thumb) {
- if (!this.isDiscrete) return;
- this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, thumb);
- if (this.isRange) {
- var otherThumb = thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START;
- this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_WITH_INDICATOR, otherThumb);
- }
- };
- /**
- * Emits custom dragStart event, along with focusing the underlying input.
- */
- MDCSliderFoundation.prototype.handleDragStart = function (event, value, thumb) {
- this.adapter.focusInput(thumb);
- // Prevent the input (that we just focused) from losing focus.
- event.preventDefault();
- this.adapter.emitDragStartEvent(value, thumb);
- };
- /**
- * @return The thumb to be moved based on initial down event.
- */
- MDCSliderFoundation.prototype.getThumbFromDownEvent = function (clientX, value) {
- // For single point slider, thumb to be moved is always the END (only)
- // thumb.
- if (!this.isRange) return types_1.Thumb.END;
- // Check if event press point is in the bounds of any thumb.
- var thumbStartRect = this.adapter.getThumbBoundingClientRect(types_1.Thumb.START);
- var thumbEndRect = this.adapter.getThumbBoundingClientRect(types_1.Thumb.END);
- var inThumbStartBounds = clientX >= thumbStartRect.left && clientX <= thumbStartRect.right;
- var inThumbEndBounds = clientX >= thumbEndRect.left && clientX <= thumbEndRect.right;
- if (inThumbStartBounds && inThumbEndBounds) {
- // Thumbs overlapping. Thumb to be moved cannot be determined yet.
- return null;
- }
- // If press is in bounds for either thumb on down event, that's the thumb
- // to be moved.
- if (inThumbStartBounds) {
- return types_1.Thumb.START;
- }
- if (inThumbEndBounds) {
- return types_1.Thumb.END;
- }
- // Otherwise, if press occurred outside of the range, return either start
- // or end thumb based on which the press is closer to.
- if (value < this.valueStart) {
- return types_1.Thumb.START;
- }
- if (value > this.value) {
- return types_1.Thumb.END;
- }
- return null;
- };
- /**
- * @return The thumb to be moved based on move event (based on drag
- * direction from original down event). Only applicable if thumbs
- * were overlapping in the down event.
- */
- MDCSliderFoundation.prototype.getThumbFromMoveEvent = function (clientX) {
- // Thumb has already been chosen.
- if (this.thumb !== null) return this.thumb;
- if (this.downEventClientX === null) {
- throw new Error('`downEventClientX` is null after move event.');
- }
- var moveDistanceUnderThreshold = Math.abs(this.downEventClientX - clientX) < constants_1.numbers.THUMB_UPDATE_MIN_PX;
- if (moveDistanceUnderThreshold) return this.thumb;
- var draggedThumbToLeft = clientX < this.downEventClientX;
- if (draggedThumbToLeft) {
- return this.adapter.isRTL() ? types_1.Thumb.END : types_1.Thumb.START;
- } else {
- return this.adapter.isRTL() ? types_1.Thumb.START : types_1.Thumb.END;
- }
- };
- /**
- * Updates UI based on internal state.
- * @param thumb Thumb whose value is being updated. If undefined, UI is
- * updated for both thumbs based on current internal state.
- */
- MDCSliderFoundation.prototype.updateUI = function (thumb) {
- this.updateThumbAndInputAttributes(thumb);
- this.updateThumbAndTrackUI(thumb);
- this.updateValueIndicatorUI(thumb);
- this.updateTickMarksUI();
- };
- /**
- * Updates thumb and input attributes based on current value.
- * @param thumb Thumb whose aria attributes to update.
- */
- MDCSliderFoundation.prototype.updateThumbAndInputAttributes = function (thumb) {
- if (!thumb) return;
- var value = this.isRange && thumb === types_1.Thumb.START ? this.valueStart : this.value;
- var valueStr = String(value);
- this.adapter.setInputAttribute(constants_1.attributes.INPUT_VALUE, valueStr, thumb);
- if (this.isRange && thumb === types_1.Thumb.START) {
- this.adapter.setInputAttribute(constants_1.attributes.INPUT_MIN, valueStr, types_1.Thumb.END);
- } else if (this.isRange && thumb === types_1.Thumb.END) {
- this.adapter.setInputAttribute(constants_1.attributes.INPUT_MAX, valueStr, types_1.Thumb.START);
- }
- // Sync attribute with property.
- if (this.adapter.getInputValue(thumb) !== valueStr) {
- this.adapter.setInputValue(valueStr, thumb);
- }
- var valueToAriaValueTextFn = this.adapter.getValueToAriaValueTextFn();
- if (valueToAriaValueTextFn) {
- this.adapter.setInputAttribute(constants_1.attributes.ARIA_VALUETEXT, valueToAriaValueTextFn(value), thumb);
- }
- };
- /**
- * Updates value indicator UI based on current value.
- * @param thumb Thumb whose value indicator to update. If undefined, all
- * thumbs' value indicators are updated.
- */
- MDCSliderFoundation.prototype.updateValueIndicatorUI = function (thumb) {
- if (!this.isDiscrete) return;
- var value = this.isRange && thumb === types_1.Thumb.START ? this.valueStart : this.value;
- this.adapter.setValueIndicatorText(value, thumb === types_1.Thumb.START ? types_1.Thumb.START : types_1.Thumb.END);
- if (!thumb && this.isRange) {
- this.adapter.setValueIndicatorText(this.valueStart, types_1.Thumb.START);
- }
- };
- /**
- * Updates tick marks UI within slider, based on current min, max, and step.
- */
- MDCSliderFoundation.prototype.updateTickMarksUI = function () {
- if (!this.isDiscrete || !this.hasTickMarks) return;
- var numTickMarksInactiveStart = (this.valueStart - this.min) / this.step;
- var numTickMarksActive = (this.value - this.valueStart) / this.step + 1;
- var numTickMarksInactiveEnd = (this.max - this.value) / this.step;
- var tickMarksInactiveStart = Array.from({ length: numTickMarksInactiveStart }).fill(types_1.TickMark.INACTIVE);
- var tickMarksActive = Array.from({ length: numTickMarksActive }).fill(types_1.TickMark.ACTIVE);
- var tickMarksInactiveEnd = Array.from({ length: numTickMarksInactiveEnd }).fill(types_1.TickMark.INACTIVE);
- this.adapter.updateTickMarks(tickMarksInactiveStart.concat(tickMarksActive).concat(tickMarksInactiveEnd));
- };
- /** Maps clientX to a value on the slider scale. */
- MDCSliderFoundation.prototype.mapClientXOnSliderScale = function (clientX) {
- var xPos = clientX - this.rect.left;
- var pctComplete = xPos / this.rect.width;
- if (this.adapter.isRTL()) {
- pctComplete = 1 - pctComplete;
- }
- // Fit the percentage complete between the range [min,max]
- // by remapping from [0, 1] to [min, min+(max-min)].
- var value = this.min + pctComplete * (this.max - this.min);
- if (value === this.max || value === this.min) {
- return value;
- }
- return this.quantize(value);
- };
- /**
- * Updates slider value (internal state and UI) based on the given value.
- */
- MDCSliderFoundation.prototype.updateValue = function (value, thumb, _a) {
- var _b = _a === void 0 ? {} : _a,
- emitInputEvent = _b.emitInputEvent,
- emitChangeEvent = _b.emitChangeEvent;
- value = this.clampValue(value, thumb);
- if (this.isRange && thumb === types_1.Thumb.START) {
- // Exit early if current value is the same as the new value.
- if (this.valueStart === value) return;
- this.valueStart = value;
- } else {
- // Exit early if current value is the same as the new value.
- if (this.value === value) return;
- this.value = value;
- }
- this.updateUI(thumb);
- if (emitInputEvent) {
- this.adapter.emitInputEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
- }
- if (emitChangeEvent) {
- this.adapter.emitChangeEvent(thumb === types_1.Thumb.START ? this.valueStart : this.value, thumb);
- }
- };
- /** Calculates the quantized value based on step value. */
- MDCSliderFoundation.prototype.quantize = function (value) {
- var numSteps = Math.round(value / this.step);
- return numSteps * this.step;
- };
- /**
- * Clamps the given value for the given thumb based on slider properties:
- * - Restricts value within [min, max].
- * - If range slider, clamp start value <= end value, and
- * end value >= start value.
- */
- MDCSliderFoundation.prototype.clampValue = function (value, thumb) {
- // Clamp value to [min, max] range.
- value = Math.min(Math.max(value, this.min), this.max);
- var thumbStartMovedPastThumbEnd = this.isRange && thumb === types_1.Thumb.START && value > this.value;
- if (thumbStartMovedPastThumbEnd) {
- return this.value;
- }
- var thumbEndMovedPastThumbStart = this.isRange && thumb === types_1.Thumb.END && value < this.valueStart;
- if (thumbEndMovedPastThumbStart) {
- return this.valueStart;
- }
- return value;
- };
- /**
- * Updates the active track and thumb style properties to reflect current
- * value.
- */
- MDCSliderFoundation.prototype.updateThumbAndTrackUI = function (thumb) {
- var _this = this;
- var _a = this,
- max = _a.max,
- min = _a.min;
- var pctComplete = (this.value - this.valueStart) / (max - min);
- var rangePx = pctComplete * this.rect.width;
- var isRtl = this.adapter.isRTL();
- var transformProp = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transform') : 'transform';
- if (this.isRange) {
- var thumbLeftPos_1 = this.adapter.isRTL() ? (max - this.value) / (max - min) * this.rect.width : (this.valueStart - min) / (max - min) * this.rect.width;
- var thumbRightPos_1 = thumbLeftPos_1 + rangePx;
- requestAnimationFrame(function () {
- // Set active track styles, accounting for animation direction by
- // setting `transform-origin`.
- var trackAnimatesFromRight = !isRtl && thumb === types_1.Thumb.START || isRtl && thumb !== types_1.Thumb.START;
- if (trackAnimatesFromRight) {
- _this.adapter.setTrackActiveStyleProperty('transform-origin', 'right');
- _this.adapter.setTrackActiveStyleProperty('left', 'unset');
- _this.adapter.setTrackActiveStyleProperty('right', _this.rect.width - thumbRightPos_1 + "px");
- } else {
- _this.adapter.setTrackActiveStyleProperty('transform-origin', 'left');
- _this.adapter.setTrackActiveStyleProperty('right', 'unset');
- _this.adapter.setTrackActiveStyleProperty('left', thumbLeftPos_1 + "px");
- }
- _this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
- // Set thumb styles.
- var thumbStartPos = isRtl ? thumbRightPos_1 : thumbLeftPos_1;
- var thumbEndPos = _this.adapter.isRTL() ? thumbLeftPos_1 : thumbRightPos_1;
- if (thumb === types_1.Thumb.START || !thumb || !_this.initialStylesRemoved) {
- _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", types_1.Thumb.START);
- }
- if (thumb === types_1.Thumb.END || !thumb || !_this.initialStylesRemoved) {
- _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbEndPos + "px)", types_1.Thumb.END);
- }
- _this.removeInitialStyles(isRtl);
- _this.updateOverlappingThumbsUI(thumbStartPos, thumbEndPos, thumb);
- });
- } else {
- requestAnimationFrame(function () {
- var thumbStartPos = isRtl ? _this.rect.width - rangePx : rangePx;
- _this.adapter.setThumbStyleProperty(transformProp, "translateX(" + thumbStartPos + "px)", types_1.Thumb.END);
- _this.adapter.setTrackActiveStyleProperty(transformProp, "scaleX(" + pctComplete + ")");
- _this.removeInitialStyles(isRtl);
- });
- }
- };
- /**
- * Removes initial inline styles if not already removed. `left:<...>%`
- * inline styles can be added to position the thumb correctly before JS
- * initialization. However, they need to be removed before the JS starts
- * positioning the thumb. This is because the JS uses
- * `transform:translateX(<...>)px` (for performance reasons) to position
- * the thumb (which is not possible for initial styles since we need the
- * bounding rect measurements).
- */
- MDCSliderFoundation.prototype.removeInitialStyles = function (isRtl) {
- if (this.initialStylesRemoved) return;
- // Remove thumb position properties that were added for initial render.
- var position = isRtl ? 'right' : 'left';
- this.adapter.removeThumbStyleProperty(position, types_1.Thumb.END);
- if (this.isRange) {
- this.adapter.removeThumbStyleProperty(position, types_1.Thumb.START);
- }
- this.initialStylesRemoved = true;
- this.resetTrackAndThumbAnimation();
- };
- /**
- * Resets track/thumb animation to prevent animation when adding
- * `transform` styles to thumb initially.
- */
- MDCSliderFoundation.prototype.resetTrackAndThumbAnimation = function () {
- var _this = this;
- if (!this.isDiscrete) return;
- // Set transition properties to default (no animation), so that the
- // newly added `transform` styles do not animate thumb/track from
- // their default positions.
- var transitionProp = HAS_WINDOW ? util_1.getCorrectPropertyName(window, 'transition') : 'transition';
- var transitionDefault = 'all 0s ease 0s';
- this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, types_1.Thumb.END);
- if (this.isRange) {
- this.adapter.setThumbStyleProperty(transitionProp, transitionDefault, types_1.Thumb.START);
- }
- this.adapter.setTrackActiveStyleProperty(transitionProp, transitionDefault);
- // In the next frame, remove the transition inline styles we just
- // added, such that any animations added in the CSS can now take effect.
- requestAnimationFrame(function () {
- _this.adapter.removeThumbStyleProperty(transitionProp, types_1.Thumb.END);
- _this.adapter.removeTrackActiveStyleProperty(transitionProp);
- if (_this.isRange) {
- _this.adapter.removeThumbStyleProperty(transitionProp, types_1.Thumb.START);
- }
- });
- };
- /**
- * Adds THUMB_TOP class to active thumb if thumb knobs overlap; otherwise
- * removes THUMB_TOP class from both thumbs.
- * @param thumb Thumb that is active (being moved).
- */
- MDCSliderFoundation.prototype.updateOverlappingThumbsUI = function (thumbStartPos, thumbEndPos, thumb) {
- var thumbsOverlap = false;
- if (this.adapter.isRTL()) {
- var startThumbLeftEdge = thumbStartPos - this.startThumbKnobWidth / 2;
- var endThumbRightEdge = thumbEndPos + this.endThumbKnobWidth / 2;
- thumbsOverlap = endThumbRightEdge >= startThumbLeftEdge;
- } else {
- var startThumbRightEdge = thumbStartPos + this.startThumbKnobWidth / 2;
- var endThumbLeftEdge = thumbEndPos - this.endThumbKnobWidth / 2;
- thumbsOverlap = startThumbRightEdge >= endThumbLeftEdge;
- }
- if (thumbsOverlap) {
- this.adapter.addThumbClass(constants_1.cssClasses.THUMB_TOP,
- // If no thumb was dragged (in the case of initial layout), end
- // thumb is on top by default.
- thumb || types_1.Thumb.END);
- this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, thumb === types_1.Thumb.START ? types_1.Thumb.END : types_1.Thumb.START);
- } else {
- this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, types_1.Thumb.START);
- this.adapter.removeThumbClass(constants_1.cssClasses.THUMB_TOP, types_1.Thumb.END);
- }
- };
- /**
- * Converts attribute value to a number, e.g. '100' => 100. Throws errors
- * for invalid values.
- * @param attributeValue Attribute value, e.g. 100.
- * @param attributeName Attribute name, e.g. `aria-valuemax`.
- */
- MDCSliderFoundation.prototype.convertAttributeValueToNumber = function (attributeValue, attributeName) {
- if (attributeValue === null) {
- throw new Error("MDCSliderFoundation: `" + attributeName + "` must be non-null.");
- }
- var value = Number(attributeValue);
- if (isNaN(value)) {
- throw new Error("MDCSliderFoundation: `" + attributeName + "` value is " + ("`" + attributeValue + "`, but must be a number."));
- }
- return value;
- };
- /** Checks that the given properties are valid slider values. */
- MDCSliderFoundation.prototype.validateProperties = function (_a) {
- var min = _a.min,
- max = _a.max,
- value = _a.value,
- valueStart = _a.valueStart;
- if (min >= max) {
- throw new Error("MDCSliderFoundation: min must be strictly less than max. " + ("Current: [min: " + min + ", max: " + max + "]"));
- }
- if (this.isRange) {
- if (value < min || value > max || valueStart < min || valueStart > max) {
- throw new Error("MDCSliderFoundation: values must be in [min, max] range. " + ("Current values: [start value: " + valueStart + ", end value: " + value + "]"));
- }
- if (valueStart > value) {
- throw new Error("MDCSliderFoundation: start value must be <= end value. " + ("Current values: [start value: " + valueStart + ", end value: " + value + "]"));
- }
- } else {
- // Single point slider.
- if (value < min || value > max) {
- throw new Error("MDCSliderFoundation: value must be in [min, max] range. " + ("Current value: " + value));
- }
- }
- };
- MDCSliderFoundation.prototype.registerEventHandlers = function () {
- this.adapter.registerWindowEventHandler('resize', this.resizeListener);
- if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
- // If supported, use pointer events API with #setPointerCapture.
- this.adapter.registerEventHandler('pointerdown', this.pointerdownListener);
- this.adapter.registerEventHandler('pointerup', this.pointerupListener);
- } else {
- // Otherwise, fall back to mousedown/touchstart events.
- this.adapter.registerEventHandler('mousedown', this.mousedownOrTouchstartListener);
- this.adapter.registerEventHandler('touchstart', this.mousedownOrTouchstartListener);
- }
- if (this.isRange) {
- this.adapter.registerThumbEventHandler(types_1.Thumb.START, 'mouseenter', this.thumbMouseenterListener);
- this.adapter.registerThumbEventHandler(types_1.Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
- this.adapter.registerInputEventHandler(types_1.Thumb.START, 'change', this.inputStartChangeListener);
- this.adapter.registerInputEventHandler(types_1.Thumb.START, 'focus', this.inputStartFocusListener);
- this.adapter.registerInputEventHandler(types_1.Thumb.START, 'blur', this.inputStartBlurListener);
- }
- this.adapter.registerThumbEventHandler(types_1.Thumb.END, 'mouseenter', this.thumbMouseenterListener);
- this.adapter.registerThumbEventHandler(types_1.Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
- this.adapter.registerInputEventHandler(types_1.Thumb.END, 'change', this.inputEndChangeListener);
- this.adapter.registerInputEventHandler(types_1.Thumb.END, 'focus', this.inputEndFocusListener);
- this.adapter.registerInputEventHandler(types_1.Thumb.END, 'blur', this.inputEndBlurListener);
- };
- MDCSliderFoundation.prototype.deregisterEventHandlers = function () {
- this.adapter.deregisterWindowEventHandler('resize', this.resizeListener);
- if (MDCSliderFoundation.SUPPORTS_POINTER_EVENTS) {
- this.adapter.deregisterEventHandler('pointerdown', this.pointerdownListener);
- this.adapter.deregisterEventHandler('pointerup', this.pointerupListener);
- } else {
- this.adapter.deregisterEventHandler('mousedown', this.mousedownOrTouchstartListener);
- this.adapter.deregisterEventHandler('touchstart', this.mousedownOrTouchstartListener);
- }
- if (this.isRange) {
- this.adapter.deregisterThumbEventHandler(types_1.Thumb.START, 'mouseenter', this.thumbMouseenterListener);
- this.adapter.deregisterThumbEventHandler(types_1.Thumb.START, 'mouseleave', this.thumbMouseleaveListener);
- this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'change', this.inputStartChangeListener);
- this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'focus', this.inputStartFocusListener);
- this.adapter.deregisterInputEventHandler(types_1.Thumb.START, 'blur', this.inputStartBlurListener);
- }
- this.adapter.deregisterThumbEventHandler(types_1.Thumb.END, 'mouseenter', this.thumbMouseenterListener);
- this.adapter.deregisterThumbEventHandler(types_1.Thumb.END, 'mouseleave', this.thumbMouseleaveListener);
- this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'change', this.inputEndChangeListener);
- this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'focus', this.inputEndFocusListener);
- this.adapter.deregisterInputEventHandler(types_1.Thumb.END, 'blur', this.inputEndBlurListener);
- };
- MDCSliderFoundation.prototype.handlePointerup = function () {
- this.handleUp();
- this.adapter.deregisterEventHandler('pointermove', this.moveListener);
- };
- MDCSliderFoundation.SUPPORTS_POINTER_EVENTS = HAS_WINDOW && Boolean(window.PointerEvent) &&
- // #setPointerCapture is buggy on iOS, so we can't use pointer events
- // until the following bug is fixed:
- // https://bugs.webkit.org/show_bug.cgi?id=220196
- !isIOS();
- return MDCSliderFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSliderFoundation = MDCSliderFoundation;
- function isIOS() {
- // Source:
- // https://stackoverflow.com/questions/9038625/detect-if-device-is-ios
- return ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform)
- // iPad on iOS 13 detection
- || navigator.userAgent.includes('Mac') && 'ontouchend' in document;
- }
- /***/ }),
- /***/ "./packages/mdc-slider/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-slider/index.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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"));
- __export(__webpack_require__(/*! ./types */ "./packages/mdc-slider/types.ts"));
- /***/ }),
- /***/ "./packages/mdc-slider/types.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-slider/types.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /** Tick mark enum, for discrete sliders. */
- var TickMark;
- (function (TickMark) {
- TickMark[TickMark["ACTIVE"] = 0] = "ACTIVE";
- TickMark[TickMark["INACTIVE"] = 1] = "INACTIVE";
- })(TickMark = exports.TickMark || (exports.TickMark = {}));
- /**
- * Thumb types: range slider has two thumbs (START, END) whereas single point
- * slider only has one thumb (END).
- */
- var Thumb;
- (function (Thumb) {
- // Thumb at start of slider (e.g. in LTR mode, left thumb on range slider).
- Thumb[Thumb["START"] = 1] = "START";
- // Thumb at end of slider (e.g. in LTR mode, right thumb on range slider,
- // or only thumb on single point slider).
- Thumb[Thumb["END"] = 2] = "END";
- })(Thumb = exports.Thumb || (exports.Thumb = {}));
- /***/ }),
- /***/ "./packages/mdc-snackbar/component.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-snackbar/component.ts ***!
- \********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts");
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
- var SURFACE_SELECTOR = constants_1.strings.SURFACE_SELECTOR,
- LABEL_SELECTOR = constants_1.strings.LABEL_SELECTOR,
- ACTION_SELECTOR = constants_1.strings.ACTION_SELECTOR,
- DISMISS_SELECTOR = constants_1.strings.DISMISS_SELECTOR,
- OPENING_EVENT = constants_1.strings.OPENING_EVENT,
- OPENED_EVENT = constants_1.strings.OPENED_EVENT,
- CLOSING_EVENT = constants_1.strings.CLOSING_EVENT,
- CLOSED_EVENT = constants_1.strings.CLOSED_EVENT;
- var MDCSnackbar = /** @class */function (_super) {
- __extends(MDCSnackbar, _super);
- function MDCSnackbar() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCSnackbar.attachTo = function (root) {
- return new MDCSnackbar(root);
- };
- MDCSnackbar.prototype.initialize = function (announcerFactory) {
- if (announcerFactory === void 0) {
- announcerFactory = function announcerFactory() {
- return util.announce;
- };
- }
- this.announce_ = announcerFactory();
- };
- MDCSnackbar.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.surfaceEl_ = this.root.querySelector(SURFACE_SELECTOR);
- this.labelEl_ = this.root.querySelector(LABEL_SELECTOR);
- this.actionEl_ = this.root.querySelector(ACTION_SELECTOR);
- this.handleKeyDown_ = function (evt) {
- return _this.foundation.handleKeyDown(evt);
- };
- this.handleSurfaceClick_ = function (evt) {
- var target = evt.target;
- if (_this.isActionButton_(target)) {
- _this.foundation.handleActionButtonClick(evt);
- } else if (_this.isActionIcon_(target)) {
- _this.foundation.handleActionIconClick(evt);
- }
- };
- this.registerKeyDownHandler_(this.handleKeyDown_);
- this.registerSurfaceClickHandler_(this.handleSurfaceClick_);
- };
- MDCSnackbar.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.deregisterKeyDownHandler_(this.handleKeyDown_);
- this.deregisterSurfaceClickHandler_(this.handleSurfaceClick_);
- };
- MDCSnackbar.prototype.open = function () {
- this.foundation.open();
- };
- /**
- * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
- * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
- * client-specific values may also be used if desired.
- */
- MDCSnackbar.prototype.close = function (reason) {
- if (reason === void 0) {
- reason = '';
- }
- this.foundation.close(reason);
- };
- MDCSnackbar.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- var adapter = {
- addClass: function addClass(className) {
- return _this.root.classList.add(className);
- },
- announce: function announce() {
- return _this.announce_(_this.labelEl_);
- },
- notifyClosed: function notifyClosed(reason) {
- return _this.emit(CLOSED_EVENT, reason ? { reason: reason } : {});
- },
- notifyClosing: function notifyClosing(reason) {
- return _this.emit(CLOSING_EVENT, reason ? { reason: reason } : {});
- },
- notifyOpened: function notifyOpened() {
- return _this.emit(OPENED_EVENT, {});
- },
- notifyOpening: function notifyOpening() {
- return _this.emit(OPENING_EVENT, {});
- },
- removeClass: function removeClass(className) {
- return _this.root.classList.remove(className);
- }
- };
- return new foundation_1.MDCSnackbarFoundation(adapter);
- };
- Object.defineProperty(MDCSnackbar.prototype, "timeoutMs", {
- get: function get() {
- return this.foundation.getTimeoutMs();
- },
- set: function set(timeoutMs) {
- this.foundation.setTimeoutMs(timeoutMs);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbar.prototype, "closeOnEscape", {
- get: function get() {
- return this.foundation.getCloseOnEscape();
- },
- set: function set(closeOnEscape) {
- this.foundation.setCloseOnEscape(closeOnEscape);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbar.prototype, "isOpen", {
- get: function get() {
- return this.foundation.isOpen();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbar.prototype, "labelText", {
- get: function get() {
- // This property only returns null if the node is a document, DOCTYPE, or notation.
- // On Element nodes, it always returns a string.
- return this.labelEl_.textContent;
- },
- set: function set(labelText) {
- this.labelEl_.textContent = labelText;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbar.prototype, "actionButtonText", {
- get: function get() {
- return this.actionEl_.textContent;
- },
- set: function set(actionButtonText) {
- this.actionEl_.textContent = actionButtonText;
- },
- enumerable: true,
- configurable: true
- });
- MDCSnackbar.prototype.registerKeyDownHandler_ = function (handler) {
- this.listen('keydown', handler);
- };
- MDCSnackbar.prototype.deregisterKeyDownHandler_ = function (handler) {
- this.unlisten('keydown', handler);
- };
- MDCSnackbar.prototype.registerSurfaceClickHandler_ = function (handler) {
- this.surfaceEl_.addEventListener('click', handler);
- };
- MDCSnackbar.prototype.deregisterSurfaceClickHandler_ = function (handler) {
- this.surfaceEl_.removeEventListener('click', handler);
- };
- MDCSnackbar.prototype.isActionButton_ = function (target) {
- return Boolean(ponyfill_1.closest(target, ACTION_SELECTOR));
- };
- MDCSnackbar.prototype.isActionIcon_ = function (target) {
- return Boolean(ponyfill_1.closest(target, DISMISS_SELECTOR));
- };
- return MDCSnackbar;
- }(component_1.MDCComponent);
- exports.MDCSnackbar = MDCSnackbar;
- /***/ }),
- /***/ "./packages/mdc-snackbar/constants.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-snackbar/constants.ts ***!
- \********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var cssClasses = {
- CLOSING: 'mdc-snackbar--closing',
- OPEN: 'mdc-snackbar--open',
- OPENING: 'mdc-snackbar--opening'
- };
- exports.cssClasses = cssClasses;
- var strings = {
- ACTION_SELECTOR: '.mdc-snackbar__action',
- ARIA_LIVE_LABEL_TEXT_ATTR: 'data-mdc-snackbar-label-text',
- CLOSED_EVENT: 'MDCSnackbar:closed',
- CLOSING_EVENT: 'MDCSnackbar:closing',
- DISMISS_SELECTOR: '.mdc-snackbar__dismiss',
- LABEL_SELECTOR: '.mdc-snackbar__label',
- OPENED_EVENT: 'MDCSnackbar:opened',
- OPENING_EVENT: 'MDCSnackbar:opening',
- REASON_ACTION: 'action',
- REASON_DISMISS: 'dismiss',
- SURFACE_SELECTOR: '.mdc-snackbar__surface'
- };
- exports.strings = strings;
- var numbers = {
- DEFAULT_AUTO_DISMISS_TIMEOUT_MS: 5000,
- INDETERMINATE: -1,
- MAX_AUTO_DISMISS_TIMEOUT_MS: 10000,
- MIN_AUTO_DISMISS_TIMEOUT_MS: 4000,
- // These variables need to be kept in sync with the values in _variables.scss.
- SNACKBAR_ANIMATION_CLOSE_TIME_MS: 75,
- SNACKBAR_ANIMATION_OPEN_TIME_MS: 150,
- /**
- * Number of milliseconds to wait between temporarily clearing the label text
- * in the DOM and subsequently restoring it. This is necessary to force IE 11
- * to pick up the `aria-live` content change and announce it to the user.
- */
- ARIA_LIVE_DELAY_MS: 1000
- };
- exports.numbers = numbers;
- /***/ }),
- /***/ "./packages/mdc-snackbar/foundation.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-snackbar/foundation.ts ***!
- \*********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
- var OPENING = constants_1.cssClasses.OPENING,
- OPEN = constants_1.cssClasses.OPEN,
- CLOSING = constants_1.cssClasses.CLOSING;
- var REASON_ACTION = constants_1.strings.REASON_ACTION,
- REASON_DISMISS = constants_1.strings.REASON_DISMISS;
- var MDCSnackbarFoundation = /** @class */function (_super) {
- __extends(MDCSnackbarFoundation, _super);
- function MDCSnackbarFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCSnackbarFoundation.defaultAdapter), adapter)) || this;
- _this.isOpen_ = false;
- _this.animationFrame_ = 0;
- _this.animationTimer_ = 0;
- _this.autoDismissTimer_ = 0;
- _this.autoDismissTimeoutMs_ = constants_1.numbers.DEFAULT_AUTO_DISMISS_TIMEOUT_MS;
- _this.closeOnEscape_ = true;
- return _this;
- }
- Object.defineProperty(MDCSnackbarFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbarFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbarFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSnackbarFoundation, "defaultAdapter", {
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- announce: function announce() {
- return undefined;
- },
- notifyClosed: function notifyClosed() {
- return undefined;
- },
- notifyClosing: function notifyClosing() {
- return undefined;
- },
- notifyOpened: function notifyOpened() {
- return undefined;
- },
- notifyOpening: function notifyOpening() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCSnackbarFoundation.prototype.destroy = function () {
- this.clearAutoDismissTimer_();
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = 0;
- clearTimeout(this.animationTimer_);
- this.animationTimer_ = 0;
- this.adapter.removeClass(OPENING);
- this.adapter.removeClass(OPEN);
- this.adapter.removeClass(CLOSING);
- };
- MDCSnackbarFoundation.prototype.open = function () {
- var _this = this;
- this.clearAutoDismissTimer_();
- this.isOpen_ = true;
- this.adapter.notifyOpening();
- this.adapter.removeClass(CLOSING);
- this.adapter.addClass(OPENING);
- this.adapter.announce();
- // Wait a frame once display is no longer "none", to establish basis for animation
- this.runNextAnimationFrame_(function () {
- _this.adapter.addClass(OPEN);
- _this.animationTimer_ = setTimeout(function () {
- var timeoutMs = _this.getTimeoutMs();
- _this.handleAnimationTimerEnd_();
- _this.adapter.notifyOpened();
- if (timeoutMs !== constants_1.numbers.INDETERMINATE) {
- _this.autoDismissTimer_ = setTimeout(function () {
- _this.close(REASON_DISMISS);
- }, timeoutMs);
- }
- }, constants_1.numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS);
- });
- };
- /**
- * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the
- * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom
- * client-specific values may also be used if desired.
- */
- MDCSnackbarFoundation.prototype.close = function (reason) {
- var _this = this;
- if (reason === void 0) {
- reason = '';
- }
- if (!this.isOpen_) {
- // Avoid redundant close calls (and events), e.g. repeated interactions as the snackbar is animating closed
- return;
- }
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = 0;
- this.clearAutoDismissTimer_();
- this.isOpen_ = false;
- this.adapter.notifyClosing(reason);
- this.adapter.addClass(constants_1.cssClasses.CLOSING);
- this.adapter.removeClass(constants_1.cssClasses.OPEN);
- this.adapter.removeClass(constants_1.cssClasses.OPENING);
- clearTimeout(this.animationTimer_);
- this.animationTimer_ = setTimeout(function () {
- _this.handleAnimationTimerEnd_();
- _this.adapter.notifyClosed(reason);
- }, constants_1.numbers.SNACKBAR_ANIMATION_CLOSE_TIME_MS);
- };
- MDCSnackbarFoundation.prototype.isOpen = function () {
- return this.isOpen_;
- };
- MDCSnackbarFoundation.prototype.getTimeoutMs = function () {
- return this.autoDismissTimeoutMs_;
- };
- MDCSnackbarFoundation.prototype.setTimeoutMs = function (timeoutMs) {
- // Use shorter variable names to make the code more readable
- var minValue = constants_1.numbers.MIN_AUTO_DISMISS_TIMEOUT_MS;
- var maxValue = constants_1.numbers.MAX_AUTO_DISMISS_TIMEOUT_MS;
- var indeterminateValue = constants_1.numbers.INDETERMINATE;
- if (timeoutMs === constants_1.numbers.INDETERMINATE || timeoutMs <= maxValue && timeoutMs >= minValue) {
- this.autoDismissTimeoutMs_ = timeoutMs;
- } else {
- throw new Error("\n timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + "\n (or " + indeterminateValue + " to disable), but got '" + timeoutMs + "'");
- }
- };
- MDCSnackbarFoundation.prototype.getCloseOnEscape = function () {
- return this.closeOnEscape_;
- };
- MDCSnackbarFoundation.prototype.setCloseOnEscape = function (closeOnEscape) {
- this.closeOnEscape_ = closeOnEscape;
- };
- MDCSnackbarFoundation.prototype.handleKeyDown = function (evt) {
- var isEscapeKey = evt.key === 'Escape' || evt.keyCode === 27;
- if (isEscapeKey && this.getCloseOnEscape()) {
- this.close(REASON_DISMISS);
- }
- };
- MDCSnackbarFoundation.prototype.handleActionButtonClick = function (_evt) {
- this.close(REASON_ACTION);
- };
- MDCSnackbarFoundation.prototype.handleActionIconClick = function (_evt) {
- this.close(REASON_DISMISS);
- };
- MDCSnackbarFoundation.prototype.clearAutoDismissTimer_ = function () {
- clearTimeout(this.autoDismissTimer_);
- this.autoDismissTimer_ = 0;
- };
- MDCSnackbarFoundation.prototype.handleAnimationTimerEnd_ = function () {
- this.animationTimer_ = 0;
- this.adapter.removeClass(constants_1.cssClasses.OPENING);
- this.adapter.removeClass(constants_1.cssClasses.CLOSING);
- };
- /**
- * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
- */
- MDCSnackbarFoundation.prototype.runNextAnimationFrame_ = function (callback) {
- var _this = this;
- cancelAnimationFrame(this.animationFrame_);
- this.animationFrame_ = requestAnimationFrame(function () {
- _this.animationFrame_ = 0;
- clearTimeout(_this.animationTimer_);
- _this.animationTimer_ = setTimeout(callback, 0);
- });
- };
- return MDCSnackbarFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSnackbarFoundation = MDCSnackbarFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCSnackbarFoundation;
- /***/ }),
- /***/ "./packages/mdc-snackbar/index.ts":
- /*!****************************************!*\
- !*** ./packages/mdc-snackbar/index.ts ***!
- \****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-snackbar/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-snackbar/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-snackbar/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-snackbar/util.ts":
- /*!***************************************!*\
- !*** ./packages/mdc-snackbar/util.ts ***!
- \***************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-snackbar/constants.ts");
- var ARIA_LIVE_DELAY_MS = constants_1.numbers.ARIA_LIVE_DELAY_MS;
- var ARIA_LIVE_LABEL_TEXT_ATTR = constants_1.strings.ARIA_LIVE_LABEL_TEXT_ATTR;
- function announce(ariaEl, labelEl) {
- if (labelEl === void 0) {
- labelEl = ariaEl;
- }
- var priority = ariaEl.getAttribute('aria-live');
- // Trim text to ignore ` ` (see below).
- // textContent is only null if the node is a document, DOCTYPE, or notation.
- var labelText = labelEl.textContent.trim();
- if (!labelText || !priority) {
- return;
- }
- // Temporarily disable `aria-live` to prevent JAWS+Firefox from announcing the message twice.
- ariaEl.setAttribute('aria-live', 'off');
- // Temporarily clear `textContent` to force a DOM mutation event that will be detected by screen readers.
- // `aria-live` elements are only announced when the element's `textContent` *changes*, so snackbars
- // sent to the browser in the initial HTML response won't be read unless we clear the element's `textContent` first.
- // Similarly, displaying the same snackbar message twice in a row doesn't trigger a DOM mutation event,
- // so screen readers won't announce the second message unless we first clear `textContent`.
- //
- // We have to clear the label text two different ways to make it work in all browsers and screen readers:
- //
- // 1. `textContent = ''` is required for IE11 + JAWS
- // 2. `innerHTML = ' '` is required for Chrome + JAWS and NVDA
- //
- // All other browser/screen reader combinations support both methods.
- //
- // The wrapper `<span>` visually hides the space character so that it doesn't cause jank when added/removed.
- // N.B.: Setting `position: absolute`, `opacity: 0`, or `height: 0` prevents Chrome from detecting the DOM change.
- //
- // This technique has been tested in:
- //
- // * JAWS 2019:
- // - Chrome 70
- // - Firefox 60 (ESR)
- // - IE 11
- // * NVDA 2018:
- // - Chrome 70
- // - Firefox 60 (ESR)
- // - IE 11
- // * ChromeVox 53
- labelEl.textContent = '';
- labelEl.innerHTML = '<span style="display: inline-block; width: 0; height: 1px;"> </span>';
- // Prevent visual jank by temporarily displaying the label text in the ::before pseudo-element.
- // CSS generated content is normally announced by screen readers
- // (except in IE 11; see https://tink.uk/accessibility-support-for-css-generated-content/);
- // however, `aria-live` is turned off, so this DOM update will be ignored by screen readers.
- labelEl.setAttribute(ARIA_LIVE_LABEL_TEXT_ATTR, labelText);
- setTimeout(function () {
- // Allow screen readers to announce changes to the DOM again.
- ariaEl.setAttribute('aria-live', priority);
- // Remove the message from the ::before pseudo-element.
- labelEl.removeAttribute(ARIA_LIVE_LABEL_TEXT_ATTR);
- // Restore the original label text, which will be announced by screen readers.
- labelEl.textContent = labelText;
- }, ARIA_LIVE_DELAY_MS);
- }
- exports.announce = announce;
- /***/ }),
- /***/ "./packages/mdc-switch/component.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-switch/component.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var __read = this && this.__read || function (o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o),
- r,
- ar = [],
- e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
- ar.push(r.value);
- }
- } catch (error) {
- e = { error: error };
- } finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- } finally {
- if (e) throw e.error;
- }
- }
- return ar;
- };
- var __spread = this && this.__spread || function () {
- for (var ar = [], i = 0; i < arguments.length; i++) {
- ar = ar.concat(__read(arguments[i]));
- }return ar;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
- var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
- var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-switch/foundation.ts");
- var MDCSwitch = /** @class */function (_super) {
- __extends(MDCSwitch, _super);
- function MDCSwitch() {
- var _this = _super !== null && _super.apply(this, arguments) || this;
- _this.ripple_ = _this.createRipple_();
- return _this;
- }
- MDCSwitch.attachTo = function (root) {
- return new MDCSwitch(root);
- };
- MDCSwitch.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.ripple_.destroy();
- this.nativeControl_.removeEventListener('change', this.changeHandler_);
- };
- MDCSwitch.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.changeHandler_ = function () {
- var _a;
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return (_a = _this.foundation).handleChange.apply(_a, __spread(args));
- };
- this.nativeControl_.addEventListener('change', this.changeHandler_);
- // Sometimes the checked state of the input element is saved in the history.
- // The switch styling should match the checked state of the input element.
- // Do an initial sync between the native control and the foundation.
- this.checked = this.checked;
- };
- MDCSwitch.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- var adapter = {
- addClass: function addClass(className) {
- return _this.root.classList.add(className);
- },
- removeClass: function removeClass(className) {
- return _this.root.classList.remove(className);
- },
- setNativeControlChecked: function setNativeControlChecked(checked) {
- return _this.nativeControl_.checked = checked;
- },
- setNativeControlDisabled: function setNativeControlDisabled(disabled) {
- return _this.nativeControl_.disabled = disabled;
- },
- setNativeControlAttr: function setNativeControlAttr(attr, value) {
- return _this.nativeControl_.setAttribute(attr, value);
- }
- };
- return new foundation_2.MDCSwitchFoundation(adapter);
- };
- Object.defineProperty(MDCSwitch.prototype, "ripple", {
- get: function get() {
- return this.ripple_;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSwitch.prototype, "checked", {
- get: function get() {
- return this.nativeControl_.checked;
- },
- set: function set(checked) {
- this.foundation.setChecked(checked);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSwitch.prototype, "disabled", {
- get: function get() {
- return this.nativeControl_.disabled;
- },
- set: function set(disabled) {
- this.foundation.setDisabled(disabled);
- },
- enumerable: true,
- configurable: true
- });
- MDCSwitch.prototype.createRipple_ = function () {
- var _this = this;
- var RIPPLE_SURFACE_SELECTOR = foundation_2.MDCSwitchFoundation.strings.RIPPLE_SURFACE_SELECTOR;
- var rippleSurface = this.root.querySelector(RIPPLE_SURFACE_SELECTOR);
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- var adapter = __assign(__assign({}, component_2.MDCRipple.createAdapter(this)), { addClass: function addClass(className) {
- return rippleSurface.classList.add(className);
- }, computeBoundingRect: function computeBoundingRect() {
- return rippleSurface.getBoundingClientRect();
- }, deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
- _this.nativeControl_.removeEventListener(evtType, handler, events_1.applyPassive());
- }, isSurfaceActive: function isSurfaceActive() {
- return ponyfill_1.matches(_this.nativeControl_, ':active');
- }, isUnbounded: function isUnbounded() {
- return true;
- }, registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
- _this.nativeControl_.addEventListener(evtType, handler, events_1.applyPassive());
- }, removeClass: function removeClass(className) {
- rippleSurface.classList.remove(className);
- }, updateCssVariable: function updateCssVariable(varName, value) {
- rippleSurface.style.setProperty(varName, value);
- } });
- return new component_2.MDCRipple(this.root, new foundation_1.MDCRippleFoundation(adapter));
- };
- Object.defineProperty(MDCSwitch.prototype, "nativeControl_", {
- get: function get() {
- var NATIVE_CONTROL_SELECTOR = foundation_2.MDCSwitchFoundation.strings.NATIVE_CONTROL_SELECTOR;
- return this.root.querySelector(NATIVE_CONTROL_SELECTOR);
- },
- enumerable: true,
- configurable: true
- });
- return MDCSwitch;
- }(component_1.MDCComponent);
- exports.MDCSwitch = MDCSwitch;
- /***/ }),
- /***/ "./packages/mdc-switch/constants.ts":
- /*!******************************************!*\
- !*** ./packages/mdc-switch/constants.ts ***!
- \******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- /** CSS classes used by the switch. */
- var cssClasses = {
- /** Class used for a switch that is in the "checked" (on) position. */
- CHECKED: 'mdc-switch--checked',
- /** Class used for a switch that is disabled. */
- DISABLED: 'mdc-switch--disabled'
- };
- exports.cssClasses = cssClasses;
- /** String constants used by the switch. */
- var strings = {
- /** Aria attribute for checked or unchecked state of switch */
- ARIA_CHECKED_ATTR: 'aria-checked',
- /** A CSS selector used to locate the native HTML control for the switch. */
- NATIVE_CONTROL_SELECTOR: '.mdc-switch__native-control',
- /** A CSS selector used to locate the ripple surface element for the switch. */
- RIPPLE_SURFACE_SELECTOR: '.mdc-switch__thumb-underlay'
- };
- exports.strings = strings;
- /***/ }),
- /***/ "./packages/mdc-switch/foundation.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-switch/foundation.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts");
- var MDCSwitchFoundation = /** @class */function (_super) {
- __extends(MDCSwitchFoundation, _super);
- function MDCSwitchFoundation(adapter) {
- return _super.call(this, __assign(__assign({}, MDCSwitchFoundation.defaultAdapter), adapter)) || this;
- }
- Object.defineProperty(MDCSwitchFoundation, "strings", {
- /** The string constants used by the switch. */
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSwitchFoundation, "cssClasses", {
- /** The CSS classes used by the switch. */
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCSwitchFoundation, "defaultAdapter", {
- /** The default Adapter for the switch. */
- get: function get() {
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- setNativeControlChecked: function setNativeControlChecked() {
- return undefined;
- },
- setNativeControlDisabled: function setNativeControlDisabled() {
- return undefined;
- },
- setNativeControlAttr: function setNativeControlAttr() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- /** Sets the checked state of the switch. */
- MDCSwitchFoundation.prototype.setChecked = function (checked) {
- this.adapter.setNativeControlChecked(checked);
- this.updateAriaChecked_(checked);
- this.updateCheckedStyling_(checked);
- };
- /** Sets the disabled state of the switch. */
- MDCSwitchFoundation.prototype.setDisabled = function (disabled) {
- this.adapter.setNativeControlDisabled(disabled);
- if (disabled) {
- this.adapter.addClass(constants_1.cssClasses.DISABLED);
- } else {
- this.adapter.removeClass(constants_1.cssClasses.DISABLED);
- }
- };
- /** Handles the change event for the switch native control. */
- MDCSwitchFoundation.prototype.handleChange = function (evt) {
- var nativeControl = evt.target;
- this.updateAriaChecked_(nativeControl.checked);
- this.updateCheckedStyling_(nativeControl.checked);
- };
- /** Updates the styling of the switch based on its checked state. */
- MDCSwitchFoundation.prototype.updateCheckedStyling_ = function (checked) {
- if (checked) {
- this.adapter.addClass(constants_1.cssClasses.CHECKED);
- } else {
- this.adapter.removeClass(constants_1.cssClasses.CHECKED);
- }
- };
- MDCSwitchFoundation.prototype.updateAriaChecked_ = function (checked) {
- this.adapter.setNativeControlAttr(constants_1.strings.ARIA_CHECKED_ATTR, "" + !!checked);
- };
- return MDCSwitchFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCSwitchFoundation = MDCSwitchFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCSwitchFoundation;
- /***/ }),
- /***/ "./packages/mdc-switch/index.ts":
- /*!**************************************!*\
- !*** ./packages/mdc-switch/index.ts ***!
- \**************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-switch/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-switch/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-switch/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-tab-bar/component.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-tab-bar/component.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/tab-scroller/component */ "./packages/mdc-tab-scroller/component.ts");
- var component_3 = __webpack_require__(/*! @material/tab/component */ "./packages/mdc-tab/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/tab/foundation */ "./packages/mdc-tab/foundation.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab-bar/foundation.ts");
- var strings = foundation_2.MDCTabBarFoundation.strings;
- var tabIdCounter = 0;
- var MDCTabBar = /** @class */function (_super) {
- __extends(MDCTabBar, _super);
- function MDCTabBar() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTabBar.attachTo = function (root) {
- return new MDCTabBar(root);
- };
- Object.defineProperty(MDCTabBar.prototype, "focusOnActivate", {
- set: function set(focusOnActivate) {
- this.tabList_.forEach(function (tab) {
- return tab.focusOnActivate = focusOnActivate;
- });
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabBar.prototype, "useAutomaticActivation", {
- set: function set(useAutomaticActivation) {
- this.foundation.setUseAutomaticActivation(useAutomaticActivation);
- },
- enumerable: true,
- configurable: true
- });
- MDCTabBar.prototype.initialize = function (tabFactory, tabScrollerFactory) {
- if (tabFactory === void 0) {
- tabFactory = function tabFactory(el) {
- return new component_3.MDCTab(el);
- };
- }
- if (tabScrollerFactory === void 0) {
- tabScrollerFactory = function tabScrollerFactory(el) {
- return new component_2.MDCTabScroller(el);
- };
- }
- this.tabList_ = this.instantiateTabs_(tabFactory);
- this.tabScroller_ = this.instantiateTabScroller_(tabScrollerFactory);
- };
- MDCTabBar.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.handleTabInteraction_ = function (evt) {
- return _this.foundation.handleTabInteraction(evt);
- };
- this.handleKeyDown_ = function (evt) {
- return _this.foundation.handleKeyDown(evt);
- };
- this.listen(foundation_1.MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_);
- this.listen('keydown', this.handleKeyDown_);
- for (var i = 0; i < this.tabList_.length; i++) {
- if (this.tabList_[i].active) {
- this.scrollIntoView(i);
- break;
- }
- }
- };
- MDCTabBar.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.unlisten(foundation_1.MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_);
- this.unlisten('keydown', this.handleKeyDown_);
- this.tabList_.forEach(function (tab) {
- return tab.destroy();
- });
- if (this.tabScroller_) {
- this.tabScroller_.destroy();
- }
- };
- MDCTabBar.prototype.getDefaultFoundation = function () {
- var _this = this;
- // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
- // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- var adapter = {
- scrollTo: function scrollTo(scrollX) {
- return _this.tabScroller_.scrollTo(scrollX);
- },
- incrementScroll: function incrementScroll(scrollXIncrement) {
- return _this.tabScroller_.incrementScroll(scrollXIncrement);
- },
- getScrollPosition: function getScrollPosition() {
- return _this.tabScroller_.getScrollPosition();
- },
- getScrollContentWidth: function getScrollContentWidth() {
- return _this.tabScroller_.getScrollContentWidth();
- },
- getOffsetWidth: function getOffsetWidth() {
- return _this.root.offsetWidth;
- },
- isRTL: function isRTL() {
- return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl';
- },
- setActiveTab: function setActiveTab(index) {
- return _this.foundation.activateTab(index);
- },
- activateTabAtIndex: function activateTabAtIndex(index, clientRect) {
- return _this.tabList_[index].activate(clientRect);
- },
- deactivateTabAtIndex: function deactivateTabAtIndex(index) {
- return _this.tabList_[index].deactivate();
- },
- focusTabAtIndex: function focusTabAtIndex(index) {
- return _this.tabList_[index].focus();
- },
- getTabIndicatorClientRectAtIndex: function getTabIndicatorClientRectAtIndex(index) {
- return _this.tabList_[index].computeIndicatorClientRect();
- },
- getTabDimensionsAtIndex: function getTabDimensionsAtIndex(index) {
- return _this.tabList_[index].computeDimensions();
- },
- getPreviousActiveTabIndex: function getPreviousActiveTabIndex() {
- for (var i = 0; i < _this.tabList_.length; i++) {
- if (_this.tabList_[i].active) {
- return i;
- }
- }
- return -1;
- },
- getFocusedTabIndex: function getFocusedTabIndex() {
- var tabElements = _this.getTabElements_();
- var activeElement = document.activeElement;
- return tabElements.indexOf(activeElement);
- },
- getIndexOfTabById: function getIndexOfTabById(id) {
- for (var i = 0; i < _this.tabList_.length; i++) {
- if (_this.tabList_[i].id === id) {
- return i;
- }
- }
- return -1;
- },
- getTabListLength: function getTabListLength() {
- return _this.tabList_.length;
- },
- notifyTabActivated: function notifyTabActivated(index) {
- return _this.emit(strings.TAB_ACTIVATED_EVENT, { index: index }, true);
- }
- };
- // tslint:enable:object-literal-sort-keys
- return new foundation_2.MDCTabBarFoundation(adapter);
- };
- /**
- * Activates the tab at the given index
- * @param index The index of the tab
- */
- MDCTabBar.prototype.activateTab = function (index) {
- this.foundation.activateTab(index);
- };
- /**
- * Scrolls the tab at the given index into view
- * @param index THe index of the tab
- */
- MDCTabBar.prototype.scrollIntoView = function (index) {
- this.foundation.scrollIntoView(index);
- };
- /**
- * Returns all the tab elements in a nice clean array
- */
- MDCTabBar.prototype.getTabElements_ = function () {
- return [].slice.call(this.root.querySelectorAll(strings.TAB_SELECTOR));
- };
- /**
- * Instantiates tab components on all child tab elements
- */
- MDCTabBar.prototype.instantiateTabs_ = function (tabFactory) {
- return this.getTabElements_().map(function (el) {
- el.id = el.id || "mdc-tab-" + ++tabIdCounter;
- return tabFactory(el);
- });
- };
- /**
- * Instantiates tab scroller component on the child tab scroller element
- */
- MDCTabBar.prototype.instantiateTabScroller_ = function (tabScrollerFactory) {
- var tabScrollerElement = this.root.querySelector(strings.TAB_SCROLLER_SELECTOR);
- if (tabScrollerElement) {
- return tabScrollerFactory(tabScrollerElement);
- }
- return null;
- };
- return MDCTabBar;
- }(component_1.MDCComponent);
- exports.MDCTabBar = MDCTabBar;
- /***/ }),
- /***/ "./packages/mdc-tab-bar/constants.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-tab-bar/constants.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var strings = {
- ARROW_LEFT_KEY: 'ArrowLeft',
- ARROW_RIGHT_KEY: 'ArrowRight',
- END_KEY: 'End',
- ENTER_KEY: 'Enter',
- HOME_KEY: 'Home',
- SPACE_KEY: 'Space',
- TAB_ACTIVATED_EVENT: 'MDCTabBar:activated',
- TAB_SCROLLER_SELECTOR: '.mdc-tab-scroller',
- TAB_SELECTOR: '.mdc-tab'
- };
- exports.strings = strings;
- var numbers = {
- ARROW_LEFT_KEYCODE: 37,
- ARROW_RIGHT_KEYCODE: 39,
- END_KEYCODE: 35,
- ENTER_KEYCODE: 13,
- EXTRA_SCROLL_AMOUNT: 20,
- HOME_KEYCODE: 36,
- SPACE_KEYCODE: 32
- };
- exports.numbers = numbers;
- /***/ }),
- /***/ "./packages/mdc-tab-bar/foundation.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-tab-bar/foundation.ts ***!
- \********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-bar/constants.ts");
- var ACCEPTABLE_KEYS = new Set();
- // IE11 has no support for new Set with iterable so we need to initialize this by hand
- ACCEPTABLE_KEYS.add(constants_1.strings.ARROW_LEFT_KEY);
- ACCEPTABLE_KEYS.add(constants_1.strings.ARROW_RIGHT_KEY);
- ACCEPTABLE_KEYS.add(constants_1.strings.END_KEY);
- ACCEPTABLE_KEYS.add(constants_1.strings.HOME_KEY);
- ACCEPTABLE_KEYS.add(constants_1.strings.ENTER_KEY);
- ACCEPTABLE_KEYS.add(constants_1.strings.SPACE_KEY);
- var KEYCODE_MAP = new Map();
- // IE11 has no support for new Map with iterable so we need to initialize this by hand
- KEYCODE_MAP.set(constants_1.numbers.ARROW_LEFT_KEYCODE, constants_1.strings.ARROW_LEFT_KEY);
- KEYCODE_MAP.set(constants_1.numbers.ARROW_RIGHT_KEYCODE, constants_1.strings.ARROW_RIGHT_KEY);
- KEYCODE_MAP.set(constants_1.numbers.END_KEYCODE, constants_1.strings.END_KEY);
- KEYCODE_MAP.set(constants_1.numbers.HOME_KEYCODE, constants_1.strings.HOME_KEY);
- KEYCODE_MAP.set(constants_1.numbers.ENTER_KEYCODE, constants_1.strings.ENTER_KEY);
- KEYCODE_MAP.set(constants_1.numbers.SPACE_KEYCODE, constants_1.strings.SPACE_KEY);
- var MDCTabBarFoundation = /** @class */function (_super) {
- __extends(MDCTabBarFoundation, _super);
- function MDCTabBarFoundation(adapter) {
- var _this = _super.call(this, __assign(__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(__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(__assign({}, MDCTabScrollerFoundation.defaultAdapter), adapter)) || this;
- /**
- * Controls whether we should handle the transitionend and interaction events during the animation.
- */
- _this.isAnimating_ = false;
- return _this;
- }
- Object.defineProperty(MDCTabScrollerFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabScrollerFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTabScrollerFoundation, "defaultAdapter", {
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- eventTargetMatchesSelector: function eventTargetMatchesSelector() {
- return false;
- },
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- addScrollAreaClass: function addScrollAreaClass() {
- return undefined;
- },
- setScrollAreaStyleProperty: function setScrollAreaStyleProperty() {
- return undefined;
- },
- setScrollContentStyleProperty: function setScrollContentStyleProperty() {
- return undefined;
- },
- getScrollContentStyleValue: function getScrollContentStyleValue() {
- return '';
- },
- setScrollAreaScrollLeft: function setScrollAreaScrollLeft() {
- return undefined;
- },
- getScrollAreaScrollLeft: function getScrollAreaScrollLeft() {
- return 0;
- },
- getScrollContentOffsetWidth: function getScrollContentOffsetWidth() {
- return 0;
- },
- getScrollAreaOffsetWidth: function getScrollAreaOffsetWidth() {
- return 0;
- },
- computeScrollAreaClientRect: function computeScrollAreaClientRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- computeScrollContentClientRect: function computeScrollContentClientRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- computeHorizontalScrollbarHeight: function computeHorizontalScrollbarHeight() {
- return 0;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCTabScrollerFoundation.prototype.init = function () {
- // Compute horizontal scrollbar height on scroller with overflow initially hidden, then update overflow to scroll
- // and immediately adjust bottom margin to avoid the scrollbar initially appearing before JS runs.
- var horizontalScrollbarHeight = this.adapter.computeHorizontalScrollbarHeight();
- this.adapter.setScrollAreaStyleProperty('margin-bottom', -horizontalScrollbarHeight + 'px');
- this.adapter.addScrollAreaClass(MDCTabScrollerFoundation.cssClasses.SCROLL_AREA_SCROLL);
- };
- /**
- * Computes the current visual scroll position
- */
- MDCTabScrollerFoundation.prototype.getScrollPosition = function () {
- if (this.isRTL_()) {
- return this.computeCurrentScrollPositionRTL_();
- }
- var currentTranslateX = this.calculateCurrentTranslateX_();
- var scrollLeft = this.adapter.getScrollAreaScrollLeft();
- return scrollLeft - currentTranslateX;
- };
- /**
- * Handles interaction events that occur during transition
- */
- MDCTabScrollerFoundation.prototype.handleInteraction = function () {
- // Early exit if we aren't animating
- if (!this.isAnimating_) {
- return;
- }
- // Prevent other event listeners from handling this event
- this.stopScrollAnimation_();
- };
- /**
- * Handles the transitionend event
- */
- MDCTabScrollerFoundation.prototype.handleTransitionEnd = function (evt) {
- // Early exit if we aren't animating or the event was triggered by a different element.
- var evtTarget = evt.target;
- if (!this.isAnimating_ || !this.adapter.eventTargetMatchesSelector(evtTarget, MDCTabScrollerFoundation.strings.CONTENT_SELECTOR)) {
- return;
- }
- this.isAnimating_ = false;
- this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
- };
- /**
- * Increment the scroll value by the scrollXIncrement using animation.
- * @param scrollXIncrement The value by which to increment the scroll position
- */
- MDCTabScrollerFoundation.prototype.incrementScroll = function (scrollXIncrement) {
- // Early exit for non-operational increment values
- if (scrollXIncrement === 0) {
- return;
- }
- this.animate_(this.getIncrementScrollOperation_(scrollXIncrement));
- };
- /**
- * Increment the scroll value by the scrollXIncrement without animation.
- * @param scrollXIncrement The value by which to increment the scroll position
- */
- MDCTabScrollerFoundation.prototype.incrementScrollImmediate = function (scrollXIncrement) {
- // Early exit for non-operational increment values
- if (scrollXIncrement === 0) {
- return;
- }
- var operation = this.getIncrementScrollOperation_(scrollXIncrement);
- if (operation.scrollDelta === 0) {
- return;
- }
- this.stopScrollAnimation_();
- this.adapter.setScrollAreaScrollLeft(operation.finalScrollPosition);
- };
- /**
- * Scrolls to the given scrollX value
- */
- MDCTabScrollerFoundation.prototype.scrollTo = function (scrollX) {
- if (this.isRTL_()) {
- return this.scrollToRTL_(scrollX);
- }
- this.scrollTo_(scrollX);
- };
- /**
- * @return Browser-specific {@link MDCTabScrollerRTL} instance.
- */
- MDCTabScrollerFoundation.prototype.getRTLScroller = function () {
- if (!this.rtlScrollerInstance_) {
- this.rtlScrollerInstance_ = this.rtlScrollerFactory_();
- }
- return this.rtlScrollerInstance_;
- };
- /**
- * @return translateX value from a CSS matrix transform function string.
- */
- MDCTabScrollerFoundation.prototype.calculateCurrentTranslateX_ = function () {
- var transformValue = this.adapter.getScrollContentStyleValue('transform');
- // Early exit if no transform is present
- if (transformValue === 'none') {
- return 0;
- }
- // The transform value comes back as a matrix transformation in the form
- // of `matrix(a, b, c, d, tx, ty)`. We only care about tx (translateX) so
- // we're going to grab all the parenthesized values, strip out tx, and
- // parse it.
- var match = /\((.+?)\)/.exec(transformValue);
- if (!match) {
- return 0;
- }
- var matrixParams = match[1];
- // tslint:disable-next-line:ban-ts-ignore "Unused vars" should be a linter warning, not a compiler error.
- // @ts-ignore These unused variables should retain their semantic names for clarity.
- var _a = __read(matrixParams.split(','), 6),
- a = _a[0],
- b = _a[1],
- c = _a[2],
- d = _a[3],
- tx = _a[4],
- ty = _a[5];
- return parseFloat(tx); // tslint:disable-line:ban
- };
- /**
- * Calculates a safe scroll value that is > 0 and < the max scroll value
- * @param scrollX The distance to scroll
- */
- MDCTabScrollerFoundation.prototype.clampScrollValue_ = function (scrollX) {
- var edges = this.calculateScrollEdges_();
- return Math.min(Math.max(edges.left, scrollX), edges.right);
- };
- MDCTabScrollerFoundation.prototype.computeCurrentScrollPositionRTL_ = function () {
- var translateX = this.calculateCurrentTranslateX_();
- return this.getRTLScroller().getScrollPositionRTL(translateX);
- };
- MDCTabScrollerFoundation.prototype.calculateScrollEdges_ = function () {
- var contentWidth = this.adapter.getScrollContentOffsetWidth();
- var rootWidth = this.adapter.getScrollAreaOffsetWidth();
- return {
- left: 0,
- right: contentWidth - rootWidth
- };
- };
- /**
- * Internal scroll method
- * @param scrollX The new scroll position
- */
- MDCTabScrollerFoundation.prototype.scrollTo_ = function (scrollX) {
- var currentScrollX = this.getScrollPosition();
- var safeScrollX = this.clampScrollValue_(scrollX);
- var scrollDelta = safeScrollX - currentScrollX;
- this.animate_({
- finalScrollPosition: safeScrollX,
- scrollDelta: scrollDelta
- });
- };
- /**
- * Internal RTL scroll method
- * @param scrollX The new scroll position
- */
- MDCTabScrollerFoundation.prototype.scrollToRTL_ = function (scrollX) {
- var animation = this.getRTLScroller().scrollToRTL(scrollX);
- this.animate_(animation);
- };
- /**
- * Internal method to compute the increment scroll operation values.
- * @param scrollX The desired scroll position increment
- * @return MDCTabScrollerAnimation with the sanitized values for performing the scroll operation.
- */
- MDCTabScrollerFoundation.prototype.getIncrementScrollOperation_ = function (scrollX) {
- if (this.isRTL_()) {
- return this.getRTLScroller().incrementScrollRTL(scrollX);
- }
- var currentScrollX = this.getScrollPosition();
- var targetScrollX = scrollX + currentScrollX;
- var safeScrollX = this.clampScrollValue_(targetScrollX);
- var scrollDelta = safeScrollX - currentScrollX;
- return {
- finalScrollPosition: safeScrollX,
- scrollDelta: scrollDelta
- };
- };
- /**
- * Animates the tab scrolling
- * @param animation The animation to apply
- */
- MDCTabScrollerFoundation.prototype.animate_ = function (animation) {
- var _this = this;
- // Early exit if translateX is 0, which means there's no animation to perform
- if (animation.scrollDelta === 0) {
- return;
- }
- this.stopScrollAnimation_();
- // This animation uses the FLIP approach.
- // Read more here: https://aerotwist.com/blog/flip-your-animations/
- this.adapter.setScrollAreaScrollLeft(animation.finalScrollPosition);
- this.adapter.setScrollContentStyleProperty('transform', "translateX(" + animation.scrollDelta + "px)");
- // Force repaint
- this.adapter.computeScrollAreaClientRect();
- requestAnimationFrame(function () {
- _this.adapter.addClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
- _this.adapter.setScrollContentStyleProperty('transform', 'none');
- });
- this.isAnimating_ = true;
- };
- /**
- * Stops scroll animation
- */
- MDCTabScrollerFoundation.prototype.stopScrollAnimation_ = function () {
- this.isAnimating_ = false;
- var currentScrollPosition = this.getAnimatingScrollPosition_();
- this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING);
- this.adapter.setScrollContentStyleProperty('transform', 'translateX(0px)');
- this.adapter.setScrollAreaScrollLeft(currentScrollPosition);
- };
- /**
- * Gets the current scroll position during animation
- */
- MDCTabScrollerFoundation.prototype.getAnimatingScrollPosition_ = function () {
- var currentTranslateX = this.calculateCurrentTranslateX_();
- var scrollLeft = this.adapter.getScrollAreaScrollLeft();
- if (this.isRTL_()) {
- return this.getRTLScroller().getAnimatingScrollPosition(scrollLeft, currentTranslateX);
- }
- return scrollLeft - currentTranslateX;
- };
- /**
- * Determines the RTL Scroller to use
- */
- MDCTabScrollerFoundation.prototype.rtlScrollerFactory_ = function () {
- // Browsers have three different implementations of scrollLeft in RTL mode,
- // dependent on the browser. The behavior is based off the max LTR
- // scrollLeft value and 0.
- //
- // * Default scrolling in RTL *
- // - Left-most value: 0
- // - Right-most value: Max LTR scrollLeft value
- //
- // * Negative scrolling in RTL *
- // - Left-most value: Negated max LTR scrollLeft value
- // - Right-most value: 0
- //
- // * Reverse scrolling in RTL *
- // - Left-most value: Max LTR scrollLeft value
- // - Right-most value: 0
- //
- // We use those principles below to determine which RTL scrollLeft
- // behavior is implemented in the current browser.
- var initialScrollLeft = this.adapter.getScrollAreaScrollLeft();
- this.adapter.setScrollAreaScrollLeft(initialScrollLeft - 1);
- var newScrollLeft = this.adapter.getScrollAreaScrollLeft();
- // If the newScrollLeft value is negative,then we know that the browser has
- // implemented negative RTL scrolling, since all other implementations have
- // only positive values.
- if (newScrollLeft < 0) {
- // Undo the scrollLeft test check
- this.adapter.setScrollAreaScrollLeft(initialScrollLeft);
- return new rtl_negative_scroller_1.MDCTabScrollerRTLNegative(this.adapter);
- }
- var rootClientRect = this.adapter.computeScrollAreaClientRect();
- var contentClientRect = this.adapter.computeScrollContentClientRect();
- var rightEdgeDelta = Math.round(contentClientRect.right - rootClientRect.right);
- // Undo the scrollLeft test check
- this.adapter.setScrollAreaScrollLeft(initialScrollLeft);
- // By calculating the clientRect of the root element and the clientRect of
- // the content element, we can determine how much the scroll value changed
- // when we performed the scrollLeft subtraction above.
- if (rightEdgeDelta === newScrollLeft) {
- return new rtl_reverse_scroller_1.MDCTabScrollerRTLReverse(this.adapter);
- }
- return new rtl_default_scroller_1.MDCTabScrollerRTLDefault(this.adapter);
- };
- MDCTabScrollerFoundation.prototype.isRTL_ = function () {
- return this.adapter.getScrollContentStyleValue('direction') === 'rtl';
- };
- return MDCTabScrollerFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTabScrollerFoundation = MDCTabScrollerFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabScrollerFoundation;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/index.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-tab-scroller/index.ts ***!
- \********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var util = __importStar(__webpack_require__(/*! ./util */ "./packages/mdc-tab-scroller/util.ts"));
- exports.util = util;
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-tab-scroller/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tab-scroller/foundation.ts"));
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/rtl-default-scroller.ts":
- /*!***********************************************************!*\
- !*** ./packages/mdc-tab-scroller/rtl-default-scroller.ts ***!
- \***********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
- var MDCTabScrollerRTLDefault = /** @class */function (_super) {
- __extends(MDCTabScrollerRTLDefault, _super);
- function MDCTabScrollerRTLDefault() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTabScrollerRTLDefault.prototype.getScrollPositionRTL = function () {
- var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
- var right = this.calculateScrollEdges_().right;
- // Scroll values on most browsers are ints instead of floats so we round
- return Math.round(right - currentScrollLeft);
- };
- MDCTabScrollerRTLDefault.prototype.scrollToRTL = function (scrollX) {
- var edges = this.calculateScrollEdges_();
- var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(edges.right - scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: clampedScrollLeft - currentScrollLeft
- };
- };
- MDCTabScrollerRTLDefault.prototype.incrementScrollRTL = function (scrollX) {
- var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft - scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: clampedScrollLeft - currentScrollLeft
- };
- };
- MDCTabScrollerRTLDefault.prototype.getAnimatingScrollPosition = function (scrollX) {
- return scrollX;
- };
- MDCTabScrollerRTLDefault.prototype.calculateScrollEdges_ = function () {
- var contentWidth = this.adapter.getScrollContentOffsetWidth();
- var rootWidth = this.adapter.getScrollAreaOffsetWidth();
- return {
- left: 0,
- right: contentWidth - rootWidth
- };
- };
- MDCTabScrollerRTLDefault.prototype.clampScrollValue_ = function (scrollX) {
- var edges = this.calculateScrollEdges_();
- return Math.min(Math.max(edges.left, scrollX), edges.right);
- };
- return MDCTabScrollerRTLDefault;
- }(rtl_scroller_1.MDCTabScrollerRTL);
- exports.MDCTabScrollerRTLDefault = MDCTabScrollerRTLDefault;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabScrollerRTLDefault;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/rtl-negative-scroller.ts":
- /*!************************************************************!*\
- !*** ./packages/mdc-tab-scroller/rtl-negative-scroller.ts ***!
- \************************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
- var MDCTabScrollerRTLNegative = /** @class */function (_super) {
- __extends(MDCTabScrollerRTLNegative, _super);
- function MDCTabScrollerRTLNegative() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTabScrollerRTLNegative.prototype.getScrollPositionRTL = function (translateX) {
- var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
- return Math.round(translateX - currentScrollLeft);
- };
- MDCTabScrollerRTLNegative.prototype.scrollToRTL = function (scrollX) {
- var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(-scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: clampedScrollLeft - currentScrollLeft
- };
- };
- MDCTabScrollerRTLNegative.prototype.incrementScrollRTL = function (scrollX) {
- var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft - scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: clampedScrollLeft - currentScrollLeft
- };
- };
- MDCTabScrollerRTLNegative.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
- return scrollX - translateX;
- };
- MDCTabScrollerRTLNegative.prototype.calculateScrollEdges_ = function () {
- var contentWidth = this.adapter.getScrollContentOffsetWidth();
- var rootWidth = this.adapter.getScrollAreaOffsetWidth();
- return {
- left: rootWidth - contentWidth,
- right: 0
- };
- };
- MDCTabScrollerRTLNegative.prototype.clampScrollValue_ = function (scrollX) {
- var edges = this.calculateScrollEdges_();
- return Math.max(Math.min(edges.right, scrollX), edges.left);
- };
- return MDCTabScrollerRTLNegative;
- }(rtl_scroller_1.MDCTabScrollerRTL);
- exports.MDCTabScrollerRTLNegative = MDCTabScrollerRTLNegative;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabScrollerRTLNegative;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/rtl-reverse-scroller.ts":
- /*!***********************************************************!*\
- !*** ./packages/mdc-tab-scroller/rtl-reverse-scroller.ts ***!
- \***********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- Object.defineProperty(exports, "__esModule", { value: true });
- var rtl_scroller_1 = __webpack_require__(/*! ./rtl-scroller */ "./packages/mdc-tab-scroller/rtl-scroller.ts");
- var MDCTabScrollerRTLReverse = /** @class */function (_super) {
- __extends(MDCTabScrollerRTLReverse, _super);
- function MDCTabScrollerRTLReverse() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTabScrollerRTLReverse.prototype.getScrollPositionRTL = function (translateX) {
- var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
- // Scroll values on most browsers are ints instead of floats so we round
- return Math.round(currentScrollLeft - translateX);
- };
- MDCTabScrollerRTLReverse.prototype.scrollToRTL = function (scrollX) {
- var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: currentScrollLeft - clampedScrollLeft
- };
- };
- MDCTabScrollerRTLReverse.prototype.incrementScrollRTL = function (scrollX) {
- var currentScrollLeft = this.adapter.getScrollAreaScrollLeft();
- var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft + scrollX);
- return {
- finalScrollPosition: clampedScrollLeft,
- scrollDelta: currentScrollLeft - clampedScrollLeft
- };
- };
- MDCTabScrollerRTLReverse.prototype.getAnimatingScrollPosition = function (scrollX, translateX) {
- return scrollX + translateX;
- };
- MDCTabScrollerRTLReverse.prototype.calculateScrollEdges_ = function () {
- var contentWidth = this.adapter.getScrollContentOffsetWidth();
- var rootWidth = this.adapter.getScrollAreaOffsetWidth();
- return {
- left: contentWidth - rootWidth,
- right: 0
- };
- };
- MDCTabScrollerRTLReverse.prototype.clampScrollValue_ = function (scrollX) {
- var edges = this.calculateScrollEdges_();
- return Math.min(Math.max(edges.right, scrollX), edges.left);
- };
- return MDCTabScrollerRTLReverse;
- }(rtl_scroller_1.MDCTabScrollerRTL);
- exports.MDCTabScrollerRTLReverse = MDCTabScrollerRTLReverse;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabScrollerRTLReverse;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/rtl-scroller.ts":
- /*!***************************************************!*\
- !*** ./packages/mdc-tab-scroller/rtl-scroller.ts ***!
- \***************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var MDCTabScrollerRTL = /** @class */function () {
- function MDCTabScrollerRTL(adapter) {
- this.adapter = adapter;
- }
- return MDCTabScrollerRTL;
- }();
- exports.MDCTabScrollerRTL = MDCTabScrollerRTL;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTabScrollerRTL;
- /***/ }),
- /***/ "./packages/mdc-tab-scroller/util.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-tab-scroller/util.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tab-scroller/constants.ts");
- /**
- * Stores result from computeHorizontalScrollbarHeight to avoid redundant processing.
- */
- var horizontalScrollbarHeight_;
- /**
- * Computes the height of browser-rendered horizontal scrollbars using a self-created test element.
- * May return 0 (e.g. on OS X browsers under default configuration).
- */
- function computeHorizontalScrollbarHeight(documentObj, shouldCacheResult) {
- if (shouldCacheResult === void 0) {
- shouldCacheResult = true;
- }
- if (shouldCacheResult && typeof horizontalScrollbarHeight_ !== 'undefined') {
- return horizontalScrollbarHeight_;
- }
- var el = documentObj.createElement('div');
- el.classList.add(constants_1.cssClasses.SCROLL_TEST);
- documentObj.body.appendChild(el);
- var horizontalScrollbarHeight = el.offsetHeight - el.clientHeight;
- documentObj.body.removeChild(el);
- if (shouldCacheResult) {
- horizontalScrollbarHeight_ = horizontalScrollbarHeight;
- }
- return horizontalScrollbarHeight;
- }
- exports.computeHorizontalScrollbarHeight = computeHorizontalScrollbarHeight;
- /***/ }),
- /***/ "./packages/mdc-tab/component.ts":
- /*!***************************************!*\
- !*** ./packages/mdc-tab/component.ts ***!
- \***************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2018 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var component_2 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var component_3 = __webpack_require__(/*! @material/tab-indicator/component */ "./packages/mdc-tab-indicator/component.ts");
- var foundation_2 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tab/foundation.ts");
- var MDCTab = /** @class */function (_super) {
- __extends(MDCTab, _super);
- function MDCTab() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTab.attachTo = function (root) {
- return new MDCTab(root);
- };
- MDCTab.prototype.initialize = function (rippleFactory, tabIndicatorFactory) {
- if (rippleFactory === void 0) {
- rippleFactory = function rippleFactory(el, foundation) {
- return new component_2.MDCRipple(el, foundation);
- };
- }
- if (tabIndicatorFactory === void 0) {
- tabIndicatorFactory = function tabIndicatorFactory(el) {
- return new component_3.MDCTabIndicator(el);
- };
- }
- this.id = this.root.id;
- var rippleSurface = this.root.querySelector(foundation_2.MDCTabFoundation.strings.RIPPLE_SELECTOR);
- var rippleAdapter = __assign(__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(__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, "foundationForTextField", {
- // Provided for access by MDCTextField component
- 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(__assign({}, MDCTextFieldCharacterCounterFoundation.defaultAdapter), adapter)) || this;
- }
- Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "defaultAdapter", {
- /**
- * See {@link MDCTextFieldCharacterCounterAdapter} for typing information on parameters and return types.
- */
- get: function get() {
- return {
- setContent: function setContent() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCTextFieldCharacterCounterFoundation.prototype.setCounterValue = function (currentLength, maxLength) {
- currentLength = Math.min(currentLength, maxLength);
- this.adapter.setContent(currentLength + " / " + maxLength);
- };
- return MDCTextFieldCharacterCounterFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTextFieldCharacterCounterFoundation = MDCTextFieldCharacterCounterFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTextFieldCharacterCounterFoundation;
- /***/ }),
- /***/ "./packages/mdc-textfield/character-counter/index.ts":
- /*!***********************************************************!*\
- !*** ./packages/mdc-textfield/character-counter/index.ts ***!
- \***********************************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/character-counter/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/character-counter/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/character-counter/constants.ts");
- exports.characterCountCssClasses = constants_1.cssClasses;
- exports.characterCountStrings = constants_1.strings;
- /***/ }),
- /***/ "./packages/mdc-textfield/component.ts":
- /*!*********************************************!*\
- !*** ./packages/mdc-textfield/component.ts ***!
- \*********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2016 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- var __extends = this && this.__extends || function () {
- var _extendStatics = function extendStatics(d, b) {
- _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
- d.__proto__ = b;
- } || function (d, b) {
- for (var p in b) {
- if (b.hasOwnProperty(p)) d[p] = b[p];
- }
- };
- return _extendStatics(d, b);
- };
- return function (d, b) {
- _extendStatics(d, b);
- function __() {
- this.constructor = d;
- }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- }();
- var __assign = this && this.__assign || function () {
- __assign = Object.assign || function (t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) {
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
- }
- }
- return t;
- };
- return __assign.apply(this, arguments);
- };
- var __importStar = this && this.__importStar || function (mod) {
- if (mod && mod.__esModule) return mod;
- var result = {};
- if (mod != null) for (var k in mod) {
- if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
- }result["default"] = mod;
- return result;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
- var events_1 = __webpack_require__(/*! @material/dom/events */ "./packages/mdc-dom/events.ts");
- var ponyfill = __importStar(__webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts"));
- var component_2 = __webpack_require__(/*! @material/floating-label/component */ "./packages/mdc-floating-label/component.ts");
- var component_3 = __webpack_require__(/*! @material/line-ripple/component */ "./packages/mdc-line-ripple/component.ts");
- var component_4 = __webpack_require__(/*! @material/notched-outline/component */ "./packages/mdc-notched-outline/component.ts");
- var component_5 = __webpack_require__(/*! @material/ripple/component */ "./packages/mdc-ripple/component.ts");
- var foundation_1 = __webpack_require__(/*! @material/ripple/foundation */ "./packages/mdc-ripple/foundation.ts");
- var component_6 = __webpack_require__(/*! ./character-counter/component */ "./packages/mdc-textfield/character-counter/component.ts");
- var foundation_2 = __webpack_require__(/*! ./character-counter/foundation */ "./packages/mdc-textfield/character-counter/foundation.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts");
- var foundation_3 = __webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/foundation.ts");
- var component_7 = __webpack_require__(/*! ./helper-text/component */ "./packages/mdc-textfield/helper-text/component.ts");
- var foundation_4 = __webpack_require__(/*! ./helper-text/foundation */ "./packages/mdc-textfield/helper-text/foundation.ts");
- var component_8 = __webpack_require__(/*! ./icon/component */ "./packages/mdc-textfield/icon/component.ts");
- var MDCTextField = /** @class */function (_super) {
- __extends(MDCTextField, _super);
- function MDCTextField() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTextField.attachTo = function (root) {
- return new MDCTextField(root);
- };
- MDCTextField.prototype.initialize = function (rippleFactory, lineRippleFactory, helperTextFactory, characterCounterFactory, iconFactory, labelFactory, outlineFactory) {
- if (rippleFactory === void 0) {
- rippleFactory = function rippleFactory(el, foundation) {
- return new component_5.MDCRipple(el, foundation);
- };
- }
- if (lineRippleFactory === void 0) {
- lineRippleFactory = function lineRippleFactory(el) {
- return new component_3.MDCLineRipple(el);
- };
- }
- if (helperTextFactory === void 0) {
- helperTextFactory = function helperTextFactory(el) {
- return new component_7.MDCTextFieldHelperText(el);
- };
- }
- if (characterCounterFactory === void 0) {
- characterCounterFactory = function characterCounterFactory(el) {
- return new component_6.MDCTextFieldCharacterCounter(el);
- };
- }
- if (iconFactory === void 0) {
- iconFactory = function iconFactory(el) {
- return new component_8.MDCTextFieldIcon(el);
- };
- }
- if (labelFactory === void 0) {
- labelFactory = function labelFactory(el) {
- return new component_2.MDCFloatingLabel(el);
- };
- }
- if (outlineFactory === void 0) {
- outlineFactory = function outlineFactory(el) {
- return new component_4.MDCNotchedOutline(el);
- };
- }
- this.input_ = this.root.querySelector(constants_1.strings.INPUT_SELECTOR);
- var labelElement = this.root.querySelector(constants_1.strings.LABEL_SELECTOR);
- this.label_ = labelElement ? labelFactory(labelElement) : null;
- var lineRippleElement = this.root.querySelector(constants_1.strings.LINE_RIPPLE_SELECTOR);
- this.lineRipple_ = lineRippleElement ? lineRippleFactory(lineRippleElement) : null;
- var outlineElement = this.root.querySelector(constants_1.strings.OUTLINE_SELECTOR);
- this.outline_ = outlineElement ? outlineFactory(outlineElement) : null;
- // Helper text
- var helperTextStrings = foundation_4.MDCTextFieldHelperTextFoundation.strings;
- var nextElementSibling = this.root.nextElementSibling;
- var hasHelperLine = nextElementSibling && nextElementSibling.classList.contains(constants_1.cssClasses.HELPER_LINE);
- var helperTextEl = hasHelperLine && nextElementSibling && nextElementSibling.querySelector(helperTextStrings.ROOT_SELECTOR);
- this.helperText_ = helperTextEl ? helperTextFactory(helperTextEl) : null;
- // Character counter
- var characterCounterStrings = foundation_2.MDCTextFieldCharacterCounterFoundation.strings;
- var characterCounterEl = this.root.querySelector(characterCounterStrings.ROOT_SELECTOR);
- // If character counter is not found in root element search in sibling element.
- if (!characterCounterEl && hasHelperLine && nextElementSibling) {
- characterCounterEl = nextElementSibling.querySelector(characterCounterStrings.ROOT_SELECTOR);
- }
- this.characterCounter_ = characterCounterEl ? characterCounterFactory(characterCounterEl) : null;
- // Leading icon
- var leadingIconEl = this.root.querySelector(constants_1.strings.LEADING_ICON_SELECTOR);
- this.leadingIcon_ = leadingIconEl ? iconFactory(leadingIconEl) : null;
- // Trailing icon
- var trailingIconEl = this.root.querySelector(constants_1.strings.TRAILING_ICON_SELECTOR);
- this.trailingIcon_ = trailingIconEl ? iconFactory(trailingIconEl) : null;
- // Prefix and Suffix
- this.prefix_ = this.root.querySelector(constants_1.strings.PREFIX_SELECTOR);
- this.suffix_ = this.root.querySelector(constants_1.strings.SUFFIX_SELECTOR);
- 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
- });
- Object.defineProperty(MDCTextField.prototype, "prefixText", {
- /**
- * Gets the text content of the prefix, or null if it does not exist.
- */
- get: function get() {
- return this.prefix_ ? this.prefix_.textContent : null;
- },
- /**
- * Sets the text content of the prefix, if it exists.
- */
- set: function set(prefixText) {
- if (this.prefix_) {
- this.prefix_.textContent = prefixText;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextField.prototype, "suffixText", {
- /**
- * Gets the text content of the suffix, or null if it does not exist.
- */
- get: function get() {
- return this.suffix_ ? this.suffix_.textContent : null;
- },
- /**
- * Sets the text content of the suffix, if it exists.
- */
- set: function set(suffixText) {
- if (this.suffix_) {
- this.suffix_.textContent = suffixText;
- }
- },
- 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(__assign(__assign(__assign(__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) {
- _this.listen(evtType, handler);
- },
- deregisterTextFieldInteractionHandler: function deregisterTextFieldInteractionHandler(evtType, handler) {
- _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) {
- 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_;
- },
- setInputAttr: function setInputAttr(attr, value) {
- _this.input_.setAttribute(attr, value);
- },
- removeInputAttr: function removeInputAttr(attr) {
- _this.input_.removeAttribute(attr);
- },
- isFocused: function isFocused() {
- return document.activeElement === _this.input_;
- },
- registerInputInteractionHandler: function registerInputInteractionHandler(evtType, handler) {
- _this.input_.addEventListener(evtType, handler, events_1.applyPassive());
- },
- deregisterInputInteractionHandler: function deregisterInputInteractionHandler(evtType, handler) {
- _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);
- },
- setLabelRequired: function setLabelRequired(isRequired) {
- return _this.label_ && _this.label_.setRequired(isRequired);
- }
- };
- };
- 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_.foundationForTextField : undefined,
- helperText: this.helperText_ ? this.helperText_.foundationForTextField : undefined,
- leadingIcon: this.leadingIcon_ ? this.leadingIcon_.foundationForTextField : undefined,
- trailingIcon: this.trailingIcon_ ? this.trailingIcon_.foundationForTextField : 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(__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',
- ARIA_DESCRIBEDBY: 'aria-describedby',
- INPUT_SELECTOR: '.mdc-text-field__input',
- LABEL_SELECTOR: '.mdc-floating-label',
- LEADING_ICON_SELECTOR: '.mdc-text-field__icon--leading',
- LINE_RIPPLE_SELECTOR: '.mdc-line-ripple',
- OUTLINE_SELECTOR: '.mdc-notched-outline',
- PREFIX_SELECTOR: '.mdc-text-field__affix--prefix',
- SUFFIX_SELECTOR: '.mdc-text-field__affix--suffix',
- TRAILING_ICON_SELECTOR: '.mdc-text-field__icon--trailing'
- };
- exports.strings = strings;
- var cssClasses = {
- DISABLED: 'mdc-text-field--disabled',
- FOCUSED: 'mdc-text-field--focused',
- HELPER_LINE: 'mdc-text-field-helper-line',
- INVALID: 'mdc-text-field--invalid',
- LABEL_FLOATING: 'mdc-text-field--label-floating',
- 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 = {
- 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(__assign({}, MDCTextFieldFoundation.defaultAdapter), adapter)) || this;
- _this.isFocused_ = false;
- _this.receivedUserInput_ = false;
- _this.isValid_ = true;
- _this.useNativeValidation_ = true;
- _this.validateOnValueChange_ = true;
- _this.helperText_ = foundationMap.helperText;
- _this.characterCounter_ = foundationMap.characterCounter;
- _this.leadingIcon_ = foundationMap.leadingIcon;
- _this.trailingIcon_ = foundationMap.trailingIcon;
- _this.inputFocusHandler_ = function () {
- return _this.activateFocus();
- };
- _this.inputBlurHandler_ = function () {
- return _this.deactivateFocus();
- };
- _this.inputInputHandler_ = function () {
- return _this.handleInput();
- };
- _this.setPointerXOffset_ = function (evt) {
- return _this.setTransformOrigin(evt);
- };
- _this.textFieldInteractionHandler_ = function () {
- return _this.handleTextFieldInteraction();
- };
- _this.validationAttributeChangeHandler_ = function (attributesList) {
- return _this.handleValidationAttributeChange(attributesList);
- };
- return _this;
- }
- Object.defineProperty(MDCTextFieldFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation, "numbers", {
- get: function get() {
- return constants_1.numbers;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldAlwaysFloat_", {
- get: function get() {
- var type = this.getNativeInput_().type;
- return constants_1.ALWAYS_FLOAT_TYPES.indexOf(type) >= 0;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldFloat", {
- get: function get() {
- return this.shouldAlwaysFloat_ || this.isFocused_ || !!this.getValue() || this.isBadInput_();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldShake", {
- get: function get() {
- return !this.isFocused_ && !this.isValid() && !!this.getValue();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldFoundation, "defaultAdapter", {
- /**
- * See {@link MDCTextFieldAdapter} for typing information on parameters and
- * return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- addClass: function addClass() {
- return undefined;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return true;
- },
- setInputAttr: function setInputAttr() {
- return undefined;
- },
- removeInputAttr: function removeInputAttr() {
- return undefined;
- },
- 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;
- },
- setLabelRequired: function setLabelRequired() {
- 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.hasLabel() && this.getNativeInput_().required) {
- this.adapter.setLabelRequired(true);
- }
- if (this.adapter.isFocused()) {
- this.inputFocusHandler_();
- } else if (this.adapter.hasLabel() && this.shouldFloat) {
- this.notchOutline(true);
- this.adapter.floatLabel(true);
- this.styleFloating_(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);
- _this.adapter.setLabelRequired(_this.getNativeInput_().required);
- 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() || !this.adapter.hasLabel()) {
- return;
- }
- if (openNotch) {
- var labelWidth = this.adapter.getLabelWidth() * constants_1.numbers.LABEL_SCALE;
- 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.styleFloating_(this.shouldFloat);
- this.adapter.shakeLabel(this.shouldShake);
- }
- if (this.helperText_ && (this.helperText_.isPersistent() || !this.helperText_.isValidation() || !this.isValid_)) {
- 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) {
- if (this.isDisabled() || this.adapter.hasOutline()) {
- return;
- }
- 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.styleFloating_(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);
- if (this.validateOnValueChange_) {
- var isValid = this.isValid();
- this.styleValidity_(isValid);
- }
- if (this.adapter.hasLabel()) {
- this.notchOutline(this.shouldFloat);
- this.adapter.floatLabel(this.shouldFloat);
- this.styleFloating_(this.shouldFloat);
- if (this.validateOnValueChange_) {
- this.adapter.shakeLabel(this.shouldShake);
- }
- }
- };
- /**
- * @return The custom validity state, if set; otherwise, the result of a
- * native validity check.
- */
- MDCTextFieldFoundation.prototype.isValid = function () {
- return this.useNativeValidation_ ? this.isNativeInputValid_() : this.isValid_;
- };
- /**
- * @param isValid Sets the custom validity state of the Text Field.
- */
- MDCTextFieldFoundation.prototype.setValid = function (isValid) {
- this.isValid_ = isValid;
- this.styleValidity_(isValid);
- var shouldShake = !isValid && !this.isFocused_ && !!this.getValue();
- if (this.adapter.hasLabel()) {
- this.adapter.shakeLabel(shouldShake);
- }
- };
- /**
- * @param shouldValidate Whether or not validity should be updated on
- * value change.
- */
- MDCTextFieldFoundation.prototype.setValidateOnValueChange = function (shouldValidate) {
- this.validateOnValueChange_ = shouldValidate;
- };
- /**
- * @return Whether or not validity should be updated on value change. `true`
- * by default.
- */
- MDCTextFieldFoundation.prototype.getValidateOnValueChange = function () {
- return this.validateOnValueChange_;
- };
- /**
- * 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);
- // We dynamically set or unset aria-describedby for validation helper text
- // only, based on whether the field is valid
- var helperTextValidation = this.helperText_.isValidation();
- if (!helperTextValidation) {
- return;
- }
- var helperTextVisible = this.helperText_.isVisible();
- var helperTextId = this.helperText_.getId();
- if (helperTextVisible && helperTextId) {
- this.adapter.setInputAttr(constants_1.strings.ARIA_DESCRIBEDBY, helperTextId);
- } else {
- this.adapter.removeInputAttr(constants_1.strings.ARIA_DESCRIBEDBY);
- }
- }
- };
- /**
- * 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);
- }
- };
- /**
- * Styles the component based on the label floating state.
- */
- MDCTextFieldFoundation.prototype.styleFloating_ = function (isFloating) {
- var LABEL_FLOATING = MDCTextFieldFoundation.cssClasses.LABEL_FLOATING;
- if (isFloating) {
- this.adapter.addClass(LABEL_FLOATING);
- } else {
- this.adapter.removeClass(LABEL_FLOATING);
- }
- };
- /**
- * @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,
- required: false,
- 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, "foundationForTextField", {
- // Provided for access by MDCTextField component
- 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);
- },
- 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;
- }
- };
- // 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(__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;
- },
- getAttr: function getAttr() {
- return null;
- },
- 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
- });
- MDCTextFieldHelperTextFoundation.prototype.getId = function () {
- return this.adapter.getAttr('id');
- };
- MDCTextFieldHelperTextFoundation.prototype.isVisible = function () {
- return this.adapter.getAttr(constants_1.strings.ARIA_HIDDEN) !== 'true';
- };
- /**
- * Sets the content of the helper text field.
- */
- MDCTextFieldHelperTextFoundation.prototype.setContent = function (content) {
- this.adapter.setContent(content);
- };
- MDCTextFieldHelperTextFoundation.prototype.isPersistent = function () {
- return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_PERSISTENT);
- };
- /**
- * @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);
- }
- };
- /**
- * @return whether the helper text acts as an error validation message.
- */
- MDCTextFieldHelperTextFoundation.prototype.isValidation = function () {
- return this.adapter.hasClass(constants_1.cssClasses.HELPER_TEXT_VALIDATION_MSG);
- };
- /**
- * @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.showToScreenReader();
- 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, "foundationForTextField", {
- // Provided for access by MDCTextField component
- 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(__assign({}, MDCTextFieldIconFoundation.defaultAdapter), adapter)) || this;
- _this.savedTabIndex_ = null;
- _this.interactionHandler_ = function (evt) {
- return _this.handleInteraction(evt);
- };
- return _this;
- }
- Object.defineProperty(MDCTextFieldIconFoundation, "strings", {
- get: function get() {
- return constants_1.strings;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldIconFoundation, "cssClasses", {
- get: function get() {
- return constants_1.cssClasses;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(MDCTextFieldIconFoundation, "defaultAdapter", {
- /**
- * See {@link MDCTextFieldIconAdapter} for typing information on parameters and return types.
- */
- get: function get() {
- // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
- return {
- getAttr: function getAttr() {
- return null;
- },
- setAttr: function setAttr() {
- return undefined;
- },
- removeAttr: function removeAttr() {
- return undefined;
- },
- setContent: function setContent() {
- return undefined;
- },
- registerInteractionHandler: function registerInteractionHandler() {
- return undefined;
- },
- deregisterInteractionHandler: function deregisterInteractionHandler() {
- return undefined;
- },
- notifyIconAction: function notifyIconAction() {
- return undefined;
- }
- };
- // tslint:enable:object-literal-sort-keys
- },
- enumerable: true,
- configurable: true
- });
- MDCTextFieldIconFoundation.prototype.init = function () {
- var _this = this;
- this.savedTabIndex_ = this.adapter.getAttr('tabindex');
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.adapter.registerInteractionHandler(evtType, _this.interactionHandler_);
- });
- };
- MDCTextFieldIconFoundation.prototype.destroy = function () {
- var _this = this;
- INTERACTION_EVENTS.forEach(function (evtType) {
- _this.adapter.deregisterInteractionHandler(evtType, _this.interactionHandler_);
- });
- };
- MDCTextFieldIconFoundation.prototype.setDisabled = function (disabled) {
- if (!this.savedTabIndex_) {
- return;
- }
- if (disabled) {
- this.adapter.setAttr('tabindex', '-1');
- this.adapter.removeAttr('role');
- } else {
- this.adapter.setAttr('tabindex', this.savedTabIndex_);
- this.adapter.setAttr('role', constants_1.strings.ICON_ROLE);
- }
- };
- MDCTextFieldIconFoundation.prototype.setAriaLabel = function (label) {
- this.adapter.setAttr('aria-label', label);
- };
- MDCTextFieldIconFoundation.prototype.setContent = function (content) {
- this.adapter.setContent(content);
- };
- MDCTextFieldIconFoundation.prototype.handleInteraction = function (evt) {
- var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13;
- if (evt.type === 'click' || isEnterKey) {
- evt.preventDefault(); // stop click from causing host label to focus
- // input
- this.adapter.notifyIconAction();
- }
- };
- return MDCTextFieldIconFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTextFieldIconFoundation = MDCTextFieldIconFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTextFieldIconFoundation;
- /***/ }),
- /***/ "./packages/mdc-textfield/icon/index.ts":
- /*!**********************************************!*\
- !*** ./packages/mdc-textfield/icon/index.ts ***!
- \**********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/icon/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/icon/foundation.ts"));
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-textfield/icon/constants.ts");
- exports.iconCssClasses = constants_1.cssClasses;
- exports.iconStrings = constants_1.strings;
- /***/ }),
- /***/ "./packages/mdc-textfield/index.ts":
- /*!*****************************************!*\
- !*** ./packages/mdc-textfield/index.ts ***!
- \*****************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2019 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- function __export(m) {
- for (var p in m) {
- if (!exports.hasOwnProperty(p)) exports[p] = m[p];
- }
- }
- Object.defineProperty(exports, "__esModule", { value: true });
- __export(__webpack_require__(/*! ./component */ "./packages/mdc-textfield/component.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-textfield/constants.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-textfield/foundation.ts"));
- __export(__webpack_require__(/*! ./character-counter/index */ "./packages/mdc-textfield/character-counter/index.ts"));
- __export(__webpack_require__(/*! ./helper-text/index */ "./packages/mdc-textfield/helper-text/index.ts"));
- __export(__webpack_require__(/*! ./icon/index */ "./packages/mdc-textfield/icon/index.ts"));
- /***/ }),
- /***/ "./packages/mdc-tooltip/component.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-tooltip/component.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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 constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts");
- var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-tooltip/foundation.ts");
- var MDCTooltip = /** @class */function (_super) {
- __extends(MDCTooltip, _super);
- function MDCTooltip() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDCTooltip.attachTo = function (root) {
- return new MDCTooltip(root);
- };
- MDCTooltip.prototype.initialize = function () {
- var tooltipId = this.root.getAttribute('id');
- if (!tooltipId) {
- throw new Error('MDCTooltip: Tooltip component must have an id.');
- }
- var anchorElem = document.querySelector("[aria-describedby=\"" + tooltipId + "\"]") || document.querySelector("[data-tooltip-id=\"" + tooltipId + "\"]");
- if (!anchorElem) {
- throw new Error('MDCTooltip: Tooltip component requires an anchor element annotated with [aria-describedby] or [data-tooltip-id] anchor element.');
- }
- this.anchorElem = anchorElem;
- };
- MDCTooltip.prototype.initialSyncWithDOM = function () {
- var _this = this;
- this.isTooltipRich = this.foundation.isRich();
- this.isTooltipPersistent = this.foundation.isPersistent();
- this.handleMouseEnter = function () {
- _this.foundation.handleAnchorMouseEnter();
- };
- this.handleFocus = function (evt) {
- _this.foundation.handleAnchorFocus(evt);
- };
- this.handleMouseLeave = function () {
- _this.foundation.handleAnchorMouseLeave();
- };
- this.handleBlur = function (evt) {
- _this.foundation.handleAnchorBlur(evt);
- };
- this.handleTransitionEnd = function () {
- _this.foundation.handleTransitionEnd();
- };
- this.handleClick = function () {
- _this.foundation.handleAnchorClick();
- };
- this.anchorElem.addEventListener('blur', this.handleBlur);
- if (this.isTooltipRich && this.isTooltipPersistent) {
- this.anchorElem.addEventListener('click', this.handleClick);
- } else {
- this.anchorElem.addEventListener('mouseenter', this.handleMouseEnter);
- // TODO(b/157075286): Listening for a 'focus' event is too broad.
- this.anchorElem.addEventListener('focus', this.handleFocus);
- this.anchorElem.addEventListener('mouseleave', this.handleMouseLeave);
- }
- this.listen('transitionend', this.handleTransitionEnd);
- };
- MDCTooltip.prototype.destroy = function () {
- if (this.anchorElem) {
- this.anchorElem.removeEventListener('blur', this.handleBlur);
- if (this.isTooltipRich && this.isTooltipPersistent) {
- this.anchorElem.removeEventListener('click', this.handleClick);
- } else {
- this.anchorElem.removeEventListener('mouseenter', this.handleMouseEnter);
- this.anchorElem.removeEventListener('focus', this.handleFocus);
- this.anchorElem.removeEventListener('mouseleave', this.handleMouseLeave);
- }
- }
- this.unlisten('transitionend', this.handleTransitionEnd);
- _super.prototype.destroy.call(this);
- };
- MDCTooltip.prototype.setTooltipPosition = function (position) {
- this.foundation.setTooltipPosition(position);
- };
- MDCTooltip.prototype.setAnchorBoundaryType = function (type) {
- this.foundation.setAnchorBoundaryType(type);
- };
- MDCTooltip.prototype.hide = function () {
- this.foundation.hide();
- };
- MDCTooltip.prototype.isShown = function () {
- this.foundation.isShown();
- };
- MDCTooltip.prototype.getDefaultFoundation = function () {
- var _this = this;
- var adapter = {
- getAttribute: function getAttribute(attr) {
- return _this.root.getAttribute(attr);
- },
- setAttribute: function setAttribute(attr, value) {
- _this.root.setAttribute(attr, value);
- },
- addClass: function addClass(className) {
- _this.root.classList.add(className);
- },
- hasClass: function hasClass(className) {
- return _this.root.classList.contains(className);
- },
- removeClass: function removeClass(className) {
- _this.root.classList.remove(className);
- },
- setStyleProperty: function setStyleProperty(propertyName, value) {
- _this.root.style.setProperty(propertyName, value);
- },
- getViewportWidth: function getViewportWidth() {
- return window.innerWidth;
- },
- getViewportHeight: function getViewportHeight() {
- return window.innerHeight;
- },
- getTooltipSize: function getTooltipSize() {
- return {
- width: _this.root.offsetWidth,
- height: _this.root.offsetHeight
- };
- },
- getAnchorBoundingRect: function getAnchorBoundingRect() {
- return _this.anchorElem ? _this.anchorElem.getBoundingClientRect() : null;
- },
- getAnchorAttribute: function getAnchorAttribute(attr) {
- return _this.anchorElem ? _this.anchorElem.getAttribute(attr) : null;
- },
- setAnchorAttribute: function setAnchorAttribute(attr, value) {
- var _a;
- (_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.setAttribute(attr, value);
- },
- isRTL: function isRTL() {
- return getComputedStyle(_this.root).direction === 'rtl';
- },
- anchorContainsElement: function anchorContainsElement(element) {
- var _a;
- return !!((_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.contains(element));
- },
- tooltipContainsElement: function tooltipContainsElement(element) {
- return _this.root.contains(element);
- },
- focusAnchorElement: function focusAnchorElement() {
- var _a;
- (_a = _this.anchorElem) === null || _a === void 0 ? void 0 : _a.focus();
- },
- registerEventHandler: function registerEventHandler(evt, handler) {
- if (_this.root instanceof HTMLElement) {
- _this.root.addEventListener(evt, handler);
- }
- },
- deregisterEventHandler: function deregisterEventHandler(evt, handler) {
- if (_this.root instanceof HTMLElement) {
- _this.root.removeEventListener(evt, handler);
- }
- },
- registerDocumentEventHandler: function registerDocumentEventHandler(evt, handler) {
- document.body.addEventListener(evt, handler);
- },
- deregisterDocumentEventHandler: function deregisterDocumentEventHandler(evt, handler) {
- document.body.removeEventListener(evt, handler);
- },
- registerWindowEventHandler: function registerWindowEventHandler(evt, handler) {
- window.addEventListener(evt, handler);
- },
- deregisterWindowEventHandler: function deregisterWindowEventHandler(evt, handler) {
- window.removeEventListener(evt, handler);
- },
- notifyHidden: function notifyHidden() {
- _this.emit(constants_1.events.HIDDEN, {});
- }
- };
- //tslint:enable:object-literal-sort-keys
- return new foundation_1.MDCTooltipFoundation(adapter);
- };
- return MDCTooltip;
- }(component_1.MDCComponent);
- exports.MDCTooltip = MDCTooltip;
- /***/ }),
- /***/ "./packages/mdc-tooltip/constants.ts":
- /*!*******************************************!*\
- !*** ./packages/mdc-tooltip/constants.ts ***!
- \*******************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- Object.defineProperty(exports, "__esModule", { value: true });
- var CssClasses;
- (function (CssClasses) {
- CssClasses["RICH"] = "mdc-tooltip--rich";
- CssClasses["SHOWN"] = "mdc-tooltip--shown";
- CssClasses["SHOWING"] = "mdc-tooltip--showing";
- CssClasses["SHOWING_TRANSITION"] = "mdc-tooltip--showing-transition";
- CssClasses["HIDE"] = "mdc-tooltip--hide";
- CssClasses["HIDE_TRANSITION"] = "mdc-tooltip--hide-transition";
- CssClasses["MULTILINE_TOOLTIP"] = "mdc-tooltip--multiline";
- })(CssClasses || (CssClasses = {}));
- exports.CssClasses = CssClasses;
- var numbers = {
- BOUNDED_ANCHOR_GAP: 4,
- UNBOUNDED_ANCHOR_GAP: 8,
- MIN_VIEWPORT_TOOLTIP_THRESHOLD: 8,
- HIDE_DELAY_MS: 600,
- SHOW_DELAY_MS: 500,
- // LINT.IfChange(tooltip-dimensions)
- MIN_HEIGHT: 24,
- MAX_WIDTH: 200
- };
- exports.numbers = numbers;
- var attributes = {
- ARIA_EXPANDED: 'aria-expanded',
- ARIA_HASPOPUP: 'aria-haspopup',
- PERSISTENT: 'data-mdc-tooltip-persistent'
- };
- exports.attributes = attributes;
- var events = {
- HIDDEN: 'MDCTooltip:hidden'
- };
- exports.events = events;
- /** Enum for possible tooltip positioning relative to its anchor element. */
- var XPosition;
- (function (XPosition) {
- XPosition[XPosition["DETECTED"] = 0] = "DETECTED";
- XPosition[XPosition["START"] = 1] = "START";
- // Note: CENTER is not valid for rich tooltips.
- XPosition[XPosition["CENTER"] = 2] = "CENTER";
- XPosition[XPosition["END"] = 3] = "END";
- })(XPosition || (XPosition = {}));
- exports.XPosition = XPosition;
- var YPosition;
- (function (YPosition) {
- YPosition[YPosition["DETECTED"] = 0] = "DETECTED";
- YPosition[YPosition["ABOVE"] = 1] = "ABOVE";
- YPosition[YPosition["BELOW"] = 2] = "BELOW";
- })(YPosition || (YPosition = {}));
- exports.YPosition = YPosition;
- /**
- * Enum for possible anchor boundary types. This determines the gap between the
- * bottom of the anchor and the tooltip element.
- * Bounded anchors have an identifiable boundary (e.g. buttons).
- * Unbounded anchors don't have a visually declared boundary (e.g. plain text).
- */
- var AnchorBoundaryType;
- (function (AnchorBoundaryType) {
- AnchorBoundaryType[AnchorBoundaryType["BOUNDED"] = 0] = "BOUNDED";
- AnchorBoundaryType[AnchorBoundaryType["UNBOUNDED"] = 1] = "UNBOUNDED";
- })(AnchorBoundaryType || (AnchorBoundaryType = {}));
- exports.AnchorBoundaryType = AnchorBoundaryType;
- /***/ }),
- /***/ "./packages/mdc-tooltip/foundation.ts":
- /*!********************************************!*\
- !*** ./packages/mdc-tooltip/foundation.ts ***!
- \********************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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 s = typeof Symbol === "function" && Symbol.iterator,
- m = s && o[s],
- i = 0;
- if (m) return m.call(o);
- if (o && typeof o.length === "number") return {
- next: function next() {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- var animationframe_1 = __webpack_require__(/*! @material/animation/animationframe */ "./packages/mdc-animation/animationframe.ts");
- var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
- var keyboard_1 = __webpack_require__(/*! @material/dom/keyboard */ "./packages/mdc-dom/keyboard.ts");
- var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.ts");
- var RICH = constants_1.CssClasses.RICH,
- SHOWN = constants_1.CssClasses.SHOWN,
- SHOWING = constants_1.CssClasses.SHOWING,
- SHOWING_TRANSITION = constants_1.CssClasses.SHOWING_TRANSITION,
- HIDE = constants_1.CssClasses.HIDE,
- HIDE_TRANSITION = constants_1.CssClasses.HIDE_TRANSITION,
- MULTILINE_TOOLTIP = constants_1.CssClasses.MULTILINE_TOOLTIP;
- var AnimationKeys;
- (function (AnimationKeys) {
- AnimationKeys["POLL_ANCHOR"] = "poll_anchor";
- })(AnimationKeys || (AnimationKeys = {}));
- var MDCTooltipFoundation = /** @class */function (_super) {
- __extends(MDCTooltipFoundation, _super);
- function MDCTooltipFoundation(adapter) {
- var _this = _super.call(this, __assign(__assign({}, MDCTooltipFoundation.defaultAdapter), adapter)) || this;
- _this.tooltipShown = false;
- _this.anchorGap = constants_1.numbers.BOUNDED_ANCHOR_GAP;
- _this.xTooltipPos = constants_1.XPosition.DETECTED;
- _this.yTooltipPos = constants_1.YPosition.DETECTED;
- // Minimum threshold distance needed between the tooltip and the viewport.
- _this.minViewportTooltipThreshold = constants_1.numbers.MIN_VIEWPORT_TOOLTIP_THRESHOLD;
- _this.hideDelayMs = constants_1.numbers.HIDE_DELAY_MS;
- _this.showDelayMs = constants_1.numbers.SHOW_DELAY_MS;
- _this.anchorRect = null;
- _this.frameId = null;
- _this.hideTimeout = null;
- _this.showTimeout = null;
- _this.animFrame = new animationframe_1.AnimationFrame();
- _this.documentClickHandler = function (evt) {
- _this.handleDocumentClick(evt);
- };
- _this.documentKeydownHandler = function (evt) {
- _this.handleKeydown(evt);
- };
- _this.richTooltipMouseEnterHandler = function () {
- _this.handleRichTooltipMouseEnter();
- };
- _this.richTooltipMouseLeaveHandler = function () {
- _this.handleRichTooltipMouseLeave();
- };
- _this.richTooltipFocusOutHandler = function (evt) {
- _this.handleRichTooltipFocusOut(evt);
- };
- _this.windowScrollHandler = function () {
- _this.handleWindowChangeEvent();
- };
- _this.windowResizeHandler = function () {
- _this.handleWindowChangeEvent();
- };
- return _this;
- }
- Object.defineProperty(MDCTooltipFoundation, "defaultAdapter", {
- get: function get() {
- return {
- getAttribute: function getAttribute() {
- return null;
- },
- setAttribute: function setAttribute() {
- return undefined;
- },
- addClass: function addClass() {
- return undefined;
- },
- hasClass: function hasClass() {
- return false;
- },
- removeClass: function removeClass() {
- return undefined;
- },
- setStyleProperty: function setStyleProperty() {
- return undefined;
- },
- getViewportWidth: function getViewportWidth() {
- return 0;
- },
- getViewportHeight: function getViewportHeight() {
- return 0;
- },
- getTooltipSize: function getTooltipSize() {
- return { width: 0, height: 0 };
- },
- getAnchorBoundingRect: function getAnchorBoundingRect() {
- return { top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 };
- },
- getAnchorAttribute: function getAnchorAttribute() {
- return null;
- },
- setAnchorAttribute: function setAnchorAttribute() {
- return null;
- },
- isRTL: function isRTL() {
- return false;
- },
- anchorContainsElement: function anchorContainsElement() {
- return false;
- },
- tooltipContainsElement: function tooltipContainsElement() {
- return false;
- },
- focusAnchorElement: function focusAnchorElement() {
- return undefined;
- },
- registerEventHandler: function registerEventHandler() {
- return undefined;
- },
- deregisterEventHandler: function deregisterEventHandler() {
- return undefined;
- },
- registerDocumentEventHandler: function registerDocumentEventHandler() {
- return undefined;
- },
- deregisterDocumentEventHandler: function deregisterDocumentEventHandler() {
- return undefined;
- },
- registerWindowEventHandler: function registerWindowEventHandler() {
- return undefined;
- },
- deregisterWindowEventHandler: function deregisterWindowEventHandler() {
- return undefined;
- },
- notifyHidden: function notifyHidden() {
- return undefined;
- }
- };
- },
- enumerable: true,
- configurable: true
- });
- MDCTooltipFoundation.prototype.init = function () {
- this.richTooltip = this.adapter.hasClass(RICH);
- this.persistentTooltip = this.adapter.getAttribute(constants_1.attributes.PERSISTENT) === 'true';
- this.interactiveTooltip = !!this.adapter.getAnchorAttribute(constants_1.attributes.ARIA_EXPANDED) && this.adapter.getAnchorAttribute(constants_1.attributes.ARIA_HASPOPUP) === 'dialog';
- };
- MDCTooltipFoundation.prototype.isShown = function () {
- return this.tooltipShown;
- };
- MDCTooltipFoundation.prototype.isRich = function () {
- return this.richTooltip;
- };
- MDCTooltipFoundation.prototype.isPersistent = function () {
- return this.persistentTooltip;
- };
- MDCTooltipFoundation.prototype.handleAnchorMouseEnter = function () {
- var _this = this;
- if (this.tooltipShown) {
- // Covers the instance where a user hovers over the anchor to reveal the
- // tooltip, and then quickly navigates away and then back to the anchor.
- // The tooltip should stay visible without animating out and then back in
- // again.
- this.show();
- } else {
- // clearHideTimeout here since handleAnchorMouseLeave sets a hideTimeout
- // and that can execute before the showTimeout executes, resulting in hide
- // being called and the showTimeout set below to be cleared.
- this.clearHideTimeout();
- this.showTimeout = setTimeout(function () {
- _this.show();
- }, this.showDelayMs);
- }
- };
- MDCTooltipFoundation.prototype.handleAnchorFocus = function (evt) {
- var _this = this;
- // TODO(b/157075286): Need to add some way to distinguish keyboard
- // navigation focus events from other focus events, and only show the
- // tooltip on the former of these events.
- var relatedTarget = evt.relatedTarget;
- var tooltipContainsRelatedTarget = relatedTarget instanceof HTMLElement && this.adapter.tooltipContainsElement(relatedTarget);
- // Do not show tooltip if the previous focus was on a tooltip element. This
- // occurs when a rich tooltip is closed and focus is restored to the anchor
- // or when user tab-navigates back into the anchor from the rich tooltip.
- if (tooltipContainsRelatedTarget) {
- return;
- }
- this.showTimeout = setTimeout(function () {
- _this.show();
- }, this.showDelayMs);
- };
- MDCTooltipFoundation.prototype.handleAnchorMouseLeave = function () {
- var _this = this;
- this.clearShowTimeout();
- this.hideTimeout = setTimeout(function () {
- _this.hide();
- }, this.hideDelayMs);
- };
- MDCTooltipFoundation.prototype.handleAnchorBlur = function (evt) {
- if (this.richTooltip) {
- var tooltipContainsRelatedTargetElement = evt.relatedTarget instanceof HTMLElement && this.adapter.tooltipContainsElement(evt.relatedTarget);
- // If focus changed to the tooltip element, don't hide the tooltip.
- if (tooltipContainsRelatedTargetElement) {
- return;
- }
- }
- // Hide tooltip immediately on focus change.
- this.hide();
- };
- MDCTooltipFoundation.prototype.handleAnchorClick = function () {
- if (this.tooltipShown) {
- this.hide();
- } else {
- this.show();
- }
- };
- MDCTooltipFoundation.prototype.handleDocumentClick = function (evt) {
- var anchorOrTooltipContainsTargetElement = evt.target instanceof HTMLElement && (this.adapter.anchorContainsElement(evt.target) || this.adapter.tooltipContainsElement(evt.target));
- // For persistent rich tooltips, we will not hide if:
- // - The click target is within the anchor element. Otherwise, both
- // the anchor element's click handler and this handler will handle the
- // click (due to event propagation), resulting in a shown tooltip
- // being immediately hidden if the tooltip was initially hidden.
- // - The click target is within the tooltip element, since clicks
- // on the tooltip do not close the tooltip.
- if (this.richTooltip && this.persistentTooltip && anchorOrTooltipContainsTargetElement) {
- return;
- }
- // Hide the tooltip immediately on click.
- this.hide();
- };
- MDCTooltipFoundation.prototype.handleKeydown = function (evt) {
- // Hide the tooltip immediately on ESC key.
- var key = keyboard_1.normalizeKey(evt);
- if (key === keyboard_1.KEY.ESCAPE) {
- var tooltipContainsActiveElement = document.activeElement instanceof HTMLElement && this.adapter.tooltipContainsElement(document.activeElement);
- if (tooltipContainsActiveElement) {
- this.adapter.focusAnchorElement();
- }
- this.hide();
- }
- };
- MDCTooltipFoundation.prototype.handleRichTooltipMouseEnter = function () {
- this.show();
- };
- MDCTooltipFoundation.prototype.handleRichTooltipMouseLeave = function () {
- var _this = this;
- this.clearShowTimeout();
- this.hideTimeout = setTimeout(function () {
- _this.hide();
- }, this.hideDelayMs);
- };
- MDCTooltipFoundation.prototype.handleRichTooltipFocusOut = function (evt) {
- var anchorOrTooltipContainsRelatedTargetElement = evt.relatedTarget instanceof HTMLElement && (this.adapter.anchorContainsElement(evt.relatedTarget) || this.adapter.tooltipContainsElement(evt.relatedTarget));
- // If the focus is still within the anchor or the tooltip, do not hide the
- // tooltip.
- if (anchorOrTooltipContainsRelatedTargetElement) {
- return;
- }
- this.hide();
- };
- /**
- * On window resize or scroll, check the anchor position and size and
- * repostion tooltip if necessary.
- */
- MDCTooltipFoundation.prototype.handleWindowChangeEvent = function () {
- var _this = this;
- // Since scroll and resize events can fire at a high rate, we throttle
- // the potential re-positioning of tooltip component using
- // requestAnimationFrame.
- this.animFrame.request(AnimationKeys.POLL_ANCHOR, function () {
- _this.repositionTooltipOnAnchorMove();
- });
- };
- MDCTooltipFoundation.prototype.show = function () {
- var _this = this;
- this.clearHideTimeout();
- this.clearShowTimeout();
- if (this.tooltipShown) {
- return;
- }
- this.tooltipShown = true;
- var showTooltipOptions = this.parseShowTooltipOptions();
- if (!showTooltipOptions.hideFromScreenreader) {
- this.adapter.setAttribute('aria-hidden', 'false');
- }
- if (this.richTooltip) {
- if (this.interactiveTooltip) {
- this.adapter.setAnchorAttribute('aria-expanded', 'true');
- }
- this.adapter.registerEventHandler('focusout', this.richTooltipFocusOutHandler);
- if (!this.persistentTooltip) {
- this.adapter.registerEventHandler('mouseenter', this.richTooltipMouseEnterHandler);
- this.adapter.registerEventHandler('mouseleave', this.richTooltipMouseLeaveHandler);
- }
- }
- this.adapter.removeClass(HIDE);
- this.adapter.addClass(SHOWING);
- if (this.isTooltipMultiline() && !this.richTooltip) {
- this.adapter.addClass(MULTILINE_TOOLTIP);
- }
- this.anchorRect = this.adapter.getAnchorBoundingRect();
- this.positionTooltip();
- this.adapter.registerDocumentEventHandler('click', this.documentClickHandler);
- this.adapter.registerDocumentEventHandler('keydown', this.documentKeydownHandler);
- this.adapter.registerWindowEventHandler('scroll', this.windowScrollHandler);
- this.adapter.registerWindowEventHandler('resize', this.windowResizeHandler);
- this.frameId = requestAnimationFrame(function () {
- _this.clearAllAnimationClasses();
- _this.adapter.addClass(SHOWN);
- _this.adapter.addClass(SHOWING_TRANSITION);
- });
- };
- MDCTooltipFoundation.prototype.hide = function () {
- this.clearHideTimeout();
- this.clearShowTimeout();
- if (!this.tooltipShown) {
- return;
- }
- if (this.frameId) {
- cancelAnimationFrame(this.frameId);
- }
- this.tooltipShown = false;
- this.adapter.setAttribute('aria-hidden', 'true');
- this.adapter.deregisterEventHandler('focusout', this.richTooltipFocusOutHandler);
- if (this.richTooltip) {
- if (this.interactiveTooltip) {
- this.adapter.setAnchorAttribute('aria-expanded', 'false');
- }
- if (!this.persistentTooltip) {
- this.adapter.deregisterEventHandler('mouseenter', this.richTooltipMouseEnterHandler);
- this.adapter.deregisterEventHandler('mouseleave', this.richTooltipMouseLeaveHandler);
- }
- }
- this.clearAllAnimationClasses();
- this.adapter.addClass(HIDE);
- this.adapter.addClass(HIDE_TRANSITION);
- this.adapter.removeClass(SHOWN);
- this.adapter.deregisterDocumentEventHandler('click', this.documentClickHandler);
- this.adapter.deregisterDocumentEventHandler('keydown', this.documentKeydownHandler);
- this.adapter.deregisterWindowEventHandler('scroll', this.windowScrollHandler);
- this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
- };
- MDCTooltipFoundation.prototype.handleTransitionEnd = function () {
- var isHidingTooltip = this.adapter.hasClass(HIDE);
- this.adapter.removeClass(SHOWING);
- this.adapter.removeClass(SHOWING_TRANSITION);
- this.adapter.removeClass(HIDE);
- this.adapter.removeClass(HIDE_TRANSITION);
- // If handleTransitionEnd is called after hiding the tooltip, the tooltip
- // will have the HIDE class (before calling the adapter removeClass method).
- // If tooltip is now hidden, send a notification that the animation has
- // completed and the tooltip is no longer visible.
- if (isHidingTooltip) {
- this.adapter.notifyHidden();
- }
- };
- MDCTooltipFoundation.prototype.clearAllAnimationClasses = function () {
- this.adapter.removeClass(SHOWING_TRANSITION);
- this.adapter.removeClass(HIDE_TRANSITION);
- };
- MDCTooltipFoundation.prototype.setTooltipPosition = function (position) {
- var xPos = position.xPos,
- yPos = position.yPos;
- if (xPos) {
- this.xTooltipPos = xPos;
- }
- if (yPos) {
- this.yTooltipPos = yPos;
- }
- };
- MDCTooltipFoundation.prototype.setAnchorBoundaryType = function (type) {
- if (type === constants_1.AnchorBoundaryType.UNBOUNDED) {
- this.anchorGap = constants_1.numbers.UNBOUNDED_ANCHOR_GAP;
- } else {
- this.anchorGap = constants_1.numbers.BOUNDED_ANCHOR_GAP;
- }
- };
- MDCTooltipFoundation.prototype.parseShowTooltipOptions = function () {
- var hideFromScreenreader = Boolean(this.adapter.getAnchorAttribute('data-tooltip-id'));
- return { hideFromScreenreader: hideFromScreenreader };
- };
- MDCTooltipFoundation.prototype.isTooltipMultiline = function () {
- var tooltipSize = this.adapter.getTooltipSize();
- return tooltipSize.height > constants_1.numbers.MIN_HEIGHT && tooltipSize.width >= constants_1.numbers.MAX_WIDTH;
- };
- MDCTooltipFoundation.prototype.positionTooltip = function () {
- var _a = this.calculateTooltipDistance(this.anchorRect),
- top = _a.top,
- left = _a.left;
- this.adapter.setStyleProperty('top', top + "px");
- this.adapter.setStyleProperty('left', left + "px");
- };
- /**
- * Calculates the position of the tooltip. A tooltip will be placed beneath
- * the anchor element and aligned either with the 'start'/'end' edge of the
- * anchor element or the 'center'.
- *
- * Tooltip alignment is selected such that the tooltip maintains a threshold
- * distance away from the viewport (defaulting to 'center' alignment). If the
- * placement of the anchor prevents this threshold distance from being
- * maintained, the tooltip is positioned so that it does not collide with the
- * viewport.
- *
- * Users can specify an alignment, however, if this alignment results in the
- * tooltip colliding with the viewport, this specification is overwritten.
- */
- MDCTooltipFoundation.prototype.calculateTooltipDistance = function (anchorRect) {
- if (!anchorRect) {
- return { top: 0, left: 0 };
- }
- var tooltipSize = this.adapter.getTooltipSize();
- var top = this.calculateYTooltipDistance(anchorRect, tooltipSize.height);
- var left = this.calculateXTooltipDistance(anchorRect, tooltipSize.width);
- return { top: top, left: left };
- };
- /**
- * Calculates the `left` distance for the tooltip.
- */
- MDCTooltipFoundation.prototype.calculateXTooltipDistance = function (anchorRect, tooltipWidth) {
- var isLTR = !this.adapter.isRTL();
- var startPos, endPos, centerPos;
- if (this.richTooltip) {
- startPos = isLTR ? anchorRect.left - tooltipWidth : anchorRect.right;
- endPos = isLTR ? anchorRect.right : anchorRect.left - tooltipWidth;
- } else {
- startPos = isLTR ? anchorRect.left : anchorRect.right - tooltipWidth;
- endPos = isLTR ? anchorRect.right - tooltipWidth : anchorRect.left;
- centerPos = anchorRect.left + (anchorRect.width - tooltipWidth) / 2;
- }
- var positionOptions = this.richTooltip ? this.determineValidPositionOptions(startPos, endPos) :
- // For plain tooltips, centerPos is defined
- this.determineValidPositionOptions(centerPos, startPos, endPos);
- if (this.xTooltipPos === constants_1.XPosition.START && positionOptions.has(startPos)) {
- return startPos;
- }
- if (this.xTooltipPos === constants_1.XPosition.END && positionOptions.has(endPos)) {
- return endPos;
- }
- if (this.xTooltipPos === constants_1.XPosition.CENTER && positionOptions.has(centerPos)) {
- return centerPos;
- }
- // If no user position is supplied, rich tooltips default to end pos, then
- // start position. Plain tooltips default to center, start, then end.
- var possiblePositions = this.richTooltip ? [endPos, startPos] : [centerPos, startPos, endPos];
- var validPosition = possiblePositions.find(function (pos) {
- return positionOptions.has(pos);
- });
- if (validPosition) {
- return validPosition;
- }
- // Indicates that all potential positions would result in the tooltip
- // colliding with the viewport. This would only occur when the anchor
- // element itself collides with the viewport, or the viewport is very
- // narrow. In this case, we allow the tooltip to be mis-aligned from the
- // anchor element.
- if (anchorRect.left < 0) {
- return this.minViewportTooltipThreshold;
- } else {
- var viewportWidth = this.adapter.getViewportWidth();
- return viewportWidth - (tooltipWidth + this.minViewportTooltipThreshold);
- }
- };
- /**
- * Given the values for the horizontal alignments of the tooltip, calculates
- * which of these options would result in the tooltip maintaining the required
- * threshold distance vs which would result in the tooltip staying within the
- * viewport.
- *
- * A Set of values is returned holding the distances that would honor the
- * above requirements. Following the logic for determining the tooltip
- * position, if all alignments violate the threshold, then the returned Set
- * contains values that keep the tooltip within the viewport.
- */
- MDCTooltipFoundation.prototype.determineValidPositionOptions = function () {
- var e_1, _a;
- var positions = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- positions[_i] = arguments[_i];
- }
- var posWithinThreshold = new Set();
- var posWithinViewport = new Set();
- try {
- for (var positions_1 = __values(positions), positions_1_1 = positions_1.next(); !positions_1_1.done; positions_1_1 = positions_1.next()) {
- var position = positions_1_1.value;
- if (this.positionHonorsViewportThreshold(position)) {
- posWithinThreshold.add(position);
- } else if (this.positionDoesntCollideWithViewport(position)) {
- posWithinViewport.add(position);
- }
- }
- } catch (e_1_1) {
- e_1 = { error: e_1_1 };
- } finally {
- try {
- if (positions_1_1 && !positions_1_1.done && (_a = positions_1.return)) _a.call(positions_1);
- } finally {
- if (e_1) throw e_1.error;
- }
- }
- return posWithinThreshold.size ? posWithinThreshold : posWithinViewport;
- };
- MDCTooltipFoundation.prototype.positionHonorsViewportThreshold = function (leftPos) {
- var viewportWidth = this.adapter.getViewportWidth();
- var tooltipWidth = this.adapter.getTooltipSize().width;
- return leftPos + tooltipWidth <= viewportWidth - this.minViewportTooltipThreshold && leftPos >= this.minViewportTooltipThreshold;
- };
- MDCTooltipFoundation.prototype.positionDoesntCollideWithViewport = function (leftPos) {
- var viewportWidth = this.adapter.getViewportWidth();
- var tooltipWidth = this.adapter.getTooltipSize().width;
- return leftPos + tooltipWidth <= viewportWidth && leftPos >= 0;
- };
- /**
- * Calculates the `top` distance for the tooltip.
- */
- MDCTooltipFoundation.prototype.calculateYTooltipDistance = function (anchorRect, tooltipHeight) {
- var belowYPos = anchorRect.bottom + this.anchorGap;
- var aboveYPos = anchorRect.top - (this.anchorGap + tooltipHeight);
- var yPositionOptions = this.determineValidYPositionOptions(aboveYPos, belowYPos);
- if (this.yTooltipPos === constants_1.YPosition.ABOVE && yPositionOptions.has(aboveYPos)) {
- return aboveYPos;
- } else if (this.yTooltipPos === constants_1.YPosition.BELOW && yPositionOptions.has(belowYPos)) {
- return belowYPos;
- }
- if (yPositionOptions.has(belowYPos)) {
- return belowYPos;
- }
- if (yPositionOptions.has(aboveYPos)) {
- return aboveYPos;
- }
- // Indicates that all potential positions would result in the tooltip
- // colliding with the viewport. This would only occur when the viewport is
- // very short.
- return belowYPos;
- };
- /**
- * Given the values for above/below alignment of the tooltip, calculates
- * which of these options would result in the tooltip maintaining the required
- * threshold distance vs which would result in the tooltip staying within the
- * viewport.
- *
- * A Set of values is returned holding the distances that would honor the
- * above requirements. Following the logic for determining the tooltip
- * position, if all possible alignments violate the threshold, then the
- * returned Set contains values that keep the tooltip within the viewport.
- */
- MDCTooltipFoundation.prototype.determineValidYPositionOptions = function (aboveAnchorPos, belowAnchorPos) {
- var posWithinThreshold = new Set();
- var posWithinViewport = new Set();
- if (this.yPositionHonorsViewportThreshold(aboveAnchorPos)) {
- posWithinThreshold.add(aboveAnchorPos);
- } else if (this.yPositionDoesntCollideWithViewport(aboveAnchorPos)) {
- posWithinViewport.add(aboveAnchorPos);
- }
- if (this.yPositionHonorsViewportThreshold(belowAnchorPos)) {
- posWithinThreshold.add(belowAnchorPos);
- } else if (this.yPositionDoesntCollideWithViewport(belowAnchorPos)) {
- posWithinViewport.add(belowAnchorPos);
- }
- return posWithinThreshold.size ? posWithinThreshold : posWithinViewport;
- };
- MDCTooltipFoundation.prototype.yPositionHonorsViewportThreshold = function (yPos) {
- var viewportHeight = this.adapter.getViewportHeight();
- var tooltipHeight = this.adapter.getTooltipSize().height;
- return yPos + tooltipHeight + this.minViewportTooltipThreshold <= viewportHeight && yPos >= this.minViewportTooltipThreshold;
- };
- MDCTooltipFoundation.prototype.yPositionDoesntCollideWithViewport = function (yPos) {
- var viewportHeight = this.adapter.getViewportHeight();
- var tooltipHeight = this.adapter.getTooltipSize().height;
- return yPos + tooltipHeight <= viewportHeight && yPos >= 0;
- };
- MDCTooltipFoundation.prototype.repositionTooltipOnAnchorMove = function () {
- var newAnchorRect = this.adapter.getAnchorBoundingRect();
- if (!newAnchorRect || !this.anchorRect) return;
- if (newAnchorRect.top !== this.anchorRect.top || newAnchorRect.left !== this.anchorRect.left || newAnchorRect.height !== this.anchorRect.height || newAnchorRect.width !== this.anchorRect.width) {
- this.anchorRect = newAnchorRect;
- this.positionTooltip();
- }
- };
- MDCTooltipFoundation.prototype.clearShowTimeout = function () {
- if (this.showTimeout) {
- clearTimeout(this.showTimeout);
- this.showTimeout = null;
- }
- };
- MDCTooltipFoundation.prototype.clearHideTimeout = function () {
- if (this.hideTimeout) {
- clearTimeout(this.hideTimeout);
- this.hideTimeout = null;
- }
- };
- MDCTooltipFoundation.prototype.destroy = function () {
- if (this.frameId) {
- cancelAnimationFrame(this.frameId);
- this.frameId = null;
- }
- this.clearHideTimeout();
- this.clearShowTimeout();
- this.adapter.removeClass(SHOWN);
- this.adapter.removeClass(SHOWING_TRANSITION);
- this.adapter.removeClass(SHOWING);
- this.adapter.removeClass(HIDE);
- this.adapter.removeClass(HIDE_TRANSITION);
- if (this.richTooltip) {
- this.adapter.deregisterEventHandler('focusout', this.richTooltipFocusOutHandler);
- if (!this.persistentTooltip) {
- this.adapter.deregisterEventHandler('mouseenter', this.richTooltipMouseEnterHandler);
- this.adapter.deregisterEventHandler('mouseleave', this.richTooltipMouseLeaveHandler);
- }
- }
- this.adapter.deregisterDocumentEventHandler('click', this.documentClickHandler);
- this.adapter.deregisterDocumentEventHandler('keydown', this.documentKeydownHandler);
- this.adapter.deregisterWindowEventHandler('scroll', this.windowScrollHandler);
- this.adapter.deregisterWindowEventHandler('resize', this.windowResizeHandler);
- this.animFrame.cancelAll();
- };
- return MDCTooltipFoundation;
- }(foundation_1.MDCFoundation);
- exports.MDCTooltipFoundation = MDCTooltipFoundation;
- // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
- exports.default = MDCTooltipFoundation;
- /***/ }),
- /***/ "./packages/mdc-tooltip/index.ts":
- /*!***************************************!*\
- !*** ./packages/mdc-tooltip/index.ts ***!
- \***************************************/
- /*! no static exports found */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- /**
- * @license
- * Copyright 2020 Google Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
- 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-tooltip/component.ts"));
- __export(__webpack_require__(/*! ./foundation */ "./packages/mdc-tooltip/foundation.ts"));
- __export(__webpack_require__(/*! ./constants */ "./packages/mdc-tooltip/constants.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(__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
|